/* Tiller design tokens: one accent (emerald), status colours kept apart
   from it, Geist for text and Geist Mono + tabular figures for identifiers. */
@font-face { font-family: "Geist"; src: url("/fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  --bg: #f3f5f7; --panel: #ffffff; --panel-2: #f7f9fa; --ink: #0d1318; --muted: #63707c; --faint: #9aa5ae;
  --line: #e2e7eb; --line-2: #cdd5db; --mono-bg: #eef2f4;
  --accent: #0a8763; --accent-2: #14b386; --accent-soft: #e1f3ec; --accent-ink: #06573f;
  --up: #0a8763; --warn: #9d6800; --warn-soft: #fbf0d8; --crit: #c13a2b; --crit-soft: #fbe5e1; --off: #a1acb4;
  --shadow-sm: 0 1px 2px rgba(13, 22, 30, .05), 0 1px 3px rgba(13, 22, 30, .04);
  --shadow: 0 28px 56px -24px rgba(13, 22, 30, .32), 0 2px 8px rgba(13, 22, 30, .06);
  --plate: linear-gradient(160deg, #ffffff, #e9eef1);
  --wash: radial-gradient(1100px 420px at 100% -8%, rgba(20, 179, 134, .07), transparent 70%);
  --f-body: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-disp: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 14px; --r-sm: 9px;
  --rh: 52px; /* two-line name cell: name + Winbox address */
  /* Left menu: its own tokens so a theme can colour it. */
  --side-bg: color-mix(in srgb, var(--panel) 60%, transparent); --side-solid: var(--panel);
  --side-ink: var(--ink); --side-muted: var(--muted); --side-faint: var(--faint);
  --side-hover: color-mix(in srgb, var(--ink) 5%, transparent);
  --side-on-bg: var(--panel); --side-on-ring: var(--line); --side-icon: var(--accent); --side-line: var(--line);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090d10; --panel: #10161a; --panel-2: #0c1114; --ink: #e8eef1; --muted: #8995a0; --faint: #56626b;
    --line: #1c252b; --line-2: #29353d; --mono-bg: #172026;
    --accent: #3fd0a0; --accent-2: #24b386; --accent-soft: #0e2b22; --accent-ink: #9af2d1;
    --up: #3fd0a0; --warn: #e8b65c; --warn-soft: #2b2311; --crit: #f2806f; --crit-soft: #311915; --off: #4e5a63;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow: 0 28px 64px -20px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .03);
    --plate: radial-gradient(120% 100% at 30% 15%, #4a5963, #232d34 72%);
    --wash: radial-gradient(1100px 420px at 100% -8%, rgba(63, 208, 160, .07), transparent 70%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #090d10; --panel: #10161a; --panel-2: #0c1114; --ink: #e8eef1; --muted: #8995a0; --faint: #56626b;
  --line: #1c252b; --line-2: #29353d; --mono-bg: #172026;
  --accent: #3fd0a0; --accent-2: #24b386; --accent-soft: #0e2b22; --accent-ink: #9af2d1;
  --up: #3fd0a0; --warn: #e8b65c; --warn-soft: #2b2311; --crit: #f2806f; --crit-soft: #311915; --off: #4e5a63;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow: 0 28px 64px -20px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .03);
  --plate: radial-gradient(120% 100% at 30% 15%, #4a5963, #232d34 72%);
  --wash: radial-gradient(1100px 420px at 100% -8%, rgba(63, 208, 160, .07), transparent 70%);
  color-scheme: dark;
}

/* ---- themes -------------------------------------------------------------
   data-theme is the scheme (light | dark; absent = follow the system) and
   every scheme rule above keys on it. data-palette picks a named theme on
   top: it overrides surfaces, accent and the left menu; status colours stay
   the scheme's own. Set by app.js (applyTheme), saved as "tiller-theme". */
:root[data-palette="meadow"] {
  --bg: #eef5f1; --panel: #ffffff; --panel-2: #f4f9f6; --line: #d8e6de; --line-2: #c3d6cb; --mono-bg: #e7f1eb;
  --accent: #0a8763; --accent-2: #19b98b; --accent-soft: #dcf2e8; --accent-ink: #06573f;
  --wash: radial-gradient(1200px 520px at 100% -10%, rgba(25, 185, 139, .16), transparent 70%), radial-gradient(900px 500px at -10% 110%, rgba(10, 135, 99, .08), transparent 70%);
  --side-bg: linear-gradient(180deg, #0b3d2e, #08291f); --side-solid: #0a3327;
  --side-ink: #f1fbf6; --side-muted: #a9cdbe; --side-faint: #6f9a88; --side-hover: rgba(255, 255, 255, .07);
  --side-on-bg: rgba(255, 255, 255, .13); --side-on-ring: rgba(255, 255, 255, .12); --side-icon: #5fe0b2; --side-line: #0b3d2e;
}
:root[data-palette="ocean"] {
  --bg: #edf2f8; --panel: #ffffff; --panel-2: #f4f7fb; --line: #d9e2ee; --line-2: #c4d1e2; --mono-bg: #e7eef7;
  --accent: #1f63d6; --accent-2: #3f86f0; --accent-soft: #e1ebfb; --accent-ink: #123f8c;
  --wash: radial-gradient(1200px 520px at 100% -10%, rgba(63, 134, 240, .16), transparent 70%), radial-gradient(900px 500px at -10% 110%, rgba(16, 180, 200, .08), transparent 70%);
  --side-bg: linear-gradient(180deg, #102a4c, #0a1c35); --side-solid: #0e2442;
  --side-ink: #eef4ff; --side-muted: #a7bbd9; --side-faint: #6c84a8; --side-hover: rgba(255, 255, 255, .07);
  --side-on-bg: rgba(255, 255, 255, .13); --side-on-ring: rgba(255, 255, 255, .12); --side-icon: #7fb2ff; --side-line: #102a4c;
}
:root[data-palette="sunset"] {
  --bg: #faf3ec; --panel: #fffdfa; --panel-2: #fbf6f0; --line: #eddfd2; --line-2: #e0cdbb; --mono-bg: #f6ece2;
  --accent: #c2410c; --accent-2: #ea7a2f; --accent-soft: #fde7d8; --accent-ink: #7c2a08;
  --wash: radial-gradient(1200px 520px at 100% -10%, rgba(234, 122, 47, .16), transparent 70%), radial-gradient(900px 500px at -10% 110%, rgba(219, 39, 119, .07), transparent 70%);
  --side-bg: linear-gradient(180deg, #3d1d12, #28130b); --side-solid: #361a10;
  --side-ink: #fff4ec; --side-muted: #d8b6a3; --side-faint: #9c7a68; --side-hover: rgba(255, 255, 255, .07);
  --side-on-bg: rgba(255, 255, 255, .12); --side-on-ring: rgba(255, 255, 255, .12); --side-icon: #ffa36b; --side-line: #3d1d12;
}
:root[data-palette="lavender"] {
  --bg: #f2f0fa; --panel: #ffffff; --panel-2: #f7f5fc; --line: #e1ddf1; --line-2: #cfc8e8; --mono-bg: #ece8f8;
  --accent: #6a45d8; --accent-2: #8b6cf0; --accent-soft: #ebe5fd; --accent-ink: #3f2493;
  --wash: radial-gradient(1200px 520px at 100% -10%, rgba(139, 108, 240, .17), transparent 70%), radial-gradient(900px 500px at -10% 110%, rgba(236, 72, 153, .07), transparent 70%);
  --side-bg: linear-gradient(180deg, #2a1d5e, #1b123f); --side-solid: #241953;
  --side-ink: #f4f0ff; --side-muted: #bdb1e3; --side-faint: #7f72aa; --side-hover: rgba(255, 255, 255, .07);
  --side-on-bg: rgba(255, 255, 255, .13); --side-on-ring: rgba(255, 255, 255, .12); --side-icon: #b8a3ff; --side-line: #2a1d5e;
}
:root[data-palette="midnight"] {
  --bg: #080c18; --panel: #0f1526; --panel-2: #0b101e; --ink: #e8ecf7; --muted: #8b95b0; --faint: #555f7a;
  --line: #1b2338; --line-2: #283350; --mono-bg: #151c30;
  --accent: #7aa2ff; --accent-2: #5b84f0; --accent-soft: #16203d; --accent-ink: #c4d4ff;
  --wash: radial-gradient(1100px 480px at 100% -8%, rgba(122, 162, 255, .12), transparent 70%), radial-gradient(900px 500px at -10% 110%, rgba(167, 112, 255, .08), transparent 70%);
  --plate: radial-gradient(120% 100% at 30% 15%, #4b5677, #20283f 72%);
}
:root[data-palette="graphite"] {
  --bg: #111111; --panel: #1a1a1a; --panel-2: #151515; --ink: #ececec; --muted: #9a9a9a; --faint: #5f5f5f;
  --line: #262626; --line-2: #333333; --mono-bg: #212121;
  --accent: #f5a524; --accent-2: #d98b10; --accent-soft: #2e2410; --accent-ink: #ffd590;
  --wash: radial-gradient(1100px 480px at 100% -8%, rgba(245, 165, 36, .07), transparent 70%);
  --plate: radial-gradient(120% 100% at 30% 15%, #5a5a5a, #262626 72%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--wash), var(--bg); background-attachment: fixed; color: var(--ink);
  font: 14px/1.55 var(--f-body); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01"; text-rendering: optimizeLegibility;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono, .kbd { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kbd {
  font-size: 11px; background: var(--panel); border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 5px; color: var(--muted); line-height: 18px; display: inline-block;
}

/* top bar */
.bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px; min-height: 58px; position: relative; z-index: 10;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font: 650 16.5px var(--f-disp); letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--accent-2), #077154);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 4px 10px -3px color-mix(in srgb, var(--accent-2) 70%, transparent);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.counts { display: flex; gap: 6px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.counts b { color: var(--ink); font-family: var(--f-mono); font-weight: 600; }
.counts .c {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--panel-2) 70%, transparent); border: 1px solid var(--line);
}
.counts .c .dot { width: 7px; height: 7px; }
.sp { flex: 1; }
.btn {
  font: 500 13px var(--f-body); color: var(--ink); background: var(--panel); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 5px 11px; cursor: pointer; display: inline-flex; gap: 5px; align-items: center;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s, transform .06s;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line-2)); background: var(--panel-2); }
.btn:active { transform: translateY(.5px); }
.live { display: inline-flex; align-items: center; gap: 6px; font: 11.5px var(--f-mono); color: var(--muted); }
.live .lv { width: 7px; height: 7px; border-radius: 50%; background: var(--off); }
.live[data-state="open"] { color: var(--up); }
.live[data-state="open"] .lv { background: var(--up); animation: pulse 2.4s ease-in-out infinite; }
.live[data-state="down"] { color: var(--crit); }
.live[data-state="down"] .lv { background: var(--crit); }
@keyframes pulse { 50% { opacity: .35; } }

.banner {
  margin: 12px 16px 0; padding: 9px 13px; border-radius: 9px; font-size: 13px;
  background: var(--warn-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line));
}
.banner b { font-weight: 600; }

/* status dots */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.on { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 18%, transparent); }
.dot.off { background: var(--crit); box-shadow: 0 0 0 3px color-mix(in srgb, var(--crit) 16%, transparent); }
.dot.unk { background: var(--off); }

/* list view */
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
.search {
  flex: 1 1 260px; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--panel);
  border: 1px solid var(--line-2); border-radius: 11px; padding: 0 12px; box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 9px 0; outline: none; }
.search input::placeholder { color: var(--faint); }
.mag { color: var(--muted); }
.chips { display: flex; gap: 6px; }
.chip {
  font: 500 12.5px var(--f-body); color: var(--muted); background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.chip .dot { width: 7px; height: 7px; }
.shown { margin-left: auto; font: 12px var(--f-mono); color: var(--muted); white-space: nowrap; }

.grid-head, .row {
  display: grid; gap: 12px; align-items: center; padding: 0 16px;
  grid-template-columns: 38px minmax(180px, 2.2fr) minmax(90px, 1fr) 76px 76px 118px 150px minmax(96px, 1fr);
}
.grid-head {
  font: 600 11px var(--f-body); letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-bottom: 8px;
}
.grid-head button {
  all: unset; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid-head button:focus-visible { outline: 2px solid var(--accent); }
.grid-head button[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
.grid-head button[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.scroller { flex: 1; overflow-y: auto; position: relative; min-height: 200px; outline: none; }
.spacer { width: 1px; }
.row {
  position: absolute; left: 0; right: 0; top: 0; height: var(--rh);
  border-bottom: 1px solid var(--line); cursor: pointer; text-decoration: none; color: var(--ink);
}
.row { transition: background .1s; }
.row:hover { background: color-mix(in srgb, var(--panel) 75%, transparent); }
.row.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.row > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .nm { font: 500 13px var(--f-mono); letter-spacing: -.01em; }
.row .dim { color: var(--muted); font-size: 12.5px; }
.row .id { font: 12px var(--f-mono); color: var(--muted); }
.row .st { font: 12px var(--f-mono); color: var(--muted); }
.row .st.on { color: var(--up); }
.row .st.off { color: var(--crit); }
.empty { padding: 40px 16px; color: var(--muted); text-align: center; }

@media (max-width: 900px) {
  .grid-head, .row { grid-template-columns: 38px minmax(140px, 2fr) 76px 118px minmax(84px, 1fr); }
  :is(.row, .grid-head) :is(.c-board, .c-rb, .c-mac) { display: none; }
}
@media (max-width: 560px) {
  .grid-head, .row { grid-template-columns: 34px 1fr auto; }
  :is(.row, .grid-head) :is(.c-ros, .c-ip) { display: none; }
  .shown { margin-left: 0; }
}

/* router page */
#view-router { overflow-y: auto; }
.rp { max-width: 1100px; width: 100%; margin: 0 auto; padding: 18px 16px 48px; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.back:hover { color: var(--ink); }
.rp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 4px; }
.rp-head h1 { font: 650 clamp(21px, 3.4vw, 28px)/1.15 var(--f-disp); margin: 0; letter-spacing: -.025em; word-break: break-all; }
.pill { font: 600 12px var(--f-body); padding: 3px 11px 3px 9px; border-radius: 999px; display: inline-flex; gap: 7px; align-items: center; }
.pill .dot { width: 7px; height: 7px; box-shadow: none; }
.pill.on { background: var(--accent-soft); color: var(--up); }
.pill.off { background: var(--crit-soft); color: var(--crit); }
.pill.unk { background: var(--mono-bg); color: var(--muted); }
.rp-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
/* router hero: product photo on a plate, name, status, key facts */
.rp-hero { display: flex; gap: 20px; align-items: center; margin: 14px 0 4px; }
.rp-hero .thumb { width: 104px; height: 104px; border-radius: 20px; }
.rp-hero-main { min-width: 0; flex: 1; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fact {
  display: inline-flex; align-items: baseline; gap: 6px; font-size: 12.5px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; box-shadow: var(--shadow-sm);
}
.fact b { font: 600 12.5px var(--f-mono); color: var(--ink); letter-spacing: -.01em; }
/* product thumbnails: photo scaled to fit on a soft plate; icon when unknown */
.thumb {
  flex: none; display: grid; place-items: center; overflow: hidden; background: var(--plate);
  border: 1px solid var(--line); border-radius: 9px; color: var(--faint);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
}
.thumb img { width: 88%; height: 88%; object-fit: contain; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .18)); }
.thumb svg { width: 52%; height: 52%; }
.row .thumb { width: 36px; height: 36px; border-radius: 9px; }
.c-thumb { position: relative; display: grid; }
.row > .c-thumb { overflow: visible; }
.c-thumb > .dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border: 2px solid var(--bg); box-shadow: none; }
@media (max-width: 560px) {
  .rp-hero { gap: 14px; align-items: flex-start; }
  .rp-hero .thumb { width: 72px; height: 72px; border-radius: 16px; }
  .row .thumb { width: 32px; height: 32px; }
}
/* router page tabs: header above, one panel of cards per tab below */
.rp.rp-top { padding-bottom: 0; }
.rp-top .rp-hero { margin-bottom: 16px; }
.rp-hero .rp-sub { margin: 3px 0 0; }
.rp-tabs { position: sticky; top: 0; z-index: 5; padding-inline: max(16px, calc((100% - 1100px) / 2 + 4px)); }
.rp.rp-body { padding-top: 16px; }
.rp-panel > .cards + .cards { margin-top: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font: 600 11.5px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.card h2.sub-h { margin-top: 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.kv dd.mono { font-size: 13px; }
.note { color: var(--muted); font-size: 12px; font-family: var(--f-body); }
.none { color: var(--muted); }
.copy {
  all: unset; cursor: pointer; font: 11px var(--f-mono); color: var(--muted); border: 1px solid var(--line);
  border-radius: 5px; padding: 0 5px; line-height: 17px;
}
.copy:hover { color: var(--ink); border-color: var(--line-2); }
.copy:focus-visible { outline: 2px solid var(--accent); }
.meter { height: 6px; border-radius: 4px; background: var(--mono-bg); overflow: hidden; width: 100%; max-width: 160px; align-self: center; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 4px; }
.meter i.hot { background: var(--warn); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font: 500 11.5px var(--f-mono); background: var(--mono-bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.hist li { display: grid; gap: 1px; }
.hist .mono { font-size: 12.5px; }

/* command palette */
.palette-back {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(3px);
  display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; z-index: 20;
}
.palette { width: 100%; max-width: 600px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.pin { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.pin input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font: 15px var(--f-body); }
.phint { font: 11px var(--f-mono); color: var(--muted); white-space: nowrap; }
.pres { padding: 6px; max-height: 52vh; overflow-y: auto; }
.pr { display: flex; align-items: center; gap: 11px; padding: 8px 11px; border-radius: 8px; cursor: pointer; min-width: 0; }
.pr.sel { background: var(--accent-soft); }
.pr .thumb { width: 28px; height: 28px; border-radius: 7px; }
.pr .nm { font: 500 13px var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr .meta { margin-left: auto; font: 12px var(--f-mono); color: var(--muted); white-space: nowrap; padding-left: 10px; }
.pr .act { font-size: 13px; font-weight: 600; color: var(--accent); }
.pgroup { font: 600 11px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 11px 4px; }
.pfoot { border-top: 1px solid var(--line); padding: 8px 14px; display: flex; gap: 16px; flex-wrap: wrap; font: 11px var(--f-mono); color: var(--muted); }
.pempty { padding: 18px 12px; color: var(--muted); font-size: 13px; }
@media (max-width: 560px) { .phint, .kbtn { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* account menu */
.who { position: relative; }
.who-btn { font-family: var(--f-mono); font-size: 12px; }
.who-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; min-width: 200px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px;
}
.who-menu .wm-id { padding: 6px 9px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 13px; }
.who-menu .wm-id small { display: block; color: var(--muted); font: 11.5px var(--f-mono); }
.who-menu button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.who-menu button:hover, .who-menu button:focus-visible { background: var(--accent-soft); }

/* sign-in page */
.login-page {
  justify-content: center; align-items: center; padding: 24px 16px;
  background:
    radial-gradient(700px 380px at 50% 0%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 70%),
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
}
.login { width: 100%; max-width: 360px; }
.login-brand { display: flex; align-items: center; gap: 11px; font: 650 22px var(--f-disp); letter-spacing: -.025em; margin-bottom: 22px; justify-content: center; }
.login-brand .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
.login-brand .brand-mark svg { width: 22px; height: 22px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; display: grid; gap: 6px; box-shadow: var(--shadow); }
.login-card h1 { font: 650 21px var(--f-disp); letter-spacing: -.02em; margin: 0 0 8px; }
.login-card label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.login-card input {
  font: 15px var(--f-body); color: var(--ink); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .12s, box-shadow .12s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.login-card #username { font-family: var(--f-mono); }
.pw-field { position: relative; display: grid; }
.pw-field input { padding-right: 44px; }
.login-card .pw-eye {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%); margin: 0; width: 40px; height: 40px;
  display: grid; place-items: center; padding: 0; background: none; color: var(--muted); border-radius: 6px;
}
.login-card .pw-eye { box-shadow: none; }
.login-card .pw-eye:hover, .login-card .pw-eye[aria-pressed="true"] { color: var(--ink); }
.login-card .pw-eye:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pw-eye[aria-pressed="false"] .eye-slash { display: none; }
.login-card .remember { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.login-card .remember[hidden] { display: none; }
.login-card .remember input { width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--accent); }
.login-card button {
  margin-top: 16px; font: 600 14.5px var(--f-body); color: #fff; border: 0; border-radius: 10px; padding: 11px; cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-2) 70%, var(--accent)), var(--accent));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.login-card button:disabled { opacity: .6; cursor: progress; }
.login-err { margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--crit-soft); color: var(--crit); font-size: 13px; }
.login-card[hidden] { display: none; }
.login-card #code { font: 600 22px var(--f-mono); letter-spacing: .18em; text-align: center; }
.login-card .login-link { margin-top: 4px; background: none; box-shadow: none; color: var(--muted); font-weight: 500; font-size: 13px; padding: 8px; }
.login-card .login-link:hover { color: var(--ink); }
.code-send { display: grid; gap: 4px; margin: 2px 0 4px; }
.login-card .code-via { margin: 0; background: var(--panel-2); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: none; font-weight: 600; }
.login-card .code-via:hover { background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); }
.login-card .code-via:disabled { color: var(--muted); border-color: var(--line); cursor: default; }
.code-send[hidden] { display: none; }
.code-alt { margin: 10px 0 0; font-size: 12.5px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 14px; }

/* add router */
.add-btn { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); font-weight: 600; }
.enroll { max-width: 760px; }
.en-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.en-head h2 { font: 700 16px var(--f-disp); margin: 0; }
.en-body { padding: 14px 15px 16px; display: grid; gap: 8px; }
.en-lede { margin: 0 0 4px; color: var(--muted); font-size: 13.5px; }
.en-body label { font-size: 12.5px; color: var(--muted); }
.en-body input { font: 14px var(--f-mono); color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; }
.en-body input:focus { border-color: var(--accent); }
.primary {
  justify-self: start; margin-top: 6px; font: 600 13.5px var(--f-body); color: #fff; border: 0; border-radius: var(--r-sm); padding: 8px 15px; cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-2) 70%, var(--accent)), var(--accent));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 2px 6px -2px color-mix(in srgb, var(--accent) 60%, transparent);
}
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: .6; cursor: progress; }
.en-meta { font: 12.5px var(--f-mono); color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.en-script { position: relative; }
.en-script pre { margin: 0; max-height: 40vh; overflow: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px 12px 12px; font: 12px/1.55 var(--f-mono); white-space: pre-wrap; word-break: break-all; }
.en-script .copy { position: absolute; top: 8px; right: 8px; background: var(--panel); }
.en-status { margin: 4px 0 0; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.en-status .dot { width: 8px; height: 8px; }
.en-status.wait .dot { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
.en-status.ok { color: var(--up); }
.en-status.err { color: var(--crit); }
.login-note { margin: -2px 0 6px; font-size: 13px; color: var(--muted); }
.login-card .opt { color: var(--muted); font-size: 11.5px; }

/* ---- shell: left menu + content ---- */
.shell { flex: 1; display: flex; min-height: 0; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side {
  width: 224px; flex: none; overflow-y: auto; border-right: 1px solid var(--side-line);
  background: var(--side-bg); padding: 14px 12px 24px;
}
.side nav { display: grid; gap: 2px; }
.side a {
  color: var(--side-muted); text-decoration: none; font: 500 13.5px var(--f-body); padding: 7px 10px; border-radius: 9px;
  display: flex; align-items: center; gap: 11px; transition: background .12s, color .12s;
}
.side a svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.side a:hover { color: var(--side-ink); background: var(--side-hover); }
.side a.on { color: var(--side-ink); background: var(--side-on-bg); box-shadow: var(--shadow-sm), 0 0 0 1px var(--side-on-ring); font-weight: 600; }
.side a.on svg { color: var(--side-icon); opacity: 1; }
.side-h {
  font: 600 11px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--side-faint);
  padding: 18px 10px 6px;
}
.menu-btn { display: none; font-size: 15px; }
.side-back { position: fixed; inset: 0; z-index: 24; background: color-mix(in srgb, var(--bg) 55%, transparent); }
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 25; width: min(270px, 84vw); background: var(--side-solid);
    transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow);
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  body.side-open .side { transform: none; }
}

/* router-list tabs (Routers · Backups · Firmware · Fleet Commander · Security · Login Manager) */
.tabs {
  display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  overflow-x: auto; scrollbar-width: none; flex: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  font: 500 13.5px var(--f-body); color: var(--muted); position: relative;
  text-decoration: none; padding: 12px 10px 11px; white-space: nowrap; transition: color .12s;
}
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); font-weight: 600; }
.tabs a.on::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0;
  background: var(--accent);
}
#view-page > .tabs { position: sticky; top: 0; z-index: 5; }

/* firmware tab */
#view-list[data-tab="firmware"] :is(.grid-head, .row) {
  grid-template-columns: 38px minmax(180px, 2fr) minmax(120px, 1.2fr) 110px 100px 90px minmax(200px, 1.6fr) minmax(96px, 1fr);
}
#view-list[data-tab="firmware"] { --rh: 48px; }
.fw-warn { font: 11.5px var(--f-mono); color: var(--warn); background: var(--warn-soft); border-radius: 5px; padding: 1px 6px; }
.fw-old { font: 11.5px var(--f-mono); color: var(--muted); }
.fw-ok { font: 11.5px var(--f-mono); color: var(--up); }
@media (max-width: 900px) {
  #view-list[data-tab="firmware"] :is(.grid-head, .row) { grid-template-columns: 38px minmax(140px, 2fr) 96px minmax(120px, 1fr); }
  #view-list[data-tab="firmware"] :is(.grid-head, .row) :is(.c-board, .c-rb, .c-ch, .st) { display: none; }
  #view-list[data-tab="firmware"] .grid-head > :last-child { display: none; }
}

/* ---- shared building blocks for features ---- */
#view-page { overflow-y: auto; }
.rp-sec { padding-top: 0; }
.card.sec.wide { grid-column: 1 / -1; }
.sec-tools { display: flex; gap: 8px; justify-content: flex-end; margin: -30px 0 10px; flex-wrap: wrap; }
.btn.danger, .primary.danger { color: var(--crit); }
.primary.danger { color: #fff; background: var(--crit); }
.tbl-wrap { overflow-x: auto; }
.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th { text-align: left; font: 600 11px var(--f-body); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.err { color: var(--crit); margin: 0; font-size: 13px; }
.dlg { max-width: 480px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.dlg .primary { margin-top: 0; }
#toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 40; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--line-2); border-left: 4px solid var(--muted); border-radius: 11px; padding: 9px 12px; font-size: 13.5px; box-shadow: var(--shadow); }
.toast.ok { border-left-color: var(--up); }
.toast.err { border-left-color: var(--crit); }

/* ---- phone ---- */
/* Sideways-scrolling strips and tables show a soft edge where more content
   is hidden (the shadows scroll away at either end). */
.tabs, .tbl-wrap {
  --edge: color-mix(in srgb, var(--ink) 22%, transparent);
  background:
    linear-gradient(to right, var(--panel) 30%, transparent) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--panel) 30%, transparent) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--edge), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--edge), transparent) right / 10px 100% no-repeat scroll,
    var(--panel);
}
@media (max-width: 560px) {
  /* Header: menu, brand and controls on one row; fleet counts under it. */
  .bar { gap: 8px 10px; padding-bottom: 8px; }
  .bar .counts { order: 10; flex-basis: 100%; gap: 12px; font-size: 12px; }
  .bar .counts .c:last-child, #live-text { display: none; }
  .bar .sp { flex: 1; }
  .toolbar { padding: 10px 12px; gap: 8px; }
  .rp { padding: 14px 12px 40px; }
  .grid-head, .row { padding: 0 12px; }
  /* Firmware tab: name, then the firmware note (may take two lines). */
  #view-list[data-tab="firmware"] { --rh: 54px; }
  #view-list[data-tab="firmware"] :is(.grid-head, .row) { grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1.1fr); }
  #view-list[data-tab="firmware"] :is(.grid-head, .row) :is(.c-ros, .c-ch) { display: none; }
  #view-list[data-tab="firmware"] .row .c-fw { white-space: normal; display: flex; flex-wrap: wrap; gap: 2px 6px; line-height: 1.35; }
}
/* Touch screens: controls big enough to hit with a thumb. */
@media (pointer: coarse) {
  .btn, .chip, .facet, .primary, .seg button { min-height: 36px; }
  .side a { padding-top: 10px; padding-bottom: 10px; }
  .tabs a { padding-top: 14px; padding-bottom: 13px; }
}

/* theme picker (top bar ◐) */
.theme-menu { position: absolute; right: 12px; top: calc(100% + 6px); z-index: 40; width: min(320px, calc(100vw - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 10px; }
.theme-menu h3 { margin: 4px 6px 8px; font: 600 12px var(--f-body); color: var(--muted); }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.theme-opt { display: grid; gap: 6px; padding: 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  font: 500 12.5px var(--f-body); text-align: left; cursor: pointer; }
.theme-opt:hover { border-color: var(--line-2); }
.theme-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.theme-sw { height: 38px; border-radius: 7px; display: grid; grid-template-columns: 30% 1fr; overflow: hidden; border: 1px solid rgba(0, 0, 0, .08); }
.theme-sw i { display: block; background: var(--sw-side); }
.theme-sw b { background: var(--sw-bg); }
.theme-sw.split { background: linear-gradient(135deg, #f3f5f7 50%, #090d10 50%); }
.theme-sw.split i, .theme-sw.split b { background: transparent; }
.theme-sw b { display: grid; align-content: center; gap: 4px; padding: 0 8px; }
.theme-sw b::before, .theme-sw b::after { content: ""; display: block; height: 5px; border-radius: 3px; background: var(--sw-line); }
.theme-sw b::after { width: 55%; background: var(--sw-accent); }
