/* ======================================================================================================
   管理控制台 (admin.js, admin-ui.js, admin-settings.js, calls.js inside the console).
   Colours come from app.css's tokens; this file adds the admin's semantic states and its components.
   Type scale 20 / 16 / 14 / 13 / 12, spacing 4 / 8 / 12 / 16 / 24, radius 6 (controls) / 8 (cards).
   States always carry an icon and words (statusBadge), never colour alone.
   ====================================================================================================== */
:root {
  --adm-ok: var(--online);
  --adm-ok-soft: #E7F3EC;
  --adm-ok-line: #B8D6C4;
  --adm-warn: #8F5A00;
  --adm-warn-soft: #FFF5E1;
  --adm-warn-line: #E2C58F;
  --adm-error: var(--danger);
  --adm-error-soft: #FBEDEC;
  --adm-error-line: #E3B6B2;
  --adm-idle: var(--faint);
  --adm-idle-soft: var(--raised);
  --adm-nav-w: 224px;
  /* 界面模板 hooks (themes/README.md): a theme restyles the console through these, not by editing this file */
  --adm-nav-bg: var(--surface);
  --adm-nav-line: var(--line);
  --adm-nav-active-bg: var(--accent-soft);
  --adm-nav-active-ink: var(--accent-text);
  --adm-page-bg: transparent;
  --adm-title-font: var(--sans);
  --adm-title-size: 18px;
  --adm-num-font: var(--sans);
  --adm-card-bg: var(--surface);
  --adm-card-line: var(--line);
  --adm-card-radius: 8px;
  --adm-card-shadow: none;
  --adm-stat-bg: var(--adm-card-bg);
  --adm-stat-line: var(--adm-card-line);
  --adm-stat-gap: 12px;
  /* 趋势图 (admin-charts.js): every colour, font and line a chart draws with; themes override these (README 「图表变量」).
     Series and bar pairs checked with the dataviz palette validator on white (CVD ΔE ≥ 14). */
  --adm-chart-font: var(--sans);
  --adm-chart-num-font: var(--mono);
  --adm-chart-text: var(--faint);
  --adm-chart-text-strong: var(--text);
  --adm-chart-grid: #ECEEF2;
  --adm-chart-axis: var(--line-strong);
  --adm-chart-line: #91520C;
  --adm-chart-line-2: #3B6FB6;
  --adm-chart-area: rgba(145, 82, 12, .10);
  --adm-chart-capacity: var(--text-2);
  --adm-chart-limit: #B43B3A;
  --adm-chart-bar: #C08A3E;
  --adm-chart-bad: #B43B3A;
  --adm-health-ok: #3E9A68;
  --adm-health-warn: #C2413B;
  --adm-health-off: #E4E7EC;
  --adm-chart-unknown: #F1F3F5;
  --adm-chart-hatch: #AEB5C0;
  --adm-chart-hatch-bg: transparent;
  --adm-chart-gap-text: var(--faint);
  --adm-chart-restart: var(--text-2);
  --adm-chart-cross: var(--line-strong);
  --adm-chart-surface: var(--adm-card-bg);
  --adm-chart-tip-bg: var(--surface);
  --adm-chart-tip-line: var(--line);
  --adm-chart-tip-text: var(--text);
  --adm-chart-tip-muted: var(--faint);
  --adm-chart-tip-shadow: 0 4px 16px rgba(17, 24, 39, .10);
  --adm-chart-height: 200px;
  --adm-chart-tl-row: 28px;
  --adm-chart-tl-label-w: 148px;
}

/* ---------- shell: the view, the side nav, the main column ---------- */
#view-admin { max-width: none; padding: 0; gap: 0; }
#view-admin > .navbar { display: none; }             /* the side nav carries the console's name and the way back */
.console { display: grid; grid-template-columns: var(--adm-nav-w) minmax(0, 1fr); align-items: start; align-content: start; min-width: 0;
  min-height: calc(100dvh - 64px);
  /* the nav column's surface and rule run the full page height, past the sticky nav */
  background: linear-gradient(to right, var(--adm-nav-bg) calc(var(--adm-nav-w) - 1px), var(--adm-nav-line) calc(var(--adm-nav-w) - 1px),
    var(--adm-nav-line) var(--adm-nav-w), var(--adm-page-bg) var(--adm-nav-w)); }
.adm-nav { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 16px; height: calc(100dvh - 64px);
  overflow-y: auto; padding: 16px 12px 24px; }
.adm-nav-head { display: flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 4px; }
.adm-nav-title { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.adm-nav-back { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); }
.console-nav-group { display: flex; flex-direction: column; gap: 2px; }
.console-nav-label { padding: 0 10px 4px; font-size: 12px; color: var(--faint); }
.console-nav-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 6px;
  color: var(--text-2); text-decoration: none; font-size: 14px; }
.console-nav-item svg { flex: none; width: 16px; height: 16px; color: var(--muted); }
.adm-nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-nav-item .nav-count { margin-left: auto; }
.console-nav-item[aria-current="page"] { background: var(--adm-nav-active-bg); color: var(--adm-nav-active-ink); font-weight: 500; }
.console-nav-item[aria-current="page"] svg { color: var(--accent); }
.console-nav-item:focus-visible, .adm-nav-back:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-count { display: inline-block; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font: 600 11px/18px var(--sans); text-align: center; }
@media (hover: hover) {
  .console-nav-item:not([aria-current="page"]):hover, .adm-nav-back:hover { background: var(--bg); color: var(--text); }
}
.console-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 16px 32px 48px; container-type: inline-size; }
.admin-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- page header: one line, no hero ---------- */
.adm-page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  min-height: 40px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.adm-page-title { display: flex; align-items: baseline; gap: 4px 12px; min-width: 0; flex: 1 1 320px; flex-wrap: wrap; }
.adm-page-head .console-title { margin: 0; font-family: var(--adm-title-font); font-size: var(--adm-title-size); font-weight: 600; line-height: 1.4; white-space: nowrap; }
.adm-page-desc { margin: 0; min-width: 0; flex: 1 1 200px; font-size: 13px; line-height: 1.5; color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-page-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adm-updated { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.adm-updated[data-stale="true"] { color: var(--adm-warn); }
.adm-updated svg { width: 14px; height: 14px; }

/* ---------- buttons ---------- */
.adm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; min-width: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 13px;
  font-weight: 500; white-space: nowrap; }
.adm-btn svg { flex: none; width: 16px; height: 16px; }
.adm-btn:has(> svg:only-child) { padding: 0; width: 32px; }
.adm-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.adm-btn-danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.adm-btn-danger-outline { color: var(--danger); border-color: var(--adm-error-line); }
.adm-btn-text { border-color: transparent; background: transparent; color: var(--accent); padding: 0 6px; }
.adm-btn:disabled { opacity: .5; cursor: default; }
.adm-btn:focus-visible, .adm-tab:focus-visible, .adm-stat-link:focus-visible, .adm-row-link:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) {
  .adm-btn-default:not(:disabled):hover { background: var(--bg); }
  .adm-btn-text:not(:disabled):hover { background: var(--accent-soft); }
}

/* ---------- status ---------- */
.adm-badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px 0 6px; border-radius: 11px;
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; border: 1px solid transparent; }
.adm-badge svg { flex: none; width: 14px; height: 14px; }
.adm-badge[data-state="ok"] { background: var(--adm-ok-soft); color: var(--adm-ok); border-color: var(--adm-ok-line); }
.adm-badge[data-state="warn"] { background: var(--adm-warn-soft); color: var(--adm-warn); border-color: var(--adm-warn-line); }
.adm-badge[data-state="error"] { background: var(--adm-error-soft); color: var(--adm-error); border-color: var(--adm-error-line); }
.adm-badge[data-state="idle"], .adm-badge[data-state="unknown"] { background: var(--adm-idle-soft); color: var(--muted); border-color: var(--line); }
.adm-state-icon { display: inline-flex; }
.adm-state-icon svg { width: 14px; height: 14px; }
[data-state="ok"] > .adm-state-icon, .adm-state-icon[data-state="ok"] { color: var(--adm-ok); }
.adm-state-icon[data-state="warn"] { color: var(--adm-warn); }
.adm-state-icon[data-state="error"] { color: var(--adm-error); }
.adm-state-icon[data-state="idle"], .adm-state-icon[data-state="unknown"] { color: var(--faint); }

.adm-meter { display: block; min-width: 64px; }
.adm-meter-track { display: block; height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.adm-meter-fill { display: block; height: 100%; border-radius: 3px; background: var(--adm-ok); min-width: 0; }
.adm-meter[data-state="warn"] .adm-meter-fill { background: #C98A1B; }
.adm-meter[data-state="error"] .adm-meter-fill { background: var(--adm-error); }
.adm-meter[data-state="idle"] .adm-meter-fill, .adm-meter[data-state="unknown"] .adm-meter-fill { background: var(--line-strong); }

/* ---------- KPI row ---------- */
.adm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--adm-stat-gap); }
.adm-stat { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 12px 16px; border-radius: var(--adm-card-radius);
  background: var(--adm-stat-bg); border: 1px solid var(--adm-stat-line); color: inherit; font: inherit; text-align: left; }
.adm-stat[data-state="warn"] { box-shadow: inset 3px 0 0 #C98A1B; }
.adm-stat[data-state="error"] { box-shadow: inset 3px 0 0 var(--adm-error); }
.adm-stat-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.adm-stat-value { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.adm-stat-num { font-family: var(--adm-num-font); font-size: 24px; font-weight: 600; line-height: 1.25; color: var(--text); font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere; }
.adm-stat-unit { font-size: 13px; color: var(--muted); }
.adm-stat[data-state="warn"] .adm-stat-num { color: var(--adm-warn); }
.adm-stat[data-state="error"] .adm-stat-num { color: var(--adm-error); }
.adm-stat-hint { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; line-height: 1.5; color: var(--faint); overflow-wrap: anywhere; }
.adm-stat-link { cursor: pointer; }
@media (hover: hover) { .adm-stat-link:hover { border-color: var(--line-strong); background: var(--bg); } }

/* ---------- cards ---------- */
.adm-card { display: flex; flex-direction: column; min-width: 0; border-radius: var(--adm-card-radius); background: var(--adm-card-bg);
  border: 1px solid var(--adm-card-line); box-shadow: var(--adm-card-shadow); }
.adm-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; min-height: 48px;
  padding: 8px 16px; border-bottom: 1px solid var(--line); }
.adm-card-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.adm-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adm-card-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px; container-type: inline-size; }
.adm-card-dense > .adm-card-body { padding: 0; gap: 0; }
.adm-card-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }
.adm-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.adm-grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@container (max-width: 920px) { .adm-grid-2, .adm-grid-main { grid-template-columns: minmax(0, 1fr); } }

/* ---------- description list ---------- */
.adm-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13px; }
.adm-dl-row { display: contents; }
.adm-dl dt { color: var(--faint); }
.adm-dl dd { margin: 0; color: var(--text-2); overflow-wrap: anywhere; min-width: 0; }
.adm-dl-2 { grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); }
@container (max-width: 560px) { .adm-dl-2 { grid-template-columns: max-content minmax(0, 1fr); } }

/* ---------- empty / error ---------- */
.adm-state-block { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 20px 16px; }
.adm-state-block-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--raised); color: var(--muted); }
.adm-error .adm-state-block-icon { background: var(--adm-error-soft); color: var(--adm-error); }
.adm-state-block-text { flex: 1 1 200px; min-width: 0; }
.adm-state-block-title { margin: 0; font-size: 14px; font-weight: 500; color: var(--text-2); }
.adm-state-block-body { margin: 2px 0 0; font-size: 13px; line-height: 1.6; color: var(--faint); }
.adm-muted { color: var(--faint); }
.adm-mono, .adm-num { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.adm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.adm-skel { display: inline-block; width: 70%; height: 10px; border-radius: 4px; background: var(--raised); }
@media (prefers-reduced-motion: no-preference) { .adm-skel { animation: skel 1.4s ease-in-out infinite; } }

/* ---------- tables: rows with a header when wide, label/value cards when narrow ---------- */
.adm-table-wrap { min-width: 0; container-type: inline-size; }
.adm-table-wrap[data-loading] { opacity: .6; }
.adm-table-inner { overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm-table th { padding: 8px 12px; font-size: 12px; font-weight: 500; color: var(--faint); text-align: left; white-space: nowrap;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.adm-table td { padding: 10px 12px; color: var(--text-2); vertical-align: middle; border-bottom: 1px solid var(--line); min-width: 0;
  overflow-wrap: anywhere; }
.adm-table tbody tr:last-child td { border-bottom: 0; }
.adm-table [data-align="right"] { text-align: right; }
.adm-table [data-align="center"] { text-align: center; }
.adm-table .adm-td-primary { color: var(--text); font-weight: 500; }
.adm-table-msg td { padding: 0; }
.adm-row-link { cursor: pointer; }
.adm-table tr[aria-selected="true"] td { background: var(--bg); }
.adm-table tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
@media (hover: hover) { .adm-row-link:hover td { background: var(--bg); } }
@container (max-width: 640px) {
  .adm-table, .adm-table tbody, .adm-table tr, .adm-table td { display: block; width: 100%; }
  .adm-table thead { display: none; }
  .adm-table tbody tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .adm-table tbody tr:last-child { border-bottom: 0; }
  .adm-table td { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; border: 0; font-size: 13px; text-align: right; }
  .adm-table td[data-label]::before { content: attr(data-label); flex: none; color: var(--faint); text-align: left; }
  .adm-table td.adm-td-primary { display: block; padding-bottom: 4px; font-size: 14px; text-align: left; }
  .adm-table td.adm-td-primary::before { content: none; }
  .adm-table-msg td { display: block; text-align: left; }
  .adm-table-skel td::before { content: none !important; }
  .adm-table tr[aria-selected="true"] { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
  .adm-table tr[aria-selected="true"] td, .adm-table tr[aria-selected="true"] td:first-child { background: none; box-shadow: none; }
}

/* ---------- filters, pagination, tabs ---------- */
.adm-filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adm-search { position: relative; display: flex; align-items: center; flex: 0 1 280px; min-width: 180px; }
.adm-search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.adm-search-input { width: 100%; height: 32px; padding: 0 10px 0 32px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); font-size: 13px; }
.adm-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adm-filters select, .adm-select { height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); font-size: 13px; }
.adm-filter-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.adm-pagination { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; font-size: 13px;
  color: var(--muted); }
.adm-page-btns { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.adm-page-no { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.adm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.adm-tab { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 0; margin-bottom: -1px;
  border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 14px; white-space: nowrap; }
.adm-tab[aria-selected="true"] { color: var(--text); font-weight: 500; border-bottom-color: var(--accent); }
.adm-tab-count { min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--raised); font-size: 12px; color: var(--muted); }

/* ---------- confirmation dialog ---------- */
.adm-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; border-radius: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); box-shadow: 0 12px 40px rgba(28, 36, 48, .18); }
.adm-dialog::backdrop { background: rgba(28, 36, 48, .34); }
.adm-dialog-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.adm-dialog-body { margin: 0 0 12px; font-size: 14px; line-height: 1.7; color: var(--text-2); }
.adm-diff { width: 100%; margin: 0 0 12px; border-collapse: collapse; font-size: 13px; }
.adm-diff th, .adm-diff td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.adm-diff thead th { color: var(--faint); font-weight: 500; }
.adm-diff tbody th { color: var(--muted); font-weight: 400; white-space: nowrap; }
.adm-diff td { color: var(--muted); }
.adm-diff .adm-diff-after { color: var(--text); font-weight: 500; }
.adm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- narrow screens: the nav becomes a segmented strip under the site header ---------- */
@media (max-width: 899px) {
  .console { grid-template-columns: minmax(0, 1fr); background: none; }
  .adm-nav { background: var(--adm-nav-bg); position: sticky; top: 64px; z-index: 4; flex-direction: row; align-items: center; gap: 4px; height: auto;
    padding: 8px 16px; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .adm-nav::-webkit-scrollbar { display: none; }
  .adm-nav-head { flex: none; padding: 0; }
  .adm-nav-title { display: none; }
  .console-nav-group { flex-direction: row; gap: 4px; flex: none; }
  .console-nav-label { display: none; }
  .console-nav-item { height: 32px; padding: 0 10px; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); }
  .console-nav-item[aria-current="page"] { border-color: var(--accent-soft); }
  .console-main { padding: 12px 16px 32px; }
  .adm-page-desc { white-space: normal; flex-basis: 100%; }
}
@media (max-width: 480px) {
  .adm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .adm-stat { padding: 10px 12px; }
  .adm-stat-num { font-size: 20px; }
  .adm-search { flex: 1 1 100%; }
  .adm-filter-actions { margin-left: 0; }
  .adm-dialog-actions .adm-btn { flex: 1 1 0; height: 40px; }
}

/* ---------- shared by the console pages (kept from app.css) ---------- */
.stack-2 { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-title { margin: 0; font-size: 16px; font-weight: 600; }
a.text-action { text-decoration: none; }
.status-tag { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px;
  font-size: 12px; border: 1px solid var(--adm-ok-line); color: var(--online); white-space: nowrap; }
.status-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-tag[data-state="warn"] { border-color: var(--adm-warn-line); color: var(--adm-warn); }
.status-tag[data-state="error"] { border-color: var(--adm-error-line); color: var(--danger); }

/* ---------- page parts: 概览 ---------- */
.adm-cell-sub { font-size: 12px; line-height: 1.5; color: var(--faint); font-weight: 400; }
.adm-num[data-state="warn"] { color: var(--adm-warn); }
.ov-attention:empty { display: none; }
.ov-alerts { list-style: none; margin: 0; padding: 0; border: 1px solid var(--adm-warn-line); border-radius: 8px; background: var(--adm-warn-soft); }
.ov-alerts:has(.ov-alert[data-state="error"]) { border-color: var(--adm-error-line); background: var(--adm-error-soft); }
.ov-alert { display: flex; align-items: center; gap: 8px 12px; min-height: 44px; padding: 6px 12px; flex-wrap: wrap; }
.ov-alert + .ov-alert { border-top: 1px solid rgba(0, 0, 0, .06); }
.ov-alert-text { flex: 1 1 240px; min-width: 0; font-size: 14px; color: var(--text); }
.ov-allclear { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; border: 1px solid var(--adm-ok-line);
  border-radius: 8px; background: var(--adm-ok-soft); font-size: 14px; color: var(--text-2); }
.ov-load { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ov-load .adm-meter { flex: 1 1 80px; max-width: 160px; }
.ov-load .adm-num { flex: none; }
.ov-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.ov-flag { display: inline-block; padding: 1px 8px; border-radius: 4px; background: var(--adm-warn-soft); color: var(--adm-warn); font-size: 12px;
  line-height: 20px; white-space: nowrap; }

/* ---------- page parts: 模型与服务 ---------- */
.svc-ckpt { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.svc-detail:empty { display: none; }
.svc-detail { border-top: 1px solid var(--line); background: var(--bg); }
.svc-detail-body { display: flex; flex-direction: column; gap: 16px; padding: 16px; container-type: inline-size; }
.svc-detail-head { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.svc-detail-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.svc-prompt { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.model-llm { display: flex; flex-direction: column; gap: 16px; }
.model-inuse-name { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 500; color: var(--text); }
.model-form { display: flex; flex-direction: column; gap: 12px; max-width: 760px; padding-top: 16px; border-top: 1px solid var(--line); }
.model-profile { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.model-profile > .adm-field { flex: 1 1 240px; min-width: 0; }
.model-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@container (min-width: 600px) { .model-fields { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); } }
.model-actions { display: flex; justify-content: flex-end; gap: 8px; }
.adm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.adm-label { font-size: 13px; color: var(--muted); }
.adm-input, .adm-field .adm-select { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); font-size: 14px; color: var(--text); }
.adm-input:focus-visible, .adm-select:focus-visible, .adm-search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.adm-input:disabled, .adm-select:disabled { background: var(--bg); color: var(--muted); }
@media (max-width: 480px) { .model-actions .adm-btn { flex: 1 1 0; height: 40px; } }

/* pages not yet on the framework: their own section title repeats the page header */
.console .admin-panel > .admin-head > .admin-h2, .console .admin-panel > .admin-head > .stack-4 > .admin-h2,
.console .admin-panel .calls-hint { display: none; }
.console .admin-panel > .admin-head { justify-content: flex-end; }
.console .admin-panel > .admin-head:empty { display: none; }

/* ---------- page styles moved from app.css (users, invites, sessions, audit, dialogs, transcripts) ---------- */
/* 管理 → 在线: conversation monitor (admin.js) */
.session-open { cursor: pointer; }
.role.speaking { color: var(--accent); }
.transcript { display: flex; flex-direction: column; gap: 10px; }
.t-line { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--raised); }
.t-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--faint); }
.t-text { font-size: 15px; line-height: 1.6; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.t-assistant { background: transparent; border: 1px solid var(--line); }
.t-tool, .t-task { background: transparent; padding-top: 4px; padding-bottom: 4px; }
.t-tool .t-head, .t-task .t-head { color: var(--accent); }
.t-tool .t-text, .t-task .t-text { font-size: 13px; }


/* 管理后台 (admin.js): overview tiles on top, a side nav on wide screens (segmented tabs on narrow ones),
   tables that read as rows with a header on wide panels and stack into cards on narrow ones. */
#view-mycalls { max-width: 1440px; }
#view-admin select.input { appearance: auto; -webkit-appearance: auto; }
.notice[data-level="ok"] { border-color: #B8D6C4; color: var(--online); }
.btn-40 { height: 40px; padding: 0 16px; font-size: 14px; border-radius: 8px; }
.input-sm { height: 40px; border-radius: 8px; padding: 0 12px; }
  background: var(--surface); border: 1px solid var(--line); color: inherit; font: inherit; }
.admin-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.admin-main { min-width: 0; container-type: inline-size; }
.admin-tabs button[aria-selected="true"] { background: var(--line); color: var(--text); font-weight: 500; }
.nav-count { display: inline-block; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font: 600 11px/18px var(--sans); text-align: center; vertical-align: 1px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; min-height: 40px; }
.admin-h2 { margin: 0; font-size: 18px; font-weight: 600; }
.admin-h3 { margin: 8px 0 -4px; font-size: 14px; font-weight: 500; color: var(--muted); }
.admin-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field select { width: auto; min-width: 116px; }
.admin-tools input[type="search"] { width: 260px; max-width: 100%; }
.admin-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pager-btns { display: flex; gap: 8px; margin-left: auto; }
.admin-empty { display: flex; flex-direction: column; gap: 4px; padding: 28px 16px; border: 1px dashed var(--line-strong);
  border-radius: 8px; text-align: center; }
.admin-empty-title { font-size: 15px; color: var(--text-2); }
.monitor-note { padding-top: 4px; }

.dt { min-width: 0; border-radius: var(--adm-card-radius); background: var(--adm-card-bg); border: 1px solid var(--adm-card-line); overflow: hidden; }
.dt-head { display: none; }
.dt-body > * + * { border-top: 1px solid var(--line); }
.dt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; width: 100%; min-width: 0; padding: 12px 14px; }
.dt-row::after { content: ""; order: 2; flex-basis: 100%; height: 0; }
.dt-main { order: 0; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 15px; color: var(--text); }
.dt-act { order: 1; flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.dt-cell:not(.dt-main):not(.dt-act) { order: 3; font-size: 12px; color: var(--muted); }
.dt-cell[data-label]:not([data-label=""])::before { content: attr(data-label) "\00a0"; color: var(--faint); }
.dt-title { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-sub { font-size: 12px; color: var(--faint); }
.dt-wrap { white-space: normal; overflow-wrap: anywhere; }
.dt-empty { padding: 16px 14px; font-size: 14px; color: var(--muted); }
.dt .badge { height: 22px; line-height: 20px; padding: 0 8px; font-size: 12px; border-radius: 4px; }
.badge[data-state="ended"] { color: var(--faint); }
.dt-row .role { margin-left: 0; }
.dt-row-button { border: 0; background: transparent; color: inherit; font: inherit; text-align: left; }
.dt-user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dt-user .avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.chevron { display: block; width: 8px; height: 8px; margin: 0 4px; border-right: 1.5px solid var(--faint);
  border-bottom: 1.5px solid var(--faint); transform: rotate(45deg); transition: transform .15s; }
[aria-expanded="true"] .chevron { transform: rotate(-135deg); }
.user-wrap[data-state="pending"] > .dt-row { background: var(--accent-soft); }
.user-editor { padding: 14px; border-top: 1px dashed var(--line); background: var(--bg); }
.editor-limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }
.editor-limits .btn { grid-column: 1 / -1; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (hover: hover) {
  .dt-row-button:hover { background: var(--raised); }
}
@container (min-width: 860px) {
  .dt-head { display: grid; grid-template-columns: var(--cols); gap: 12px; padding: 10px 16px; font-size: 12px; color: var(--faint);
    border-bottom: 1px solid var(--line); }
  .dt-row { display: grid; grid-template-columns: var(--cols); gap: 12px; padding: 10px 16px; min-height: 52px; }
  .dt-row::after { content: none; }
  .dt-row > .dt-act { order: 0; }
  .dt-cell .mono { font-size: 13px; }
  .dt-cell:not(.dt-main):not(.dt-act) { order: 0; font-size: 14px; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
  .dt-cell[data-label]::before { content: none !important; }
  .dt-main { font-size: 14px; }
  .editor-limits { grid-template-columns: 180px 180px auto; justify-content: start; }
  .editor-limits .btn { grid-column: auto; }
}

.admin-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px;
  border-radius: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); }
.admin-dialog::backdrop { background: rgba(28, 36, 48, .34); }
.admin-dialog .input { height: 48px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.codebox-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 14px;
  border-radius: 8px; background: var(--raised); border: 1px solid var(--line); }
.codebox-row code { min-width: 0; user-select: all; }
.admin-dialog .qr-box { width: min(200px, 56vw); }
.copy-state:empty { display: none; }
.copy-state { color: var(--online); }

.transcript-view { max-width: 760px; display: flex; flex-direction: column; gap: 12px; }
.transcript-back { align-self: flex-start; }
.transcript-head { padding: 14px 16px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.transcript-head [data-live="true"] { color: var(--accent); }
.stack-4 { display: flex; flex-direction: column; gap: 4px; }

@media (min-width: 960px) {
  #view-mycalls { padding-left: 32px; padding-right: 32px; }
  .admin-body { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 28px; align-items: start; }
  .admin-nav { position: sticky; top: 16px; }
  .admin-tabs { display: flex; flex-direction: column; gap: 2px; padding: 0; background: transparent; border: 0; }
  .admin-tabs button { height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px;
    border-radius: 6px; font-size: 15px; text-align: left; }
  .admin-tabs button[aria-selected="true"] { background: var(--surface); box-shadow: inset 2px 0 0 var(--accent); }
}
@media (hover: hover) and (min-width: 960px) {
  .admin-tabs button[aria-selected="false"]:hover { background: var(--surface); color: var(--text-2); }
}
@media (max-width: 759px) {
  .admin-tools, .admin-tools input[type="search"] { width: 100%; }
  .inline-field { flex: 1 1 auto; }
  .inline-field select { flex: 1; }
  .dialog-actions .btn, .model-actions .btn { flex: 1 1 0; }
  .admin-dialog { padding: 20px 16px; }
  .codebox-row .small-code { font-size: 20px; letter-spacing: 1px; }
}


#myCallsRoot { container-type: inline-size; min-width: 0; }
/* 停用… on the admin rows: a native select styled like the pill buttons beside it. */
.pill-select { padding: 0 12px; cursor: pointer; background: transparent; }
.pill-select:disabled { opacity: .5; cursor: default; }
/* ---------- 趋势图 (admin-charts.js): colours, fonts and lines only through --adm-chart-* / --adm-health-* ---------- */
.chart-card-title { display: inline-flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
.chart-sub { font-size: 12px; font-weight: 400; color: var(--adm-chart-text); font-variant-numeric: tabular-nums; }
.trend-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@container (max-width: 920px) { .trend-grid { grid-template-columns: minmax(0, 1fr); } }
.chart-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.chart-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--adm-chart-text); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font: 12px/1.4 var(--adm-chart-font);
  color: var(--adm-chart-text); }
.chart-key { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chart-swatch { display: inline-block; flex: none; width: 14px; height: 2px; border-radius: 1px; background: var(--adm-chart-line); }
.chart-swatch[data-key="s2"] { background: var(--adm-chart-line-2); }
.chart-swatch-dash { height: 0; background: none; border-top: 2px dashed var(--adm-chart-capacity); }
.chart-swatch-dash[data-key="threshold"] { border-top-color: var(--adm-chart-limit); }
.chart-swatch-box { width: 10px; height: 10px; border-radius: 2px; }
.chart-swatch-box[data-key="bar"] { background: var(--adm-chart-bar); }
.chart-swatch-box[data-key="bad"] { background: var(--adm-chart-bad); }
.chart-swatch-box[data-key="ok"] { background: var(--adm-health-ok); }
.chart-swatch-box[data-key="down"] { background: var(--adm-health-warn); }
.chart-swatch-box[data-key="off"] { background: var(--adm-health-off); }
.chart-swatch-box[data-key="unknown"] { background: var(--adm-chart-unknown); box-shadow: inset 0 0 0 1px var(--adm-chart-hatch); }
.chart-swatch-hatch { width: 10px; height: 10px; border-radius: 2px; box-shadow: inset 0 0 0 1px var(--adm-chart-hatch);
  background: repeating-linear-gradient(45deg, var(--adm-chart-hatch) 0 1px, var(--adm-chart-hatch-bg) 1px 4px); }
.chart-swatch-restart { width: 0; height: 0; border-radius: 0; background: none; border: 5px solid transparent; border-top: 6px solid var(--adm-chart-restart);
  border-bottom: 0; }

.chart { position: relative; min-width: 0; }
.chart-plot { position: relative; height: var(--adm-chart-height); min-width: 0; border-radius: 4px; touch-action: pan-y; }
.chart-plot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart-svg { display: block; overflow: visible; font-family: var(--adm-chart-font); }
.chart-grid { stroke: var(--adm-chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { stroke: var(--adm-chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-tick { fill: var(--adm-chart-text); font-family: var(--adm-chart-num-font); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--adm-chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line-s2 { stroke: var(--adm-chart-line-2); }
.chart-lone { fill: var(--adm-chart-line); stroke: none; }
.chart-lone.chart-line-s2 { fill: var(--adm-chart-line-2); }
.chart-area { fill: var(--adm-chart-area); stroke: none; }
.chart-capacity { fill: none; stroke: var(--adm-chart-capacity); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-threshold { stroke: var(--adm-chart-limit); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-ref-label { font-family: var(--adm-chart-num-font); font-size: 11px; fill: var(--adm-chart-capacity); paint-order: stroke;
  stroke: var(--adm-chart-surface); stroke-width: 3px; stroke-linejoin: round; }
.chart-threshold-label { fill: var(--adm-chart-limit); }
.chart-gap { stroke: none; }
.chart-hatch { stroke: var(--adm-chart-hatch); stroke-width: 1; }
.chart-hatch-bg { fill: var(--adm-chart-hatch-bg); }
.chart-gap-label { fill: var(--adm-chart-gap-text); font-size: 11px; paint-order: stroke; stroke: var(--adm-chart-surface); stroke-width: 3px; }
.chart-restart { stroke: var(--adm-chart-restart); stroke-width: 1; stroke-dasharray: 2 2; }
.chart-restart-mark { fill: var(--adm-chart-restart); }
.chart-cross { stroke: var(--adm-chart-cross); stroke-width: 1; }
.chart-dot { fill: var(--adm-chart-line); stroke: var(--adm-chart-surface); stroke-width: 2; }
.chart-dot-s2 { fill: var(--adm-chart-line-2); }
.chart-bar { fill: var(--adm-chart-bar); }
.chart-bar-bad { fill: var(--adm-chart-bad); }
.chart-hover-band { fill: var(--adm-chart-text); opacity: .08; }
.chart-spark { display: block; flex: none; overflow: visible; }
.chart-spark-line { fill: none; stroke: var(--adm-chart-line); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-spark-line.chart-lone, .chart-spark-end { fill: var(--adm-chart-line); stroke: none; }
.adm-stat-spark { display: inline-flex; align-items: flex-end; margin-left: auto; padding-left: 8px; }
.adm-stat:has(.adm-stat-spark) .adm-stat-hint { align-items: flex-end; flex-wrap: nowrap; }
.adm-stat-hint-text { min-width: 0; }

/* the tooltip: one for every series at that time; value first, then what it is */
.chart-tip { position: absolute; top: 4px; left: 0; z-index: 2; min-width: 148px; max-width: min(280px, 90%); padding: 8px 10px;
  border-radius: 6px; background: var(--adm-chart-tip-bg); border: 1px solid var(--adm-chart-tip-line); box-shadow: var(--adm-chart-tip-shadow);
  color: var(--adm-chart-tip-text); font: 12px/1.5 var(--adm-chart-font); pointer-events: none; }
.chart-tip-title { margin: 0 0 4px; color: var(--adm-chart-tip-muted); font-family: var(--adm-chart-num-font); font-variant-numeric: tabular-nums; }
.chart-tip-row { display: flex; align-items: center; gap: 6px; margin: 0; }
.chart-tip-row[data-muted="true"] .chart-tip-value { color: var(--adm-chart-tip-muted); font-weight: 500; }
.chart-tip-key { flex: none; width: 10px; height: 2px; border-radius: 1px; background: var(--adm-chart-line); }
.chart-tip-key[data-key="s2"] { background: var(--adm-chart-line-2); }
.chart-tip-key[data-key="capacity"] { height: 0; background: none; border-top: 2px dashed var(--adm-chart-capacity); }
.chart-tip-key[data-key="bar"] { height: 8px; background: var(--adm-chart-bar); }
.chart-tip-key[data-key="bad"] { height: 8px; background: var(--adm-chart-bad); }
.chart-tip-key[data-key^="state-"] { height: 8px; border-radius: 2px; }
.chart-tip-key[data-key="state-ok"] { background: var(--adm-health-ok); }
.chart-tip-key[data-key="state-down"] { background: var(--adm-health-warn); }
.chart-tip-key[data-key="state-off"] { background: var(--adm-health-off); }
.chart-tip-key[data-key="state-unknown"] { background: var(--adm-chart-unknown); box-shadow: inset 0 0 0 1px var(--adm-chart-hatch); }
.chart-tip-key[data-key="state-stopped"] { background: repeating-linear-gradient(45deg, var(--adm-chart-hatch) 0 1px, var(--adm-chart-hatch-bg) 1px 3px); }
.chart-tip-value { font-family: var(--adm-chart-num-font); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-tip-label { min-width: 0; color: var(--adm-chart-tip-muted); overflow-wrap: anywhere; }
.chart-tip-note { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--adm-chart-tip-line); color: var(--adm-chart-tip-muted); }

/* 健康时间线: names on the left (HTML, so long names ellipsize), strips in one SVG on the right */
.chart-tl-wrap { display: grid; grid-template-columns: var(--adm-chart-tl-label-w) minmax(0, 1fr); gap: 12px; align-items: start; }
.chart-tl-names { margin: 0; padding: var(--adm-chart-tl-top, 10px) 0 0; list-style: none; }
.chart-tl-name { height: var(--adm-chart-tl-row); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12px/var(--adm-chart-tl-row) var(--adm-chart-font);
  color: var(--adm-chart-text-strong); }
.chart-tl-plot { height: auto; }
.chart-seg-track { fill: var(--adm-chart-unknown); }
.chart-seg[data-state="ok"] { fill: var(--adm-health-ok); }
.chart-seg[data-state="down"] { fill: var(--adm-health-warn); }
.chart-seg[data-state="off"] { fill: var(--adm-health-off); }
.chart-seg[data-state="unknown"] { fill: var(--adm-chart-unknown); }
.chart-seg-label { fill: var(--adm-chart-text); font-size: 11px; }
@container (max-width: 520px) { .chart-tl-wrap { --adm-chart-tl-label-w: 96px; gap: 8px; } }

/* while a chart has nothing to draw: as tall as a chart, so the page does not jump */
.chart-state { display: flex; flex-direction: column; justify-content: center; min-height: var(--adm-chart-height); }
.chart-state[data-kind="loading"] { align-items: flex-start; gap: 10px; padding: 0 4px; }
.chart-state-text { margin: 0; font-size: 12px; color: var(--adm-chart-text); }
.chart-state .adm-state-block { padding: 12px 4px; }

/* 模型与服务 → the selected instance's trends */
.svc-trends { display: flex; flex-direction: column; gap: 12px; }
.svc-trends-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.svc-trends[aria-busy="true"] .chart-body { opacity: .5; transition: opacity .2s; }
.chart-panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px; border: 1px solid var(--adm-card-line);
  border-radius: var(--adm-card-radius); }
.chart-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.chart-range { display: inline-flex; padding: 2px; gap: 2px; border-radius: 6px; background: var(--raised); }
.chart-range-btn { height: 28px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted);
  font: 500 12px/1 var(--adm-chart-font); white-space: nowrap; cursor: pointer; }
.chart-range-btn[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(17, 24, 39, .08); }
.chart-range-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) { .chart-range-btn[aria-checked="false"]:hover { color: var(--text); } }
@media (forced-colors: active) {
  .chart-line, .chart-capacity, .chart-threshold { stroke: CanvasText; }
  .chart-bar, .chart-seg[data-state="ok"] { fill: CanvasText; }
}
