/* ============================================================================
   Leuffen RMM — modernised UI
   Design tokens: dark default + light theme, tweakable accent / radius / density
   Font: Onest (UI) + JetBrains Mono (technical). Lucide-style inline SVG icons.
   ========================================================================== */

:root {
  /* --- tweakable (overwritten by Tweaks panel) --- */
  --accent: #3b82f6;
  --radius-scale: 1;          /* 0 = sharp, 1 = default, 1.6 = round */
  --density: 1;               /* 0.85 compact, 1 comfortable */

  /* --- derived radii --- */
  --r-xs: calc(4px * var(--radius-scale));
  --r-sm: calc(7px * var(--radius-scale));
  --r-md: calc(10px * var(--radius-scale));
  --r-lg: calc(14px * var(--radius-scale));
  --r-xl: calc(20px * var(--radius-scale));
  --r-pill: 999px;

  /* --- derived density --- */
  --row-py: calc(13px * var(--density));
  --cell-px: 16px;
  --gap: calc(16px * var(--density));
  --pad: calc(20px * var(--density));

  /* --- accent-derived tints (auto-update when accent changes) --- */
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-softer: color-mix(in srgb, var(--accent) 9%, transparent);
  --accent-ring: color-mix(in srgb, var(--accent) 35%, transparent);
  --accent-text: var(--accent);

  /* --- semantic --- */
  --good: #34d399; --warn: #fbbf24; --bad: #f87171;
  --good-soft: color-mix(in srgb, var(--good) 15%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 15%, transparent);
  --bad-soft:  color-mix(in srgb, var(--bad) 15%, transparent);

  --font-sans: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ---- DARK theme (default) ---- */
:root, [data-theme="dark"] {
  --bg: #0a0c11;
  --bg-grid: #0d1016;
  --surface: #12161e;
  --surface-2: #171c26;
  --surface-3: #1c222e;
  --surface-hover: #1a212c;
  --border: #232b37;
  --border-soft: #1b222d;
  --border-strong: #303a48;
  --text: #e9eef6;
  --text-dim: #97a3b4;
  --text-faint: #5f6b7c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -8px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 60px -16px rgba(0,0,0,.65);
  --meter-track: #0c0f15;
  --term-bg: #070a0f;
  color-scheme: dark;
}

/* ---- LIGHT theme ---- */
[data-theme="light"] {
  /* Green, yellow and red that still read on white. */
  --good: #059669; --warn: #b45309; --bad: #dc2626;
  --bg: #f4f6fa;
  --bg-grid: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eef2f8;
  --surface-hover: #f2f5fa;
  --border: #e4e9f1;
  --border-soft: #edf1f7;
  --border-strong: #d3dbe7;
  --text: #111826;
  --text-dim: #5d6b7e;
  --text-faint: #93a0b2;
  --shadow: 0 1px 2px rgba(16,28,48,.06), 0 10px 30px -12px rgba(16,28,48,.18);
  --shadow-lg: 0 30px 70px -20px rgba(16,28,48,.30);
  --meter-track: #eaeef4;
  --term-bg: #0b0f16;
  color-scheme: light;
}

/* ---- density attribute → scalar ---- */
[data-density="compact"]     { --density: 0.62; --cell-px: 13px; }
[data-density="comfortable"] { --density: 1;    --cell-px: 16px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--accent-softer), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  letter-spacing: -0.005em;
}
.hidden { display: none !important; }
/* sane default size for inline icons; specific charts override below */
svg { width: 16px; height: 16px; flex: none; }
.spark { width: 64px !important; height: 22px !important; }
.ring { width: 44px !important; height: 44px !important; }
.kspark { width: 74px !important; height: 30px !important; }
.mono { font-family: var(--font-mono); font-feature-settings: "ss01"; }
.muted { color: var(--text-dim); }
a { color: inherit; }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ============================================================================
   App shell
   ========================================================================== */
.app { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }

/* ---- Header ---- */
header.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px; height: 60px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand .logo {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7c3aed));
  box-shadow: 0 4px 14px -4px var(--accent-ring);
}
.brand .logo svg { width: 17px; height: 17px; }
.brand span { color: var(--text-dim); font-weight: 600; }

.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-dim); }
.crumbs a { text-decoration: none; color: var(--text-dim); padding: 4px 9px; border-radius: var(--r-sm); cursor: pointer; transition: .15s; }
.crumbs a:hover { color: var(--text); background: var(--surface-hover); }
.crumbs a.here { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--text-faint); }

.spacer { flex: 1; }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 7px 11px; min-width: 230px; color: var(--text-faint);
  transition: .15s;
}
.searchbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.searchbox svg { width: 15px; height: 15px; flex: none; }
.searchbox input { border: 0; background: none; outline: none; color: var(--text); font: inherit; font-size: 13px; width: 100%; }
.searchbox kbd { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 5px; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-dim); cursor: pointer; transition: .15s; position: relative;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .ping { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--surface); }

.userchip { display: flex; align-items: center; gap: 9px; padding: 4px 6px 4px 4px; border-radius: var(--r-pill); cursor: pointer; transition: .15s; }
.userchip:hover { background: var(--surface-hover); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff;
  background: linear-gradient(140deg, #f59e0b, #ef4444); }
.userchip .who { font-size: 12.5px; line-height: 1.1; }
.userchip .who small { display: block; color: var(--text-faint); font-size: 11px; }

/* ============================================================================
   Layout body
   ========================================================================== */
main { padding: 26px clamp(20px, 4vw, 40px); max-width: 1480px; margin: 0 auto; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.025em; }
.page-head p { margin: 4px 0 0; color: var(--text-dim); font-size: 13.5px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  border-radius: var(--r-sm); padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: .15s; white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 4px 14px -6px var(--accent-ring);
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 15px; height: 15px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.ghost:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.btn.subtle { background: var(--accent-soft); color: var(--accent-text); box-shadow: none; }
.btn.subtle:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.btn.warn { background: var(--warn); color: #1a1407; box-shadow: none; }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); box-shadow: none; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 22%, transparent); }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* ============================================================================
   KPI summary band
   ========================================================================== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--gap); margin-bottom: 26px; }
.kpi {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi .klabel { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 7px; font-weight: 500; }
.kpi .klabel .ki { width: 22px; height: 22px; border-radius: var(--r-xs); display: grid; place-items: center; }
.kpi .klabel .ki svg { width: 13px; height: 13px; }
.kpi .kval { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 10px; line-height: 1; }
.kpi .kdelta { font-size: 12px; margin-top: 7px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.kpi .kdelta.up { color: var(--good); }
.kpi .kdelta.down { color: var(--bad); }
.kpi .kspark { position: absolute; right: 14px; bottom: 12px; width: 74px; height: 30px; opacity: .9; }
.ki.blue { background: var(--accent-soft); color: var(--accent-text); }
.ki.green { background: var(--good-soft); color: var(--good); }
.ki.amber { background: var(--warn-soft); color: var(--warn); }
.ki.red { background: var(--bad-soft); color: var(--bad); }

/* ============================================================================
   Org cards (global view)
   ========================================================================== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gap); }
.orgcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px; cursor: pointer; transition: .18s; position: relative;
}
.orgcard:hover { border-color: var(--accent-ring); transform: translateY(-2px); box-shadow: var(--shadow); }
.orgcard .oc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.orgcard .oc-mark { width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff; flex: none; }
.orgcard h3 { margin: 0; font-size: 15.5px; font-weight: 650; }
.orgcard .oc-head small { color: var(--text-faint); font-size: 12px; }
.orgcard .oc-arrow { margin-left: auto; color: var(--text-faint); transition: .18s; }
.orgcard:hover .oc-arrow { color: var(--accent); transform: translateX(3px); }

.health-bar { height: 8px; border-radius: 99px; overflow: hidden; display: flex; background: var(--meter-track); margin-bottom: 14px; }
.health-bar i { display: block; height: 100%; }
.health-bar i.on { background: var(--good); }
.health-bar i.off { background: var(--text-faint); }
.health-bar i.nc { background: var(--bad); }

.oc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.oc-stats .s { text-align: left; }
.oc-stats .s b { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.oc-stats .s span { display: block; font-size: 11.5px; color: var(--text-dim); margin-top: 1px; }
.dot-led { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot-led.g { background: var(--good); box-shadow: 0 0 7px var(--good); }
.dot-led.r { background: var(--bad); }
.dot-led.m { background: var(--text-faint); }

/* ============================================================================
   Org layout (sidebar + content)
   ========================================================================== */
.org-layout { display: grid; grid-template-columns: 216px 1fr; gap: 26px; align-items: start; }
.sidebar { position: sticky; top: 84px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text-dim); padding: 9px 12px; border-radius: var(--r-sm);
  font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: .14s;
}
.nav button svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav button:hover { color: var(--text); background: var(--surface-hover); }
.nav button.active { color: var(--text); background: var(--accent-soft); font-weight: 600; }
.nav button.active svg { color: var(--accent); opacity: 1; }
.nav button .count { margin-left: auto; font-size: 11px; color: var(--text-faint); background: var(--surface-2); padding: 1px 7px; border-radius: 99px; }
.nav button.active .count { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-text); }

.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); font-weight: 600; margin: 22px 0 8px 12px; }
.groups { display: flex; flex-direction: column; gap: 2px; }
.groups button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: 0;
  color: var(--text-dim); padding: 7px 12px; border-radius: var(--r-sm); font: inherit; font-size: 13px; cursor: pointer; transition: .14s; }
.groups button:hover { color: var(--text); background: var(--surface-hover); }
.groups button.active { color: var(--text); background: var(--surface-2); }
.groups button .gdot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.groups button .count { margin-left: auto; font-size: 11px; color: var(--text-faint); }

/* ---- content panel ---- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; }
.panel-head .sub { color: var(--text-dim); font-size: 12.5px; }
.panel-head .spacer { flex: 1; }
.seg { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.seg button { background: none; border: 0; color: var(--text-dim); font: inherit; font-size: 12px; padding: 5px 11px; border-radius: calc(var(--r-sm) - 2px); cursor: pointer; transition: .14s; }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow); }

/* ============================================================================
   Tables
   ========================================================================== */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid thead th {
  text-align: left; padding: 11px var(--cell-px); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
table.grid tbody td { padding: var(--row-py) var(--cell-px); border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.grid tbody tr { cursor: pointer; transition: background .12s; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--surface-hover); }
.empty { padding: 56px 20px; text-align: center; color: var(--text-dim); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .4; }

.host { display: flex; align-items: center; gap: 11px; }
.os-ico { width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); flex: none; color: var(--text-dim); }
.os-ico svg { width: 16px; height: 16px; }
.host .h-name { font-weight: 600; font-size: 13px; }
.host .h-sub { font-size: 11.5px; color: var(--text-faint); }

/* status pill */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px 3px 7px; border-radius: var(--r-pill); }
.status .led { width: 7px; height: 7px; border-radius: 50%; }
.status.on { background: var(--good-soft); color: var(--good); } .status.on .led { background: var(--good); box-shadow: 0 0 7px var(--good); }
.status.off { background: color-mix(in srgb, var(--text-faint) 16%, transparent); color: var(--text-dim); } .status.off .led { background: var(--text-faint); }

/* meter */
.meter { display: flex; align-items: center; gap: 9px; }
.meter .track { position: relative; height: 6px; width: 78px; background: var(--meter-track); border-radius: 99px; overflow: hidden; }
.meter .track i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--accent); }
.meter.warn .track i { background: var(--warn); } .meter.crit .track i { background: var(--bad); }
.meter .pct { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-dim); min-width: 30px; }
.meter.warn .pct { color: var(--warn); } .meter.crit .pct { color: var(--bad); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600; }
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.na { background: color-mix(in srgb, var(--text-faint) 14%, transparent); color: var(--text-faint); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--accent-soft); color: var(--accent-text); }

.spark { width: 64px; height: 22px; display: block; }
[data-dataviz="off"] .spark, [data-dataviz="off"] .kpi .kspark { display: none; }

/* node + download cards */
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; }
.node-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.code {
  background: var(--term-bg); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 13px 15px; font-family: var(--font-mono); font-size: 12.5px; color: #cde3ff; overflow-x: auto; position: relative;
}
.code .copy { position: absolute; top: 9px; right: 9px; }
/* ---- callout: an icon beside a title and a line of explanation ----
   Used across the dashboard, Settings, Account and Setup, so it lives here in
   the shared sheet. It used to be defined only in settings.css and setup.css,
   which left every callout on the dashboard (the enrolment-key and share-link
   reveals among them) rendering as bare, unframed text. */
.callout { display: flex; gap: 13px; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); }
.callout .ic { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; }
.callout .ic svg { width: 17px; height: 17px; }
.callout.info .ic { background: var(--accent-soft); color: var(--accent-text); }
.callout.warn .ic { background: var(--warn-soft); color: var(--warn); }
.vk-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.vk-key { margin-top: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.vk-title { font-weight: 650; margin-bottom: 8px; }
.vk-value { display: block; padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
            font-size: 13px; word-break: break-all; user-select: all; }
.vk-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 6px; }
.vk-choice { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 4px 0; cursor: pointer; }
.callout .ct { font-size: 13px; font-weight: 600; }
.callout .cd { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.5; }
.callout .cd code { font-family: var(--font-mono); font-size: 11.5px; background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }

.dl-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 15px 17px; margin-bottom: 12px; }
.dl-block .lab { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.dl-block .lab svg { width: 15px; height: 15px; color: var(--text-dim); flex: none; }
.dl-block .h-sub { line-height: 1.55; }
.dl-block .seg { flex: none; }

/* Downloads has two audiences and they must not be confused: the agent goes on
   every customer device, the console goes on a technician's own machine. The
   headings carry that distinction, so they hold the explanation, not just a
   label -- and the console block is tinted so it can't read as one more agent
   download on an org-scoped page. */
.dl-sec { margin-bottom: 26px; }
.dl-sec:last-child { margin-bottom: 0; }
.dl-sec-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
            margin: 0 0 12px; padding-bottom: 9px; border-bottom: 1px solid var(--border); }
.dl-sec-t { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px;
            font-weight: 700; color: var(--text); }
.dl-sec-t svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.dl-sec-s { flex: 1; min-width: 200px; font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.dl-block.tech { background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
                 border-color: color-mix(in srgb, var(--accent) 32%, var(--border)); }
.dl-block.tech .lab svg { color: var(--accent); }

.subnet-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-3); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 12.5px; margin-bottom: 6px; }
.subnet-row .x { margin-left: auto; color: var(--text-faint); cursor: pointer; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; }
.subnet-row .x:hover { background: var(--bad-soft); color: var(--bad); }

/* ============================================================================
   Drawer
   ========================================================================== */
.scrim { position: fixed; inset: 0; background: rgba(3,5,9,.5); backdrop-filter: blur(2px); z-index: 60; opacity: 0; animation: fade .2s forwards; }
@keyframes fade { to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; width: 560px; max-width: 96vw; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; z-index: 61;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.22,.61,.36,1);
}
.drawer.open { transform: translateX(0); }
.drawer.hidden { display: flex !important; transform: translateX(100%); pointer-events: none; }
.drawer-head { padding: 20px 22px 0; }
.drawer-head .top { display: flex; align-items: flex-start; gap: 13px; }
.drawer-head .os-ico { width: 42px; height: 42px; border-radius: var(--r-md); }
.drawer-head .os-ico svg { width: 22px; height: 22px; }
.drawer-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.drawer-head .meta { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.drawer-head .meta span { display: inline-flex; align-items: center; gap: 5px; }
.drawer-close { margin-left: auto; }
.dtabs { display: flex; gap: 4px; margin: 18px 0 0; }
.dtabs button { background: none; border: 0; color: var(--text-dim); font: inherit; font-size: 13px; font-weight: 500; padding: 9px 4px; margin-right: 16px; cursor: pointer; position: relative; }
.dtabs button.active { color: var(--text); font-weight: 600; }
.dtabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.drawer-head .dtabs { border-bottom: 1px solid var(--border); }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-grid .sg {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px 15px;
}
.stat-grid .sg .l { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; }
.stat-grid .sg .v { font-size: 18px; font-weight: 700; margin-top: 5px; }
.stat-grid .sg .v small { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.stat-grid .sg.wide { grid-column: 1 / -1; }
.stat-grid .sg.clickable { cursor: pointer; transition: border-color .12s, background .12s; }
.stat-grid .sg.clickable:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.ring { width: 44px; height: 44px; flex: none; }

/* Device history charts */
.hist-range { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.hist-range button { font-size: 11px; font-weight: 600; color: var(--text-dim); background: none; border: 0; padding: 3px 9px; border-radius: calc(var(--r-sm) - 2px); cursor: pointer; }
.hist-range button.active { color: var(--text); background: var(--surface-hover); }
.hist-row { margin-bottom: 12px; }
.hist-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.hist-more { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 6px; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); color: var(--text-dim); font-size: 12px; cursor: pointer; transition: border-color .12s, color .12s; }
.hist-more:hover { border-color: var(--border-strong); color: var(--text); }
.hist-more .chev { display: inline-flex; transition: transform .15s; }
.hist-more .chev svg { width: 14px; height: 14px; }
.hist-more.open .chev { transform: rotate(180deg); }
.area { width: 100%; height: 56px; display: block; }
.area-wrap { position: relative; cursor: crosshair; }
.area-guide { position: absolute; top: 0; bottom: 0; width: 1px; opacity: .45; pointer-events: none; display: none; transform: translateX(-.5px); }
.area-dot { position: absolute; width: 7px; height: 7px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px rgba(0,0,0,.25); pointer-events: none; display: none; transform: translate(-50%, -50%); }
.area-tip { position: absolute; bottom: calc(100% + 6px); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px 8px; font-size: 11.5px; line-height: 1.2; white-space: nowrap; pointer-events: none; display: none; z-index: 6; box-shadow: var(--shadow-lg); }
.area-tip b { font-weight: 700; }
.area-tip span { color: var(--text-dim); margin-left: 6px; }

/* Applied policies (device drawer) */
.pol-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.pol-row { display: flex; align-items: center; gap: 9px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); font-size: 12.5px; }
.pol-row .pol-ic { display: inline-flex; color: var(--text-dim); }
.pol-row .pol-ic svg { width: 15px; height: 15px; }
.pol-row .pol-name { font-weight: 600; }
.pol-row .pol-val { flex: 1; }

/* Configurable dashboard widgets */
.dwidget { margin-bottom: 18px; }
.dw-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 10px; }
.dw-head h3 { font-size: 15px; font-weight: 650; }
.dw-sub { font-size: 12px; color: var(--text-faint); }
.dw-empty { padding: 16px; color: var(--text-dim); font-size: 13px; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); }
.dw-empty svg { width: 15px; height: 15px; color: var(--good); }
table.grid.mini td { padding: 8px 12px; }
table.grid.mini .dot-led { margin-right: 7px; }
.ver-bars { display: flex; flex-direction: column; gap: 9px; padding: 4px 2px; }
.ver-row { display: grid; grid-template-columns: 160px 1fr 32px; align-items: center; gap: 12px; font-size: 12.5px; }
.ver-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ver-track { height: 7px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.ver-track i { display: block; height: 100%; background: var(--accent); }
.ver-n { text-align: right; color: var(--text-dim); }

.cust-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw; z-index: 120;
  background: var(--surface-1); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  padding: 20px; overflow-y: auto; display: flex; flex-direction: column; }
.cust-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cust-head h3 { font-size: 16px; font-weight: 650; }
.cust-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.cust-move { display: flex; flex-direction: column; gap: 2px; }
.icon-btn.xs { width: 22px; height: 18px; padding: 0; }
.icon-btn.xs svg { width: 13px; height: 13px; }
.cust-t { font-size: 13.5px; font-weight: 550; }
.cust-d { font-size: 11.5px; color: var(--text-faint); }
.cust-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 16px; }
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 110; }
.switch { width: 44px; height: 25px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; transition: .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: var(--text-faint); transition: .2s; }
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { left: 21px; background: #fff; }

/* Remote file management — centered modal */
.files-modal { position: fixed; z-index: 130; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(860px, 94vw); height: min(78vh, 720px); display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; }
.fm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); }
.fm-head h3 { font-size: 15.5px; font-weight: 650; }
.fm-host { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.fm-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.file-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.file-bar .inp, .file-bar input[type="text"] { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text); font-size: 13px; padding: 7px 11px; outline: none; }
.file-bar .inp:focus { border-color: var(--accent); }
.inp { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text); font: inherit; font-size: 13px; padding: 7px 11px; outline: none; }
.inp:focus { border-color: var(--accent); }
.snmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.snmp-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.snmp-grid .inp { width: 100%; }
/* Paired cells stretch to equal height; push the control to the bottom so the
   inputs line up even when one caption wraps (e.g. "Name (optional)"). */
.snmp-grid label > .inp { margin-top: auto; }
@media (max-width: 600px) { .snmp-grid { grid-template-columns: 1fr; } }
.snmp-readings { margin-top: 10px; padding-left: 42px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 5px 18px; }
.snmp-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding-bottom: 3px; border-bottom: 1px dotted var(--border-soft); }
.file-bar .file-path { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-dim); font-size: 12.5px; padding: 4px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.file-table td { cursor: default; }
.file-table .file-ico { display: inline-flex; vertical-align: middle; margin-right: 9px; color: var(--text-dim); }
.file-table .file-ico svg { width: 16px; height: 16px; }
.file-table a.file-open { color: var(--text); cursor: pointer; font-weight: 550; }
.file-table a.file-open:hover { color: var(--accent); text-decoration: underline; }
.file-table .file-size { color: var(--text-dim); white-space: nowrap; }

dl.inv { display: grid; grid-template-columns: 130px 1fr; gap: 0; font-size: 13px; margin: 0;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
dl.inv dt { color: var(--text-dim); padding: 9px 14px; border-bottom: 1px solid var(--border-soft); }
dl.inv dd { margin: 0; padding: 9px 14px; border-bottom: 1px solid var(--border-soft); word-break: break-word; }
dl.inv dt:last-of-type, dl.inv dd:last-of-type { border-bottom: 0; }
.sec-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); font-weight: 600; margin: 22px 0 10px; }

/* terminal */
.terminal { background: var(--term-bg); border: 1px solid var(--border-strong); border-radius: var(--r-md); overflow: hidden; }
.terminal .tbar { display: flex; align-items: center; gap: 7px; padding: 9px 13px; border-bottom: 1px solid #18202b; background: #0b0f16; }
.terminal .tbar .d { width: 11px; height: 11px; border-radius: 50%; }
.terminal .tbar .d.r { background: #ff5f57; } .terminal .tbar .d.y { background: #febc2e; } .terminal .tbar .d.g { background: #28c840; }
.terminal .tbar .t { margin-left: 8px; font-family: var(--font-mono); font-size: 11.5px; color: #6b7c90; }
.terminal pre { margin: 0; padding: 14px; height: 320px; overflow-y: auto; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; color: #d4e7ff; }
.terminal pre .p { color: var(--good); }
.term-form { display: flex; align-items: center; gap: 8px; margin-top: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px 4px 4px 13px; }
.term-form .chev { color: var(--accent); font-family: var(--font-mono); }
.term-form input { flex: 1; border: 0; background: none; outline: none; color: var(--text); font-family: var(--font-mono); font-size: 13px; padding: 8px 0; }

.actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.action {
  display: flex; align-items: center; gap: 11px; text-align: left; padding: 13px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--text); cursor: pointer; transition: .14s; font: inherit;
}
.action:hover { border-color: var(--border-strong); background: var(--surface-hover); transform: translateY(-1px); }
.action .ai { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; background: var(--surface-3); }
.action .ai svg { width: 16px; height: 16px; }
.action .at { font-size: 13px; font-weight: 600; }
.action .ad { font-size: 11.5px; color: var(--text-faint); }
.action.danger .ai { background: var(--bad-soft); color: var(--bad); }
.action.warn .ai { background: var(--warn-soft); color: var(--warn); }

/* Split "Remote control" button: the chevron drops this menu so a session can be
   opened in the browser viewer or handed to the desktop console. */
.remote-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 208px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 5px; display: grid; gap: 2px;
}
.remote-menu.hidden { display: none; }
.remote-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 10px; background: none; border: 0; border-radius: var(--r-sm);
  color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer;
}
.remote-menu button:hover { background: var(--surface-3); }
.remote-menu button svg { width: 15px; height: 15px; color: var(--text-dim); flex: none; }
.action.go .ai { background: var(--accent-soft); color: var(--accent); }

.field { display: flex; gap: 8px; margin-top: 10px; }
.field input { flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--r-sm); padding: 9px 12px; font: inherit; font-family: var(--font-mono); font-size: 12.5px; outline: none; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
  padding: 11px 18px; border-radius: var(--r-md); font-size: 13px; z-index: 200; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px; opacity: 0; pointer-events: none; transition: .22s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 16px; height: 16px; color: var(--good); }

/* ============================================================================
   Design refresh — net-new components from the Claude design handoff.
   (Tokens + the rest of the system already match the handoff; only these
   pieces were missing: org switcher, segmented option cards, generic modal,
   the device card grid, live-stat mini tiles, and consistent selects.)
   ========================================================================== */

/* org switcher (topbar) */
.org-switch {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s;
}
.org-switch:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.org-switch .dotmark { flex: none; }
.org-switch #org-switch-chev { display: grid; place-items: center; margin-left: 2px; color: var(--text-faint); }
.org-switch #org-switch-chev svg { width: 14px; height: 14px; transition: transform .15s; }
.org-switch.open #org-switch-chev svg { transform: rotate(180deg); }
.hmenu a .org-dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.hmenu a .org-meta { margin-left: auto; font-size: 11.5px; color: var(--text-faint); }
.hmenu a.active { background: var(--surface-hover); }
.hmenu a.active .org-check { color: var(--accent); }

/* consistent selects (dashboard) — match the settings design system */
select {
  appearance: none; background-color: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 9px 34px 9px 12px; font: inherit; font-size: 13px; outline: none; transition: .15s; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2397a3b4' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background-color: var(--surface); }
select option { background: var(--surface); color: var(--text); }
.field select { flex: 1; padding-right: 34px; }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* segmented / option cards (New policy modal, edit-user role, mail method) */
.segmented { display: grid; grid-auto-flow: column; gap: 8px; }
.seg-opt { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--r-md); padding: 13px 14px; cursor: pointer; transition: .15s; text-align: left; color: var(--text); font: inherit; }
.seg-opt:hover { border-color: var(--border-strong); }
.seg-opt.sel { border-color: var(--accent); background: var(--accent-softer); box-shadow: 0 0 0 3px var(--accent-ring); }
.seg-opt .so-top { display: flex; align-items: center; gap: 9px; }
.seg-opt .so-ic { width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-3); color: var(--text-dim); flex: none; }
.seg-opt.sel .so-ic { background: var(--accent-soft); color: var(--accent-text); }
.seg-opt .so-ic svg { width: 15px; height: 15px; }
.seg-opt .so-t { font-size: 13px; font-weight: 600; }
.seg-opt .so-d { font-size: 11.5px; color: var(--text-dim); margin-top: 8px; line-height: 1.4; }

/* generic modal (design handoff) */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 560px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); z-index: 120; padding: 22px;
}
.modal.wide { width: 720px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.modal-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-dim); }
.modal-close { margin-left: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-soft); }

/* devices card grid (replaces the device table) */
.tab-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.tab-head h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.tab-head .sub { color: var(--text-dim); font-size: 13px; }
.tab-head .spacer { flex: 1; }
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.dev-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 17px; cursor: pointer; transition: .16s; display: flex; flex-direction: column; gap: 14px;
}
.dev-card:hover { border-color: var(--accent-ring); transform: translateY(-2px); box-shadow: var(--shadow); }
.dev-card .dc-head { display: flex; align-items: center; gap: 11px; }
.dev-card .dc-id { flex: 1; min-width: 0; }
.dev-card .dc-id .h-name { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-card .dc-id .h-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-card .dc-gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dev-card .dc-gauge { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--r-md); padding: 12px 6px 9px; }
.dev-card .dc-gl { font-size: 10px; font-weight: 600; letter-spacing: .06em; color: var(--text-faint); }
.dev-card .dc-offline { text-align: center; color: var(--text-dim); font-size: 12.5px; padding: 18px 0; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--r-md); }
.dev-card .dc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 2px; }
.dev-card .dc-foot .h-sub { font-size: 11.5px; color: var(--text-dim); }

/* live-stat mini tiles (device drawer) — scoped to .mini-grid so it never
   matches the existing widget `table.grid.mini`. */
.mini-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 4px; }
.mini-grid .mini { display: flex; align-items: center; gap: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 13px; }
.mini-grid .mi { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--surface-3); color: var(--text-dim); }
.mini-grid .mi svg { width: 16px; height: 16px; }
.mini-grid .ml { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.mini-grid .mv { font-size: 14px; font-weight: 650; margin-top: 2px; }
.mini-grid .mv small { font-size: 11px; font-weight: 500; color: var(--text-dim); }

/* Sidebar hamburger (mobile only) */
.nav-toggle { display: none; }
.sidebar-scrim { display: none; }

@media (max-width: 900px) {
  .org-layout { grid-template-columns: 1fr; gap: 16px; }
  body.org-mode .nav-toggle { display: grid; }
  .searchbox { display: none; }
  /* The sidebar slides in from the left as an off-canvas hamburger menu
     (nav + groups), over a tap-to-dismiss scrim. */
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 62;
    width: 264px; max-width: 82vw; height: 100vh; height: 100dvh;
    background: var(--surface); border-right: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg); padding: 16px 14px; overflow-y: auto;
    transform: translateX(-100%); transition: transform .26s cubic-bezier(.22,.61,.36,1);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.open { display: block; position: fixed; inset: 0; z-index: 61;
    background: rgba(3,5,9,.5); backdrop-filter: blur(2px); }
}

/* Phone layout */
@media (max-width: 560px) {
  header.topbar { gap: 8px; padding: 0 12px; }
  .brand { gap: 0; font-size: 0; }           /* collapse to the logo mark to save width */
  .crumbs { display: none; }                 /* org context stays in the switcher + page title */
  .userchip .who { display: none; }          /* avatar only */
  .userchip { padding: 4px; }
  .icon-btn { width: 32px; height: 32px; }
  .org-switch { max-width: 42vw; overflow: hidden; }
  main { padding: 18px 14px; }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 19px; }
  .cards, .node-grid, .device-grid { grid-template-columns: 1fr; }   /* one card per row; no min-track overflow */
  /* Full-screen slide-over drawer + scrollable device tabs. */
  .drawer { width: 100vw; max-width: 100vw; border-left: none; }
  .drawer-head { padding: 16px 16px 0; }
  .drawer-body { padding: 16px; }
  .dtabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dtabs button { flex: 0 0 auto; white-space: nowrap; margin-right: 12px; }
  .ver-row { grid-template-columns: 118px 1fr 28px; }
  .files-modal { width: 96vw; height: 88vh; }
  .hmenu { max-width: calc(100vw - 24px); }
}

/* changelog */
.cl-wrap { padding: 4px 0; }
.cl-ver { font-size: 14px; font-weight: 600; color: var(--text); margin: 18px 0 6px; }
.cl-ver:first-child { margin-top: 0; }
.cl-cat { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 4px; }
.cl-item { font-size: 13px; color: var(--text-dim); padding: 2px 0 2px 14px; position: relative; }
.cl-item::before { content: "–"; position: absolute; left: 0; color: var(--border-strong); }
.cl-hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.cl-pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.cl-page-info { font-size: 12px; color: var(--text-dim); }

/* access groups */
.ag-card { border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 14px; overflow: hidden; }
.ag-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.ag-name { font-weight: 600; font-size: 14px; }
.ag-body { display: grid; grid-template-columns: 1fr 2fr; gap: 0; }
.ag-col { padding: 14px 16px; }
.ag-col + .ag-col { border-left: 1px solid var(--border); }
.ag-col-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-bottom: 10px; }
.ag-member-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.ag-org-row { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.ag-org-row:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.ag-org-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.ag-org-name { font-size: 13px; font-weight: 500; flex: 1; }
.ag-perms { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-toggle { font-size: 11.5px !important; padding: 4px 8px !important; color: var(--text-dim); }
.perm-toggle.perm-deny-ov { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.perm-toggle.perm-allow-ov { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: color-mix(in srgb, var(--good) 8%, transparent); }
.perm-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; }
.perm-badge.deny { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.perm-badge.allow { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); }
.perm-note { font-size: 11px; color: var(--text-faint); }
.role-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-dim); }
.role-pill.admin { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.role-pill.member { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); }
.role-pill.viewer { background: color-mix(in srgb, var(--text-faint) 12%, transparent); color: var(--text-faint); }
@media (max-width: 700px) { .ag-body { grid-template-columns: 1fr; } .ag-col + .ag-col { border-left: none; border-top: 1px solid var(--border); } }

/* UniFi network map + WAN health */
.umap-wrap { overflow-x: auto; padding: 8px 0 2px; margin-top: 4px; }
/* Opt out of the global `svg { width:16px; height:16px }` icon sizing — the map
   must render at its own width/height attributes, not shrink to a 16px dot. */
.umap { display: block; width: auto; height: auto; }
.umap-node { fill: var(--surface-2); stroke-width: 1.6; }
.umap-edge { fill: none; stroke: var(--border); stroke-width: 1.6; }
.umap-lbl { fill: var(--text-faint); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.umap-name { fill: var(--text); font-size: 12px; font-weight: 600; }
.umap-sub { fill: var(--text-dim); font-size: 10.5px; }
.unifi-wan { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 12px; }
.unifi-wan-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.unifi-wan-item svg { width: 15px; height: 15px; color: var(--text-dim); flex: none; }
