/* =====================================================================
 * Mesh PM20 — shared application stylesheet
 * Loaded by both admin (base.html) and portal (portal_base.html) shells.
 * portal.css layers on top with portal-only overrides.
 *
 * Sections
 *   1. Tokens (colors, spacing, radii, shadows)
 *   2. Reset + typography
 *   3. App shell (topbar, sidebar, main)
 *   4. Forms & buttons
 *   5. Tables
 *   6. Tags & pills (status chips)
 *   7. Cards & KPI tiles
 *   8. Utilities (.code, .kbd, .actions, .grid2, .muted, .empty)
 *   9. Login card shell
 *   10. Skeletons & helpers
 * ===================================================================== */

/* ── 1. Tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:        #0f1115;
  --fg:        #e6e6e6;
  --mut:       #8a8f98;
  --line:      #262932;
  --line-soft: #1d2029;
  --acc:       #5aa2ff;
  --acc-soft:  rgba(90,162,255,.10);
  --bad:       #ff7676;
  --ok:        #5fd38d;
  --warn:      #e0a84e;
  --surface:   #161922;
  --surface-2: #1c2029;
  --surface-3: #22252e;

  --radius:    14px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);

  --sidebar-w: 232px;
  --topbar-h:  56px;
  --content-w: 1280px;

  --font-sans: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ── 2. Reset + typography ──────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 28px 0 10px; font-size: 13px; font-weight: 600;
     color: var(--mut); text-transform: uppercase; letter-spacing: .06em; }
h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 600; }
small { font-size: 12px; color: var(--mut); }
code, .code, .kbd {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.code { white-space: pre-wrap; word-break: break-all; }
.kbd { background: var(--surface-2); padding: 1px 5px; border-radius: var(--radius-xs);
       border: 1px solid var(--line); }

/* ── 3. App shell ───────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}
.shell.no-sidebar {
  grid-template-columns: 1fr;
  grid-template-areas:
    "topbar"
    "main";
}

.topbar {
  grid-area: topbar;
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: rgba(15,17,21,.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: inherit; font-weight: 700; letter-spacing: .01em;
}
/* Brand mark — sourced from mesh_root_main_app_v200/main/logo.png so
 * cloud + firmware WebUI share the same visual identity. Dark-theme
 * variant (cyan-only) is in /static/logo.png; light-theme variant
 * with the dark wordmark glyph is /static/logo-light.png — currently
 * unused because the cloud is dark-theme-only, but staged here for
 * future light-mode work. The PNG is roughly square, so use a fixed
 * box and let object-fit handle aspect. */
/* 25px box (~75% of the previous 33) sits as the secondary brand mark
   alongside the 'Mesh PM20' wordmark. Width intrinsic so landscape
   wordmarks render at natural aspect. margin-right adds 10px on top
   of the .brand's flex gap (10px) for a total ~20px breathing room
   between logo and product name. */
.brand .logo {
  height: 25px; width: auto;
  max-width: 200px;
  margin-right: 10px;
  display: block; flex-shrink: 0;
  object-fit: contain;
}
/* Legacy .dot fallback retained for any template that still uses it. */
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(95,211,141,.14);
}
.brand small {
  color: var(--mut); font-weight: 500; font-size: 12px; margin-left: 4px;
}
.topbar-right {
  display: flex; align-items: center; gap: 14px;
  font-size: 13px; color: var(--mut);
}
.topbar-right .who { color: var(--fg); font-weight: 600; }
.topbar-right a { color: var(--mut); }
.topbar-right a:hover { color: var(--fg); text-decoration: none; }

.sidebar {
  grid-area: sidebar;
  position: sticky; top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 18px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar .section-label {
  font-size: 10.5px; font-weight: 600;
  color: var(--mut); text-transform: uppercase; letter-spacing: .08em;
  padding: 14px 10px 6px;
}
.sidebar .section-label:first-child { padding-top: 0; }
.sidebar a, .sidebar button.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--fg); font-size: 13.5px;
  text-decoration: none;
  border: 0; background: transparent; width: 100%;
  text-align: left; cursor: pointer; font-family: inherit;
}
.sidebar a:hover, .sidebar button.nav-btn:hover {
  background: var(--surface-2); text-decoration: none;
}
.sidebar a.active {
  background: var(--acc-soft);
  color: var(--acc);
}
.sidebar svg { width: 16px; height: 16px; flex: 0 0 16px; stroke-width: 1.8; }

main {
  grid-area: main;
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 24px;
}

.crumbs {
  font-size: 13px; color: var(--mut);
  margin-bottom: 6px;
}
.crumbs a { color: var(--mut); }
.crumbs a:hover { color: var(--fg); text-decoration: none; }
.crumbs .sep { padding: 0 6px; color: var(--line); }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin-top: 0; }
.page-head .sub {
  color: var(--mut); font-size: 13px; margin-top: 4px;
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.page-head .sub a { color: var(--mut); }
.page-head .sub a:hover { color: var(--fg); text-decoration: none; }

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "sidebar" "main"; }
  .sidebar { position: static; height: auto;
             border-right: 0; border-bottom: 1px solid var(--line);
             display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 12px; }
  .sidebar .section-label { display: none; }
  .sidebar a, .sidebar button.nav-btn { width: auto; padding: 6px 10px; }
}

/* ── 4. Forms & buttons ─────────────────────────────────────────────── */
form.inline {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin: 8px 0 18px;
}
form.inline label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--mut);
}
input[type=text], input[type=password], input[type=number],
input[type=email], input[type=search], textarea, select {
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 14px;
  font-family: inherit;
  min-width: 180px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-soft);
}
textarea { font-family: var(--font-mono); min-width: 320px; min-height: 80px; }

button, .btn {
  background: var(--acc);
  color: #0a0f1d;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: filter .12s, background .12s;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button.secondary, .btn.secondary {
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--line);
}
button.secondary:hover { background: var(--surface-3); }
button.danger, .btn.danger {
  background: rgba(255,118,118,.12);
  color: var(--bad);
  border: 1px solid rgba(255,118,118,.3);
}
button.danger:hover { background: rgba(255,118,118,.2); }

.error {
  color: var(--bad);
  background: rgba(255,118,118,.08);
  border: 1px solid rgba(255,118,118,.25);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 8px 0 14px;
}

.success {
  color: var(--ok);
  background: rgba(95,211,141,.08);
  border: 1px solid rgba(95,211,141,.25);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 8px 0 14px;
}

/* ── 5. Tables ──────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
}
th {
  color: var(--mut);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--surface);
}
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* Bordered table inside a card-style wrapper */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.table-scroll table { margin-bottom: 0; }
.table-scroll th { position: sticky; top: 0; z-index: 1; }
.table-scroll tr:last-child td { border-bottom: 0; }

th.num, td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── 6. Tags & pills ────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--fg);
}
.tag.ok  { background: rgba(95,211,141,.10); border-color: rgba(95,211,141,.3); color: #9ce4b4; }
.tag.bad { background: rgba(255,118,118,.10); border-color: rgba(255,118,118,.3); color: #e49c9c; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill::before {
  content: ''; width: 7px; height: 7px;
  border-radius: 50%; background: currentColor;
}
.pill.on  { color: var(--ok); background: rgba(95,211,141,.10); border-color: rgba(95,211,141,.3); }
.pill.off { color: var(--mut); background: transparent; }
.pill.warn { color: var(--warn); background: rgba(224,168,78,.10); border-color: rgba(224,168,78,.3); }
.pill.err  { color: var(--bad); background: rgba(255,118,118,.10); border-color: rgba(255,118,118,.3); }

/* ── 7. Cards & KPI tiles ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card:last-child { margin-bottom: 0; }
.card-pad { padding: 18px; }

/* Section-card header — a labelled band at the top of a card so the
 * section boundary is obvious when many cards stack on a page. Inside
 * the header, h2 is restyled (not the global small-uppercase-grey).
 * Use as: <header class="card-head"><h2>Title</h2><span class="sub">…</span></header> */
.card-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0;
}
.card-head .sub {
  color: var(--mut); font-size: 12px; font-weight: 400;
}
.card-head .spacer { flex: 1; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi .label {
  color: var(--mut); font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.kpi .value {
  font-size: 28px; font-weight: 700;
  margin-top: 6px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi .value small { font-size: 14px; color: var(--mut); font-weight: 500; }
.kpi .sub { color: var(--mut); font-size: 12px; margin-top: 6px; }
.kpi.accent .value { color: var(--acc); }
.kpi.ok     .value { color: var(--ok); }
.kpi.bad    .value { color: var(--bad); }
.kpi.warn   .value { color: var(--warn); }

/* ── 7a. Chart chips (period / metric selectors) ──────────────────── */
/* Pill-shaped chip used by both the portal site chart and the admin
 * uptime heatmap to pick period / metric. Promoted from portal_site
 * inline <style> so admin pages get the styling too. */
.chart-chip-row { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chart-chip {
  background: transparent;
  color: var(--mut);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color .12s, background .12s, border-color .12s;
}
.chart-chip:hover { color: var(--fg); }
.chart-chip.active {
  color: var(--acc);
  background: var(--acc-soft);
  border-color: rgba(90,162,255,.4);
}
.chart-chip.disabled,
.chart-chip[disabled] {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: auto;       /* keep title tooltip clickable on hover */
}
.chart-chip.disabled:hover,
.chart-chip[disabled]:hover { color: var(--mut); }

/* ── 7b. Uptime heatmap ────────────────────────────────────────────── */
/* One row per device. Roots are collapsible group headers — click the
 * root row to show/hide its child node rows. Used by both
 * /portal/sites/{id} and /roots/{root}. */
.uptime-heatmap {
  font-size: 12px;
  display: flex; flex-direction: column;
  gap: 4px;
}
.uptime-heatmap .uptime-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: center;
}
.uptime-heatmap .uptime-row.node.hidden { display: none; }
.uptime-heatmap .uptime-row.root {
  cursor: pointer;
  user-select: none;
}
.uptime-heatmap .uptime-row.root:hover .row-label { color: var(--acc); }
.uptime-heatmap .uptime-row.node .row-label {
  padding-left: 18px;
}
.uptime-heatmap .row-label {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 4px;
  display: flex; align-items: center; gap: 5px;
}
.uptime-heatmap .row-label .chev {
  display: inline-block;
  width: 10px; text-align: center;
  color: var(--mut);
  font-size: 9px;
  transition: transform .12s;
}
.uptime-heatmap .uptime-row.root.collapsed .chev { transform: rotate(-90deg); }
.uptime-heatmap .row-label .muted {
  color: var(--mut);
  font-size: 10.5px;
  margin-left: 4px;
}
.uptime-heatmap .row-cells {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 1px;
  height: 18px;
}
.uptime-heatmap .uptime-row.root .row-cells { height: 14px; }
.uptime-heatmap .cell {
  background: var(--surface-2);
  border-radius: 1px;
  cursor: help;
  transition: filter .08s;
}
.uptime-heatmap .cell:hover { filter: brightness(1.25); }
.uptime-heatmap .cell.up   { background: var(--ok);  }
.uptime-heatmap .cell.mid  { background: var(--warn); }
.uptime-heatmap .cell.down { background: var(--bad); }
.uptime-heatmap .cell.gap  { background: var(--surface-3); }

.uptime-axis {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  font-size: 10.5px;
  color: var(--mut);
  margin-top: 6px;
  /* Tall enough to hold a 45-degree-rotated label projecting ~35 px
     downward (for typical 50 px wordmarks like 'Jun 2026'). */
  min-height: 46px;
}
.uptime-axis .row-cells {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 1px;
  height: 46px;
}
.uptime-axis .tick {
  position: relative;
  overflow: visible;
  text-align: center;
}
/* Major tick — label rotated 45deg ccw. Anchor the text's TOP-RIGHT
   corner at the column-top (right: 50% so the right edge sits at
   column horizontal center; transform-origin: top right pivots from
   there). The whole label then hangs entirely BELOW the axis row and
   to the LEFT of its column — no part of it can crawl up into the
   cells above, and adjacent labels don't crowd each other because
   each one extends in the same direction. */
.uptime-axis .tick > span {
  position: absolute;
  top: 2px;
  right: 50%;
  transform: rotate(-45deg);
  transform-origin: top right;
  white-space: nowrap;
  font-size: 10px;
  color: var(--mut);
  padding-right: 4px;
  pointer-events: none;
}
.uptime-axis .tick.minor::before {
  content: '·';
  color: var(--mut);
  opacity: .6;
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
}

.uptime-legend {
  display: inline-flex; gap: 14px; align-items: center;
  font-size: 11px; color: var(--mut);
}
.uptime-legend .swatch {
  display: inline-block;
  width: 14px; height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}
.uptime-legend .swatch.up   { background: var(--ok);  }
.uptime-legend .swatch.mid  { background: var(--warn); }
.uptime-legend .swatch.down { background: var(--bad); }
.uptime-legend .swatch.gap  { background: var(--surface-3); }

/* ── 8. Utilities ───────────────────────────────────────────────────── */
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
.muted { color: var(--mut); }
.empty { color: var(--mut); padding: 24px; text-align: center; }

.hstack { display: inline-flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* ── 9. Login card shell (used by /login and /portal/login) ─────────── */
.login-wrap {
  min-height: calc(100vh - var(--topbar-h));
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 360px;
  max-width: 100%;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--mut); font-size: 13px; margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label {
  display: block; font-size: 12px; color: var(--mut);
}
.login-card input { width: 100%; margin-top: 4px; }
.login-card button { width: 100%; padding: 10px; margin-top: 4px; }

/* ── Toasts (transient feedback for fetch-driven actions) ──────────────
 * Placed bottom-right so they never compete with the topbar's
 * backdrop-filter (which creates a stacking context and blurs anything
 * positioned behind it). z-index is the max safe positive int so
 * dialogs' top-layer + sidebar can't ever cover them. */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2147483647;
  display: flex; flex-direction: column-reverse; gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px; max-width: 440px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--acc);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.4);
  font-size: 13px;
  line-height: 1.45;
  opacity: 1;
  cursor: pointer;
  /* Opacity-only fade avoids the transform-induced subpixel rasterization
   * that made the toast look out-of-focus while the slide-in keyframe
   * was running. will-change tells the browser to lay out the
   * compositor in advance so the fade is jank-free without
   * re-rasterizing the text. */
  animation: toast-in .18s ease-out;
  will-change: opacity;
  -webkit-font-smoothing: antialiased;
}
.toast.ok   { border-left-color: var(--ok); }
.toast.bad  { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast .title { font-weight: 600; }
.toast .body  { color: var(--mut); font-size: 12px; margin-top: 3px; }
.toast .body code { color: var(--fg); }
.toast.dismissing { animation: toast-out .18s ease-in forwards; }
@keyframes toast-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-out { to   { opacity: 0; } }

/* Row flash — used to highlight a just-added row in a table after a
 * successful fetch action. Pairs with toast().  */
@keyframes row-flash {
  from { background: rgba(90,162,255,.20); }
  to   { background: transparent; }
}
tr.row-flash > td { animation: row-flash 1.6s ease-out; }

/* ── Action bar (toolbar at the top of a page section) ──────────────── */
.action-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 16px;
}
.action-bar > h2 { margin: 0; }
.action-bar .spacer { flex: 1; }
.action-bar .btn, .action-bar button, .action-bar a.btn {
  padding: 7px 14px; font-size: 13.5px;
}

/* ── Form section + grid (used inside modals across admin) ────────────
 * Promoted from root_detail.html in P4-3 so the admin Add dialogs on
 * /clients, /sites, /roots share the same field grid + section header
 * as the node Add/Edit modal. */
.node-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 14px;
  align-items: end;
}
.node-form label {
  display: flex; flex-direction: column;
  font-size: 12px; gap: 3px; color: var(--mut);
}
.node-form input, .node-form select, .node-form textarea {
  font-family: inherit;
}
.node-form textarea { min-height: 44px; font-family: var(--font-mono); }
.node-form-hint { color: var(--mut); font-size: 12px; margin: 10px 0 0; }

.form-section { margin-bottom: 18px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title {
  font-size: 11px; font-weight: 600;
  color: var(--mut); text-transform: uppercase; letter-spacing: .06em;
  margin: 0 0 8px;
}

/* ── Modal (native <dialog>, used for Add/Edit/Send command forms) ──── */
dialog.modal {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 0;
  max-width: 680px;
  width: calc(100vw - 40px);
  box-shadow: var(--shadow);
}
/* The backdrop dimming alone is enough to focus the modal. The earlier
 * backdrop-filter: blur(2px) caused toasts that fire on dialog.close()
 * to render fuzzy: recent Chromium animates ::backdrop removal over
 * ~150 ms, and during that fade the blur is still active and blurs
 * everything behind it (including the toast at bottom-right). Dropping
 * backdrop-filter + forcing transition: none cures it. */
dialog.modal::backdrop {
  background: rgba(0,0,0,.6);
  transition: none;
  animation: none;
}
dialog.modal .modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
dialog.modal .modal-header h3 {
  margin: 0; font-size: 15px; flex: 1; font-weight: 600;
}
dialog.modal .modal-header .sub {
  color: var(--mut); font-size: 12px; font-weight: 400; margin-left: 8px;
}
dialog.modal .modal-close {
  background: transparent; color: var(--mut);
  border: 0; padding: 2px 8px; cursor: pointer;
  font-size: 20px; line-height: 1;
}
dialog.modal .modal-close:hover { color: var(--fg); filter: none; }
dialog.modal .modal-body {
  padding: 18px 20px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
dialog.modal .modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Tabs (page-level navigation, used on /roots/{root}) ────────────── */
.tabstrip {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 0 0 22px;
  overflow-x: auto;
}
.tabstrip .tab {
  background: transparent;
  color: var(--mut);
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  font-weight: 500;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 0;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.tabstrip .tab:hover { color: var(--fg); filter: none; }
.tabstrip .tab.active {
  color: var(--fg);
  border-bottom-color: var(--acc);
}
.tabstrip .tab small {
  color: var(--mut); font-weight: 400; margin-left: 6px;
}
.tabstrip .tab.active small { color: var(--mut); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── 10. Skeletons (used during async loads) ────────────────────────── */
.skel {
  display: inline-block;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-xs);
  animation: skel 1.2s ease-in-out infinite;
  color: transparent;
}
@keyframes skel { 0% {background-position: 200% 0;} 100% {background-position: -200% 0;} }
