:root {
  color-scheme: light dark;
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eef1f6; --line: #e1e6ee;
  --text: #17202e; --muted: #5d6a7e; --faint: #8a95a6;
  --down: #2a6fdb; --down-soft: rgba(42,111,219,.14);
  --up: #12906b; --up-soft: rgba(18,144,107,.14);
  --warn: #c2410c; --warn-soft: #fff1e6; --bad: #b42318; --bad-soft: #fdecea; --good: #12906b;
  --track: #e6eaf1; --shadow: 0 1px 2px rgba(20,30,50,.05), 0 4px 16px rgba(20,30,50,.05);
  --g0: #7c5cf0; --g1: #d1478c; --g2: #0f9bb5; --g3: #a38b00; --g4: #6b7a8f; --gx: #b5bdc9;
  --sat: rgba(194,65,12,.16); --hatch: #8a95a6;
  --radius: 14px; --nav-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131b; --surface: #171e29; --surface-2: #1e2734; --line: #283243;
    --text: #e8edf5; --muted: #9aa7ba; --faint: #6f7c90;
    --down: #6aa5ff; --down-soft: rgba(106,165,255,.18);
    --up: #3fcf9e; --up-soft: rgba(63,207,158,.16);
    --warn: #ff9a57; --warn-soft: #33241a; --bad: #ff7a70; --bad-soft: #3a1f1f; --good: #3fcf9e;
    --g0: #a58bff; --g1: #ff7eb6; --g2: #4fd1e8; --g3: #e6c84a; --g4: #9fb0c8; --gx: #566277;
    --sat: rgba(255,154,87,.2); --hatch: #6f7c90;
    --track: #2a3444; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* shell: mobile = bottom nav, desktop = left rail */
.shell { min-height: 100vh; padding: 0 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 2px 6px; }
.brand-mark { width: 24px; height: 24px; fill: none; stroke: var(--down); stroke-width: 2; stroke-linecap: round; }
.brand-mark circle { fill: var(--down); stroke: none; }
.brand-name { font-weight: 650; letter-spacing: .02em; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .75rem; color: var(--muted); }
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a[aria-current="page"] { color: var(--down); font-weight: 600; }
.nav a:focus-visible, a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--down); outline-offset: 2px; border-radius: 8px; }
.foot { margin-top: 24px; font-size: .78rem; color: var(--faint); text-align: center; }
.noscript { padding: 16px; }
main { outline: none; }

@media (min-width: 768px) {
  .shell { max-width: 1180px; display: grid; grid-template-columns: 188px minmax(0, 1fr); column-gap: 32px; padding: 0 28px 40px; align-content: start; grid-template-rows: auto 1fr; }
  .brand { grid-column: 1; padding-top: 28px; }
  .nav { position: sticky; top: 16px; grid-column: 1; grid-row: 2; align-self: start; flex-direction: column; height: auto; padding: 0; background: none; border: 0; gap: 4px; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: .95rem; }
  .nav a:hover { background: var(--surface-2); }
  .nav a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow); }
  main { grid-column: 2; grid-row: 1 / span 2; padding-top: 28px; min-width: 0; }
  .foot { grid-column: 2; text-align: left; }
}

/* generic card */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border: 1px solid var(--line); }
.card-title { font-size: .85rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.page { display: grid; gap: 14px; }
.page-title { font-size: 1.25rem; margin: 2px 0 2px; }

/* status */
.status { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--up-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.banner { border-radius: 12px; padding: 12px 14px; font-size: .92rem; font-weight: 500; background: var(--warn-soft); color: var(--warn); border: 1px solid currentColor; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner[hidden] { display: none; }

/* speed meters */
.meters { display: grid; gap: 14px; }
.meter { display: grid; gap: 6px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; }
.meter-label { display: flex; align-items: center; gap: 8px; }
.meter-label i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.meter.down { --c: var(--down); --soft: var(--down-soft); }
.meter.up { --c: var(--up); --soft: var(--up-soft); }
.meter-value { font-size: 3.1rem; line-height: 1.05; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.meter-unit { font-size: 1rem; font-weight: 500; color: var(--muted); margin-left: 6px; }
.meter-pct { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 6px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 6px; background: var(--c); transition: width .4s ease; }
.meter.hot .bar-fill { background: var(--warn); }
.meter.hot .meter-pct { color: var(--warn); font-weight: 600; }
.meter.stale .meter-value { opacity: .4; }
.meter.idle .meter-value { color: var(--faint); }
@media (min-width: 560px) { .meters { grid-template-columns: 1fr 1fr; } }

/* chart */
.chart-card { display: grid; gap: 10px; }
.chart-block { display: grid; gap: 2px; }
.chart-label { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); }
.chart-label i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); }
.chart-label .dash { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.chart-label .dash b { width: 16px; border-top: 2px dashed var(--warn); }
.chart { width: 100%; min-height: 120px; position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 11px var(--font); fill: var(--faint); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .thresh { stroke: var(--warn); stroke-width: 1.2; stroke-dasharray: 5 4; }
.chart .thresh-text { fill: var(--warn); }
.chart .line { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.down { stroke: var(--down); } .chart .line.up { stroke: var(--up); }
.chart .area.down { fill: var(--down-soft); } .chart .area.up { fill: var(--up-soft); }
.chart .pt.down { fill: var(--down); } .chart .pt.up { fill: var(--up); }
.chart .cross { stroke: var(--faint); stroke-width: 1; }
.chart .tip { position: absolute; pointer-events: none; padding: 4px 8px; border-radius: 8px; background: var(--text); color: var(--bg);
  font-size: .75rem; white-space: nowrap; transform: translate(-50%, -100%); font-variant-numeric: tabular-nums; }
.chart .tip[hidden] { display: none; }
.empty { color: var(--faint); font-size: .9rem; padding: 18px 0; text-align: center; }

/* devices */
.dev-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.dev-list { list-style: none; margin: 0; padding: 0; }
.dev { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 12px; padding: 11px 4px; border-top: 1px solid var(--line); }
.dev:first-child { border-top: 0; }
.dev:hover { background: var(--surface-2); border-radius: 10px; }
.dev-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dev-rates { display: flex; gap: 12px; font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dev-rates .d { color: var(--down); } .dev-rates .u { color: var(--up); }
.dev.quiet .dev-name { color: var(--muted); font-weight: 400; }
details.idle { margin-top: 6px; border-top: 1px solid var(--line); }
details.idle summary { cursor: pointer; padding: 12px 4px; font-size: .9rem; color: var(--muted); list-style: none; }
details.idle summary::-webkit-details-marker { display: none; }
details.idle summary::before { content: "▸ "; } details.idle[open] summary::before { content: "▾ "; }
.live-grid { display: grid; gap: 14px; }
.placeholder { text-align: center; padding: 56px 16px; }
.placeholder h2 { margin-bottom: 8px; }
.placeholder p { color: var(--muted); margin: 0; word-break: break-all; }
@media (min-width: 1000px) { .live-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; } .live-grid > .card { height: 100%; } }
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }

/* ---- phase 3: shared controls ---- */
.page-head.manage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.controls-end { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-left: auto; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 2px; max-width: 100%; }
.seg-btn { font: inherit; font-size: .88rem; color: var(--muted); background: none; border: 0; border-radius: 9px; padding: 6px 12px; cursor: pointer; white-space: nowrap; min-height: 34px; }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.seg-btn:hover { color: var(--text); }
.seg-btn:focus-visible, .ghost:focus-visible, .sat-item:focus-visible, .select:focus-visible, .date-input:focus-visible { outline: 2px solid var(--down); outline-offset: 2px; }
.date-pick { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); }
.date-pick.on .date-input { border-color: var(--down); }
.date-input, .select { font: inherit; font-size: .88rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 5px 8px; min-height: 34px; max-width: 100%; color-scheme: light dark; }
.select { max-width: 210px; text-overflow: ellipsis; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); cursor: pointer; }
.ghost { font: inherit; font-size: .85rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 5px 12px; min-height: 34px; cursor: pointer; }
.ghost:hover:not(:disabled) { background: var(--surface-2); }
.ghost:disabled { opacity: .4; cursor: default; }
.ghost.wide { width: 100%; margin-top: 8px; }
.custom-range { display: none; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.custom-range.on { display: flex; }
.note { margin: 10px 0 0; font-size: .78rem; color: var(--faint); line-height: 1.5; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); }
.legend-title { color: var(--muted); font-weight: 600; width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.chip i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; flex: none; }
.chip i.line { height: 3px; border-radius: 2px; }
.chip i.line.down { background: var(--down); } .chip i.line.up { background: var(--up); }
.chip i.peakkey { height: 2px; background: var(--faint); }
.chip i.threshkey { height: 0; border-top: 2px dashed var(--warn); width: 16px; border-radius: 0; }
.chip i.satkey { background: var(--sat); border: 1px solid var(--warn); }
.chip i.gapkey { background: repeating-linear-gradient(45deg, var(--hatch) 0 1.5px, transparent 1.5px 5px); border: 1px solid var(--line); }
.chip i.sw.down { background: var(--down); } .chip i.sw.up { background: var(--up); }
.chip i.g0 { background: var(--g0); } .chip i.g1 { background: var(--g1); } .chip i.g2 { background: var(--g2); }
.chip i.g3 { background: var(--g3); } .chip i.g4 { background: var(--g4); } .chip i.gx { background: var(--gx); }

/* ---- timeline ---- */
.tl-card { display: grid; gap: 10px; }
.tl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; margin-bottom: 4px; }
.tl { display: grid; grid-template-columns: 44px minmax(0, 1fr); }
.tl-axis, .tl-plot { display: flex; flex-direction: column; gap: 6px; }
.tl-axis { margin-top: 26px; }   /* 2px + the 24px label lane of .tl-plot */
.tl-scroll { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; outline: none; border-radius: 8px; padding-top: 2px; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
.tl-scroll:focus-visible { outline: 2px solid var(--down); outline-offset: 1px; }
.tl-plot { position: relative; padding-top: 24px; cursor: crosshair; user-select: none; -webkit-user-select: none; touch-action: pan-x pan-y; }
.tl-svg, .ax { display: block; flex: none; }
.tl-svg text, .ax text { font: 11px var(--font); fill: var(--faint); font-variant-numeric: tabular-nums; }
.ax .thresh-text { fill: var(--warn); }
.tl-svg .grid { stroke: var(--line); stroke-width: 1; }
.tl-svg .grid.v { stroke-dasharray: 2 4; }
.tl-svg .thresh { stroke: var(--warn); stroke-width: 1.2; stroke-dasharray: 5 4; }
.tl-svg .line { fill: none; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.tl-svg .line.down { stroke: var(--down); } .tl-svg .line.up { stroke: var(--up); }
.tl-svg .peak { fill: none; stroke-width: 1; opacity: .45; stroke-linejoin: round; }
.tl-svg .peak.down { stroke: var(--down); } .tl-svg .peak.up { stroke: var(--up); }
.tl-svg .area.down { fill: var(--down-soft); } .tl-svg .area.up { fill: var(--up-soft); }
.tl-svg .pt.down { fill: var(--down); } .tl-svg .pt.up { fill: var(--up); }
.tl-svg .sat-band { fill: var(--sat); }
.tl-svg .gap-band { stroke: none; opacity: .8; }
.tl-svg .hatch-line { stroke: var(--hatch); stroke-width: 1.2; }
.tl-svg .stack { stroke: var(--surface); stroke-width: .5; }
.tl-svg .stack.g0 { fill: var(--g0); } .tl-svg .stack.g1 { fill: var(--g1); } .tl-svg .stack.g2 { fill: var(--g2); }
.tl-svg .stack.g3 { fill: var(--g3); } .tl-svg .stack.g4 { fill: var(--g4); } .tl-svg .stack.gx { fill: var(--gx); }
.tl-sel { position: absolute; top: 24px; bottom: 0; pointer-events: none; background: color-mix(in srgb, var(--text) 10%, transparent);
  border-left: 1px solid var(--text); border-right: 1px solid var(--text); }
.tl-sel[hidden] { display: none; }
.tl-tip { position: absolute; top: 1px; left: 0; height: 18px; box-sizing: border-box; padding: 0 8px; border-radius: 9px; pointer-events: none;
  background: var(--text); color: var(--surface); font-size: .75rem; line-height: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; z-index: 2; }
.tl-tip::after { content: ""; position: absolute; top: 100%; left: var(--notch, 50%); width: 0; height: 0; margin-left: -3px;
  border: 3px solid transparent; border-top-color: var(--text); border-bottom-width: 0; }
.tl-tip[hidden] { display: none; }
.tl-hit, .tl-grip { position: absolute; left: 50%; pointer-events: none; }
.tl-hit { top: 0; bottom: 0; width: 32px; transform: translateX(-50%); touch-action: none; }
.tl-grip { bottom: 6px; width: 18px; height: 8px; transform: translateX(-50%); border-radius: 4px; background: var(--text);
  border: 2px solid var(--surface); box-sizing: content-box; opacity: .75; display: none; }
.tl-hint { display: none; margin: 0; font-size: .8rem; color: var(--muted); }
@media (pointer: coarse) {
  .tl-hit { pointer-events: auto; }
  /* .tl-grip stays hidden: it covered the x-axis time labels; the time pill above the chart now marks the band */
  .tl-hint { display: block; }
  .tl-sel { -webkit-touch-callout: none; }
}
.sat-list { display: grid; gap: 8px; margin-top: 8px; }
.sat-item { font: inherit; text-align: left; display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; }
.sat-item b { font-weight: 600; font-variant-numeric: tabular-nums; }
.sat-item span { font-size: .82rem; color: var(--muted); }
.sat-item.down b { color: var(--down); } .sat-item.up b { color: var(--up); }
.sat-item:hover { border-color: var(--warn); }
.tl-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.tl-detail-head .card-title { font-size: .95rem; color: var(--text); font-variant-numeric: tabular-nums; }
.step-btns { display: flex; gap: 6px; }
.wan-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.wan-sum .empty { grid-column: 1 / -1; }
.wan-cell { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; border-left: 3px solid var(--c); }
.wan-cell.down { --c: var(--down); } .wan-cell.up { --c: var(--up); }
.wan-cell .k { font-size: .78rem; color: var(--muted); }
.wan-cell .v { font-size: 1.3rem; font-weight: 650; }
.wan-cell .s { font-size: .78rem; color: var(--muted); }
.wan-note { grid-column: 1 / -1; font-size: .78rem; color: var(--faint); }
.dg-list { display: grid; }
.dg { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, .7fr)) minmax(0, .8fr); gap: 4px 10px; align-items: baseline; padding: 9px 4px; border-top: 1px solid var(--line); font-size: .88rem; }
.dg-head { border-top: 0; font-size: .75rem; color: var(--faint); padding-top: 0; }
.dg-head span:not(:first-child), .dg-c, .dg-b { text-align: right; }
.dg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
a.dg-name:hover { text-decoration: underline; }
.dg-c.d { color: var(--down); } .dg-c.u { color: var(--up); }
.dg-b { color: var(--muted); }
@media (max-width: 640px) {
  .dg-head { display: none; }
  .dg { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 10px 2px; row-gap: 2px; }
  .dg-name { grid-column: 1 / 4; grid-row: 1; }
  .dg-b { grid-column: 4; grid-row: 1; white-space: nowrap; font-weight: 500; }
  .dg-c { grid-row: 2; text-align: left; font-size: .85rem; }
  .dg-c::before { content: attr(data-label) " "; display: block; font-size: .68rem; color: var(--faint); }
  .controls-end { margin-left: 0; }
}

/* ---- ranking ---- */
.rk-list { display: grid; }
.rk { display: grid; gap: 6px; padding: 12px 4px; border-top: 1px solid var(--line); border-radius: 0; }
.rk:first-child { border-top: 0; }
a.rk:hover { background: var(--surface-2); border-radius: 10px; }
.rk-top { display: flex; align-items: baseline; gap: 10px; }
.rk-rank { color: var(--faint); width: 1.4em; font-size: .85rem; }
.rk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.rk-total { font-weight: 600; }
.rk-bars { display: grid; gap: 4px; padding-left: calc(1.4em + 10px); }
.rk-line { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 10px; align-items: center; }
.rk-track { height: 8px; background: var(--track); border-radius: 5px; overflow: hidden; }
.rk-fill { height: 100%; border-radius: 5px; }
.rk-fill.down { background: var(--down); } .rk-fill.up { background: var(--up); }
.rk-bytes { font-size: .78rem; color: var(--muted); text-align: right; }
.rk-meta { padding-left: calc(1.4em + 10px); font-size: .78rem; color: var(--muted); }

.hm { display: grid; grid-template-columns: 22px repeat(24, minmax(0, 1fr)); gap: 2px; outline: none; margin-top: 8px; }
.hm:focus-visible { outline: 2px solid var(--down); outline-offset: 3px; border-radius: 4px; }
.hm-hour { font-size: 10px; color: var(--faint); text-align: left; height: 14px; line-height: 14px; overflow: visible; white-space: nowrap; }
.hm-day { font-size: .75rem; color: var(--muted); display: flex; align-items: center; }
.hm-cell { height: 24px; border-radius: 4px; cursor: pointer; background: color-mix(in srgb, var(--down) calc(var(--v, 0) * 100%), var(--surface-2)); }
.hm-cell:hover, .hm-cell.cur { outline: 2px solid var(--text); outline-offset: -1px; }
.hm-cell.empty { background: transparent; border: 1px dashed var(--line); }
.hm-info { margin-top: 10px; min-height: 1.5em; font-size: .85rem; color: var(--muted); }
.hm-legend { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--faint); margin-top: 6px; flex-wrap: wrap; }
.hm-scale { width: 90px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--down)); border: 1px solid var(--line); }
.hm-empty-key { margin-left: auto; }
@media (max-width: 420px) { .rk-line { grid-template-columns: minmax(0, 1fr) 72px; } .hm { grid-template-columns: 18px repeat(24, minmax(0, 1fr)); gap: 1px; } .hm-cell { height: 26px; border-radius: 3px; } }

.tl-svg .clip-mark { fill: var(--warn); }

/* ---- phase 4: device detail, management ---- */
.back { font-size: .88rem; color: var(--muted); justify-self: start; padding: 4px 2px; }
.back:hover { color: var(--text); }
.dev-card { display: grid; gap: 8px; }
.dev-titlerow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dev-title { overflow-wrap: anywhere; margin: 0; }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge[hidden] { display: none; }
.dev-actions, .grp-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.dev-actions[hidden], .inline-form[hidden] { display: none; }
.link-btn { display: inline-flex; align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.text-input { font: inherit; font-size: .95rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; min-height: 38px; flex: 1 1 180px; min-width: 0; }
.text-input:focus-visible { outline: 2px solid var(--down); outline-offset: 1px; }
.ghost { touch-action: manipulation; }
.ghost.primary { background: var(--down); border-color: var(--down); color: #fff; font-weight: 600; }
.ghost.primary:hover:not(:disabled) { background: var(--down); filter: brightness(1.08); }
.ghost.danger { color: var(--bad); border-color: var(--bad); }
.ghost.danger:hover:not(:disabled) { background: var(--bad-soft); }
.ghost.small { min-height: 30px; padding: 2px 10px; font-size: .8rem; }
@media (prefers-color-scheme: dark) { .ghost.primary { color: #0e131b; } }
@media (pointer: coarse) { .ghost, .seg-btn, .text-input, .select { min-height: 44px; } .ghost.small { min-height: 40px; } }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
@media (min-width: 900px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat .k { font-size: .78rem; color: var(--muted); }
.stat .v { font-size: 1.15rem; font-weight: 650; overflow-wrap: anywhere; }
.stat .v.small { font-size: .95rem; font-weight: 600; }
.stat .s { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.chart.bars { outline: none; touch-action: pan-y; }
.chart.bars:focus-visible { outline: 2px solid var(--down); outline-offset: 2px; border-radius: 6px; }
.chart .col-hit { fill: transparent; }
.chart .col-fill.down { fill: var(--down); } .chart .col-fill.up { fill: var(--up); }
.chart .col-miss { stroke: var(--hatch); stroke-width: 2; stroke-dasharray: 3 2; }
.chart .col.cur .col-hit { fill: color-mix(in srgb, var(--text) 8%, transparent); }
.mac-list, .stack { display: grid; gap: 10px; margin-top: 8px; }
.mac-row { padding: 8px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.mac-row:first-child { border-top: 0; }
.mac-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mac-names, .mac-text { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
code.mac { font: .85rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.note.lead { margin: 4px 0 8px; }
.sug, .grp { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; background: var(--surface-2); }
.sug-head { font-weight: 600; overflow-wrap: anywhere; }
.sug-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .85rem; }
.sug .note { margin: 0; }
.pick-list { display: grid; margin-top: 6px; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.pick { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.pick:first-child { border-top: 0; }
.pick:hover { background: var(--surface-2); }
.pick input, .check input { width: 20px; height: 20px; flex: none; margin-top: 2px; accent-color: var(--down); }
.pick-text { display: grid; min-width: 0; }
.pick-name { font-weight: 550; overflow-wrap: anywhere; }
.pick-meta { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.action-bar { display: grid; gap: 10px; margin-top: 12px; }
.grp-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grp-name { font-weight: 600; overflow-wrap: anywhere; }
a.grp-name:hover { text-decoration: underline; }
.grp-macs summary { cursor: pointer; font-size: .85rem; color: var(--muted); padding: 4px 0; }
.grp-macs .mac-line { padding: 4px 0; }
.sys summary { cursor: pointer; font-size: .85rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; list-style: none; }
.sys summary::-webkit-details-marker { display: none; }
.sys summary::before { content: "▸ "; } .sys[open] summary::before { content: "▾ "; }
.sys-body { display: grid; gap: 16px; margin-top: 12px; }
.sys-block { display: grid; gap: 6px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; padding: 3px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.kv .k { color: var(--muted); overflow-wrap: anywhere; } .kv .v { text-align: right; }
.cov { display: flex; align-items: flex-end; gap: 2px; height: 56px; padding: 2px; border-bottom: 1px solid var(--line); }
.cov-bar { flex: 1; min-width: 2px; background: var(--up); border-radius: 2px 2px 0 0; }
.cov-bar.low { background: var(--warn); } .cov-bar.open { opacity: .55; }
.banner.bad[hidden] { display: none; }

/* confirmation dialog */
dialog.dlg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 12px 40px rgba(0,0,0,.35); }
dialog.dlg::backdrop { background: rgba(10,14,22,.55); }
.dlg-title { font-size: 1.05rem; overflow-wrap: anywhere; }
.dlg-body { margin: 10px 0 18px; color: var(--muted); font-size: .92rem; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.dlg-actions .ghost { min-width: 88px; min-height: 42px; }
.page > .banner:not([hidden]) { position: sticky; top: 8px; z-index: 5; box-shadow: var(--shadow); }
.banner:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.page > .banner.static:not([hidden]) { position: static; box-shadow: none; }

/* admin login: card on the manage page, field in the login dialog */
.page-head.manage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card[hidden], .ghost[hidden] { display: none; }
.login-error, .dlg-error { color: var(--bad); font-size: .88rem; margin: 6px 0 0; }
.login-error[hidden], .dlg-error[hidden] { display: none; }
.dlg-form { display: grid; gap: 12px; margin-top: 10px; }
.dlg-field { display: grid; gap: 6px; }
.dlg-label { color: var(--muted); font-size: .88rem; }
.dlg-field .text-input { flex: none; width: 100%; }
