/* =============================================================
   Halo — Dark Design System
   Adapted for Stratum Admin Dashboard
   ============================================================= */

:root {
  --color-background: #0A0B0F;
  --color-surface: #14151C;
  --color-elevated: #1E2029;
  --color-overlay: rgba(10, 11, 15, 0.72);
  --color-border: #2A2D38;
  --color-border-strong: #3A3D4A;
  --color-border-soft: rgba(255, 255, 255, 0.04);
  --color-text-primary: #F2F4F8;
  --color-text-secondary: #9AA0AE;
  --color-text-muted: #5C6170;
  --color-text-inverse: #0A0B0F;
  /* Brand orange, sampled from the logo mark (assets/logo1.png). */
  --color-primary: #F45708;
  --color-primary-hover: #FF6F24;
  --color-primary-pressed: #C74504;
  --color-primary-soft: rgba(244, 87, 8, 0.12);
  --color-success: #2BE08C;
  --color-warning: #F5D547;
  --color-info: #3DD7E5;
  --color-danger: #FF3A5C;
  --color-success-soft: rgba(43, 224, 140, 0.12);
  --color-warning-soft: rgba(245, 213, 71, 0.14);
  --color-info-soft: rgba(61, 215, 229, 0.14);
  --color-danger-soft: rgba(255, 58, 92, 0.14);

  /* Stratum severity: high uses brand orange */
  --color-high: #E2641C;
  --color-high-soft: rgba(226, 100, 28, 0.14);

  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px; --space-20: 80px;

  --radius-none: 0px; --radius-sm: 6px; --radius-md: 10px;
  --radius-lg: 16px; --radius-xl: 24px; --radius-full: 999px;

  --border-width: 1px;
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.02) inset, 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.03) inset;
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.04) inset;
  --focus-ring: 0 0 0 3px rgba(244, 87, 8, 0.35);
  --motion-fast: 120ms; --motion-base: 150ms; --motion-slow: 240ms;
  --easing-standard: cubic-bezier(0.2, 0.6, 0.2, 1);
  --container-max: 1280px;
  --container-pad: clamp(20px, 4vw, 48px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Always reserve the scrollbar gutter so navigating between short and long
   pages doesn't shift the nav sideways. */
html { overflow-y: scroll; }
body {
  background-color: var(--color-background);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
hr { border: 0; border-top: var(--border-width) solid var(--color-border); margin: 0; }
a { color: inherit; text-decoration: none; }
::selection { background-color: var(--color-primary-soft); color: var(--color-text-primary); }

/* Layout */
.container { width: 100%; max-width: var(--container-max); margin-inline: auto; padding-inline: var(--container-pad); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Nav */
.page-nav {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
  background-color: rgba(10, 11, 15, 0.80);
  border-bottom: 1px solid var(--color-border);
}
.page-nav .container { height: 64px; display: flex; align-items: center; justify-content: space-between; }
.nav-left { display: inline-flex; align-items: center; gap: var(--space-8); flex: 1; min-width: 0; }
.brand-row { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
/* The mark is a transparent PNG cut from logo1, sitting on a brand-gradient
   tile — the same rounded-square treatment the icon tiles below use, so the
   logo reads as the first member of that family. buildNav() writes this
   markup on every page, so no per-page HTML carries it. */
.brand-mark {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: var(--radius-md);
  background:
    url("../assets/logo1.png") center / 21px 21px no-repeat,
    linear-gradient(145deg, var(--color-primary-hover), var(--color-primary-pressed));
  box-shadow: 0 4px 12px rgba(244, 87, 8, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.brand-name { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; color: var(--color-text-primary); font-size: 0.9375rem; }
.brand-suffix { font-size: 0.75rem; font-weight: 500; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-items { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-items::-webkit-scrollbar { display: none; }
.nav-items a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-display); font-size: 0.875rem; font-weight: 500;
  color: var(--color-text-secondary); white-space: nowrap; padding: 6px 10px;
  border-radius: var(--radius-md);
  transition: color var(--motion-base) var(--easing-standard), background-color var(--motion-base) var(--easing-standard);
}
.nav-items a i, .nav-items a svg { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.75; }
.nav-items a:hover, .nav-items a.active { color: var(--color-text-primary); }
.nav-items a.active { background-color: var(--color-primary-soft); }
.nav-items a.active i, .nav-items a.active svg { color: var(--color-primary); }
.nav-items a > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Count pill on a nav row. Nothing sets one yet — setNavBadge() in db.js is the
   entry point. ponytail: no page queries counts on load just to fill these. */
.nav-badge {
  margin-left: auto; flex-shrink: 0;
  min-width: 20px; height: 20px; padding-inline: 6px; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  background-color: var(--color-primary); color: var(--color-text-inverse);
  font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 600;
}
/* Section heading inside the rail ("ACCOUNT") — rail-only; the top bar the
   narrow layout falls back to has no room for section labels. */
.nav-section { display: none; font-family: var(--font-display); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-text-muted); padding: 0 10px 6px; }
.nav-right { display: inline-flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.nav-email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1280px) { .nav-email { display: none; } }

/* Sidebar (desktop ≥ 901px). The per-page header DOM — brand, nav-items,
   nav-right stacked in that order — is already vertical order, so this is a
   pure restyle: fixed left rail, content shifted over. Below 901px the base
   rules above stand and the nav stays a horizontal top bar (mobile = the
   field app anyway). ponytail: no collapse/hamburger — add if a page ever
   needs the full width on a laptop. */
@media (min-width: 901px) {
  :root { --sidebar-w: 248px; }
  .page-nav {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background-color: var(--color-surface);
    border-bottom: 0; border-right: 1px solid var(--color-border);
  }
  .page-nav .container {
    height: 100%; max-width: none;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    padding: var(--space-5) var(--space-3) var(--space-4);
    gap: var(--space-5);
    overflow-y: auto; scrollbar-width: none;
  }
  .page-nav .container::-webkit-scrollbar { display: none; }
  .nav-left { flex-direction: column; align-items: stretch; gap: var(--space-4); flex: 1; }
  /* Brand block sits in its own panel, divided from the links below it. */
  .brand-row { padding: var(--space-2) var(--space-2) var(--space-4); border-bottom: 1px solid var(--color-border); }
  .nav-items { flex-direction: column; align-items: stretch; gap: 2px; overflow: visible; }
  .nav-items a { padding: 9px 10px; }
  .nav-items a:hover { background-color: var(--color-elevated); }
  .nav-items a.active {
    background-color: var(--color-primary-soft); color: var(--color-text-primary);
    box-shadow: inset 2px 0 0 var(--color-primary);
  }
  /* Account block pinned to the foot of the rail (mirrors the reference's
     ACCOUNT section) — initAuth fills it with the identity + sign out. */
  .nav-right {
    flex-direction: column; align-items: stretch; gap: var(--space-2);
    padding-top: var(--space-4); border-top: 1px solid var(--color-border);
  }
  .nav-section { display: block; }

  /* Collapse toggle ("Hide"), pinned under the account block. */
  .nav-collapse {
    appearance: none; background: transparent; border: 0; cursor: pointer;
    display: flex; align-items: center; gap: var(--space-2);
    padding: 9px 10px; margin-top: var(--space-2); border-radius: var(--radius-md);
    font-family: var(--font-display); font-size: 0.875rem; font-weight: 500;
    color: var(--color-text-secondary);
    transition: background-color var(--motion-base) var(--easing-standard), color var(--motion-base) var(--easing-standard);
  }
  .nav-collapse:hover { background-color: var(--color-elevated); color: var(--color-text-primary); }
  .nav-collapse i { width: 17px; height: 17px; flex-shrink: 0; transition: transform var(--motion-slow) var(--easing-standard); transform: rotate(180deg); }

  /* Collapsed: icon-only rail. Labels and section headings drop out, the
     content margin follows, and the chevron flips to point back open. */
  body.nav-collapsed { --sidebar-w: 68px; }
  body.nav-collapsed .page-nav .container { padding-inline: var(--space-2); }
  body.nav-collapsed .nav-items a > span,
  body.nav-collapsed .nav-badge,
  body.nav-collapsed .brand-text,
  body.nav-collapsed .nav-section,
  body.nav-collapsed .nav-collapse span { display: none; }
  body.nav-collapsed .nav-items a, body.nav-collapsed .nav-collapse { justify-content: center; padding-inline: 0; }
  body.nav-collapsed .brand-row { justify-content: center; padding-inline: 0; }
  body.nav-collapsed .nav-collapse i { transform: rotate(0deg); }
  .nav-right > div { justify-content: space-between; }
  .nav-email { display: block !important; max-width: 100%; min-width: 0; flex: 1; }

  body:has(.page-nav) main, body:has(.page-nav) .page-footer { margin-left: var(--sidebar-w); }
}

/* Buttons */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2); height: 40px; padding-inline: 18px;
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-family: var(--font-display); font-size: 0.875rem; font-weight: 500;
  letter-spacing: -0.005em; line-height: 1; cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--color-text-primary);
  transition: background-color var(--motion-base) var(--easing-standard),
    border-color var(--motion-base) var(--easing-standard),
    box-shadow var(--motion-base) var(--easing-standard);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn svg, .btn i { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.75; }
.btn-sm { height: 32px; padding-inline: 12px; font-size: 0.8125rem; border-radius: 8px; }
.btn-sm svg, .btn-sm i { width: 14px; height: 14px; }
/* Near-black label, not white: white on brand orange is only 3.4:1. */
.btn-primary { background-color: var(--color-primary); color: var(--color-text-inverse); border-color: var(--color-primary); box-shadow: inset 0 1px 0 rgba(255,255,255,0.18); }
.btn-primary:hover { background-color: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn-secondary { background-color: var(--color-surface); color: var(--color-text-primary); border-color: var(--color-border-strong); }
.btn-secondary:hover { background-color: var(--color-elevated); }
.btn-tertiary { background: transparent; color: var(--color-text-secondary); }
.btn-tertiary:hover { background-color: var(--color-surface); color: var(--color-text-primary); }
.btn-icon { padding-inline: 0; width: 40px; }
.btn-icon.btn-sm { width: 32px; }

/* Inputs */
.input, .select {
  appearance: none; width: 100%; height: 40px;
  background-color: var(--color-surface); color: var(--color-text-primary);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding-inline: 14px;
  font-family: var(--font-body); font-size: 0.9375rem; letter-spacing: -0.005em;
  transition: border-color var(--motion-base) var(--easing-standard), box-shadow var(--motion-base) var(--easing-standard);
}
.input::placeholder { color: var(--color-text-muted); }
.input:focus, .select:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 38px; }
.input-group .input-icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--color-text-muted); pointer-events: none; display: flex; align-items: center; }
.select {
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-secondary) 50%), linear-gradient(135deg, var(--color-text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; cursor: pointer;
}

/* Cards */
.card {
  background-color: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-4);
  transition: border-color var(--motion-base) var(--easing-standard);
}
.card:hover { border-color: var(--color-border-strong); }
.card-elevated { background-color: var(--color-elevated); border-color: var(--color-border-strong); box-shadow: var(--shadow-md); }

/* Tabs */
.tabs { display: inline-flex; align-items: center; gap: 4px; padding: 4px; background-color: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-full); }
.tab {
  appearance: none; background: transparent; border: 1px solid transparent; border-radius: var(--radius-full);
  color: var(--color-text-secondary); font-family: var(--font-display); font-size: 0.8125rem; font-weight: 500;
  height: 32px; padding-inline: 14px; cursor: pointer;
  transition: background-color var(--motion-base) var(--easing-standard), color var(--motion-base) var(--easing-standard), border-color var(--motion-base) var(--easing-standard);
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.tab:hover { background-color: var(--color-elevated); color: var(--color-text-primary); }
.tab.is-active { background-color: var(--color-elevated); color: var(--color-text-primary); border-color: var(--color-primary); }
/* Anchors are used as tabs in the dashboard subnav; strip the link styling only. */
a.tab { text-decoration: none; }

/* Dashboard subnav (Overview / Feed / Inspections). Full-width above the page
   header, so it never reads as a peer of the date-range tabs inside it. */
.subnav { margin-bottom: var(--space-4); }
.subnav:empty { display: none; }
@media print { .subnav { display: none; } }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 24px; padding-inline: 10px; border-radius: var(--radius-full);
  background-color: var(--color-primary-soft); color: var(--color-primary-hover);
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
}
.chip svg, .chip i { width: 12px; height: 12px; flex-shrink: 0; }
.chip[data-tone="success"] { background-color: var(--color-success-soft); color: var(--color-success); }
.chip[data-tone="warning"] { background-color: var(--color-warning-soft); color: var(--color-warning); }
.chip[data-tone="info"] { background-color: var(--color-info-soft); color: var(--color-info); }
.chip[data-tone="danger"] { background-color: var(--color-danger-soft); color: var(--color-danger); }
.chip[data-tone="high"] { background-color: var(--color-high-soft); color: var(--color-high); }
.chip[data-tone="neutral"] { background-color: var(--color-elevated); color: var(--color-text-secondary); border-color: var(--color-border); }
.chip[data-tone="critical"] { background-color: var(--color-danger-soft); color: var(--color-danger); }
.chip[data-tone="medium"] { background-color: var(--color-warning-soft); color: var(--color-warning); }
.chip[data-tone="low"] { background-color: var(--color-success-soft); color: var(--color-success); }

/* Badge dot */
.badge-dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--radius-full); background-color: var(--color-primary); }
.badge-dot[data-tone="success"] { background-color: var(--color-success); }
.badge-dot[data-tone="warning"] { background-color: var(--color-warning); }
.badge-dot[data-tone="danger"] { background-color: var(--color-danger); }
.badge-dot[data-tone="high"] { background-color: var(--color-high); }
.badge-dot[data-tone="neutral"] { background-color: var(--color-text-muted); }

/* Icon tile — the tinted rounded square that carries a card's colour. Used in
   the stat tiles and activity rows below; `data-tone` on the tile (or on any
   ancestor stat-tile / activity-row) picks the tint. */
.icon-tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: var(--radius-md);
  background-color: var(--color-primary-soft); color: var(--color-primary);
}
.icon-tile i, .icon-tile svg { width: 18px; height: 18px; stroke-width: 1.9; }
.icon-tile-sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-tile-sm i, .icon-tile-sm svg { width: 15px; height: 15px; }
/* Severity words (critical/high/medium/low) are tones too — a findings row
   passes its own severity straight through, so they must resolve on the tile
   itself, not only when inherited from a parent. */
.icon-tile[data-tone="success"], .icon-tile[data-tone="low"],
[data-tone="success"] > .icon-tile, [data-tone="low"] > .icon-tile { background-color: var(--color-success-soft); color: var(--color-success); }
.icon-tile[data-tone="warning"], .icon-tile[data-tone="medium"],
[data-tone="warning"] > .icon-tile, [data-tone="medium"] > .icon-tile { background-color: var(--color-warning-soft); color: var(--color-warning); }
.icon-tile[data-tone="info"], [data-tone="info"] > .icon-tile { background-color: var(--color-info-soft); color: var(--color-info); }
.icon-tile[data-tone="danger"], .icon-tile[data-tone="critical"],
[data-tone="danger"] > .icon-tile, [data-tone="critical"] > .icon-tile { background-color: var(--color-danger-soft); color: var(--color-danger); }
.icon-tile[data-tone="high"], [data-tone="high"] > .icon-tile { background-color: var(--color-high-soft); color: var(--color-high); }
.icon-tile[data-tone="neutral"], [data-tone="neutral"] > .icon-tile { background-color: var(--color-elevated); color: var(--color-text-secondary); }

/* Stat Tile — the tinted icon tile carries the colour now, so no top accent bar. */
.stat-tile {
  position: relative; background-color: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2); overflow: hidden;
  transition: border-color var(--motion-base) var(--easing-standard), background-color var(--motion-base) var(--easing-standard);
}
/* Label, value and footer read as one block; the icon row sits apart from it. */
.stat-tile .stat-head { margin-bottom: var(--space-2); }
.stat-tile:hover { border-color: var(--color-border-strong); background-color: var(--color-elevated); }
/* Reference shape: `.icon-tile` leads, trend indicator sits right, label and
   value read underneath. Pages still on the legacy `eyebrow then <i>` markup
   get row-reversed instead, so the tile leads there too without an edit. */
.stat-tile .stat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.stat-tile .stat-head:not(:has(.icon-tile)) { flex-direction: row-reverse; justify-content: flex-end; }
/* A bare <i> in the head is promoted to a tinted tile, so the pages that
   already ship `.stat-head > i` markup pick the new look up untouched. */
.stat-tile .stat-head > i {
  box-sizing: content-box; width: 18px !important; height: 18px !important;
  padding: 10px; border-radius: var(--radius-md);
  background-color: var(--color-primary-soft); color: var(--color-primary) !important;
  stroke-width: 1.9;
}
.stat-tile[data-tone="success"] .stat-head > i, .stat-tile[data-tone="low"] .stat-head > i { background-color: var(--color-success-soft); color: var(--color-success) !important; }
.stat-tile[data-tone="warning"] .stat-head > i, .stat-tile[data-tone="medium"] .stat-head > i { background-color: var(--color-warning-soft); color: var(--color-warning) !important; }
.stat-tile[data-tone="info"] .stat-head > i { background-color: var(--color-info-soft); color: var(--color-info) !important; }
.stat-tile[data-tone="danger"] .stat-head > i, .stat-tile[data-tone="critical"] .stat-head > i { background-color: var(--color-danger-soft); color: var(--color-danger) !important; }
.stat-tile[data-tone="high"] .stat-head > i { background-color: var(--color-high-soft); color: var(--color-high) !important; }
.stat-tile[data-tone="neutral"] .stat-head > i { background-color: var(--color-elevated); color: var(--color-text-secondary) !important; }
.stat-tile .stat-eyebrow { font-family: var(--font-display); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-secondary); }
.stat-tile .stat-value { font-family: var(--font-mono); font-weight: 600; font-size: 2.25rem; letter-spacing: -0.02em; line-height: 1; color: var(--color-text-primary); font-variant-numeric: tabular-nums; }
.stat-tile .stat-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.stat-tile .stat-foot { font-family: var(--font-body); font-size: 0.8125rem; color: var(--color-text-muted); }
.stat-tile .stat-spark { width: 96px; height: 32px; color: var(--color-primary); }
.stat-tile[data-tone="success"] .stat-spark { color: var(--color-success); }
.stat-tile[data-tone="warning"] .stat-spark, .stat-tile[data-tone="medium"] .stat-spark { color: var(--color-warning); }
.stat-tile[data-tone="info"] .stat-spark { color: var(--color-info); }
.stat-tile[data-tone="danger"] .stat-spark, .stat-tile[data-tone="critical"] .stat-spark { color: var(--color-danger); }
.stat-tile[data-tone="high"] .stat-spark { color: var(--color-high); }
.stat-tile[data-tone="low"] .stat-spark { color: var(--color-success); }

/* Activity row — icon tile, title over subtitle, meta pinned right. Hover
   raises the row and shows a brand bar on its leading edge. */
.activity-list { display: flex; flex-direction: column; gap: 2px; }
.activity-row {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-md);
  background-color: transparent; text-align: left;
  transition: background-color var(--motion-base) var(--easing-standard);
}
.activity-row::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px;
  border-radius: 2px; background-color: var(--color-primary); opacity: 0;
  transition: opacity var(--motion-base) var(--easing-standard);
}
.activity-row:hover { background-color: var(--color-elevated); }
.activity-row:hover::before { opacity: 1; }
.activity-row .activity-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; flex: 1; }
.activity-row .activity-title { font-family: var(--font-display); font-size: 0.875rem; font-weight: 500; color: var(--color-text-primary); }
.activity-row .activity-sub { font-size: 0.8125rem; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row .activity-meta { font-family: var(--font-mono); font-size: 0.75rem; color: var(--color-text-muted); white-space: nowrap; flex-shrink: 0; }

/* Meter row — label + value over a thin rounded track (the reference's
   "Quick Stats" block). Width comes from an inline --pct or style="width:". */
.meter { display: flex; flex-direction: column; gap: var(--space-2); }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.meter-label { font-size: 0.875rem; color: var(--color-text-secondary); }
.meter-value { font-family: var(--font-mono); font-size: 0.875rem; font-weight: 600; color: var(--color-text-primary); font-variant-numeric: tabular-nums; }
.meter-track { height: 6px; border-radius: var(--radius-full); background-color: var(--color-elevated); overflow: hidden; }
.meter-fill { height: 100%; border-radius: var(--radius-full); background-color: var(--color-primary); transition: width var(--motion-slow) var(--easing-standard); }
.meter[data-tone="success"] .meter-fill, .meter[data-tone="low"] .meter-fill { background-color: var(--color-success); }
.meter[data-tone="warning"] .meter-fill, .meter[data-tone="medium"] .meter-fill { background-color: var(--color-warning); }
.meter[data-tone="info"] .meter-fill { background-color: var(--color-info); }
.meter[data-tone="danger"] .meter-fill, .meter[data-tone="critical"] .meter-fill { background-color: var(--color-danger); }
.meter[data-tone="high"] .meter-fill { background-color: var(--color-high); }

/* Table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: var(--space-3) var(--space-4);
  font-family: var(--font-display); font-size: 0.6875rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border); white-space: nowrap;
}
.data-table td {
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body); font-size: 0.875rem; color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background-color: rgba(255,255,255,0.02); }
.data-table td.mono { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--color-text-secondary); }
.data-table td.muted { color: var(--color-text-muted); font-size: 0.8125rem; }

/* Risk badge */
.risk-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding-inline: 8px; border-radius: var(--radius-full);
  font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.risk-badge[data-level="critical"] { background-color: var(--color-danger-soft); color: var(--color-danger); }
.risk-badge[data-level="high"] { background-color: var(--color-high-soft); color: var(--color-high); }
.risk-badge[data-level="medium"] { background-color: var(--color-warning-soft); color: var(--color-warning); }
.risk-badge[data-level="low"] { background-color: var(--color-success-soft); color: var(--color-success); }
.risk-badge[data-level="none"], .risk-badge:not([data-level]) { background-color: var(--color-elevated); color: var(--color-text-muted); }

/* Status badge */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding-inline: 8px; border-radius: var(--radius-full);
  font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 500;
}
.status-badge[data-status="complete"] { background-color: var(--color-success-soft); color: var(--color-success); }
.status-badge[data-status="pending"] { background-color: var(--color-elevated); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.status-badge[data-status="processing"] { background-color: var(--color-info-soft); color: var(--color-info); }
.status-badge[data-status="error"] { background-color: var(--color-danger-soft); color: var(--color-danger); }

/* Section header */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); gap: var(--space-4); }
.section-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; color: var(--color-text-primary); margin: 0; }
.eyebrow { font-family: var(--font-display); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-secondary); }

/* Skeleton loader */
.skeleton { background: linear-gradient(90deg, var(--color-elevated) 25%, var(--color-border-strong) 50%, var(--color-elevated) 75%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Loader — the mark itself, loading.
   logo1.png is five strata with one orange seam; this is that, with the seam
   travelling down through the layers. One element, no children, no JS: the grey
   strata are a repeating gradient, the seam is a second gradient layer stepped
   one bar at a time. `steps(5)` is what makes it read as rock settling rather
   than as a generic spinner sliding. Resize with --bar/--gap (see .loader-lg). */
.loader {
  --bar: 4px;
  --gap: 2px;
  --pitch: calc(var(--bar) + var(--gap));
  display: inline-block;
  vertical-align: middle;
  width: calc(var(--pitch) * 4.5);
  height: calc(var(--pitch) * 5 - var(--gap));
  background-image:
    linear-gradient(var(--color-primary), var(--color-primary)),
    repeating-linear-gradient(to bottom,
      var(--color-text-muted) 0 var(--bar), transparent var(--bar) var(--pitch));
  background-size: 100% var(--bar), 100% 100%;
  background-repeat: no-repeat;
  animation: strata 1.1s steps(5, end) infinite;
}
.loader-lg { --bar: 8px; --gap: 4px; }
/* Both layers are positioned every frame: background-position is per-layer, and
   naming only the seam would slide the strata along with it. */
@keyframes strata {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 0 calc(var(--pitch) * 5), 0 0; }
}
/* Parked on the middle seam — the logo at rest, not a loader that looks broken. */
@media (prefers-reduced-motion: reduce) {
  .loader { animation: none; background-position: 0 calc(var(--pitch) * 2), 0 0; }
}
/* Centred on its own line, for a whole panel that has nothing in it yet. */
.loader-block { display: flex; align-items: center; justify-content: center; padding: var(--space-10); }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-16) var(--space-6); gap: var(--space-3); text-align: center; }
.empty-state i { width: 40px; height: 40px; color: var(--color-text-muted); }
.empty-state p { color: var(--color-text-muted); font-size: 0.9375rem; margin: 0; max-width: 36ch; }

/* Page layout */
.page-body { padding: var(--space-8) 0 var(--space-16); display: flex; flex-direction: column; gap: var(--space-8); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; color: var(--color-text-primary); margin: 0 0 4px; }
.page-subtitle { font-family: var(--font-body); font-size: 0.9375rem; color: var(--color-text-secondary); margin: 0; }

/* Footer */
.page-footer { border-top: 1px solid var(--color-border); padding: var(--space-6) 0; }
.page-footer .container { display: flex; align-items: center; gap: var(--space-4); }
.footer-brand { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--font-mono); font-size: 0.75rem; color: var(--color-text-muted); }

/* Utility */
.divider { height: 1px; background: var(--color-border); border: 0; width: 100%; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.font-mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* ---- Toast: confirmation that a write landed. Built on demand by toast() in
   js/db.js, so no page carries markup for it. Bottom-centre — a top toast covers
   the header it is confirming a change to. ---- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200;
  transform: translate(-50%, 12px);
  max-width: min(90vw, 460px);
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-radius: var(--radius-lg);
  background: var(--color-elevated); color: var(--color-text-primary);
  border: 1px solid var(--color-border); box-shadow: var(--shadow-md);
  font-size: 0.875rem; font-weight: 500; line-height: 1.4;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast::before {
  content: '✓'; font-weight: 700; color: var(--color-success); flex-shrink: 0;
}
.toast[data-tone="error"] { border-color: var(--color-danger); }
.toast[data-tone="error"]::before { content: '!'; color: var(--color-danger); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
@media print { .toast { display: none; } }

/* ---- Read-only mode (RID-241): viewers see everything, manage nothing ---- */
body[data-readonly] .manage-only { display: none !important; }
body:not([data-readonly]) .readonly-only { display: none !important; }
/* Site administration is admin-only (RID-218/219). Applies once the role resolves
   (applyRoleGate stamps data-role); RLS blocks the action regardless. */
body[data-role]:not([data-role="admin"]) .admin-only { display: none !important; }

/* ---- Print (RID-240): every page prints as a light, chrome-free report ---- */
@media print {
  :root {
    --color-background: #ffffff;
    --color-surface: #ffffff;
    --color-elevated: #f3f4f6;
    --color-overlay: transparent;
    --color-border: #d4d7dd;
    --color-border-strong: #b9bdc7;
    --color-border-soft: rgba(0, 0, 0, 0.06);
    --color-text-primary: #111318;
    --color-text-secondary: #3c4250;
    --color-text-muted: #6a7080;
    --color-text-inverse: #ffffff;
    --color-primary: #B4470F;
    --color-success: #0f9d58;
    --color-warning: #b7791f;
    --color-info: #0e7490;
    --color-danger: #d61f3d;
    --color-success-soft: rgba(15, 157, 88, 0.12);
    --color-warning-soft: rgba(183, 121, 31, 0.12);
    --color-info-soft: rgba(14, 116, 144, 0.12);
    --color-danger-soft: rgba(214, 31, 61, 0.12);
  }
  body { background: #ffffff !important; }
  .page-nav, .page-footer, .btn, button, dialog, .ca-controls { display: none !important; }
  main { margin-left: 0 !important; } /* undo the sidebar content-shift */
  * { box-shadow: none !important; }
  a { color: inherit; text-decoration: none; }
  /* Wide tables must paginate, not clip inside their scroll containers. */
  .bench-wrap, .emp-list { overflow: visible !important; }
}
