:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #6b7385;
  --line: #e3e6ec;
  --accent: #2f6fdf;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e3f4ea;
  --warn: #9a6200;
  --warn-bg: #fdf1d8;
  --bad: #c0362c;
  --bad-bg: #fbe5e3;
  --chip: #eef1f6;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --card: #1b2029;
    --text: #e6e9ef;
    --muted: #949cad;
    --line: #2b3240;
    --accent: #5b8ff0;
    --accent-text: #0e1420;
    --ok: #5cc98a;
    --ok-bg: #173325;
    --warn: #e8b453;
    --warn-bg: #3a2e14;
    --bad: #f07a70;
    --bad-bg: #3d1d1b;
    --chip: #262c38;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }
b { font-weight: 600; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.link { color: var(--accent); text-decoration: none; font-size: 13px; }
.link:hover { text-decoration: underline; }

.pill { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-warn { color: var(--warn); background: var(--warn-bg); }
.pill-bad { color: var(--bad); background: var(--bad-bg); }
.pill-muted { color: var(--muted); background: var(--chip); }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }

.tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 8px;
  font: inherit; cursor: pointer;
}
.tab.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.tabs-right { margin-left: auto; }

.banner { background: var(--bad-bg); color: var(--bad); padding: 8px 12px; border-radius: 8px; margin: 0 0 12px; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid, .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; margin-bottom: 12px;
}
.grid > .card { margin-bottom: 0; }
.card-h { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.card-h .btn { margin-left: auto; }
.big { font-size: 20px; font-weight: 600; margin-bottom: 2px; overflow-wrap: anywhere; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.meter { height: 6px; background: var(--chip); border-radius: 3px; margin: 8px 0 4px; overflow: hidden; }
.meter > div { height: 100%; width: 0; background: var(--accent); }

.btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-danger { color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-small { padding: 2px 10px; font-size: 12px; }

input[type=text], input[type=password], input[type=search] {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-weight: 500; color: var(--muted); font-size: 12px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.dom { overflow-wrap: anywhere; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot-ok { background: var(--ok); }
.dot-bad { background: var(--bad); }

.audit { list-style: none; margin: 0; padding: 0; }
.audit li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit li:last-child { border-bottom: 0; }
.audit .t { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.audit .m { overflow-wrap: anywhere; }
.audit .fail { color: var(--bad); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1 1 220px; width: auto; }

.devlist { display: flex; flex-direction: column; gap: 8px; }
.dev {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) minmax(0, 1.6fr) auto; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
}
.dev .name { font-weight: 600; overflow-wrap: anywhere; }
.dev .sub { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.dev .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.dev.is-bypass { border-left: 3px solid var(--warn); }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; margin-left: 6px; font-weight: 500; vertical-align: 1px; }
.tag-on { color: var(--ok); background: var(--ok-bg); }
.tag-bypass { color: var(--warn); background: var(--warn-bg); }
@media (max-width: 760px) {
  .dev { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dev .acts { grid-column: 1 / -1; justify-content: flex-start; }
}

.inline-form { display: flex; gap: 8px; margin: 4px 0 10px; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); border-radius: 6px; padding: 3px 4px 3px 10px; max-width: 100%; }
.chips li span { overflow-wrap: anywhere; }
.chips li button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.chips li button:hover { color: var(--bad); background: var(--bad-bg); }
.chips .empty { background: transparent; color: var(--muted); padding-left: 0; }

.login { display: flex; justify-content: center; padding-top: 10vh; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; }
.login-card code { background: var(--chip); padding: 1px 4px; border-radius: 4px; font-size: 12px; overflow-wrap: anywhere; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); padding: 0; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 14, 22, .45); }
.dlg { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.dlg h2 { margin: 0 0 4px; font-size: 17px; }
.dlg label:not(.check) { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; max-width: calc(100vw - 32px);
  font-size: 13px; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); white-space: pre-line;
}
.toast.bad { background: var(--bad); color: #fff; }

select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; min-width: 0;
}
.node-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 6px; max-height: 48vh; overflow-y: auto; }
.node {
  font: inherit; display: flex; justify-content: space-between; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 8px;
  padding: 7px 10px; cursor: pointer; text-align: left;
}
.node:hover { border-color: var(--accent); }
.node:disabled { cursor: progress; opacity: .6; }
.node .d { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.node.cur { border-color: var(--accent); background: var(--chip); font-weight: 600; }
.node.cur .d { color: var(--accent); }
.node .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------------- 统计页与图表（配色经 dataviz 校验：亮 #2a78d6/#eb6834，暗 #3987e5/#d95926） */
:root {
  --s1: #2a78d6; --s2: #eb6834;
  --ch-grid: #eceef2; --ch-base: #c9ced8;
  --heat-0: #f0f2f6; --heat-1: #cde2fb; --heat-2: #9ec5f4; --heat-3: #6da7ec; --heat-4: #3987e5; --heat-5: #256abf; --heat-6: #184f95;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --s1: #3987e5; --s2: #d95926;
    --ch-grid: #252b36; --ch-base: #3a4252;
    --heat-0: #222834; --heat-1: #1c3556; --heat-2: #184f95; --heat-3: #256abf; --heat-4: #3987e5; --heat-5: #6da7ec; --heat-6: #9ec5f4;
  }
}
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { max-width: 100%; }
.segctl { display: inline-flex; background: var(--chip); border-radius: 8px; padding: 2px; }
.segctl button { font: inherit; border: 0; background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.segctl button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
#st-body { transition: opacity .15s; }
#st-body.loading { opacity: .55; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 0; }
.tile-k { font-size: 12px; color: var(--muted); }
.tile-v { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }

.ch { display: block; width: 100%; height: auto; overflow: visible; }
.ch-grid { stroke: var(--ch-grid); stroke-width: 1; }
.ch-base { stroke: var(--ch-base); stroke-width: 1; }
.ch-ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-line.s1 { stroke: var(--s1); } .ch-line.s2 { stroke: var(--s2); }
.ch-area { stroke: none; opacity: .1; }
.ch-area.s1 { fill: var(--s1); } .ch-area.s2 { fill: var(--s2); }
.ch-dot { stroke: var(--card); stroke-width: 2; }
.ch-dot.s1 { fill: var(--s1); } .ch-dot.s2 { fill: var(--s2); }
.ch-cross { stroke: var(--ch-base); stroke-width: 1; }
.ch-empty { margin: 24px 0; text-align: center; }
.ch-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ch-legend .li { display: inline-flex; align-items: center; gap: 6px; }
.k { display: inline-block; flex: none; }
.k.line { width: 14px; height: 2px; border-radius: 1px; }
.k.rect { width: 10px; height: 10px; border-radius: 2px; }
.k.s1 { background: var(--s1); } .k.s2 { background: var(--s2); } .k.heat { background: var(--heat-4); }
.ch-tip {
  position: fixed; z-index: 40; display: none; pointer-events: none; min-width: 150px; max-width: 280px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.ch-tip .tt { color: var(--muted); margin-bottom: 4px; }
.ch-tip .r { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.ch-tip .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-tip .n { color: var(--muted); }
.ch-table { margin-top: 6px; font-size: 12px; }
.ch-table summary { color: var(--muted); cursor: pointer; width: fit-content; }
.ch-table .tbl { margin-top: 6px; }
.ch-table[open] { max-height: 320px; overflow: auto; }

.ch-bars { display: flex; flex-direction: column; gap: 4px; }
.ch-bar-row {
  display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr) auto; align-items: center; gap: 10px;
  font: inherit; color: inherit; background: transparent; border: 0; padding: 4px 6px; border-radius: 6px; text-align: left; width: 100%;
}
button.ch-bar-row { cursor: pointer; }
button.ch-bar-row:hover { background: var(--chip); }
.ch-bar-row .lab { display: flex; flex-direction: column; min-width: 0; }
.ch-bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-bar-row .sub { font-size: 11px; color: var(--muted); }
.ch-bar-row .track { display: flex; gap: 2px; height: 12px; align-items: stretch; min-width: 0; }
.ch-bar-row .seg { display: block; height: 100%; }
.ch-bar-row .seg.end { border-radius: 0 4px 4px 0; }
.ch-bar-row .seg.s1 { background: var(--s1); } .ch-bar-row .seg.s2 { background: var(--s2); }
.ch-bar-row .seg:hover { filter: brightness(1.12); }
.ch-bar-row .val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.heat { display: grid; grid-template-columns: auto repeat(24, minmax(0, 1fr)); gap: 2px; align-items: center; }
.heat .hl { font-size: 11px; color: var(--muted); padding-right: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.heat .hh { font-size: 10px; color: var(--muted); text-align: left; font-variant-numeric: tabular-nums; }
.hc { display: block; height: 18px; border-radius: 3px; background: var(--heat-0); }
.hc:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hc.l1 { background: var(--heat-1); } .hc.l2 { background: var(--heat-2); } .hc.l3 { background: var(--heat-3); }
.hc.l4 { background: var(--heat-4); } .hc.l5 { background: var(--heat-5); } .hc.l6 { background: var(--heat-6); }
.heat .hc:hover { outline: 2px solid var(--text); outline-offset: -1px; }
.heat-legend { display: flex; align-items: center; gap: 3px; margin-top: 8px; flex-wrap: wrap; }
.heat-legend .hc { width: 16px; height: 10px; }
@media (max-width: 560px) { .hc { height: 14px; } .heat .hh { font-size: 9px; } }

.tbl-wrap { overflow-x: auto; }
.tbl-wrap .tbl { min-width: 560px; }
.grid > .card.span2 { grid-column: 1 / -1; }
.tag-who { color: var(--accent); background: var(--chip); margin: 0 6px 0 0; }

.tbl td.bad { color: var(--bad); font-weight: 600; }
.tbl tr.sel td { background: var(--chip); }
.link-btn { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.link-btn:hover { text-decoration: underline; }
.dl-detail-h { margin-top: 12px; }
.tbl-scroll { max-height: 420px; overflow-y: auto; }

.qr-wrap { display: flex; justify-content: center; padding: 8px; background: #fff; border-radius: 8px; width: fit-content; margin: 4px auto; }
.qr-wrap img { image-rendering: pixelated; display: block; }
#dlg-totp code { background: var(--chip); padding: 2px 6px; border-radius: 4px; font-size: 13px; letter-spacing: 1px; overflow-wrap: anywhere; }
