/* remulator portal. Colours: chart chrome / categorical / status from the dataviz reference
   palette (blue = in/download, orange = out/upload; status colours only for state). */
:root {
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --radius: 8px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9b9a93;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10); --border-strong: rgba(255,255,255,0.18);
  --accent: #3987e5; --accent-wash: rgba(57,135,229,0.14); --accent-fill: #2b6fd0;   /* fill: white text ≥ 4.5:1 */
  --warning-text: #fab219;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --good-text: #2fbf3a; --hover: rgba(255,255,255,0.05);
  --critical-text: #ff8080; --accent-text: #7fb3f0;      /* AA (≥ 4.5:1) on surfaces and washes */
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f9f9f7; --surface-1: #fcfcfb; --surface-2: #f3f2ee; --surface-3: #e9e8e2;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #63625d;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,0.10); --border-strong: rgba(11,11,11,0.18);
  --accent: #2a78d6; --accent-wash: rgba(42,120,214,0.10); --accent-fill: #1f66c2;
  --warning-text: #8a5a00;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --good-text: #006300; --hover: rgba(0,0,0,0.04);
  --critical-text: #b3261e; --accent-text: #1d5fae;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); background: var(--page); color: var(--text-primary); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.num { font-variant-numeric: tabular-nums; }

/* --- banner --- */
.banner { position: fixed; inset: 0 0 auto 0; height: 56px; display: flex; align-items: center; gap: 18px;
  padding: 0 16px; background: var(--surface-1); border-bottom: 1px solid var(--border); z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; color: var(--text-primary); }
.brand:hover { text-decoration: none; }
.logo { width: 40px; height: 40px; display: block; }
.brand-name { font-weight: 800; font-size: 23px; letter-spacing: -.035em; line-height: 1; }
.banner-stats { display: flex; gap: 18px; margin-left: auto; color: var(--text-secondary); font-size: 12.5px; }
.banner-stats b { color: var(--text-primary); font-weight: 600; }
.banner-actions { display: flex; gap: 8px; align-items: center; }
.menu-toggle { display: none; }

/* --- layout --- */
.layout { display: flex; padding-top: 56px; min-height: 100vh; }
.sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: 220px; overflow-y: auto; padding: 14px 10px;
  background: var(--surface-1); border-right: 1px solid var(--border); }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px;
  color: var(--text-secondary); font-weight: 500; }
.sidebar a:hover { background: var(--hover); color: var(--text-primary); text-decoration: none; }
.sidebar a.active { background: var(--accent-wash); color: var(--text-primary); }
.sidebar .ni { width: 18px; text-align: center; color: var(--text-muted); }
.sidebar a.active .ni { color: var(--accent); }
.sidebar .count { margin-left: auto; font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nav-title { margin: 18px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.nav-instances a { font-weight: 400; font-size: 13px; padding: 5px 10px; }
.nav-instances .nav-iname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-title-row { display: flex; align-items: center; gap: 8px; }
.nav-title-row > span { flex: 1; }
.nav-switch { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; text-transform: none; letter-spacing: 0;
  font-size: 11.5px; color: var(--text-secondary); user-select: none; }
.nav-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.nav-switch .sw-track { position: relative; width: 24px; height: 14px; border-radius: 7px; background: var(--surface-3);
  border: 1px solid var(--border-strong); transition: background .15s; }
.nav-switch .sw-track::after { content: ""; position: absolute; top: 1px; left: 1px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted); transition: transform .15s, background .15s; }
.nav-switch input:checked + .sw-track { background: var(--accent-wash); border-color: var(--accent); }
.nav-switch input:checked + .sw-track::after { transform: translateX(10px); background: var(--accent); }
.nav-switch input:focus-visible + .sw-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-more { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 4px 10px 4px 38px; margin: 0;
  color: var(--text-muted); font-size: 12px; cursor: pointer; border-radius: 6px; }
.nav-more:hover { background: var(--hover); color: var(--text-primary); }
.nav-empty { padding: 4px 10px; font-size: 12.5px; }
.sidebar a.nav-hidden { font-size: 11.5px; padding: 2px 10px 2px 38px; color: var(--text-muted); font-weight: 400; }
.main { flex: 1; margin-left: 220px; padding: 22px 28px 60px; min-width: 0; }

/* --- page header --- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .title { flex: 1; min-width: 240px; }
.crumbs { font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }
.crumbs a { color: var(--text-muted); }
.page-head .sub { color: var(--text-secondary); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- buttons & forms --- */
.btn, button { font: inherit; font-weight: 500; font-size: 13px; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-primary);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover, button:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.btn.primary:hover, button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--critical-text); }
button.danger:hover { background: rgba(208,59,59,0.12); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
button.ghost:hover { background: var(--hover); color: var(--text-primary); }
button.small, .btn.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { padding: 6px 9px; background: transparent; border-color: var(--border); }
input, select, textarea { font: inherit; font-size: 13px; color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: auto; }
input[type=range] { accent-color: var(--accent); padding: 0; }
textarea { font-family: var(--mono); font-size: 12.5px; width: 100%; min-height: 220px; resize: vertical; }
label.field, div.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-secondary); }
label.field > span.lbl, div.field > span.lbl { font-weight: 500; }
label.field .help, div.field .help { font-size: 11.5px; color: var(--text-muted); }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-primary); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--text-secondary); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent-wash); color: var(--text-primary); }

/* --- cards / tiles --- */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; flex: 1; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 24px; font-weight: 600; margin-top: 2px; letter-spacing: -.01em; }
.tile .delta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.hero { display: flex; gap: 36px; flex-wrap: wrap; align-items: flex-end; }
.hero .big { font-size: 48px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.hero .unit { font-size: 15px; color: var(--text-secondary); margin-left: 4px; font-weight: 500; }
.hero .cap { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.meter { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.meter > div { height: 100%; background: var(--accent); border-radius: 3px; }

/* --- tables --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
tr.clickable { cursor: pointer; }
.empty { padding: 28px; text-align: center; color: var(--text-muted); }

/* --- badges --- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 8px;
  border-radius: 99px; background: var(--surface-3); color: var(--text-secondary); white-space: nowrap; }
.badge .ic { font-size: 11px; }
.badge.good { background: rgba(12,163,12,0.14); color: var(--good-text); }
.badge.good .ic { color: var(--good); }
.badge.busy { background: var(--accent-wash); color: var(--text-primary); }
.badge.busy .ic { color: var(--accent); display: inline-block; animation: spin 1.4s linear infinite; }
.badge.warn { background: rgba(250,178,25,0.15); color: var(--text-primary); }
.badge.warn .ic { color: var(--warning); }
.badge.bad { background: rgba(208,59,59,0.15); color: var(--text-primary); }
.badge.bad .ic { color: var(--critical-text); }
.tag { display: inline-block; white-space: nowrap; font-size: 11.5px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--border-strong); color: var(--text-secondary); }
a.tag.loc { color: var(--accent-text); border-color: var(--accent); white-space: nowrap; }
a.tag.loc:hover { text-decoration: none; background: var(--accent-wash); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-muted); flex: none; }
.dot.good { background: var(--good); } .dot.busy { background: var(--accent); } .dot.bad { background: var(--critical); } .dot.warn { background: var(--warning); }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- tabs --- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-strong); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--text-secondary); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text-primary); text-decoration: none; }
.tabs a.active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* --- ports diagram --- */
.ports { display: flex; gap: 10px; flex-wrap: wrap; }
/* system diagram (instance detail, first tab) */
.topo-wrap { overflow-x: auto; }
.topo { display: block; width: 100%; min-width: 760px; height: auto; font-family: var(--font); }
.topo text { fill: var(--text-primary); font-size: 12px; }
.topo .topo-h { font-size: 14px; font-weight: 600; }
.topo .topo-t { font-size: 12.5px; font-weight: 600; }
.topo .topo-s { fill: var(--text-muted); font-size: 11px; }
.topo .topo-k { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.topo .mono { font-family: var(--mono); }
.topo .mid { text-anchor: middle; } .topo .end { text-anchor: end; }
.topo-box { fill: var(--surface-2); stroke: var(--border-strong); }
.topo-box.router { stroke: var(--accent); stroke-width: 1.5; }
.topo-box.router.off { stroke: var(--border-strong); stroke-dasharray: 5 4; }
.topo-card { fill: var(--surface-2); stroke: var(--border-strong); }
.topo-dev.phone .topo-card { stroke: var(--series-3); }
.topo-dev:hover .topo-card, .topo-node:hover .topo-box { fill: var(--surface-3); }
.topo-icon { fill: none; stroke: var(--text-secondary); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.topo-dev.phone .topo-icon { stroke: var(--series-3); }
.topo-pill { fill: var(--surface-1); stroke: var(--border-strong); }
.topo-pill.mid { fill: var(--accent-wash); stroke: var(--accent); }
.topo-stub { fill: var(--surface-3); stroke: var(--border-strong); }
.topo-stub.up { fill: var(--accent); stroke: var(--accent); }
.topo-link { fill: none; stroke: var(--border-strong); stroke-width: 2; }
.topo-link.up { stroke: var(--accent); }
.topo-link.thin { stroke-width: 1.5; }
.topo-link.warn { stroke: var(--warning); stroke-dasharray: 6 4; }
.topo-link.none { stroke-dasharray: 2 4; }
.topo-link.dashed { stroke-dasharray: 6 4; }
.topo-link.flow { stroke-dasharray: 8 5; animation: topo-flow 0.9s linear infinite; }
@keyframes topo-flow { to { stroke-dashoffset: -26; } }
@media (prefers-reduced-motion: reduce) { .topo-link.flow { animation: none; stroke-dasharray: none; } }
.topo-junction { fill: var(--border-strong); } .topo-junction.up { fill: var(--accent); }
.topo-dot { fill: var(--text-muted); } .topo-dot.good { fill: var(--good); } .topo-dot.warn { fill: var(--warning); }
.topo-dot.bad { fill: var(--critical); } .topo-dot.busy { fill: var(--accent); }
.topo-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--text-secondary); align-items: center; }
.topo-legend .lk { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--border-strong); vertical-align: middle; margin-right: 6px; }
.topo-legend .lk.up { border-top-color: var(--accent); }
.topo-legend .lk.flow { border-top: 2px dashed var(--accent); }
.topo-legend .lk.warn { border-top: 2px dashed var(--warning); }
.topo-legend .lk.dashed { border-top-style: dashed; }
.port { flex: 1; min-width: 150px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); }
.port.off { opacity: .55; }
.port .pname { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.port .plabel { font-size: 11.5px; color: var(--text-muted); margin: 2px 0 8px; }
.port .prates { font-size: 12px; color: var(--text-secondary); display: flex; gap: 10px; }
.port .members { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
/* --- multi-WAN tab: compare totals, failover timeline (pages/multiwan.js) --- */
tr.total td { border-top: 2px solid var(--border-strong); }
.mw-timeline { position: relative; height: 18px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); margin: 10px 0; overflow: hidden; }
.mw-timeline .mw-done { position: absolute; inset: 0 auto 0 0; background: rgba(12,163,12,0.18); }
.mw-timeline .mw-gap { position: absolute; top: 0; bottom: 0; background: var(--critical); opacity: .75; min-width: 2px; }
.mw-timeline .mw-fault { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-primary); }
.mw-timeline .mw-fault.ok { background: var(--good); }
.key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; vertical-align: middle; margin-right: 4px; }
.key.sq { width: 9px; height: 9px; border-radius: 2px; }

/* --- charts --- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .end-dot { stroke: var(--surface-1); stroke-width: 2; }
.chart .end-label { fill: var(--text-secondary); font-size: 11.5px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; flex-wrap: wrap; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.25); white-space: nowrap; z-index: 5; }
.tooltip .tv { font-weight: 600; color: var(--text-primary); }
.tooltip .tl { color: var(--text-secondary); }
.tooltip .tt { color: var(--text-muted); margin-bottom: 2px; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 90px; gap: 10px; align-items: center; font-size: 12.5px; margin: 6px 0; }
.bar-track { height: 14px; position: relative; }
.bar-fill { height: 14px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }

/* --- console / logs --- */
.term { height: calc(100vh - 300px); min-height: 360px; background: #0b0b0b; border-radius: var(--radius); padding: 6px; border: 1px solid var(--border); }
.term.term-mini { height: 300px; min-height: 0; }
.term.term-full { position: fixed; inset: 0; z-index: 40; height: auto; border-radius: 0; padding: 8px; }
body.no-scroll { overflow: hidden; }
pre.log { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px;
  max-height: 60vh; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-all; }
pre.out { max-height: 320px; }
iframe.webui { width: 100%; height: calc(100vh - 250px); min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

/* --- modal & toasts --- */
dialog { border: 1px solid var(--border-strong); border-radius: 10px; padding: 0; background: var(--surface-1); color: var(--text-primary);
  width: min(620px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog .m-head { padding: 16px 20px 0; font-size: 16px; font-weight: 600; }
dialog .m-body { padding: 14px 20px; max-height: 70vh; overflow: auto; }
dialog .m-foot { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--surface-1); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); border-radius: 6px;
  padding: 10px 14px; max-width: 420px; box-shadow: 0 6px 20px rgba(0,0,0,.3); font-size: 13px; white-space: pre-wrap; }
.toast.error { border-left-color: var(--critical); }
.toast.ok { border-left-color: var(--good); }
.notice { padding: 10px 14px; border-radius: 6px; background: var(--accent-wash); color: var(--text-primary); font-size: 13px; margin-bottom: 14px; }
.notice.warn { background: rgba(250,178,25,0.12); }
.notice.bad { background: rgba(208,59,59,0.12); white-space: pre-wrap; }
.stepper { display: flex; gap: 0; margin-bottom: 18px; }
.events { max-height: 300px; overflow: auto; font-size: 12.5px; }
.events div { padding: 3px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.events .t { color: var(--text-muted); font-variant-numeric: tabular-nums; flex: none; }
.events .err { color: var(--critical-text); }
.bad-text { color: var(--critical-text); font-weight: 600; }
a.bad-text:hover { color: var(--critical-text); }
.notice.bad a { color: var(--critical-text); font-weight: 600; text-decoration: underline; }
a:focus-visible, button:focus-visible, tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
a.row-link { color: inherit; font-weight: 700; }
/* instances owned by other processes (Instances card, detail) */
.owner-cell { max-width: 300px; }
.owner-cell .cell-sub { overflow: hidden; text-overflow: ellipsis; }
.owner-inline { display: none; margin-top: 4px; }
.badge.small { font-size: 11px; padding: 1px 7px; }
.cmd-copy { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 2px; padding: 3px 4px 3px 9px; border-radius: 6px;
  background: var(--surface-1); border: 1px solid var(--border-strong); font-family: var(--mono); font-size: 12.5px; }
.banner-alert { display: none; }
.banner-restart { display: inline-flex; align-items: center; gap: 6px; margin-left: 14px; padding: 3px 10px; border-radius: 99px;
  background: rgba(250,178,25,0.15); color: var(--text-primary); font-size: 12.5px; white-space: nowrap; }
.banner-restart:empty { display: none; }
.banner-restart .ic { color: var(--warning); }
.support-pill { display: inline-flex; align-items: center; gap: 8px; margin-left: 10px; padding: 3px 10px; border-radius: 99px;
  font-size: 12.5px; white-space: nowrap; color: var(--text-primary); background: rgba(250,178,25,0.15); }
.support-pill.acting { background: var(--critical); color: #fff; }
.support-pill button { padding: 0 8px; font-size: 12px; }
.sidebar .count.bad-text { color: var(--critical-text); }
.split { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 16px; align-items: start; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border-strong);
  cursor: pointer; font-size: 12.5px; user-select: none; background: transparent; color: var(--text-secondary); }
.chip.on { background: var(--accent-wash); border-color: var(--accent); color: var(--text-primary); }
.profile-card { cursor: pointer; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); }
.profile-card:hover { border-color: var(--border-strong); }
.profile-card.on { border-color: var(--accent); background: var(--accent-wash); }
.profile-card .pc-name { font-weight: 600; }
.profile-card .pc-desc { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; }

/* --- help --- */
.help-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.help-toc { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.help-toc input { width: 100%; margin-bottom: 6px; }
.help-toc a { padding: 5px 10px; border-radius: 6px; color: var(--text-secondary); font-size: 13px; }
.help-toc a:hover { background: var(--hover); color: var(--text-primary); text-decoration: none; }
.help-toc a.active { background: var(--accent-wash); color: var(--text-primary); }
.help-toc .nav-title { margin: 14px 10px 4px; }
.help-results { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; max-height: 50vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px; background: var(--surface-1); }
.help-results a { font-size: 12.5px; }
.help-results .muted { font-size: 11.5px; }
.help-content { padding: 22px 30px 40px; min-width: 0; }
.help-path { font-size: 11.5px; font-family: var(--mono); margin-bottom: 6px; }
.md { font-size: 14.5px; line-height: 1.6; max-width: 980px; }
.md h1 { font-size: 26px; margin: 0 0 16px; }
.md h2 { font-size: 19px; margin: 30px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); text-transform: none; letter-spacing: 0; color: var(--text-primary); }
.md h3 { font-size: 15.5px; margin: 22px 0 8px; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
.md h4 { font-size: 14px; margin: 18px 0 6px; }
.md h2, .md h3, .md h4 { scroll-margin-top: 72px; }
.md .anchor { margin-left: 8px; color: var(--text-muted); opacity: 0; font-weight: 400; }
.md h2:hover .anchor, .md h3:hover .anchor, .md h4:hover .anchor { opacity: 1; }
.md p, .md ul, .md ol { margin: 0 0 12px; }
.md li { margin: 3px 0; }
.md code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; line-height: 1.45; }
.md pre code { background: none; padding: 0; }
.md table { margin: 8px 0 16px; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; vertical-align: top; }
.md th { background: var(--surface-2); color: var(--text-secondary); }
.md blockquote { margin: 0 0 12px; padding: 6px 14px; border-left: 3px solid var(--accent); background: var(--accent-wash); border-radius: 0 6px 6px 0; }
.md mark { background: rgba(250,178,25,0.45); color: inherit; border-radius: 2px; }
.md .repo-path { font-family: var(--mono); font-size: 12.5px; color: var(--text-secondary); }
/* initial height only: docs/architecture.html sizes its frame to its content and follows the theme */
.arch-frame { width: 100%; height: 1150px; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; }

/* --- Android phones (pages/phones.js) --- */
.apps-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 16px; align-items: start; }
.apps-layout > div > .card + .card { margin-top: 16px; }
.phone-page { display: grid; grid-template-columns: minmax(300px, 460px) minmax(0, 1fr); gap: 16px; align-items: start; }
.phone-page > div > .card + .card { margin-top: 16px; }
.phone-pane { position: sticky; top: 72px; }
.phone-viewer { display: flex; flex-direction: column; gap: 8px; }
.phone-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.phone-tools .small-select { padding: 2px 6px; font-size: 12px; }
.phone-frame { background: #101010; border: 1px solid var(--border-strong); border-radius: 26px; padding: 12px 10px 6px;
  box-shadow: 0 8px 26px rgba(0,0,0,.35); margin: 0 auto; width: 100%; max-width: 420px; }
.phone-frame.compact { max-width: 340px; }
.phone-screen { position: relative; background: #000; border-radius: 14px; overflow: hidden; aspect-ratio: 9 / 20;
  max-height: calc(100vh - 230px); margin: 0 auto; outline: none; touch-action: none; cursor: pointer; }
.phone-screen:focus { box-shadow: 0 0 0 2px var(--accent); }
.phone-img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.phone-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 18px;
  color: #c3c2b7; font-size: 13px; background: rgba(0,0,0,.6); }
.phone-nav { display: flex; justify-content: space-around; padding: 4px 0 2px; }
.phone-nav button { color: #c3c2b7; font-size: 15px; }
.phone-nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.phone-frame.phone-full { position: fixed; inset: 0; z-index: 40; max-width: none; border-radius: 0; display: flex; flex-direction: column; justify-content: center; }
.phone-frame.phone-full .phone-screen { height: calc(100vh - 70px); max-height: none; width: auto; }
.phone-empty { min-height: 240px; }
.phone-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.phone-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); cursor: pointer; }
.phone-card:hover { border-color: var(--border-strong); }
.phone-card.on { border-color: var(--accent); background: var(--accent-wash); }
.phone-card .pc-top { display: flex; gap: 10px; align-items: center; }
.phone-card .pc-name { font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.phone-card .pc-sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; overflow-wrap: anywhere; }
.app-icon { border-radius: 22%; flex: none; display: inline-block; vertical-align: middle; background: var(--surface-3); object-fit: cover; }
.app-icon-none { display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 13px; }
.app-cell { display: inline-flex; gap: 8px; align-items: center; }
.cell-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cell-sub.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.ver-cell { max-width: 320px; }
.good-text { color: var(--good-text); font-weight: 600; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 16px; }
.app-grid > .card + .card { margin-top: 0; }
.app-card .ac-top { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.app-card .ac-name { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.app-card .ac-pkg { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-card .ac-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; align-self: flex-start; flex: none; }
.app-card .ac-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
@media (max-width: 1100px) {
  .apps-layout, .phone-page { grid-template-columns: 1fr; }
  .phone-pane { position: static; }
}

@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; max-height: none; }
  .menu-toggle { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform .15s; z-index: 15; }
  body.menu-open .sidebar { transform: none; }
  .main { margin-left: 0; padding: 16px; }
  .banner-stats, .wide-only { display: none; }
  .banner { gap: 10px; padding: 0 12px; }
  .banner-alert:not(:empty) { display: inline-flex; margin-left: auto; font-size: 12.5px; white-space: nowrap; }
  .banner-actions { margin-left: auto; }
  .banner-alert:not(:empty) + .banner-actions { margin-left: 0; }
  .card-head.wrap { flex-wrap: wrap; }
  .card-head.wrap > .muted { flex-basis: 100%; }
  .owner-col { display: none; }
  .owner-inline { display: block; }
  .where-path { flex-wrap: wrap; }
  .where-path .hop { flex: 1 1 40%; }
  .where-path .arrow { display: none; }
  .split { grid-template-columns: 1fr; }
}

/* ======================================================================================
   Test management (js/pages/testing/): library tree, case editor, suites, runs, issues.
   New classes only; nothing above is restyled.
   ====================================================================================== */
.badge.info { background: var(--accent-wash); color: var(--text-primary); }
.badge.info .ic { color: var(--accent-text); }
.badge.sev-critical { background: rgba(208,59,59,0.18); color: var(--text-primary); }
.badge.sev-critical .ic { color: var(--critical); }
.badge.sev-major { background: rgba(236,131,90,0.18); color: var(--text-primary); }
.badge.sev-major .ic { color: var(--serious); }
.badge.sev-minor { background: rgba(250,178,25,0.14); color: var(--text-primary); }
.badge.sev-minor .ic { color: var(--warning); }
.badge.sev-trivial .ic { color: var(--text-muted); }
.tag.pri { font-weight: 600; }
.tag.pri-1 { border-color: var(--critical); color: var(--critical-text); }
.tag.pri-2 { border-color: var(--serious); color: var(--text-primary); }
.tag.pri-3 { border-color: var(--warning); color: var(--text-secondary); }
.tabs a[role=tab] { cursor: pointer; }
button.big { font-size: 14px; padding: 9px 18px; }
.seg.small button { padding: 3px 9px; font-size: 12px; }
select.small { padding: 3px 8px; font-size: 12px; }
.notice.rev-banner { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.big-num { font-size: 30px; font-weight: 600; letter-spacing: -.01em; line-height: 1; }
.field.wide, .form-grid .wide { grid-column: 1 / -1; }
.form-grid .wide-2 { grid-column: span 2; }
.clickable { cursor: pointer; }

/* library: category tree + case table */
.lib-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; align-items: start; }
.lib-main > .card + .card { margin-top: 16px; }
.tree-card { position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow-y: auto; padding: 12px 10px; }
.tree-card .card-head { padding: 0 6px; margin-bottom: 8px; }
.tree-row { display: flex; align-items: center; gap: 4px; padding: 5px 8px 5px 6px; border-radius: 6px; cursor: pointer; color: var(--text-secondary); font-size: 13px; }
.tree-row:hover { background: var(--hover); color: var(--text-primary); }
.tree-row.sel { background: var(--accent-wash); color: var(--text-primary); font-weight: 500; }
tr.row-hl > td { background: var(--accent-wash); }
.tree-row .tname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .count { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.twist { display: inline-block; width: 16px; text-align: center; color: var(--text-muted); flex: none; cursor: pointer; user-select: none; }
.cat-head { margin-bottom: 16px; }
.cat-head .card-head { margin-bottom: 6px; }

/* editor layout (case editor, suite page) */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.editor-layout.wide-side { grid-template-columns: minmax(0, 1fr) 420px; }
.editor-main > .card + .card, .editor-side > .card + .card { margin-top: 16px; }
.editor-side { position: sticky; top: 72px; max-height: calc(100vh - 150px); overflow-y: auto; }
.yaml-editor { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; tab-size: 2; white-space: pre; overflow: auto; min-height: 320px; resize: vertical; }
.save-bar { position: sticky; bottom: 10px; margin-top: 16px; padding: 10px 14px; z-index: 5; box-shadow: 0 -4px 16px rgba(0,0,0,.18); }
.vlist { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
.vlist li { margin: 2px 0; }
.vlist li.warn { color: var(--text-secondary); }
.stepref-card { padding: 12px 14px; }
.stepref-list { margin-top: 8px; }
.stepref { padding: 8px 0; border-top: 1px solid var(--border); }
.stepref:first-child { border-top: 0; }
.stepref .kv dt { color: var(--text-secondary); }

/* step lists (definitions and results) */
.steps { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.step { padding: 7px 10px; border-top: 1px solid var(--border); font-size: 13px; }
.step:first-child { border-top: 0; }
.step.def { display: flex; gap: 10px; }
.step .si { width: 18px; text-align: center; flex: none; font-weight: 700; }
.step .si.st-pass { color: var(--good); } .step .si.st-fail, .step .si.st-error { color: var(--critical); }
.step .si.st-skip, .step .si.st-cancelled, .step .si.st-na { color: var(--text-muted); } .step .si.st-blocked, .step .si.st-flaky { color: var(--warning); }
.step .shead { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.step .sk { color: var(--accent-text); font-weight: 600; }
.step .sdet { color: var(--text-secondary); flex: 1; min-width: 160px; overflow-wrap: anywhere; }
.step .sec { flex: none; font-size: 12px; }
.step .sbody { min-width: 0; flex: 1; }
.step .sargs { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; font-family: var(--mono); font-size: 12px; color: var(--text-primary); }
.step .sarg { overflow-wrap: anywhere; }
.step.res.fail, .step.res.error { background: rgba(208,59,59,0.08); }
details.step > summary { cursor: pointer; list-style: none; }
details.step > summary::-webkit-details-marker { display: none; }
.step .sextra { padding: 6px 0 2px 28px; }
pre.log.console { font-size: 12px; max-height: 360px; }
.artifact { margin: 6px 0; font-size: 13px; }
.artifact summary { cursor: pointer; }
.shots { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 6px; }
figure.shot { margin: 0; max-width: 360px; }
figure.shot img { max-width: 100%; border: 1px solid var(--border-strong); border-radius: 6px; display: block; background: #fff; }
figure.shot figcaption { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* progress bar (case counts) */
.pbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); min-width: 60px; }
.pbar.tall { height: 14px; border-radius: 7px; }
.pbar > i { display: block; height: 100%; }
.pbar > i.pass, i.sw.pass { background: var(--good); }
.pbar > i.flaky, i.sw.flaky { background: var(--warning); }
.pbar > i.fail, i.sw.fail { background: var(--critical); }
.pbar > i.error, i.sw.error { background: #8c2b2b; }
.pbar > i.blocked, i.sw.blocked { background: var(--serious); }
.pbar > i.skip, i.sw.skip { background: var(--text-muted); }
.pbar > i.na, i.sw.na { background: var(--border-strong, var(--text-muted)); opacity: .6; }
.pbar > i.running, i.sw.running { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.pbar > i.pending, i.sw.pending { background: var(--axis); }
@keyframes pulse { 50% { opacity: .55; } }
.pbar-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
i.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.tile.t-pass .value { color: var(--good-text); }
.tile.t-fail .value { color: var(--critical-text); }
.tile.t-warn .value { color: var(--serious); }

/* suites */
.sel-row { display: grid; grid-template-columns: 118px minmax(0, 1fr) 34px auto auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.sel-row .sel-hint { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.pv-cat { border-top: 1px solid var(--border); padding: 6px 0; }
.pv-cat summary { cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.pv-cat summary .count { margin-left: auto; color: var(--text-muted); font-size: 12px; }
.pv-case { display: flex; align-items: baseline; gap: 8px; padding: 3px 0 3px 14px; font-size: 12.5px; flex-wrap: wrap; }
.pv-case .mono { font-size: 11px; }
.pv-case a { flex: 1; min-width: 160px; }
.preview-card { max-height: calc(100vh - 150px); overflow-y: auto; }

/* new run */
.fw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.fw-card.off { opacity: .5; cursor: not-allowed; }
.case-pick { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; background: var(--surface-2); }
.pick-group { padding: 4px 0; border-top: 1px solid var(--border); }
.pick-group:first-child { border-top: 0; }
.pick-head { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.pick-case { display: flex; align-items: baseline; gap: 8px; padding: 2px 0 2px 36px; font-size: 13px; cursor: pointer; flex-wrap: wrap; }
.pick-case .mono { font-size: 11px; }

/* run page */
.case-table tr.cat-row td { background: var(--surface-2); cursor: pointer; padding: 6px 10px; }
.case-table tr.case-row.open td { background: var(--accent-wash); }
.case-table tr.detail-row td { padding: 12px 14px 16px 22px; background: var(--surface-2); }
.case-table tbody tr:hover { background: transparent; }
.case-table tr.case-row:hover { background: var(--hover); }
.run-log { max-height: 340px; font-size: 12px; white-space: pre-wrap; }
.card-summary { cursor: pointer; }

/* issues */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th.sortable.sorted { color: var(--text-primary); }
.fields-grid { grid-template-columns: 1fr 1fr; }
.fields-grid input, .fields-grid select { width: 100%; }
.issue-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.issue-layout > div > * + * { margin-top: 16px; }
.issue-layout .card + .card { margin-top: 16px; }
.issue-layout .grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.targets-tbl td { vertical-align: top; }
.targets-tbl tr.pending td { background: var(--accent-wash); }
.targets-tbl td .badge + div { margin-top: 4px; }
.activity-tl { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.tl-item { display: flex; gap: 10px; font-size: 13px; align-items: baseline; }
.tl-item .tl-ic { width: 16px; text-align: center; color: var(--text-muted); flex: none; }
.tl-item .tl-ic.good { color: var(--good); }
.tl-item.comment { display: block; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; background: var(--surface-2); }
.tl-head { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 4px; }
.tl-t { font-size: 12px; margin-left: 4px; }
/* issue: plain-language summary first, technical evidence collapsible; likely-cause badges */
.badge.cause-firmware { background: rgba(208,59,59,0.15); color: var(--text-primary); }
.badge.cause-firmware .ic { color: var(--critical); }
.badge.cause-emulator { background: var(--accent-wash); color: var(--text-primary); }
.badge.cause-emulator .ic { color: var(--accent); }
.badge.cause-test { background: rgba(250,178,25,0.15); color: var(--text-primary); }
.badge.cause-test .ic { color: var(--warning); }
.badge.cause-environment { background: rgba(25,158,112,0.15); color: var(--text-primary); }
.badge.cause-environment .ic { color: var(--series-3); }
.badge.cause-unknown .ic { color: var(--text-muted); }
.human { display: grid; gap: 14px; }
.hblk .hl { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.hblk .hl button { text-transform: none; letter-spacing: 0; padding: 0 6px; }
.hblk .hv { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.hblk .hv.lead { font-size: 15px; }
.ai-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 14px; font-size: 12px; color: var(--text-secondary); }
.ai-ic { color: var(--accent); }
.tech-title { margin-top: 6px; font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); overflow-wrap: anywhere; }
details.evidence { border-top: 1px solid var(--border); }
details.evidence:first-child { border-top: 0; }
details.evidence > summary { display: flex; align-items: center; gap: 8px; padding: 9px 0; cursor: pointer; list-style: none; font-size: 13.5px; font-weight: 500; }
details.evidence > summary::-webkit-details-marker { display: none; }
details.evidence > summary .ev-title { flex: 1; }
details.evidence > summary .ev-chev { color: var(--text-muted); font-size: 11px; transition: transform 0.15s; }
details.evidence[open] > summary .ev-chev { transform: rotate(90deg); }
details.evidence > .ev-body { padding: 0 0 12px 19px; min-width: 0; overflow-x: auto; }
.md-sm { font-size: 13.5px; line-height: 1.5; max-width: none; }
.md-sm h1, .md-sm h2, .md-sm h3 { font-size: 14px; margin: 12px 0 6px; padding: 0; border: 0; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
.md-sm p, .md-sm ul, .md-sm ol { margin: 0 0 8px; }
.md-sm > :last-child { margin-bottom: 0; }
.md-sm img { max-width: 100%; }

/* diff */
pre.diff { margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 0; overflow: auto; max-height: 60vh; font-size: 12px; line-height: 1.5; }
pre.diff .dl { display: block; padding: 0 12px; white-space: pre; }
pre.diff .dl.add { background: rgba(12,163,12,0.15); }
pre.diff .dl.del { background: rgba(208,59,59,0.16); }
pre.diff .dl.hunk { color: var(--accent-text); background: var(--accent-wash); }
pre.diff .dl.meta { color: var(--text-muted); }
tr.current td { background: var(--accent-wash); }

@media (max-width: 900px) {
  .lib-layout, .editor-layout, .editor-layout.wide-side, .issue-layout { grid-template-columns: minmax(0, 1fr); }
  .tree-card { position: static; max-height: 260px; }
  .editor-side { position: static; max-height: none; }
  .preview-card { max-height: 420px; }
  .form-grid .wide-2 { grid-column: 1 / -1; }
  .hide-sm { display: none; }
  .sel-row { grid-template-columns: 100px minmax(0, 1fr) auto auto auto; }
  .sel-row .sel-hint { display: none; }
  .save-bar { bottom: 0; border-radius: 0; margin-left: -16px; margin-right: -16px; }
  .step .sdet { flex-basis: 100%; }
}
.try-panel { margin-bottom: 16px; }

/* --- where an instance runs / how long it lives (dashboard, instances, detail) --- */
.cell-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; }
.fw-next { color: var(--warning-text); font-weight: 600; cursor: help; }
.life { display: flex; align-items: center; gap: 7px; margin-top: 4px; font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; }
.life .meter { width: 56px; height: 4px; margin-top: 0; flex: none; }
.life.wide .meter { flex: 1; width: auto; height: 6px; }
.life.wide { font-size: 13px; }
.meter.warn > div { background: var(--warning); }
tr.group-row td { background: var(--surface-2); font-size: 12px; color: var(--text-secondary); padding: 6px 10px; }
tr.group-row td b { color: var(--text-primary); font-weight: 600; }
tr.group-row a { color: inherit; }
tr.more-row td { font-size: 12px; padding: 6px 10px; }
a.chip { text-decoration: none; }
.where-path { display: flex; align-items: stretch; gap: 5px; margin-bottom: 14px; }
.where-path .hop { flex: 1 1 0; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.where-path .hop.here { border-color: var(--accent); background: var(--accent-wash); }
.where-path .hop .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.where-path .hop .v { font-weight: 600; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.where-path .hop .s { font-size: 11.5px; color: var(--text-secondary); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.where-path .arrow { align-self: center; color: var(--text-muted); }
.timeline { position: relative; height: 34px; margin: 6px 4px 18px; }
.timeline .track { position: absolute; left: 0; right: 0; top: 13px; height: 6px; border-radius: 3px; background: var(--surface-3); }
.timeline .used { position: absolute; left: 0; top: 13px; height: 6px; border-radius: 3px; background: var(--accent); }
.timeline .used.warn { background: var(--warning); }
.timeline .mark { position: absolute; top: 8px; width: 2px; height: 16px; background: var(--text-muted); transform: translateX(-1px); }
.timeline .mark.now { background: var(--text-primary); }
.timeline .lbl { position: absolute; top: 26px; font-size: 11px; color: var(--text-muted); white-space: nowrap; transform: translateX(-50%); }
.timeline .lbl.start { transform: none; }
.timeline .lbl.end { transform: translateX(-100%); }
.life-hero { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.life-hero .big { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.where-path a.hop { color: inherit; text-decoration: none; }
.where-path a.hop:hover { border-color: var(--border-strong); }
.cell-sub .tag { font-size: 11px; padding: 0 5px; }
.store-hits { margin-top: 10px; max-height: min(46vh, 380px); overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.store-hit { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-radius: 0;
  border-bottom: 1px solid var(--border); background: none; color: inherit; font: inherit; cursor: pointer; }
.store-hit:last-child { border-bottom: 0; }
.store-hit:hover:not(:disabled) { background: var(--surface-3); }
.store-hit.on { background: var(--accent-wash); }
.store-hit:disabled { opacity: .6; cursor: default; }
.store-hit .sh-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.store-hit .sh-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* hardware devices: real routers on a test harness */
.tag.hw { border-color: var(--series-3, var(--accent)); color: var(--text-primary); }
a.tag.hw:hover { text-decoration: none; background: var(--accent-wash); }
.tag.warn-tag { border-color: var(--warning); color: var(--text-primary); }
.tag.bad-tag { border-color: var(--critical); color: var(--text-primary); }
.link-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.link-chip { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border-strong); color: var(--text-secondary); white-space: nowrap; }
.link-chip .dot-ic { font-size: 9px; }
.link-chip.up { border-color: var(--good); color: var(--text-primary); }
.link-chip.up .dot-ic { color: var(--good); }
.link-chip.down { border-color: var(--warning); }
.link-chip.down .dot-ic { color: var(--warning); }
.hw-path .hop.hw { border-color: var(--series-3, var(--accent)); }
.warn-text { color: var(--text-primary); } .warn-text::first-letter { color: var(--warning); }
.topo-harness { fill: var(--surface-1); fill-opacity: 0.55; stroke: var(--series-3); stroke-width: 1.5; stroke-dasharray: 7 5; }
.topo-box.router.hw { stroke: var(--series-3); stroke-width: 2; }
.topo-nic { fill: var(--surface-3); stroke: var(--series-3); stroke-width: 1.5; }
.topo-nic.up { fill: var(--series-3); }
.topo-legend .lk.harness { border-top: 2px dashed var(--series-3); }
.topo-legend .nic-key { display: inline-block; width: 8px; height: 12px; border: 1.5px solid var(--series-3); border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.topo .topo-s.nic { fill: var(--series-3); font-weight: 600; }
.topo-link.air { stroke-dasharray: 2 5; stroke-linecap: round; }

/* --- front-panel LED monitor (instance Overview) ---
   Dark theme: a smoked light-pipe strip. Light theme: a pale bezel, dies a touch deeper so they read
   on it, and a lit white die gets a cool outline and halo, since white on white would vanish.
   An LED's dies mix like light (screen) inside their own isolated layer, so green + red reads amber
   on either bezel. */
:root[data-theme="dark"] {
  --led-bezel: linear-gradient(180deg, #2a2c30, #161719); --led-bezel-border: rgba(255,255,255,.06);
  --led-bezel-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 -3px 8px rgba(0,0,0,.55);
  --led-off: #4a4d52; --led-label: #c9ccd0; --led-state: #8d9095;
  --led-white-glow: drop-shadow(0 0 2px currentColor) drop-shadow(0 0 7px currentColor);
}
:root[data-theme="light"] {
  --led-bezel: linear-gradient(180deg, #ffffff, #ebeae5); --led-bezel-border: rgba(11,11,11,.09);
  --led-bezel-shadow: inset 0 1px 0 #fff, inset 0 -2px 6px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.05);
  --led-off: #c8c7c0; --led-label: #3d3c39; --led-state: #6b6a65;
  --led-white-glow: drop-shadow(0 0 .6px rgba(35,50,85,.9)) drop-shadow(0 0 3px rgba(125,155,215,.65)) drop-shadow(0 0 9px rgba(170,195,240,.75));
}
.led-panel { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 26px; padding: 18px 20px 14px;
  border-radius: 14px; background: var(--led-bezel); border: 1px solid var(--led-bezel-border);
  box-shadow: var(--led-bezel-shadow); }
.led { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; cursor: default; }
.led-glyph { position: relative; width: 30px; height: 30px; }
.led-glyph svg { position: absolute; inset: 0; width: 30px; height: 30px; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.led-base { stroke: var(--led-off); }
.led-dies { position: absolute; inset: 0; isolation: isolate; }
.led-die { --die: var(--die-raw); stroke: var(--die); color: var(--die); opacity: 0; mix-blend-mode: screen;
  filter: drop-shadow(0 0 2px currentColor) drop-shadow(0 0 7px currentColor); }
.led-die[data-color="white"] { filter: var(--led-white-glow); }
:root[data-theme="light"] .led-die[data-color="red"] { --die: #e8261c; }
:root[data-theme="light"] .led-die[data-color="green"] { --die: #14b23d; }
:root[data-theme="light"] .led-die[data-color="blue"] { --die: #1f72e6; }
:root[data-theme="light"] .led-die[data-color="amber"] { --die: #f09800; }
:root[data-theme="light"] .led-die[data-color="orange"] { --die: #f06a00; }
:root[data-theme="light"] .led-die[data-color="yellow"] { --die: #e3b900; }
.led-label { font-size: 11.5px; font-weight: 600; letter-spacing: .03em; color: var(--led-label); }
.led-state { font-size: 11px; color: var(--led-state); font-variant-numeric: tabular-nums; text-align: center; max-width: 120px; }
.led-caption { font-size: 12px; margin-top: 8px; }

/* sign-in (REMU_AUTH=clerk; js/auth.js) */
.auth-box { display: flex; align-items: center; gap: 8px; }
.auth-box:empty { display: none; }
body.signed-out .sidebar, body.signed-out .banner-stats, body.signed-out .banner-actions > a,
body.signed-out .menu-toggle { display: none; }
.signin-wrap { display: flex; justify-content: center; padding: 40px 16px; }
.signin-wrap h1 { margin-top: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; margin-top: 6px; }

/* --- shared list view (js/datalist.js): toolbar, bulk actions, select-all, list/cards, pager --- */
.dl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.dl-bar:empty { display: none; }
.dl-spacer { flex: 1; }
.dl-search { width: 240px; max-width: 100%; }
.dl-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dl-count { font-size: 12.5px; color: var(--text-secondary); margin-right: 2px; }
.dl-count.muted { color: var(--text-muted); }
.dl-selall { font-size: 12.5px; padding: 6px 10px; margin-bottom: 8px; border-radius: 6px; background: var(--accent-wash); color: var(--text-secondary); text-align: center; }
th.dl-cb, td.dl-cb { width: 28px; padding-right: 0; }
.dl-check { margin: 0; cursor: pointer; }
.dl-arrow { color: var(--accent-text); }
tr.dl-selected td { background: var(--accent-wash); }
.dl-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.dl-cards > .card + .card { margin-top: 0; }
.dl-card { position: relative; display: flex; gap: 10px; padding: 12px 14px; min-width: 0; }
.dl-card.clickable { cursor: pointer; }
.dl-card.clickable:hover { border-color: var(--border-strong); background: var(--hover); }
.dl-card.dl-selected { border-color: var(--accent); background: var(--accent-wash); }
.dl-card-check { padding-top: 2px; }
.dl-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.dl-card-head { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.dl-card-title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.dl-kv { font-size: 12.5px; gap: 3px 12px; }
.dl-card-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.dl-card-foot .actions { flex-wrap: wrap !important; }
.dl-cardall { font-size: 12.5px; }
.dl-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; font-size: 12.5px; }
.dl-pager:empty { display: none; }
.dl-pages { display: flex; align-items: center; gap: 4px; }
.dl-size { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 900px) { .dl-bulk .dl-count.muted { display: none; } }
/* second-level tabs (a page's sections, e.g. Access) */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; padding: 3px; border-radius: 8px; background: var(--surface-2); width: fit-content; max-width: 100%; }
.subtabs a { padding: 5px 12px; border-radius: 6px; color: var(--text-secondary); font-weight: 500; font-size: 13px; white-space: nowrap; }
.subtabs a:hover { color: var(--text-primary); text-decoration: none; background: var(--hover); }
.subtabs a.active { background: var(--surface-1); color: var(--text-primary); box-shadow: 0 0 0 1px var(--border-strong); }
.dl-slot:empty, .dl-bulk:empty { display: none; }
.dl-card .cell-sub { white-space: normal; overflow-wrap: anywhere; }
.dl-cards > .dl-card.open { grid-column: 1 / -1; }
.dl-card-detail { border-top: 1px solid var(--border); padding-top: 10px; }
.dl-cards.cols-2 { grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); }

/* --- dashboard --- */
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
a.tile.kpi { color: inherit; display: block; }
a.tile.kpi:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }
.kpi-row { display: flex; align-items: flex-end; gap: 10px; justify-content: space-between; min-height: 34px; }
.kpi-row .value { white-space: nowrap; }
.spark { width: 96px; height: 30px; flex: none; overflow: visible; }
.spark-line { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { opacity: .12; stroke: none; }
.spark-dot { stroke: var(--surface-1); stroke-width: 1.5; }
.tiles.mini { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tiles.mini .tile { background: var(--surface-2); padding: 8px 12px; }
.tiles.mini .value { font-size: 19px; }
.dash-grid { display: grid; gap: 16px; margin-bottom: 16px; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.dash-grid.wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.dash-grid.three { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
@media (max-width: 1100px) { .dash-grid.wide-left { grid-template-columns: 1fr; } }
.dash-card { min-width: 0; }
.dash-grid > .card + .card { margin-top: 0; }
.dash-card .card-head h2 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card-sub { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.card-link { font-size: 12.5px; white-space: nowrap; }
.dash-panel + .dash-panel, .dash-panel + .dash-note, .dash-chart + .dash-panel { margin-top: 16px; }
.dash-panel h3 { font-size: 11.5px; margin-bottom: 8px; }
.dash-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.dash-note { font-size: 12px; margin-top: 10px; }
.dash-legend { margin: 8px 0 0; }
.chart-empty { padding: 18px 0; font-size: 13px; }
.chart .col-hl { fill: var(--hover); }
/* one whole split into parts */
.segbar { display: flex; gap: 2px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.segbar .seg-part { display: block; min-width: 3px; height: 100%; }
.segbar a.seg-part:hover { filter: brightness(1.15); }
.seg-empty { flex: 1; }
.seg-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12.5px; color: var(--text-secondary); }
.seg-legend a { color: inherit; }
.seg-legend b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 2px; }
.hb-row { display: grid; grid-template-columns: var(--hb-label, 110px) minmax(0, 1fr); gap: 10px; align-items: center;
  padding: 3px 4px; margin: 0 -4px; border-radius: 4px; color: inherit; font-size: 12.5px; }
a.hb-row:hover { background: var(--hover); text-decoration: none; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.hb-sub { color: var(--text-muted); margin-left: 6px; }
.hb-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hb-fill { display: flex; gap: 2px; height: 12px; flex: none; width: calc((100% - var(--hb-reserve, 60px)) * var(--f, 0)); }
.hb-fill i { display: block; height: 100%; min-width: 2px; }
.hb-fill i:last-child { border-radius: 0 4px 4px 0; }
.hb-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; white-space: nowrap; }
.hb-foot { grid-column: 2; font-size: 11.5px; color: var(--text-muted); margin-top: -2px; }
.hb-note { color: var(--text-muted); font-weight: 400; }
/* gauges */
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.gauge { text-align: center; }
.gauge svg { display: block; width: 100%; max-width: 140px; margin: 0 auto; }
.gauge .g-track { fill: none; stroke: var(--surface-3); stroke-linecap: round; }
.gauge .g-val { fill: var(--text-primary); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gauge .g-label { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.gauge .g-sub { font-size: 11.5px; color: var(--text-muted); }
/* active runs */
.dash-run { display: flex; flex-direction: column; gap: 5px; padding: 6px 4px; margin: 0 -4px; border-radius: 4px; color: inherit; }
.dash-run:hover { background: var(--hover); text-decoration: none; }
.dash-run-head { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; }
.dash-run-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ======================================================================================
   Structure (js/ui.js): on-demand help, collapsible sections, Advanced disclosures, action
   bars, page header, CLI equivalents, drawers, palette, shortcuts.
   ====================================================================================== */
/* help: long explanations open on demand (ⓘ) or all at once (banner switch: body.help-inline) */
.help.ondemand:not(.open) { display: none; }
body.help-inline .help.ondemand { display: block; }
.help.ondemand.open { display: block; }
span.help.ondemand.open, body.help-inline span.help.ondemand { display: block; }
.info-i { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--border-strong); color: var(--text-muted); font: italic 600 10.5px/1 Georgia, serif; cursor: pointer;
  vertical-align: 1px; flex: none; user-select: none; position: relative; }
.info-i::after { content: ""; position: absolute; inset: -12px; }                /* 40 px touch target */
.info-i:hover, .info-i[aria-expanded="true"] { color: var(--accent-text); border-color: var(--accent); background: var(--accent-wash); }
.info-i:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.help-inline .info-i { display: none; }
.about { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; margin: 0 0 12px; padding: 8px 12px;
  border-left: 2px solid var(--accent); background: var(--accent-wash); border-radius: 0 6px 6px 0; }
.about.page-about { margin-top: 8px; max-width: 980px; }
.doc-link { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--border-strong); color: var(--text-muted); font-size: 11.5px; font-weight: 600; flex: none; }
.doc-link:hover { text-decoration: none; color: var(--accent-text); border-color: var(--accent); }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#help-toggle[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); color: var(--text-primary); }

/* collapsible section (card) */
.sec { padding: 0; }
.sec-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 10px 8px; min-height: 48px; }
.sec-toggle { flex: 1; min-width: 0; display: flex; font: inherit; font-weight: 600; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 6px;
  text-align: left; color: var(--text-primary); white-space: normal; border-radius: 6px; }
.sec-toggle:hover { background: var(--hover); }
.sec-h { margin: 0; flex: 1; min-width: 0; font-size: 15px; display: flex; }
.sec-title { flex: none; font-weight: 600; font-size: 15px; }
.sec-chev { color: var(--text-muted); font-size: 11px; transition: transform .15s; display: inline-block; width: 12px; flex: none; }
.sec:not(.collapsed) > .sec-head .sec-chev, .adv.open > .adv-toggle .sec-chev { transform: rotate(90deg); }
.sec-sum { color: var(--text-secondary); font-size: 12.5px; font-weight: 400; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec:not(.collapsed):not(.sum-always) .sec-sum { display: none; }
.sec-tone:empty { display: none; }
.sec-actions { flex: none; }
.sec-body { padding: 2px 18px 16px; }
.sec-body[hidden] { display: none; }
.sec.collapsed { background: var(--surface-1); }
.grid > .sec + .sec { margin-top: 0; }
.sec + .card, .card + .sec { margin-top: 16px; }
.grid > .sec + .card, .grid > .card + .sec { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .sec-chev { transition: none; } }

/* Advanced disclosure inside a form */
.adv { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 8px; }
.adv-toggle { padding: 4px 6px; color: var(--text-secondary); }
.adv-count.on { color: var(--warning-text); font-weight: 600; }
.adv-body { padding-top: 10px; }
.adv-body[hidden] { display: none; }

/* sticky action bar of long forms */
.action-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.action-bar .ab-sum { flex: 1; min-width: 200px; font-size: 13px; color: var(--text-secondary); }
.action-bar .ab-sum b { color: var(--text-primary); }

/* CLI equivalent */
.cli-box { margin-top: 10px; font-size: 12.5px; }
.cli-box > summary { cursor: pointer; color: var(--text-secondary); width: max-content; }
.cli-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.cli-cmd { flex: 1; min-width: 0; display: block; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* drawer: modal docked right */
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(560px, 100vw); border-radius: 0; border-width: 0 0 0 1px;
  display: flex; flex-direction: column; }
dialog.drawer:not([open]) { display: none; }
dialog.drawer .m-body { flex: 1; max-height: none; }

/* quick jump palette + shortcut list */
dialog.palette { margin-top: 12vh; width: min(640px, 94vw); }
.palette input { width: 100%; font-size: 15px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; }
.palette input:focus { outline: none; }
.pal-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--text-primary); cursor: pointer; }
.pal-item .pal-kind { margin-left: auto; font-size: 11.5px; color: var(--text-muted); }
.pal-item.on, .pal-item:hover { background: var(--accent-wash); text-decoration: none; }
.pal-foot { padding: 6px 12px 10px; font-size: 11.5px; color: var(--text-muted); }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }
.kbd-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }

/* sidebar groups (collapsible) */
.nav-group-head { display: flex; align-items: center; gap: 6px; width: 100%; margin: 14px 0 4px; padding: 3px 10px; background: none; border: 0;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); border-radius: 6px; font-weight: 500; }
.nav-group-head:hover { background: var(--hover); color: var(--text-secondary); }
.nav-group-head .sec-chev { font-size: 9px; width: 10px; transform: rotate(90deg); }
.nav-group.collapsed .nav-group-head .sec-chev { transform: none; }
.nav-group.collapsed .nav-section > a:not(.active) { display: none; }
.nav-group-head .count { margin-left: auto; text-transform: none; letter-spacing: 0; }
.nav-group:not(.collapsed) .nav-group-head .count { display: none; }

/* banner: one line; lower-priority stats in the "more" popover */
.banner-stats { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; min-width: 0; }
.banner-stats > * { white-space: nowrap; }
.bstat-more { position: relative; }
.bstat-pop { position: fixed; top: 52px; display: grid; grid-template-columns: max-content max-content; gap: 6px 16px; padding: 10px 14px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.35); z-index: 30; font-size: 12.5px; }
.bstat-pop[hidden] { display: none; }
@media (max-width: 1500px) { .banner-stats .st-3 { display: none; } }
@media (max-width: 1300px) { .banner-stats .st-2 { display: none; } }

/* lists: column chooser, density, filters button on phones */
.dl-menu { position: relative; }
.dl-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 12; min-width: 220px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.3); font-size: 13px; }
.dl-pop[hidden] { display: none; }
.dl-pop .nav-title { margin: 4px 0 2px; }
.dl.dl-compact td { padding-top: 4px; padding-bottom: 4px; }
.dl.dl-compact .cell-sub { margin-top: 1px; }
.dl-tools { display: contents; }
.dl-filters-btn { display: none; }
@media (max-width: 700px) {
  .dl-filters-btn { display: inline-flex; }
  .dl-tools { display: none; }
  .dl-tools.open { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
  .dl-tools.open > * { flex: 1 1 140px; }
  .dl-search { flex: 1 1 140px; width: auto; }
  .dl-bulk .dl-count { display: none; }
}
.nav-group.collapsed .nav-title, .nav-group.collapsed .nav-more, .nav-group.collapsed .nav-empty,
.nav-group.collapsed a.nav-hidden { display: none; }
.nav-kbd { padding-left: 10px !important; margin-top: 6px !important; font-size: 11.5px !important; }
.nav-kbd kbd { font-size: 10px; }
@media (max-width: 900px) { .nav-kbd { display: none !important; } }
.clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
/* section summaries wrap under the title on phones */
@media (max-width: 700px) {
  .sec-toggle { flex-wrap: wrap; }
  .sec-sum { white-space: normal; flex-basis: 100%; padding-left: 20px; }
  .sec-head { flex-wrap: wrap; }
}
/* page loading placeholder (app.js): only while the page has put nothing else in main */
.page-loading { display: flex; align-items: center; gap: 10px; padding: 40px 4px; color: var(--text-secondary); opacity: 0; animation: pl-in .2s ease .35s forwards; }
.page-loading:not(:only-child) { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes pl-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* touch: targets of at least 40 px */
@media (pointer: coarse), (max-width: 700px) {
  .banner .icon-btn, .banner .btn { min-width: 40px; min-height: 40px; justify-content: center; }
  .banner { gap: 6px; }
  .banner-actions { gap: 4px; }
  button.small, .btn.small, .adv-toggle, .dl-filters-btn, .seg button { min-height: 40px; }
  .dl-check, .dl-cb input[type=checkbox] { width: 20px; height: 20px; position: relative; }
  td.dl-cb, .dl-card-check { position: relative; }
  td.dl-cb::after, .dl-card-check::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
  td.dl-cb { min-width: 44px; }
  .doc-link { position: relative; width: 26px; height: 26px; }
  .doc-link::after { content: ""; position: absolute; inset: -8px; }
  .sec-toggle { min-height: 40px; }
  label.check { min-height: 36px; }
  .chip { min-height: 36px; }
}
.info-glyph { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid currentColor; font: italic 600 10.5px/1 Georgia, serif; }
@media (max-width: 480px) { .brand-name { display: none; } }

.sec-dirty:empty { display: none; }
.sec-dirty { font-weight: 500; }
.sec-about { padding: 0 18px; }
.sec-about .about { margin-bottom: 10px; }
.sec-about:not(:has(.open)) { padding: 0; }
body.help-inline .sec-about { padding: 0 18px; }
/* sortable column headers are buttons (keyboard) */
th .sort-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; gap: 2px; white-space: nowrap; }
th .sort-btn:hover { color: var(--text-primary); }
.dl-sort { display: inline-flex; gap: 4px; align-items: center; }
/* help articles on phones: wide code and tables scroll in place */
.md pre { overflow-x: auto; }
.md table { display: block; overflow-x: auto; max-width: 100%; }
.md img { max-width: 100%; }
@media (pointer: coarse), (max-width: 700px) {
  select, input:not([type=checkbox]):not([type=radio]) { min-height: 40px; }
}
@media (max-width: 900px) {
  .banner-stats { display: flex !important; margin-left: auto; }
  .banner-stats > :not(.bstat-more):not(.bstat-pop) { display: none; }
  .bstat-more { min-width: 40px; min-height: 40px; }
  .bstat-pop { left: 8px !important; right: 8px; }
}
@media (max-width: 480px) {
  .banner-actions a.btn.icon-btn[href="#/help"] { display: none; }   /* Help stays in the menu and Ctrl+K */
  .banner { gap: 4px; padding: 0 8px; }
}

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: 6px; background: var(--accent-fill); color: #fff; }
.skip-link:focus { top: 8px; }
#main:focus { outline: none; }
/* selects and inputs fill their form-grid column, so the chosen value isn't clipped */
.form-grid > .field select, .form-grid > .field input:not([type=checkbox]):not([type=radio]), .form-grid > label.field select { width: 100%; }
/* stat tiles: whole rows on desktop, two per row on phones */
.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 700px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile .value { font-size: 20px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .title { min-width: 0; }
}

dialog h2.m-head { margin: 0; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
/* row / card selection: the checkbox's label is the hit area */
.dl-hit { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin: -6px; padding: 6px; }
@media (pointer: coarse), (max-width: 700px) { .dl-hit { min-width: 40px; min-height: 40px; margin: -10px; } }
/* cards: a long title gets its own line, badges wrap beneath */
.dl-card-head { flex-direction: column; align-items: flex-start; }
.dl-card-head > .dl-card-title { width: 100%; }
@media (min-width: 701px) { .dl-card-head { flex-direction: row; } }

/* long-value selects take two form columns (ui.js marks their field .wide-select) */
@media (min-width: 701px) { .form-grid > .field.wide-select { grid-column: span 2; } }
/* touch: sidebar, icon buttons, bar rows, tag links */
@media (pointer: coarse), (max-width: 700px) {
  .sidebar a, .nav-group-head, .nav-more, .sidebar a.nav-hidden { min-height: 40px; }
  .nav-instances a { min-height: 40px; }
  button.small, .btn.small { min-width: 40px; justify-content: center; }
  .hb-row { min-height: 40px; }
  a.tag { position: relative; }
  a.tag::after { content: ""; position: absolute; inset: -10px -4px; }
}
@media (pointer: coarse), (max-width: 700px) { details > summary { min-height: 40px; box-sizing: border-box; padding-top: 10px; } }
