/* LLM Gateway admin UI — vanilla CSS, no external dependencies */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f4f6f9;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: #6b7280; font-size: 12px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #1f2937; color: #fff; padding: 0 20px; height: 52px;
}
.topbar-brand { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-user { color: #cbd5e1; font-size: 13px; margin-right: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; border: 1px solid #d1d5db; background: #fff;
  color: #374151; border-radius: 6px; padding: 6px 14px; font-size: 13px;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; color: #e5e7eb; }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 9px 14px; font-size: 14px; }
.day-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 2px; background: #fff; border-bottom: 1px solid #e5e7eb;
  padding: 0 16px; overflow-x: auto;
}
.tab {
  border: none; background: none; padding: 12px 18px; font-size: 14px;
  cursor: pointer; color: #6b7280; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: #111827; }
.tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

/* ---------- panels ---------- */
.content { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.panel { display: none; }
.panel.active { display: block; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 0 12px;
}
.section-head h2 { font-size: 17px; margin: 0; }
.subhead { font-size: 14px; color: #374151; margin: 24px 0 8px; }

/* ---------- cards (overview) ---------- */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.bcard {
  background: #fff; border-radius: 10px; border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 14px 16px;
}
.bcard-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.bcard-name { font-weight: 700; font-size: 15px; }
.bcard-type {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: #eef2ff; color: #4338ca; font-weight: 600;
}
.bcard-url { font-size: 12px; color: #6b7280; word-break: break-all; margin-bottom: 8px; }
.bcard-row { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.bcard-row .k { color: #6b7280; }
.bcard-foot { margin-top: 10px; display: flex; justify-content: flex-end; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.badge-up { background: #dcfce7; color: #15803d; }
.badge-down { background: #fee2e2; color: #b91c1c; }
.badge-unknown { background: #e5e7eb; color: #4b5563; }

.bcard-error {
  margin-top: 8px; font-size: 12px; color: #b91c1c;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
  padding: 6px 8px; word-break: break-all;
}
.bcard-error summary { cursor: pointer; font-weight: 600; }

/* ---------- conflicts ---------- */
.conflict-list { display: flex; flex-direction: column; gap: 8px; }
.conflict-item {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
  padding: 10px 14px; font-size: 13px;
}
.conflict-item .conflict-model { font-weight: 700; margin-right: 8px; }
.conflict-item .chip {
  display: inline-block; margin: 2px 4px 2px 0; padding: 1px 8px;
  border-radius: 999px; background: #f3f4f6; font-size: 12px;
}
.conflict-empty { color: #6b7280; font-size: 13px; }
.empty-hint { color: #9ca3af; font-size: 13px; padding: 8px 0; }

/* ---------- tables ---------- */
.table-wrap {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}
.data-table th {
  background: #f9fafb; color: #6b7280; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .3px;
}
.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table tbody tr:hover { background: #f1f5f9; }
.data-table td.wrap { white-space: normal; word-break: break-all; }
.row-actions { display: flex; gap: 6px; }

/* ---------- forms ---------- */
.form-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); padding: 16px 18px; margin-top: 14px;
}
.form-card h3 { margin: 0 0 12px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-label { font-size: 12px; color: #6b7280; font-weight: 600; }
.field input[type=text], .field input[type=password], .field input[type=number], .field select {
  border: 1px solid #d1d5db; border-radius: 6px; padding: 7px 10px;
  font-size: 13px; font-family: inherit; background: #fff; color: #1f2937;
}
.field input:focus, .field select:focus {
  outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field-check { flex-direction: row; align-items: center; gap: 8px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form .field { min-width: 200px; flex: 1; margin-bottom: 0; }
.form-error, .login-error {
  color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 6px; padding: 7px 10px; font-size: 13px; margin-top: 10px;
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17,24,39,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal {
  background: #fff; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  padding: 20px 22px;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .form-actions { margin-top: 14px; }
.key-reveal {
  background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 8px;
  padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; word-break: break-all; margin: 10px 0; user-select: all;
}
.modal-warn { color: #92400e; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 6px; padding: 8px 10px; font-size: 12px; margin-bottom: 8px; }

/* ---------- toast ---------- */
#toast-container {
  position: fixed; top: 14px; right: 14px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1f2937; color: #fff; border-radius: 8px; padding: 10px 16px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  animation: toast-in .2s ease-out;
  max-width: 340px; word-break: break-all;
}
.toast-error { background: #b91c1c; }
.toast-success { background: #15803d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

/* ---------- bar chart ---------- */
.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { width: 100px; font-size: 12px; color: #6b7280; text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; background: #eef2f7; border-radius: 5px; height: 20px; overflow: hidden; }
.bar-fill { background: #3b82f6; height: 100%; border-radius: 5px; min-width: 2px; }
.bar-value { width: 70px; font-size: 12px; color: #374151; flex-shrink: 0; }

/* ---------- login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1f2937 100%);
}
.login-card {
  background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  padding: 34px 36px; width: 100%; max-width: 360px;
}
.login-title { margin: 0; font-size: 22px; text-align: center; }
.login-subtitle { margin: 4px 0 22px; text-align: center; color: #6b7280; font-size: 13px; }

@media (max-width: 640px) {
  .content { padding: 14px 10px 50px; }
  .inline-form .field { min-width: 140px; }
  .bar-label { width: 74px; }
}
