/* ============================================================
   PRODUCT / UI LAYER  (webPIMS® + PC applications)
   ------------------------------------------------------------
   Surface: dense, data-first operator tooling. Inherits the
   brand palette, fonts, radii, spacing & shadows from the
   shared core, then maps them onto the screen-tuned semantic
   tokens this layer's components consume (--bg, --ink, --line,
   --blue, …) plus the dark theme & density modes.

   Reconciled to the master system:
     • Neutrals are COOL (page bg from the brand off-white).
     • --ink is the brand slate (--eddyfi-dark-blue).
     • --blue is THE brand blue (--sn-blue) — links, focus,
       active nav AND the wordmark. There is only one blue.
     • --eddyfi-orange (from the core) is brand moments ONLY,
       NEVER status (amber --warning carries caution).
     • Status hues (critical/warning/ok/stale) come from core.
   ============================================================ */
@import url('../../tokens/brand-core.css');

:root {
  /* light theme — semantic tokens mapped onto the brand core */
  --bg: var(--grey-050);          /* cool off-white page (brand) */
  --surface: #FFFFFF;
  --surface-2: var(--grey-100);   /* cool subtle fill — headers, hovers */
  --ink: var(--eddyfi-dark-blue); /* brand slate — dense text */
  --ink-2: var(--grey-700);
  --muted: var(--grey-600);
  --muted-2: var(--grey-400);
  --line: var(--grey-100);
  --line-2: var(--grey-075);

  /* one blue, three steps — brand and interaction are the same blue */
  --blue: var(--sn-blue);         /* #1275BC — links / focus / active / wordmark */
  --blue-ink: var(--sn-blue-deep);
  --blue-soft: var(--sn-blue-tint);

  /* status hues + soft tints inherited from brand-core
     (--critical / --warning / --ok / --stale + *-soft) */

  /* density */
  --row-h: 36px;
  --row-pad-y: 8px;
  --row-pad-x: 12px;
  --gap: 16px;
  --card-pad: 20px;

  /* radii, spacing, shadows and status hues all come from the
     brand core — this layer never redeclares them. */
}

[data-theme='dark'] {
  /* ── TWILIGHT ─────────────────────────────────────────────
     Softer, lifted dark theme. The middle path — deeper than a
     neutral slate but nowhere near inky, with a faint blue-slate
     tint. A comfortable "night" surface with presence; a natural
     evolution of the original theme, just lifted and desaturated.
     Text drops from pure white to an off-white and status hues
     are desaturated. Soft status tints are mixed live over
     --surface so they hold the same relationship on any surface. */
  --bg: oklch(0.225 0.016 245);        /* lifted blue-slate — was oklch(0.16) */
  --surface: oklch(0.268 0.018 245);
  --surface-2: oklch(0.31 0.020 245);  /* headers, hovers, seg track */
  --ink: oklch(0.94 0.007 245);        /* off-white, not pure #FFF */
  --ink-2: oklch(0.81 0.012 245);
  --muted: oklch(0.65 0.016 245);
  --muted-2: oklch(0.54 0.016 245);
  --line: oklch(0.38 0.022 245);
  --line-2: oklch(0.33 0.018 245);

  --blue: oklch(0.73 0.12 244);        /* interaction — links / focus / active */
  --blue-ink: oklch(0.80 0.108 244);   /* brighter blue text on dark */
  --blue-soft: color-mix(in oklab, oklch(0.73 0.12 244) 22%, var(--surface));

  --critical: oklch(0.70 0.14 22);
  --critical-soft: color-mix(in oklab, var(--critical) 20%, var(--surface));
  --warning: oklch(0.79 0.11 75);
  --warning-soft: color-mix(in oklab, var(--warning) 20%, var(--surface));
  --ok: oklch(0.74 0.12 155);
  --ok-soft: color-mix(in oklab, var(--ok) 18%, var(--surface));
  --device: oklch(0.72 0.11 295);
  --device-soft: color-mix(in oklab, var(--device) 20%, var(--surface));
  --stale: oklch(0.61 0.016 245);
}

[data-density='compact'] {
  --row-h: 30px;
  --row-pad-y: 6px;
  --row-pad-x: 10px;
  --gap: 12px;
  --card-pad: 16px;
}

* { box-sizing: border-box; }

/* Guard: root styles.css imports the editorial layer too, which styles bare
   h1–h4 / p / code at print sizes. Inside an app shell, typography comes from
   the component classes only. */
.app h1, .app h2, .app h3, .app h4, .app p, .app code {
  font-size: inherit; line-height: inherit; color: inherit;
  letter-spacing: normal; font-family: inherit; margin: 0;
}
.app code, .app .mono { font-family: var(--font-mono); }

.app {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; letter-spacing: -0.01em; }

/* ─── Shell ─── */
.shell {
  --side-w-1: 248px;
  --side-w-2: 300px;
  display: grid;
  grid-template-columns: var(--side-w-1) 1fr;
  grid-template-rows: 52px 1fr;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
}

.shell-topbar {
  position: relative;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 16px 0 0;
}
.shell-brand {
  width: 220px;
  min-width: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
  height: 100%;
}
.shell-brand-logo {
  width: 26px; height: 26px;
  border-radius: 5px;
  flex-shrink: 0;
  display: block;
}
.shell-side.collapsed .shell-brand-logo { width: 28px; height: 28px; }
.shell-brand-mark {
  width: 22px; height: 22px;
  background: var(--ink);
  border-radius: 3px;
  position: relative;
  flex-shrink: 0;
}
.shell-brand-mark::after {
  content: '';
  position: absolute;
  inset: 5px 4px 5px auto;
  width: 4px;
  background: var(--blue);
  border-radius: 1px;
}
.shell-brand-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.shell-brand-text .wm { font-weight: 800; font-size: 13.5px; letter-spacing: -0.015em; color: var(--ink); white-space: nowrap; }
.shell-brand-text .wm .accent { color: var(--blue); }

.shell-search {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 36vw);
  height: 30px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12.5px;
  z-index: 1;
}

/* Topbar company picker chip (replaces sidebar version when topbar is mounted) */
.topbar-context-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  height: 32px;
  max-width: 220px;
}
.topbar-context-pill.is-global { border-color: var(--blue, #1F8FE0); background: var(--blue-soft, rgba(31,143,224,0.08)); }
.topbar-context-pill:hover { background: var(--surface-2); }
.topbar-context-pill .ctx-logo {
  width: 22px; height: 22px;
  border-radius: 3px;
  display:flex; align-items:center; justify-content:center;
  background: var(--ink); color: var(--surface);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  flex-shrink: 0;
}
.topbar-context-pill .ctx-meta { line-height: 1.15; min-width: 0; }
.topbar-context-pill .ctx-meta b { font-size: 12px; display: block; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.topbar-context-pill .ctx-meta span { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 140px; }
.topbar-context .company-picker { top: 38px; left: 0; right: auto; min-width: 280px; }
.topbar-context .site-picker { left: 0; }
.shell-search .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted-2);
}

.shell-actions { margin-left: auto; display:flex; align-items:center; gap: 6px; }
.icon-btn {
  height: 30px; width: 30px;
  display:inline-flex; align-items:center; justify-content:center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-md);
  cursor: pointer;
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .badge {
  position:absolute; top: 4px; right: 4px;
  background: var(--critical); color: #fff;
  min-width: 14px; height: 14px;
  border-radius: 7px;
  font-size: 9.5px;
  display:flex; align-items:center; justify-content:center;
  padding: 0 4px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.user-chip {
  display:flex; align-items:center; gap:8px;
  padding: 0 8px 0 4px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}
.user-chip .av {
  width: 22px; height: 22px; border-radius: 999px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--ink) 100%);
  color: #fff;
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.02em;
}

.shell-tabs {
  display: flex;
  gap: 0;
  align-items: stretch;
  margin-left: 8px;
}
.shell-tab {
  display:flex; align-items:center; gap: 6px;
  height: 100%;
  padding: 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  position: relative;
  top: 1px;
}
.shell-tab:hover { color: var(--ink); }
.shell-tab.active { color: var(--ink); border-bottom-color: var(--blue); }
.shell-tab .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--critical); display: inline-block; }

/* sidebar */
.shell-side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 12px 12px 16px 12px;
  overflow: auto;
  display:flex; flex-direction: column; gap: 4px;
  position: relative;
}
.shell-side.collapsed { padding: 40px 6px 16px 6px; }
.shell-side.collapsed .side-section,
.shell-side.collapsed .side-item span:not(.alarm-pip):not(.count),
.shell-side.collapsed .side-item .count,
.shell-side.collapsed .ctx-meta,
.shell-side.collapsed .side-context-pill .chev-down,
.shell-side.collapsed .side-extra { display: none !important; }
.shell-side.collapsed .side-section { padding: 10px 0 4px 0; height: 1px; visibility: hidden; }
.shell-side.collapsed .side-item { justify-content: center; padding: 8px 0; gap: 0; position: relative; }
.shell-side.collapsed .side-item .alarm-pip { position: absolute; top: 6px; right: 8px; }
.shell-side.collapsed .side-context-pill { padding: 6px; justify-content: center; }
.shell-side.collapsed .ctx-logo { width: 32px; height: 32px; font-size: 12px; }

/* drag handle on sidebar right edge */
.side-resizer {
  position: absolute;
  top: 0; right: -3px; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}
.side-resizer:hover, .side-resizer.dragging { background: var(--blue); opacity: 0.4; }

/* collapse toggle button */
.side-collapse-btn {
  position: absolute;
  top: 12px; right: 8px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted);
  cursor: pointer;
  z-index: 5;
}
.side-collapse-btn:hover { background: var(--surface-2); color: var(--ink); }
.shell-side.collapsed .side-collapse-btn { right: 50%; transform: translateX(50%); top: 8px; }

/* company picker dropdown */
.company-picker {
  position: absolute;
  top: 100%; left: 4px; right: 4px;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  z-index: 100;
  padding: 4px;
  max-height: 320px; overflow: auto;
}
.company-picker .group-h {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted-2); padding: 8px 8px 4px; font-weight: 600;
}
.company-picker .opt {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12.5px;
}
.company-picker .opt:hover { background: var(--surface-2); }
.company-picker .opt.active { background: var(--blue-soft); color: var(--blue-ink); }
.company-picker .opt .opt-logo {
  width: 24px; height: 24px; border-radius: var(--r-sm);
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; flex-shrink: 0;
}
.company-picker .opt .opt-meta { line-height: 1.2; min-width: 0; flex: 1; }
.company-picker .opt .opt-meta b { font-size: 12.5px; display: block; color: var(--ink); }
.company-picker .opt .opt-meta span { font-size: 10.5px; color: var(--muted); }
.company-picker .opt.active .opt-meta b { color: var(--blue-ink); }
[data-theme='dark'] .company-picker .opt.active .opt-meta b { color: var(--blue); }
.company-picker .divider { height: 1px; background: var(--line); margin: 4px 4px; }

.side-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); padding: 14px 8px 4px 8px; font-weight: 600; }
.side-item {
  display:flex; align-items:center; gap: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-radius: var(--r-md);
  cursor: pointer;
  position: relative;
}
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--blue-soft); color: var(--blue-ink); font-weight: 500; }
[data-theme='dark'] .side-item.active { color: var(--blue); }
.side-item .count { margin-left: auto; font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.side-item .alarm-pip { width: 6px; height: 6px; border-radius: 999px; background: var(--critical); }
.side-tree-row {
  display:flex; align-items:center; gap: 6px;
  padding: 4px 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-radius: var(--r-md);
  cursor: pointer;
}
.side-tree-row:hover { background: var(--surface-2); }
.side-tree-row .chev { width: 14px; color: var(--muted); }
.side-tree-row.depth-1 { padding-left: 22px; }
.side-tree-row.depth-2 { padding-left: 36px; }
.side-tree-row.depth-3 { padding-left: 50px; }
.side-tree-row.active { background: var(--blue-soft); color: var(--blue-ink); }
.side-context-pill {
  margin: 4px 4px 8px 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.side-context-pill .ctx-logo {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: #fff;
  display:flex; align-items:center; justify-content:center;
  font-weight: 600; font-size: 11px; letter-spacing: 0.04em;
  flex-shrink: 0;
}
.side-context-pill .ctx-meta { line-height: 1.2; min-width: 0; flex: 1; }
.side-context-pill .ctx-meta b { font-size: 12.5px; display:block; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-context-pill .ctx-meta span { font-size: 10.5px; color: var(--muted); }
.side-context-pill .chev { color: var(--muted); }

/* ─── Main ─── */
.shell-main { overflow: auto; }
.page {
  padding: 20px 28px;
  max-width: 1400px;
}
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 6px; color: var(--muted-2); }
.crumbs .now { color: var(--ink); }

.page-h {
  display:flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 18px;
}
.page-h h1 { font-size: 22px; margin: 0 0 4px 0; font-weight: 600; letter-spacing: -0.015em; }
.page-h .sub { font-size: 12.5px; color: var(--muted); }

.btn {
  height: 30px; padding: 0 12px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display:inline-flex; align-items:center; gap: 6px;
  font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; }
[data-theme='dark'] .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 11.5px; }

/* cards / tables */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-h {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display:flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-h h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.card-h .sub { font-size: 11.5px; color: var(--muted); }
.card-body { padding: var(--card-pad); }
.card-body.flush { padding: 0; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
table.tbl th {
  text-align: left;
  padding: var(--row-pad-y) var(--row-pad-x);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td {
  padding: var(--row-pad-y) var(--row-pad-x);
  border-bottom: 1px solid var(--line-2);
  color: var(--ink-2);
  white-space: nowrap;
}
table.tbl tr:hover td { background: var(--surface-2); }
table.tbl tr:last-child td { border-bottom: 0; }
.num { font-family: var(--font-mono); font-feature-settings: 'tnum'; color: var(--ink); }

.pill {
  display:inline-flex; align-items:center; gap: 5px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: var(--surface);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.pill.warn { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.pill.crit { background: var(--critical-soft); border-color: transparent; color: var(--critical); }
.pill.device { background: var(--device-soft); border-color: transparent; color: var(--device); }
.pill.stale { background: var(--surface-2); border-color: transparent; color: var(--stale); }
.pill.blue { background: var(--blue-soft); border-color: transparent; color: var(--blue-ink); }
[data-theme='dark'] .pill.blue { color: var(--blue); }

.dot { display:inline-block; width: 8px; height: 8px; border-radius: 999px; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warning); }
.dot.crit { background: var(--critical); }
.dot.device { background: var(--device); }
.dot.stale { background: var(--stale); }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display:flex; flex-direction: column; gap: 4px;
  position: relative;
}
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.kpi .val { font-family: var(--font-mono); font-size: 26px; font-weight: 500; color: var(--ink); letter-spacing: -0.02em; }
.kpi .delta { font-size: 11.5px; color: var(--muted); display:flex; align-items:center; gap: 4px; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--critical); }
.kpi .badge-tile { position: absolute; right: 14px; top: 14px; }

/* segmented */
.seg {
  display:inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* placeholder fill (subtle stripe — design system rule) */
.ph-fill {
  background-image: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, transparent 8px 16px);
  border: 1px dashed var(--line);
  color: var(--muted);
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  border-radius: var(--r-md);
}

/* artboard frame label hidden bg */
.artboard-frame {
  background: var(--bg);
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* notes/section header */
.note {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--blue);
  padding: 10px 14px;
  border-radius: var(--r-md);
  line-height: 1.5;
  max-width: 720px;
}
.note b { color: var(--ink); font-weight: 600; }

/* chart svg */
.chart-svg { width: 100%; display: block; }
.chart-grid line { stroke: var(--line); stroke-width: 1; }
.chart-grid text { fill: var(--muted); font-size: 9.5px; font-family: var(--font-mono); }
.chart-axis-label { fill: var(--muted); font-size: 10px; font-family: var(--font-mono); }

/* form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font-size: 12.5px;
  font-family: var(--font-sans);
}
.field input.mono { font-family: var(--font-mono); }
.field textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 60px; }
.field .hint { font-size: 11px; color: var(--muted); }

.fs-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }

/* ── Alarm severity row marker ─────────────────────────────
   A crisp accent bar on the row's leading edge — no wash. Set
   on the first cell so it reads as one flagged row and stays
   clear of the right-hand Status column (which already carries
   a color-coded pill). The bar is an inset box-shadow, so it
   survives the row-hover background. */
tr.row-crit td:first-child { box-shadow: inset 4px 0 0 var(--critical); }
tr.row-warn td:first-child { box-shadow: inset 4px 0 0 var(--warning); }

/* ── Cell-level severity (dense data tables) ───────────────
   Flag a SINGLE value, not the whole row, when one metric
   crosses its threshold — battery, signal, corrosion rate,
   thickness, predicted-alarm date. The value sits in the
   severity color over a soft tint, with a corner wedge so the
   flag survives a colorblind / grayscale read. Composes with
   tr.row-* (use the row glow when an ENTIRE reading is bad,
   cell flags when only specific metrics are). The hover
   variants out-specify the generic row hover so flags persist.
   .cell-ok is intentionally fill-free + wedge-free — healthy is
   the default, so reassurance shouldn't add table-wide noise. */
table.tbl td.cell-crit,
table.tbl td.cell-warn,
table.tbl td.cell-ok { position: relative; font-weight: 600; }

table.tbl td.cell-crit, table.tbl tr:hover td.cell-crit {
  background: var(--critical-soft); color: var(--critical);
}
table.tbl td.cell-warn, table.tbl tr:hover td.cell-warn {
  background: var(--warning-soft); color: var(--warning);
}
table.tbl td.cell-ok, table.tbl tr:hover td.cell-ok {
  background: transparent; color: var(--ok);
}
/* corner wedge — a non-color cue on the cells that demand action */
table.tbl td.cell-crit::after,
table.tbl td.cell-warn::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 7px 7px 0 0;
  border-color: currentColor transparent transparent transparent;
  opacity: .92;
}

/* ════════════════════════════════════════════════════════
   Hierarchy editor (Data View tree)
   ════════════════════════════════════════════════════════ */

/* Edit-mode toggle in tree header */
.he-edit-toggle { display: inline-flex; align-items: center; gap: 4px; height: 22px; font-size: 10.5px; padding: 0 8px; }
.he-edit-toggle.on { background: var(--blue-soft); color: var(--blue-ink); border-color: var(--blue); }

/* Tree row tweaks for edit mode */
.he-row { position: relative; }
.he-row.editable { padding-right: 26px; }
.he-row .he-row-more {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border: none; background: transparent; border-radius: 4px;
  display: none; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.he-row.editable:hover .he-row-more { display: inline-flex; }
.he-row .he-row-more:hover { background: var(--surface-2); }
.he-row.editable:hover { background: var(--surface-2); }

/* node-id pip on monitoring rows */
.he-node-pip {
  font-size: 10px; color: var(--muted); padding: 1px 5px; border-radius: 3px;
  background: var(--surface-2); border: 1px solid var(--line-2);
}
.he-node-pip.empty { background: transparent; border-style: dashed; color: var(--muted); }

/* Context menu */
.he-menu {
  position: fixed; z-index: 9000; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 4px 0; font-size: 12px;
}
.he-menu-h { padding: 6px 12px 4px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.he-menu-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer;
  color: var(--ink);
}
.he-menu-item:hover { background: var(--surface-2); }
.he-menu-item.danger { color: var(--critical); }
.he-menu-item.danger:hover { background: var(--critical-soft); }
.he-menu-sep { height: 1px; background: var(--line-2); margin: 4px 0; }

/* Modal (Add / Edit) — centered so eye + cursor stay near the tree */
.he-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,0.18); z-index: 8000;
}
.he-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8500;
  width: 440px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  display: flex; flex-direction: column;
  animation: he-pop-in 140ms ease-out;
}
@keyframes he-pop-in { from { transform: translate(-50%, -50%) scale(0.97); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.he-drawer-h {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.he-drawer-eyebrow { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.he-drawer-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-top: 4px; }
.he-pill { padding: 1px 7px; border-radius: 999px; background: var(--surface-2); font-size: 10px; color: var(--ink-2); letter-spacing: 0.04em; }

.he-modal-body { flex: 1; overflow: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.he-drawer-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
}

.he-field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.he-field label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.he-optional { font-weight: 400; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.he-input {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 4px; background: var(--surface);
  padding: 7px 10px; font: inherit; font-size: 12.5px; color: var(--ink);
  outline: none; transition: border-color 100ms;
}
.he-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
textarea.he-input { resize: vertical; min-height: 52px; }
.he-help { font-size: 11px; color: var(--muted); margin-top: 2px; }

.he-parent-btn { display: flex; align-items: center; justify-content: space-between; cursor: pointer; text-align: left; }
.he-parent-picker {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 2px; z-index: 10;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  max-height: 220px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.he-parent-opt { display: flex; align-items: center; gap: 6px; padding: 7px 10px; cursor: pointer; font-size: 12px; }
.he-parent-opt:hover { background: var(--surface-2); }

/* Type cards (Group / Monitoring) on Add */
.he-typegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.he-typecard {
  text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); cursor: pointer; font: inherit; transition: all 100ms;
}
.he-typecard:hover { border-color: var(--ink-2); }
.he-typecard.on { border-color: var(--blue); background: var(--blue-soft); }
.he-typecard-h { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); }
.he-typecard-sub { font-size: 10.5px; color: var(--muted); margin-top: 4px; line-height: 1.35; }

/* Delete dialog */
.he-dialog {
  position: fixed; left: 50%; top: 32%; transform: translate(-50%, -32%); z-index: 8500;
  width: 420px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  display: flex; flex-direction: column;
}
.he-dialog-h { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.he-dialog-body { padding: 16px 18px; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.he-dialog-action {
  margin-top: 12px; padding: 10px 12px; background: var(--blue-soft); border-radius: 4px;
  display: flex; gap: 10px; align-items: flex-start; font-size: 12px; color: var(--ink);
}
.he-dialog-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.btn.danger { background: var(--critical); color: #fff; border-color: var(--critical); }
.btn.danger:hover { background: #a8333d; }

/* ════════════════════════════════════════════════════════
   User detail (admin · single user)
   ════════════════════════════════════════════════════════ */

/* iOS-style switch */
.switch {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: 120ms;
}
.switch .slider::before {
  content: '';
  position: absolute;
  height: 14px; width: 14px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 120ms;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(12px); }
.switch input:disabled + .slider { opacity: 0.45; cursor: not-allowed; }

/* User detail page-specific layout */
.ud-grid { display: grid; grid-template-columns: 1fr 320px; gap: 14px; align-items: start; }
.ud-hero {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.ud-avatar {
  width: 56px; height: 56px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2a4f73 0%, var(--blue) 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  position: relative;
}
.ud-avatar .presence {
  position: absolute; right: 0; bottom: 0;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--ok);
  border: 2px solid var(--surface);
}
.ud-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.ud-name .pill { font-size: 10.5px; }
.ud-meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 12px; flex-wrap: wrap; }
.ud-meta .mono { color: var(--ink-2); }
.ud-meta b { font-weight: 500; color: var(--ink-2); }

.ud-section-h { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ud-section-h h3 { margin: 0; font-size: 13px; font-weight: 600; }
.ud-section-h .sub { font-size: 11.5px; color: var(--muted); }

/* read-only / SSO-locked input look */
.field input.locked, .field select.locked {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
.lock-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; color: var(--muted); margin-left: 6px;
  text-transform: none; letter-spacing: 0;
}

/* Permissions / capability matrix */
.cap-matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.cap-matrix th, .cap-matrix td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); text-align: center; }
.cap-matrix th { background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.cap-matrix th:first-child, .cap-matrix td:first-child { text-align: left; color: var(--ink-2); font-weight: 500; }
.cap-matrix tr:last-child td { border-bottom: 0; }
.cap-tick { color: var(--ok); }
.cap-x { color: var(--muted-2); }
.cap-partial { color: var(--warning); font-family: var(--font-mono); font-size: 11px; }

/* Location-access list */
.loc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-2);
}
.loc-row:last-child { border-bottom: 0; }
.loc-row .loc-icon {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.loc-row .loc-meta { flex: 1; min-width: 0; }
.loc-row .loc-name { font-size: 12.5px; font-weight: 500; color: var(--ink); }
.loc-row .loc-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.loc-row select.scope-select {
  height: 26px; font-size: 11.5px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink-2);
  font-family: var(--font-sans);
  min-width: 130px;
}

/* Company / site access — nested two-tier list */
.company-block { border-bottom: 1px solid var(--line); }
.company-block:last-child { border-bottom: 0; }
.company-block .loc-row.company-row { background: var(--surface-2); border-bottom: 1px solid var(--line-2); }
.company-block .loc-row.company-row .loc-name { font-size: 13px; font-weight: 600; }
.company-block .loc-row.site-row {
  position: relative;
  padding-left: 44px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}
.company-block .loc-row.site-row:last-child { border-bottom: 0; }
.company-block .loc-row.site-row .site-rail {
  position: absolute;
  left: 28px; top: 0; bottom: 0;
  width: 1px; background: var(--line);
}
.seg.sm button {
  font-size: 11px;
  padding: 3px 8px;
}
.seg.sm button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Notification matrix rows */
.notif-row {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 70px);
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-2);
  gap: 8px;
}
.notif-row.head { background: var(--surface-2); border-bottom: 1px solid var(--line); }
.notif-row.head > div { font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; font-weight: 500; }
.notif-row.head > div:not(:first-child) { text-align: center; }
.notif-row > div:not(:first-child) { display: flex; justify-content: center; }
.notif-row:last-child { border-bottom: 0; }
.notif-label { font-size: 12.5px; color: var(--ink); display: flex; align-items: center; gap: 8px; }

/* Sessions list */
.sess-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12px;
}
.sess-row:last-child { border-bottom: 0; }
.sess-row .sess-meta { flex: 1; min-width: 0; }
.sess-row .sess-meta b { display: block; color: var(--ink); font-weight: 500; }
.sess-row .sess-meta span { color: var(--muted); font-size: 11px; }
.sess-row .sess-this { font-size: 10px; padding: 1px 6px; border-radius: 3px; background: var(--blue-soft); color: var(--blue-ink); font-weight: 500; letter-spacing: 0.02em; }

/* Activity log */
.act-row {
  display: flex; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12px;
}
.act-row:last-child { border-bottom: 0; }
.act-row .act-time { font-family: var(--font-mono); font-size: 11px; color: var(--muted); width: 92px; flex-shrink: 0; padding-top: 1px; }
.act-row .act-body { flex: 1; min-width: 0; }
.act-row .act-action { color: var(--ink-2); }
.act-row .act-target { color: var(--blue); font-family: var(--font-mono); }
.act-row .act-detail { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Danger zone */
.danger-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.danger-card .danger-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.danger-card .danger-row:last-child { border-bottom: 0; }
.danger-card b { font-size: 12.5px; color: var(--ink); display: block; }
.danger-card span { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ════════════════════════════════════════════════════════
   Companies (admin · tenant directory)
   ════════════════════════════════════════════════════════ */
.co-tbl tr { transition: background 80ms; }
.co-tbl tbody tr:hover td { background: var(--surface-2); }
.co-tbl tbody tr.row-crit:hover td { background: var(--critical-soft); }
.co-tbl td { vertical-align: middle; padding-top: 10px; padding-bottom: 10px; }
.co-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.co-logo {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em; flex-shrink: 0;
}
.co-meta { min-width: 0; line-height: 1.25; }
.co-meta .co-name { font-size: 12.5px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.co-meta .co-domain { font-size: 10.5px; color: var(--muted); }
.co-drill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  opacity: 0.55;
  transition: opacity 80ms, background 80ms, border-color 80ms;
}
.co-tbl tbody tr:hover .co-drill {
  opacity: 1;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}

/* Sticky save bar */
.save-bar {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  margin: -20px -28px 18px -28px;
  padding: 10px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
[data-theme='dark'] .save-bar { background: color-mix(in oklab, var(--surface) 92%, transparent); }
.save-bar .save-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.save-bar .save-status .pill { font-size: 10.5px; }

/* ════════════════════════════════════════════════════════
   DESIGN-SYSTEM ADDITIONS
   Gap-fill primitives formalized while documenting the system.
   These were implied by the product but had no shared class.
   Additive (new selectors only) — safe to use anywhere.
   ════════════════════════════════════════════════════════ */

/* ── Toast / inline confirmation ── */
.toast {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-size: 12.5px; color: var(--ink);
  max-width: 360px;
}
.toast .toast-icon { flex-shrink: 0; display: inline-flex; }
.toast .toast-body { min-width: 0; line-height: 1.4; }
.toast .toast-body b { font-weight: 600; }
.toast .toast-body span { display: block; color: var(--muted); font-size: 11.5px; }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warning); }
.toast.crit { border-left-color: var(--critical); }
.toast .toast-x {
  margin-left: auto; flex-shrink: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 4px; border: 0; background: transparent; color: var(--muted);
}
.toast .toast-x:hover { background: var(--surface-2); color: var(--ink); }

/* ── Tooltip ── (dark micro-label; pair with position:relative parent) */
.tooltip {
  display: inline-flex; align-items: center;
  background: var(--ink); color: var(--bg);
  font-size: 11px; font-weight: 500;
  padding: 4px 8px; border-radius: var(--r-sm);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: relative;
}
.tooltip::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: var(--ink);
}
.tooltip .kbd { font-family: var(--font-mono); font-size: 10px; opacity: 0.7; margin-left: 6px; }
[data-theme='dark'] .tooltip { background: var(--ink-2); color: var(--surface); }
[data-theme='dark'] .tooltip::after { border-top-color: var(--ink-2); }

/* ── Empty state ── (formalizes the StubPage pattern) */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 44px 28px; color: var(--muted);
}
.empty-state .es-mark {
  width: 52px; height: 52px; border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); margin-bottom: 14px;
}
.empty-state h4 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.empty-state p { margin: 5px 0 0; font-size: 12.5px; max-width: 42ch; line-height: 1.5; }
.empty-state .es-actions { margin-top: 16px; display: flex; gap: 8px; }

/* ── Skeleton / loading shimmer ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--line-2) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: sk-shimmer 1.2s ease-in-out infinite;
}
.skeleton.line { height: 11px; }
.skeleton.line.sm { height: 9px; }
.skeleton.block { height: 56px; border-radius: var(--r-md); }
.skeleton.circle { border-radius: 999px; }
@keyframes sk-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ============================================================
   INDUSTRIAL / SIGNAL LAYER  (product UI)
   ------------------------------------------------------------
   Three additions, all opt-in and backward-compatible:
     1. data-theme="control"  — control-room dark
     2. data-density="glove"  — gloved / PPE field density
     3. the signal + waveform + plant-vocabulary classes
   ============================================================ */

/* ── 1 · CONTROL ROOM ─────────────────────────────────────────
   A third theme below "twilight" dark, for 24/7 console walls,
   night-shift operators and tablets held under a hard hat. The
   base drops toward black so a single alarm tile is the brightest
   thing on the screen; hairlines lift so structure survives at
   low luminance; status hues gain chroma to punch through it.
   Same token contract as light/dark — nothing else changes. */
[data-theme='control'] {
  --bg: oklch(0.155 0.014 240);
  --surface: oklch(0.196 0.016 240);
  --surface-2: oklch(0.243 0.018 240);
  --ink: oklch(0.955 0.006 240);
  --ink-2: oklch(0.83 0.010 240);
  --muted: oklch(0.66 0.014 240);
  --muted-2: oklch(0.52 0.014 240);
  --line: oklch(0.35 0.020 240);
  --line-2: oklch(0.28 0.016 240);
  --blue: oklch(0.75 0.135 244);
  --blue-ink: oklch(0.83 0.115 244);
  --blue-soft: color-mix(in oklab, oklch(0.75 0.135 244) 20%, var(--surface));
  --critical: oklch(0.695 0.175 22);
  --critical-soft: color-mix(in oklab, oklch(0.695 0.175 22) 24%, var(--surface));
  --warning: oklch(0.80 0.150 78);
  --warning-soft: color-mix(in oklab, oklch(0.80 0.150 78) 22%, var(--surface));
  --ok: oklch(0.735 0.135 150);
  --ok-soft: color-mix(in oklab, oklch(0.735 0.135 150) 20%, var(--surface));
  --device: oklch(0.72 0.130 296);
  --device-soft: color-mix(in oklab, oklch(0.72 0.130 296) 20%, var(--surface));
  --stale: oklch(0.60 0.012 240);
  --wave-grid: rgba(255,255,255,0.09);
  --wave-trace: oklch(0.75 0.135 244);
  --wave-trace-dim: color-mix(in oklab, oklch(0.75 0.135 244) 30%, transparent);
  --plate-face: oklch(0.30 0.014 240);
  --plate-etch: oklch(0.90 0.008 240);
  --plate-edge: oklch(0.38 0.018 240);
  --hazard-ink: oklch(0.90 0.008 240);
  --hazard-face: oklch(0.26 0.016 240);
  --hazard-edge: oklch(0.38 0.018 240);
  /* shadows do nothing at this luminance — borders carry elevation */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.55);
  --shadow-lg: 0 14px 40px rgba(0,0,0,0.6);
  --shadow-pop: 0 8px 24px rgba(0,0,0,0.6);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.7);
}
[data-theme='control'] .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
[data-theme='control'] .side-item.active,
[data-theme='control'] .pill.blue { color: var(--blue); }
[data-theme='control'] .tooltip { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }

/* ── 2 · GLOVE DENSITY ───────────────────────────────────────
   The field counterpart to compact: an operator in gloves, on a
   ruggedized tablet, in daylight, one-handed. Hit targets ≥56px,
   type up one step, hairlines doubled, no hover-only affordances.
   Pair with data-theme="light" outdoors, "control" at night. */
[data-density='glove'] {
  --row-h: 56px;
  --row-pad-y: 16px;
  --row-pad-x: 16px;
  --gap: 20px;
  --card-pad: 20px;
}
[data-density='glove'] .btn,
[data-density='glove'] .seg button,
[data-density='glove'] .side-item { min-height: 56px; padding-inline: 18px; font-size: 15px; }
[data-density='glove'] .seg { padding: 3px; }
[data-density='glove'] .pill { padding: 7px 12px; font-size: 12.5px; }
[data-density='glove'] table.tbl { font-size: 14px; }
[data-density='glove'] table.tbl th,
[data-density='glove'] table.tbl td { padding-block: 16px; }
[data-density='glove'] table.tbl tbody tr { border-bottom-width: 1.5px; }
[data-density='glove'] .card { border-width: 1.5px; }
[data-density='glove'] .icon-btn { width: 56px; height: 56px; }
[data-density='glove'] .card-h { padding: 16px 20px; }
[data-density='glove'] .card-h h3 { font-size: 15px; }

/* ── 3a · The sweep — the system's one signature motion ──────
   A single left-to-right pass, the way a gate sweeps a trace.
   .scan-sweep is the loading skeleton (replaces any shimmer);
   .scan-reveal is the one-shot chart entrance. Nothing loops. */
.scan-sweep { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.scan-sweep::after {
  content: ""; position: absolute; inset: 0; width: 45%;
  background: linear-gradient(90deg, transparent, var(--wave-trace-dim), transparent);
  animation: sn-sweep var(--sweep-dur) var(--ease-out) infinite;
}
.scan-reveal { animation: sn-sweep-clip var(--dur-3) var(--ease-out) both; }
@keyframes sn-sweep-clip { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) {
  .scan-sweep::after { animation: none; }
  .scan-reveal { animation: none; }
}

/* ── 3b · Instrument graticule — the chart-panel background.
   Any hand-built SVG chart sits on this, so every plot in the
   product reads as the same instrument. */
.graticule {
  background-image:
    linear-gradient(to right, var(--wave-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--wave-grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ── 3c · Datum ticks on a card — engineering-drawing structure.
   .card.datum reads as a measured figure, not a SaaS panel. */
.card.datum { position: relative; }
.card.datum::before, .card.datum::after {
  content: ""; position: absolute; width: 12px; height: 12px;
  border-color: var(--muted-2); border-style: solid; pointer-events: none;
}
.card.datum::before { top: 5px; left: 5px; border-width: 1.5px 0 0 1.5px; }
.card.datum::after { bottom: 5px; right: 5px; border-width: 0 1.5px 1.5px 0; }

/* ── 3d · Plant vocabulary in-app ───────────────────────────── */
.tag-num {
  display: inline-flex; align-items: center; font-family: var(--font-mono);
  font-size: 11.5px; font-weight: 500; letter-spacing: 0.05em; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--blue); border-radius: var(--r-xs);
  padding: 2px 7px; white-space: nowrap; font-feature-settings: 'tnum';
}
.tag-num.sensor { border-left-color: var(--teal); }
.hazard {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono);
  font-size: 10px; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--hazard-ink); background: var(--hazard-face);
  border: 1px solid var(--hazard-edge); border-radius: var(--r-xs); padding: 3px 7px; white-space: nowrap;
}
.hazard::before {
  content: ""; width: 0; height: 0; flex: none;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 7px solid var(--hazard-ink);
}

/* ── 3e · Signal ramp legend — mandatory beside any colour-mapped
   acoustic surface (B-scan, C-scan, spectrogram). */
.signal-legend { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.signal-legend .bar { height: 8px; border-radius: var(--r-xs); background: var(--signal-ramp); }
.signal-legend .ends {
  display: flex; justify-content: space-between; font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
