/* LLM Gate Admin — white / charcoal, no purple, no emoji */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* zinc-ish neutrals — aligned with providers_export / shadcn */
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f4f4f5;
  --fg: #09090b;
  --fg-muted: #71717a;
  --fg-faint: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --primary: #18181b;
  --primary-hover: #27272a;
  --primary-fg: #fafafa;
  --accent-soft: #f4f4f5;
  --success: #166534;
  --success-bg: #ecfdf3;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warning: #92400e;
  --warning-bg: #fffbeb;
  --info-bg: #f4f4f5;
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.04);
  --shadow-md: 0 10px 28px rgba(9, 9, 11, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --page-gap: 8px;
  --page-pad-x: 20px;
  --page-pad-y: 14px;
  --sidebar-w: 220px;
  --sidebar-collapsed: 64px;
  --font: "DM Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  --chart-1: #18181b;
  --chart-2: #52525b;
  --chart-3: #a1a1aa;
  --chart-ok: hsl(160, 70%, 42%);
  --chart-err: hsl(0, 75%, 55%);
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-subtle);
  color: var(--fg);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  transition: width .2s ease;
  z-index: 20;
}
.sidebar.is-collapsed { width: var(--sidebar-collapsed); }
.sidebar-brand {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.sidebar.is-collapsed .sidebar-brand { justify-content: center; padding: 0 12px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--primary); color: var(--primary-fg);
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-mark svg { width: 14px; height: 14px; }
.brand-text {
  font-size: 16px; font-weight: 650; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden;
  transition: opacity .15s, max-width .2s;
  max-width: 140px;
}
.sidebar.is-collapsed .brand-text { opacity: 0; max-width: 0; }

.sidebar-toggle {
  position: absolute; right: -14px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg);
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
  color: var(--fg-muted);
}
.sidebar-toggle:hover { background: var(--bg-muted); color: var(--fg); }
.sidebar-toggle svg { width: 14px; height: 14px; }

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--fg-muted); margin-bottom: 1px;
  font-size: 13px; font-weight: 500;
  transition: background .12s, color .12s;
}
.sidebar.is-collapsed .nav-item { justify-content: center; padding: 8px; }
.nav-item:hover { background: var(--bg-muted); color: var(--fg); }
.nav-item.active { background: var(--fg); color: var(--primary-fg); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.nav-label {
  white-space: nowrap; overflow: hidden;
  transition: opacity .15s, max-width .2s;
  max-width: 160px;
}
.sidebar.is-collapsed .nav-label { opacity: 0; max-width: 0; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sidebar.is-collapsed .sidebar-foot { justify-content: center; padding: 12px 8px; }
.sidebar-foot .ver {
  font-size: 11px; color: var(--fg-faint); white-space: nowrap;
  overflow: hidden; max-width: 140px;
}
.sidebar.is-collapsed .sidebar-foot .ver { display: none; }

.main {
  flex: 1; min-width: 0;
  min-height: 100vh;
  padding: var(--page-pad-y) var(--page-pad-x) 20px;
  background: color-mix(in srgb, var(--bg-muted) 35%, var(--bg-subtle));
}

/* Page — dense, shared with overview */
.page-header {
  margin-bottom: 10px;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.page-header h2 {
  font-size: 18px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.25; margin: 0;
}
.page-header .sub { color: var(--fg-muted); font-size: 12px; margin-top: 2px; }

/* Panels / tables — interaction containers, not decorative cards */
.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: var(--page-gap);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.panel-head.compact {
  margin-bottom: 4px;
  min-height: 0;
  align-items: center;
  gap: 8px;
}
.panel-title { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head.compact .panel-title {
  font-size: 13px;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.panel-meta { color: var(--fg-muted); font-size: 11px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; padding: 7px 10px;
  background: var(--bg-subtle);
  color: var(--fg-muted); font-weight: 600; font-size: 11.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; letter-spacing: 0.01em;
}
td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fbfbfa; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: var(--primary-fg);
  border: 1px solid var(--primary);
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 550;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover:not(:disabled) { background: var(--primary-hover); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.secondary {
  background: var(--bg); color: var(--fg);
  border-color: var(--border-strong);
}
.btn.secondary:hover:not(:disabled) { background: var(--bg-muted); }
.btn.danger {
  background: var(--bg); color: var(--danger);
  border-color: #fecaca;
}
.btn.danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn.ghost {
  background: transparent; color: var(--fg-muted);
  border-color: transparent; padding: 6px 10px;
}
.btn.ghost:hover:not(:disabled) { background: var(--bg-muted); color: var(--fg); }
.btn.sm { padding: 4px 8px; font-size: 11.5px; }
.btn.icon {
  width: 28px; height: 28px; padding: 0;
}
.btn svg { width: 15px; height: 15px; }

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 12.5px;
  width: 100%;
  background: var(--bg);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--fg);
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.08);
}
label {
  display: block; font-size: 11.5px; font-weight: 550;
  color: var(--fg-muted); margin-bottom: 4px;
}
.form-row { margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); font-size: 13px; font-weight: 500;
  color: var(--fg); cursor: pointer;
}
.check-chip input { margin: 0; }

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge.active, .badge.success {
  background: var(--success-bg); color: var(--success); border-color: #bbf7d0;
}
.badge.disabled, .badge.danger, .badge.blacklisted {
  background: var(--danger-bg); color: var(--danger); border-color: #fecaca;
}
.badge.warning {
  background: var(--warning-bg); color: var(--warning); border-color: #fde68a;
}
.badge.muted {
  background: var(--info-bg); color: var(--fg-muted); border-color: var(--border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--page-gap);
  margin-bottom: var(--page-gap);
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.stat .label { color: var(--fg-muted); font-size: 11px; font-weight: 550; }
.stat .value {
  font-size: 18px; font-weight: 650; letter-spacing: -0.03em;
  margin-top: 2px; color: var(--fg); font-variant-numeric: tabular-nums;
}
.stat .hint { font-size: 10.5px; color: var(--fg-faint); margin-top: 2px; }

.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--page-gap); }
.chart { width: 100%; height: 220px; }

.toolbar {
  display: flex; gap: 6px; margin-bottom: var(--page-gap);
  flex-wrap: wrap; align-items: center;
}
.toolbar .grow { flex: 1; }
.toolbar input { width: auto; min-width: 140px; }

.empty {
  text-align: center; padding: 28px 16px;
  color: var(--fg-muted); font-size: 12.5px;
}
.empty.sm { padding: 10px 8px; font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }

.key-secret {
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
  margin: 10px 0;
}

.alert {
  border: 1px solid #fde68a;
  background: var(--warning-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: var(--page-gap);
}
.alert-title { font-weight: 600; font-size: 12.5px; margin-bottom: 2px; }

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(23, 23, 23, 0.36);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  min-width: 400px; max-width: min(720px, 94vw);
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: popIn .16s ease;
}
.modal h3 { font-size: 15px; font-weight: 650; letter-spacing: -0.02em; margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.detail-grid { font-size: 13px; line-height: 1.85; color: var(--fg); }
.detail-grid strong { font-weight: 600; color: var(--fg-muted); margin-right: 4px; }
.code-block {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 220px; overflow: auto;
  font-family: var(--mono); font-size: 11.5px;
  white-space: pre-wrap; word-break: break-word;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse 80% 55% at 50% -8%, #e4e4e7 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 100%, #f4f4f5 0%, transparent 50%),
    var(--bg-subtle);
  padding: 24px;
}
.login-box {
  width: 100%; max-width: 400px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 28px; text-align: center;
}
.login-brand .mark {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--primary); color: var(--primary-fg);
  display: grid; place-items: center;
}
.login-brand .mark svg { width: 22px; height: 22px; }
.login-brand h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.03em; }
.login-brand p { color: var(--fg-muted); font-size: 13px; }
.login-error { color: var(--danger); font-size: 12.5px; margin-top: 8px; text-align: center; }

/* Toast */
.toast-host {
  position: fixed; top: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px; z-index: 200;
}
.toast {
  background: var(--fg); color: #fff;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-md);
  min-width: 180px; max-width: 360px;
  animation: slideIn .18s ease;
}
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }

.pager {
  display: flex; gap: 8px; justify-content: center; align-items: center;
  margin-top: 10px; color: var(--fg-muted); font-size: 12px;
}

.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--page-gap); }
.channel-meta { color: var(--fg-muted); font-size: 12px; line-height: 1.5; }
.channel-meta .mono { color: var(--fg); }
.inline-actions { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.expand-block {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.stream-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--success); margin-right: 6px;
  animation: pulse 1.2s ease infinite;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-row, .split-2 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .main { padding: 18px 14px 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { position: fixed; }
  .layout { padding-left: var(--sidebar-collapsed); }
  .sidebar:not(.is-collapsed) { box-shadow: var(--shadow-md); }
  .modal { min-width: 0; width: 100%; }
}


/* Logs — compact upper chrome + fill remaining viewport for the list */
.logs-page {
  display: flex;
  flex-direction: column;
  gap: var(--page-gap);
}
.logs-page > .screen-header { margin-bottom: 0; flex-shrink: 0; }
.logs-page .panel {
  box-shadow: var(--shadow-sm);
  margin-bottom: 0;
}
.timeline-panel { padding: 10px 12px 8px; flex-shrink: 0; }
.timeline-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.preset-select {
  width: auto; min-width: 120px; height: 28px; padding: 2px 8px;
  font-size: 12px;
}
.timeline-stats {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px; margin-bottom: 6px;
}
.tstat {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-subtle); padding: 6px 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.tstat-label { font-size: 10.5px; color: var(--fg-muted); font-weight: 550; }
.tstat-value { font-size: 14px; font-weight: 650; letter-spacing: -0.02em; }
.tstat-value.ok { color: var(--success); }
.tstat-value.err { color: var(--danger); }
.timeline-chart { width: 100%; height: 120px; }
.timeline-legend {
  display: flex; gap: 14px; justify-content: flex-end;
  font-size: 12px; color: var(--fg-muted); margin-top: 2px;
}
.timeline-legend .leg {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 6px; vertical-align: -1px;
}
.timeline-legend .leg.ok { background: var(--chart-ok); }
.timeline-legend .leg.err { background: var(--chart-err); }

.filter-panel { padding: 10px 12px; flex-shrink: 0; }
.filter-row {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end;
}
.filter-row.advanced {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.filter-field { display: flex; flex-direction: column; gap: 5px; min-width: 140px; flex: 1; }
.filter-field label { margin: 0; font-size: 11.5px; }
.filter-field input, .filter-field select { min-width: 0; }
.filter-actions { display: flex; gap: 8px; align-items: center; padding-bottom: 1px; flex-wrap: wrap; }

.list-panel {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 420px;
}
.list-panel .panel-head {
  padding: 8px 12px;
  margin-bottom: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.list-panel .table-wrap {
  flex: 1 1 auto;
  min-height: 320px;
  max-height: calc(100vh - 200px);
  overflow: auto;
  border: none;
  border-radius: 0;
  -webkit-overflow-scrolling: touch;
}
.list-panel .pager {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.log-table td { vertical-align: middle; }
.log-table.rich th { font-size: 11.5px; text-transform: none; position: sticky; top: 0; z-index: 2; }
.log-table.rich th,
.log-table.rich td { padding: 8px 12px; }
.log-time { font-size: 12px; }
.log-sub {
  color: var(--fg-faint); font-size: 11.5px; margin-top: 2px; line-height: 1.35;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.log-model-line { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.model-map { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.map-arrow { color: var(--fg-faint); font-size: 12px; }
.mono.muted, .muted { color: var(--fg-muted); }
.trace-hover { opacity: 0; transition: opacity .15s; }
tr:hover .trace-hover { opacity: 1; }
.status-retry { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.retry-pill {
  font-size: 11px; font-family: var(--mono); color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px;
  background: var(--bg-subtle);
}
tr.row-error td { background: #fffafa; }
tbody tr { transition: background .1s; }

.modal-wide { min-width: min(860px, 96vw); width: min(860px, 96vw); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.modal-head h3 { margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  padding: 8px 12px; color: var(--fg-muted); font-weight: 550; font-size: 13px;
  margin-bottom: -1px; border-radius: 0;
}
.tabs button:hover { color: var(--fg); background: transparent; }
.tabs button.active { color: var(--fg); border-bottom-color: var(--fg); }
.detail-cards { display: flex; flex-direction: column; gap: 10px; }
.detail-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; background: var(--bg-subtle);
}
.detail-card .label { font-size: 11px; color: var(--fg-muted); font-weight: 550; margin-bottom: 6px; }
.detail-card .value-sm { font-size: 13px; line-height: 1.5; }
.detail-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.route-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.route-arrow { display: inline-flex; width: 14px; height: 14px; color: var(--fg-faint); }
.route-arrow svg { width: 14px; height: 14px; }
.code-block.tall { max-height: 420px; min-height: 120px; }
.error-block { color: var(--danger); background: var(--danger-bg); border-color: #fecaca; }

@media (max-width: 1100px) {
  .timeline-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .timeline-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline-chart { height: 120px; }
  .list-panel { min-height: 360px; }
  .list-panel .table-wrap { min-height: 280px; max-height: 70vh; }
}

/* Docs */
.docs-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--page-gap); margin-bottom: var(--page-gap); }
.docs-step {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; background: var(--bg-subtle);
}
.docs-step-title { font-weight: 650; font-size: 13px; margin-bottom: 4px; }
.docs-step-body { color: var(--fg-muted); font-size: 12.5px; line-height: 1.5; }

@media (max-width: 900px) {
  .detail-card-grid, .docs-steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .detail-card-grid, .docs-steps { grid-template-columns: 1fr; }
}

/* ===== 运维大屏 ===== */
.screen { min-height: calc(100vh - 40px); }
.screen-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.screen-header h2 {
  font-size: 24px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.2;
}
.screen-clock {
  text-align: center; min-width: 160px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.clock-date { font-size: 12px; color: var(--fg-muted); }
.clock-time {
  font-size: 28px; font-weight: 650; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.screen-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 12px; color: var(--fg-muted); font-weight: 550;
}
.live-pill.on { color: var(--success); border-color: #bbf7d0; background: var(--success-bg); }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--fg-faint);
}
.live-pill.on .live-dot {
  background: var(--success);
  animation: pulse 1.2s ease infinite;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px; margin-bottom: 14px;
}
.kpi {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--fg);
  opacity: 0.85;
}
.kpi-label { color: var(--fg-muted); font-size: 11px; font-weight: 550; }
.kpi-value {
  font-size: 18px; font-weight: 650; letter-spacing: -0.02em;
  margin-top: 2px; font-variant-numeric: tabular-nums;
}
.kpi-value.kpi-model { font-size: 14px; line-height: 1.35; word-break: break-all; }
.kpi-hint { font-size: 10.5px; color: var(--fg-faint); margin-top: 2px; }
.screen-grid {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; margin-bottom: 14px;
}
.screen-grid-bottom { grid-template-columns: 1.4fr 1fr; }
.screen-panel { margin-bottom: 0; }
.chart-lg { height: 300px; }
.table-wrap.flat { border: none; border-radius: 0; }
.table-wrap.flat table { font-size: 12.5px; }
.compact th, .compact td { padding: 5px 8px; }
.relative-live { color: var(--fg); font-weight: 600; }
.rank-list { display: flex; flex-direction: column; gap: 4px; }
.rank-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-subtle);
}
.rank-idx {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--fg); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650; flex-shrink: 0;
}
.rank-body { flex: 1; min-width: 0; }
.rank-cost { font-weight: 600; white-space: nowrap; }

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .screen-grid, .screen-grid-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clock-time { font-size: 22px; }
}


/* ===== Overview (dense one-page grid) ===== */
.overview.dense { --ov-gap: var(--page-gap); }
.overview.dense .screen-actions { gap: 6px; flex-wrap: wrap; }
.ov-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--ov-gap, 8px);
  margin-bottom: var(--ov-gap, 8px);
}
.overview.dense .ov-kpi-grid .kpi {
  box-shadow: var(--shadow-sm);
  padding: 8px 10px;
  border-radius: 8px;
}
.overview.dense .kpi-label { font-size: 11px; }
.overview.dense .kpi-value {
  font-size: 18px; margin-top: 2px; letter-spacing: -0.02em;
}
.overview.dense .kpi-hint { font-size: 10.5px; margin-top: 2px; }
.kpi-value.ok { color: var(--success); }
.ov-charts {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--ov-gap, 8px);
  margin-bottom: var(--ov-gap, 8px);
}
.overview.dense .ov-charts .panel,
.overview.dense .ov-rank-grid .panel,
.overview.dense .ov-bottom-grid .panel {
  margin-bottom: 0;
  padding: 8px 10px 6px;
}
.chart-ov { height: 120px; width: 100%; }
.ov-rank-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--ov-gap, 8px);
  margin-bottom: var(--ov-gap, 8px);
}
.rank-list.dense { gap: 4px; }
.rank-list.dense .rank-row {
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
}
.rank-idx-text {
  font-size: 11px; font-weight: 650; color: var(--fg-muted);
  font-variant-numeric: tabular-nums; width: 22px; flex-shrink: 0;
}
.trunc {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}
.ov-bottom-grid {
  display: grid;
  grid-template-columns: 1.55fr 0.9fr;
  gap: var(--ov-gap, 8px);
  margin-bottom: 4px;
  align-items: start;
}
.ov-side-stack {
  display: flex; flex-direction: column; gap: var(--ov-gap, 8px);
  min-width: 0;
}
.ov-recent-scroll {
  max-height: 30vh;
  overflow: auto;
}
.ov-recent-scroll thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg);
}
.overview .row-error td { background: #fff7f7; }
.ov-active-scroll, .ov-health-scroll {
  max-height: 16vh;
  overflow: auto;
}
.active-item.dense {
  padding: 6px 8px;
  border-radius: 8px;
}
.active-item.dense .active-top {
  margin-bottom: 2px; gap: 6px;
}
.health-row.dense {
  padding: 6px 8px; gap: 6px;
}
.seg-tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-subtle);
}
.seg-tabs button {
  border: none; background: transparent;
  padding: 3px 8px; font-size: 11px; font-weight: 550;
  color: var(--fg-muted);
}
.seg-tabs button.active {
  background: var(--fg); color: var(--primary-fg);
}
.health-list { display: flex; flex-direction: column; gap: 6px; }
.health-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
}
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fafafa; }
.page-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: var(--page-gap);
}
.page-card .table-wrap { border: none; border-radius: 0; }
.config-filter {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  margin-bottom: var(--page-gap);
}
.config-filter input { width: auto; min-width: 160px; }
.binding-summary {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.binding-chip {
  font-size: 11.5px; font-family: var(--mono);
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-subtle);
  color: var(--fg-muted);
}
.bind-table .bind-handle { width: 40px; text-align: center; color: var(--fg-faint); }
.bind-table .drag-grip {
  display: inline-flex; width: 18px; height: 18px; cursor: grab;
  opacity: 0.7; vertical-align: middle;
}
.bind-table .drag-grip:active { cursor: grabbing; }
.bind-table .drag-grip svg { width: 18px; height: 18px; }
.bind-row { transition: background .12s; }
.bind-row.dragging { opacity: 0.55; background: var(--bg-muted); }
.bind-row.drag-over td { box-shadow: inset 0 2px 0 0 var(--fg); }
.bind-table .inline-actions { white-space: nowrap; }
.logs-page .row-error td { background: #fff7f7; }
.prompt-preview {
  font-size: 12.5px; line-height: 1.4; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 420px; white-space: pre-wrap; word-break: break-word;
}
.reply-preview {
  font-size: 11.5px; margin-top: 3px; max-width: 420px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.active-panel { border-color: hsl(38, 90%, 70%); background: hsl(42, 100%, 97%); }
.active-list { display: flex; flex-direction: column; gap: 6px; padding: 2px 0; }
.active-item {
  padding: 10px 12px; border: 1px solid hsl(38, 70%, 82%);
  border-radius: 10px; background: #fff;
}
.active-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.badge.warning { background: hsl(38, 95%, 90%); color: hsl(28, 80%, 32%); }
.skeleton {
  height: 14px; border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-muted), #fafafa, var(--bg-muted));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (max-width: 1200px) {
  .ov-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ov-charts, .ov-rank-grid, .ov-bottom-grid { grid-template-columns: 1fr; }
  .ov-recent-scroll { max-height: 36vh; }
}
@media (max-width: 720px) {
  .ov-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.tag-editor {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-height: 38px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg);
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: var(--bg-elevated, #f4f4f5); border: 1px solid var(--border);
  font-family: var(--mono); color: var(--fg);
}
.tag-x {
  border: 0; background: transparent; cursor: pointer; color: var(--fg-muted);
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.tag-input {
  flex: 1; min-width: 140px; border: 0 !important; box-shadow: none !important;
  outline: none; padding: 4px 2px; margin: 0; background: transparent;
}
