/* CrossDriver 管理台样式（2026-10-29 重做：侧边栏布局 + 深色模式 + 响应式） */
:root {
  --bg: #f4f5f8; --card: #fff; --card-2: #f9fafb; --line: #e4e7ec; --line-2: #eef0f4;
  --text: #182230; --muted: #667085; --faint: #98a2b3;
  --primary: #2563eb; --primary-ink: #fff; --primary-soft: #eaf1ff;
  --danger: #d92d20; --danger-soft: #fee4e2;
  --ok: #067647; --ok-soft: #dcfae6;
  --warn: #b54708; --warn-soft: #fef0c7;
  --side: #101828; --side-ink: #cfd5e0; --side-dim: #7b8498; --side-hover: #1d2939; --side-active: #2563eb;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.22);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111b; --card: #151b28; --card-2: #1a2130; --line: #27303f; --line-2: #202837;
    --text: #e6e9ef; --muted: #98a2b3; --faint: #667085;
    --primary: #4c8dff; --primary-ink: #fff; --primary-soft: #1a2a4a;
    --danger: #f97066; --danger-soft: #3b1a18;
    --ok: #47cd89; --ok-soft: #12301f;
    --warn: #fdb022; --warn-soft: #3a2a0a;
    --side: #0a0e17; --side-hover: #151b28;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.err { color: var(--danger); min-height: 1.2em; margin: 4px 0; font-size: 13px; }
.spacer { flex: 1; }
a { color: var(--primary); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--card-2); border: 1px solid var(--line-2); padding: 0 4px; border-radius: 4px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* ───── 控件 ───── */
button, .btn { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: var(--radius); padding: 6px 14px; cursor: pointer; line-height: 1.4; transition: background .12s, border-color .12s, opacity .12s; }
button:hover { background: var(--card-2); border-color: var(--faint); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
button.primary:hover { filter: brightness(1.08); background: var(--primary); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover { filter: brightness(1.08); background: var(--danger); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { background: var(--card-2); color: var(--text); }
button.sm, td.actions button { padding: 2px 10px; font-size: 12px; }
input, select, textarea { font: inherit; font-size: 13px; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { width: 100%; resize: vertical; }
input[type=search] { width: 220px; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
label.upload-btn, .upload-btn { display: inline-flex; align-items: center; gap: 4px; background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 14px; cursor: pointer; font-size: 13px; margin: 0; }
.upload-btn:hover { background: var(--card-2); border-color: var(--faint); }

/* ───── 登录 ───── */
.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.login-card { background: var(--card); padding: 32px; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); width: 360px; max-width: 100%; display: grid; gap: 12px; }
.login-card .brand { margin-bottom: 4px; }
.login-card h1 { font-size: 18px; margin: 0; }
.login-card input { width: 100%; padding: 9px 11px; font-size: 14px; }
.login-card button { padding: 9px; font-size: 14px; }

.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: 0 0 auto; }

/* ───── 主布局 ───── */
#main { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
aside.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
aside.side .brand { padding: 18px 18px 14px; color: #fff; font-weight: 600; font-size: 15px; }
aside.side nav { padding: 4px 10px 16px; flex: 1; }
.nav-group { font-size: 11px; letter-spacing: .06em; color: var(--side-dim); padding: 14px 10px 5px; text-transform: uppercase; }
aside.side nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--side-ink); text-decoration: none; font-size: 13.5px; margin-bottom: 1px; }
aside.side nav a:hover { background: var(--side-hover); color: #fff; }
aside.side nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
aside.side nav a .dot { margin-left: auto; min-width: 18px; padding: 0 6px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--side-hover); font-size: 12px; color: var(--side-dim); display: grid; gap: 2px; }
.side-foot b { color: var(--side-ink); font-weight: 600; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar #menu-btn { display: none; padding: 4px 8px; }
#srv-badge { font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: 0 0 auto; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; }
.pill.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.bad i { background: var(--danger); }
.banner { margin: 16px 24px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); font-size: 13px; display: flex; gap: 10px; align-items: center; }
section.page { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }
.page-desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

/* ───── 表格 ───── */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; }
.table-wrap table { margin: 0; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-2); font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th { background: var(--card-2); color: var(--muted); font-weight: 600; white-space: nowrap; font-size: 12px; position: sticky; top: 0; }
table.sortable th { cursor: pointer; user-select: none; }
table.sortable th:hover { color: var(--text); }
table.sortable th[data-dir="asc"]::after { content: " ▲"; font-size: 9px; }
table.sortable th[data-dir="desc"]::after { content: " ▼"; font-size: 9px; }
td .mono { word-break: break-all; }
tbody tr:hover td { background: var(--card-2); }
tr.clickable { cursor: pointer; }
td.actions { white-space: nowrap; text-align: right; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
.count { font-size: 12px; color: var(--muted); }

/* ───── 卡片 / 总览 ───── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.card h3 .muted { font-weight: 400; margin-left: 6px; }
.card.narrow { max-width: 760px; }
.pub-grid, .stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; display: block; text-decoration: none; color: inherit; }
.kpi:hover { border-color: var(--primary); }
.kpi .k-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k-val { font-size: 26px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -.01em; }
.kpi .k-val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); }
.kpi.alert .k-val { color: var(--danger); }
.snap-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 280px; overflow: auto; }
.snap-list li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 12px; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 12.5px; align-items: baseline; }
.activity li:first-child { border-top: none; }
.activity .t { color: var(--faint); flex: 0 0 auto; font-variant-numeric: tabular-nums; }

/* ───── 条形图 ───── */
.bars { display: grid; gap: 5px; max-height: 320px; overflow: auto; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 72px; gap: 8px; align-items: center; font-size: 12px; }
.bar-track { background: var(--line-2); border-radius: 4px; height: 12px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; border-radius: 4px; min-width: 2px; }
.bar-row .num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ───── 徽标 / chips ───── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: 12px; cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--faint); }
.chip b { color: var(--primary); }
.chip.active { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; white-space: nowrap; background: var(--line-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.no { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--primary-soft); color: var(--primary); }
.badge.na { background: var(--line-2); color: var(--muted); }

/* ───── 反馈 ───── */
.fb-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.fb-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-bottom: 6px; align-items: center; }
.fb-body { white-space: pre-wrap; word-break: break-word; }
.fb-actions { margin-top: 8px; display: flex; gap: 6px; }

/* ───── 对话框 ───── */
dialog { border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(780px, 94vw); max-height: 92vh; padding: 0; background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(10,14,23,.5); backdrop-filter: blur(2px); }
dialog.small { width: min(420px, 94vw); }
.dlg-form { display: flex; flex-direction: column; max-height: 92vh; }
.dlg-head { padding: 18px 22px 0; }
.dlg-body { padding: 4px 22px 4px; overflow-y: auto; }
.dlg-form h2 { margin: 0 0 6px; font-size: 16px; }
.dlg-actions { display: flex; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line-2); align-items: center; background: var(--card); border-radius: 0 0 14px 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.hint b { color: var(--danger); }
.row { display: flex; gap: 6px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; flex: 0 0 auto; }
details.adv { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0 8px; background: var(--card-2); }
details.adv > summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; user-select: none; }
details.adv[open] > summary { margin-bottom: 12px; color: var(--text); }
.vis-block { grid-column: 1 / -1; margin-bottom: 8px; }
.vis-block .vis-head { font-size: 12px; margin-bottom: 6px; color: var(--muted); }
.vis-block .chips { margin-bottom: 0; }
pre.json { white-space: pre-wrap; max-height: 60vh; overflow: auto; margin: 0; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 12px; }

/* ───── Toast ───── */
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; max-width: min(380px, 90vw); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13px;
  animation: toast-in .18s ease-out; word-break: break-word; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) { .toast.ok { color: #07210f; } .toast.err { color: #2a0b08; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.loading { color: var(--muted); padding: 20px; text-align: center; }

/* ───── 响应式 ───── */
@media (max-width: 960px) {
  .pub-grid, .stat-grid { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  #main { grid-template-columns: 1fr; }
  aside.side { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open aside.side { transform: none; box-shadow: var(--shadow-lg); }
  .topbar #menu-btn { display: inline-block; }
  .topbar, section.page { padding-left: 14px; padding-right: 14px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  input[type=search] { width: 100%; }
}
@media (max-width: 480px) {
  #circuit-pill > span { display: none; }      /* 超窄屏只留状态圆点 */
  .topbar { gap: 8px; }
}
