/* ==================================================================
   WulfWatch — "Night desk" console
   One stylesheet for every page (base.html and login.html link it).

   World: a triage desk, not a showroom. Warm graphite surfaces, one
   steel-blue signal for links, focus and the primary action, and the
   three status hues (good / warning / bad) as the only other colour.
   Status is never colour alone: every status carries a shape glyph
   (circle / triangle / octagon) and a word.

   Tiers:
     1. Primitives  (--n-*, --ink*, hues)
     2. Roles       (--surface-*, --line*, --text-*, --status-*)
     3. Legacy      (names templates, charts.js and tests still read)
   ================================================================== */

/* ---- Self-hosted type: IBM Plex Sans + Plex Mono (OFL, static/fonts) */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2'); }

:root {
  color-scheme: dark;

  /* --- 1. Primitives ------------------------------------------- */
  --n-0: oklch(13.5% 0.006 70);   /* app ground */
  --n-1: oklch(17%   0.006 70);   /* panel */
  --n-2: oklch(20.5% 0.007 70);   /* raised: thead, inputs */
  --n-3: oklch(25%   0.008 70);   /* hover, overlay */
  --n-4: oklch(31%   0.008 70);
  --ink:   oklch(94% 0.006 80);
  --ink-2: oklch(83% 0.008 80);
  --ink-3: oklch(71% 0.010 80);   /* muted: >= 5:1 on --n-3 */

  --hue-accent: 236;
  --accent:        oklch(79% 0.095 var(--hue-accent));
  --accent-strong: oklch(73% 0.120 var(--hue-accent));
  --accent-ink:    oklch(17% 0.030 var(--hue-accent));
  /* Tints are dark, translucent washes (low L) so status text and ink
     on top keep their contrast; see e2e theme-regression legibility. */
  --accent-tint:   oklch(48% 0.090 var(--hue-accent) / 0.30);

  --good: oklch(77% 0.140 152);
  --warn: oklch(82% 0.135 78);
  --bad:  oklch(71% 0.175 27);
  --bad-fill: oklch(72% 0.165 27);
  --good-tint: oklch(45% 0.100 152 / 0.30);
  --warn-tint: oklch(50% 0.100 78  / 0.28);
  --bad-tint:  oklch(45% 0.130 27  / 0.34);
  --on-status: oklch(17% 0.020 60);  /* dark ink on solid status fills */

  /* --- 2. Roles ------------------------------------------------- */
  --surface-app:    var(--n-0);
  --surface-panel:  var(--n-1);
  --surface-raised: var(--n-2);
  --surface-hover:  var(--n-3);
  --line:        oklch(27% 0.008 70);
  /* Control borders (inputs, selects, checkboxes, outline buttons) must hold
     3:1 against every surface they sit on (WCAG 1.4.11): 54% L gives
     3.2:1 on --n-3 and 3.8:1 on the panel. */
  --line-strong: oklch(54% 0.009 70);
  --text:       var(--ink);
  --text-2:     var(--ink-2);
  --text-3:     var(--ink-3);
  --focus:      var(--accent);

  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Fixed product type scale, ratio ~1.125 */
  --fs-xs: 0.75rem;    /* 12 */
  --fs-sm: 0.8125rem;  /* 13 */
  --fs-md: 0.875rem;   /* 14 — tables, controls */
  --fs-base: 0.9375rem;/* 15 — body */
  --fs-lg: 1.0625rem;  /* 17 — panel titles */
  --fs-xl: 1.375rem;   /* 22 — page titles */

  /* 4px spacing scale */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem;
  --s-5: 1.5rem;  --s-6: 2rem;   --s-7: 3rem;

  /* Panels 10, controls 6, tags 4: nesting reads at a glance */
  --radius-panel: 10px;
  --radius: 6px;
  --radius-sm: 4px;
  --icon: 16px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 150ms;

  /* --- 3. Legacy names (templates, charts.js, JS, e2e still read) -- */
  --brand-100: oklch(94% 0.03 var(--hue-accent));
  --brand-200: oklch(88% 0.06 var(--hue-accent));
  --brand-300: var(--accent);
  --brand-400: var(--accent);
  --brand-500: var(--accent-strong);
  --brand-600: oklch(64% 0.12 var(--hue-accent));
  --brand-700: oklch(52% 0.11 var(--hue-accent));
  --brand-800: oklch(36% 0.07 var(--hue-accent));
  --brand-900: oklch(24% 0.04 var(--hue-accent));
  --ink-50:  var(--ink);
  --ink-100: oklch(90% 0.006 80);
  --ink-200: var(--ink-2);
  --ink-300: var(--ink-3);
  --ink-400: oklch(58% 0.010 80);
  --ink-500: oklch(45% 0.010 80);
  --ink-600: var(--n-4);
  --ink-700: var(--n-3);
  --ink-800: var(--n-1);
  --ink-900: oklch(15% 0.006 70);
  --ink-950: var(--n-0);
  --c-success: var(--good);
  --c-warning: var(--warn);
  --c-danger:  var(--bad);
  --c-info:    var(--accent);
  --bg-app:      var(--surface-app);
  --bg-surface:  var(--surface-panel);
  --bg-raised:   var(--surface-raised);
  --bg-overlay:  var(--surface-hover);
  --bg-tint-brand:   var(--accent-tint);
  --bg-tint-success: var(--good-tint);
  --bg-tint-warning: var(--warn-tint);
  --bg-tint-danger:  var(--bad-tint);
  --bg-tint-info:    var(--accent-tint);
  --border-subtle:  var(--line);
  --border-default: var(--line-strong);
  --border-strong:  oklch(60% 0.010 70);   /* hover/emphasis border: >= 4:1 */
  --border-focus:   var(--focus);
  --text-primary:    var(--text);
  --text-secondary:  var(--text-2);
  --text-muted:      var(--text-3);
  --text-on-brand:   var(--accent-ink);
  --text-on-warning: var(--on-status);
  --text-on-success: var(--on-status);
  --text-link:       var(--accent);
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: 0 12px 32px -12px oklch(0% 0 0 / 0.6);
  --shadow-glow: none;
  --radius-md: var(--radius);
  --radius-lg: var(--radius);
  --ease: var(--ease-out);
  --midnight-start: var(--brand-800);
  --midnight-end:   var(--brand-700);
  --electric-grape: var(--accent-strong);
  --amber-burst:    var(--warn);
  --crimson-bloom:  var(--bad);
  --lunar-lilac:    var(--accent);
  --obsidian:       var(--ink-900);
  --charcoal:       var(--surface-panel);
  --violet-mist:    var(--line-strong);
  --ghost-white:    var(--text);
  --moon-dust:      var(--text-2);

  /* Bootstrap variables so its own components inherit the world */
  --bs-body-bg: var(--surface-app);
  --bs-body-color: var(--text);
  --bs-body-font-family: var(--font-sans);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--text-3);
  --bs-link-color-rgb: 141, 190, 232;
  --bs-emphasis-color: var(--text);
}

/* ================================================================
   Base
   ================================================================ */
html { scroll-padding-top: calc(var(--nav-h, 56px) + 12px); }
body {
  background: var(--surface-app);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  caret-color: var(--accent);
  accent-color: var(--accent-strong);
}
main { flex: 1 0 auto; }

/* 500 is the heading weight; 600 is kept for the L2 tag alone. No negative
   tracking below 40px. */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.25;
  text-wrap: balance;
}
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-base); }
h4, h5, h6 { font-size: var(--fs-md); }

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--brand-200); text-decoration: underline; }

::selection { background: oklch(73% 0.12 var(--hue-accent) / 0.35); color: var(--text); }

/* Scrollbars from the palette, not the OS default */
* { scrollbar-color: var(--n-4) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--n-4); border-radius: 10px; border: 2px solid var(--surface-app); }

.mono, code, kbd, samp { font-family: var(--font-mono); }
.num, .tabular, time, td, .status-strip__count { font-variant-numeric: tabular-nums; }
kbd {
  font-size: var(--fs-xs);
  padding: 0 var(--s-1);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-2);
}

/* ---- Focus: one ring everywhere --------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
.btn:focus-visible,
.page-link:focus-visible,
.dropdown-item:focus-visible,
.navbar-nav .nav-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.btn:focus, .btn.focus, .page-link:focus { box-shadow: none; }

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -3rem;
  z-index: 2000;
  padding: var(--s-2) var(--s-3);
  background: var(--accent-strong);
  color: var(--accent-ink);
  border-radius: var(--radius);
  font-weight: 500;
}
.skip-link:focus { top: var(--s-2); color: var(--accent-ink); text-decoration: none; }

/* ================================================================
   App shell
   ================================================================ */
.navbar {
  background: var(--surface-app) !important;
  border-bottom: 1px solid var(--line);
  padding-block: 0;
  min-height: 56px;
}
.navbar.sticky-top { top: 0; z-index: 1030; }
.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 500;
  font-size: var(--fs-base);
  letter-spacing: 0;
  color: var(--text) !important;
  padding-block: var(--s-3);
}
.navbar-nav { gap: var(--s-1); }
.navbar-nav .nav-link {
  position: relative;
  color: var(--text-3) !important;
  font-size: var(--fs-md);
  font-weight: 500;
  padding: var(--s-4) var(--s-3) !important;
  border-radius: 0;
  transition: color var(--t-fast) var(--ease-out);
}
.navbar-nav .nav-link:hover { color: var(--text) !important; background: transparent; text-decoration: none; }
/* Current page: brighter ink AND a bar — not colour alone */
.navbar-nav .nav-link.active,
.navbar-nav .nav-link[aria-current="page"] { color: var(--text) !important; }
.navbar-nav .nav-link.active::after {
  content: "";
  position: absolute;
  left: var(--s-3);
  right: var(--s-3);
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}
.navbar-nav .nav-logout {
  background: none;
  border: 0;
  color: var(--text-3);
}
.navbar-toggler {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--s-1) var(--s-2);
}
.navbar-toggler:focus { box-shadow: none; }

@media (max-width: 991.98px) {
  .navbar-collapse { padding-bottom: var(--s-3); }
  .navbar-nav .nav-link { padding: var(--s-2) var(--s-1) !important; }
  .navbar-nav .nav-link.active::after { left: -0.75rem; right: auto; top: 25%; bottom: 25%; width: 2px; height: auto; }
}

.app-main { padding-block: var(--s-5) var(--s-7); }

.app-footer {
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: var(--fs-xs);
  padding-block: var(--s-4);
}

/* ---- Page header ------------------------------------------------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3) var(--s-5);
  margin-bottom: var(--s-5);
}
.page-head h1 { margin: 0; }
.page-head__title { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.page-head__lede {
  margin: var(--s-1) 0 0;
  color: var(--text-3);
  font-size: var(--fs-md);
  max-width: 72ch;
}
.page-head__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-3);
  color: var(--text-3);
  font-size: var(--fs-sm);
  overflow: hidden;   /* clips a separator dot that would start a wrapped line */
}
.meta-line > * { position: relative; }
/* The separator dot sits centred in the gap before an item. An item that
   wraps to the start of a line has its dot left of the box, where the
   overflow clip hides it, so no line ever starts with a dangling dot. */
.meta-line > * + *::before {
  content: "";
  position: absolute;
  left: calc(var(--s-3) / -2 - 1.5px);
  top: 50%;
  width: 3px; height: 3px;
  margin-top: -1.5px;
  border-radius: 50%;
  background: var(--n-4);
}

.breadcrumb { font-size: var(--fs-sm); margin-bottom: var(--s-3); --bs-breadcrumb-divider-color: var(--text-3); }
.breadcrumb-item.active { color: var(--text-3); }

.section-title {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-2);
  margin: var(--s-6) 0 var(--s-3);
}

/* ================================================================
   Panels (Bootstrap .card restyled: flat, hairline, no hover theatre)
   ================================================================ */
.card {
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  color: var(--text);
  box-shadow: none;
  --bs-card-bg: var(--surface-panel);
  --bs-card-border-color: var(--line);
  --bs-card-cap-bg: transparent;
}
.card:hover { transform: none; box-shadow: none; }
.card + .card, .panel-gap { margin-top: var(--s-4); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  padding: var(--s-3) var(--s-4);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  min-height: 52px;
}
.card-header h2, .card-header h3, .card-header .card-title {
  font-size: var(--fs-base);
  font-weight: 500;
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-2);
}
.card-header .count {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-3);
}
.card-header .hint { color: var(--text-3); font-size: var(--fs-sm); font-weight: 400; }
.card-body { padding: var(--s-4); color: var(--text); }
.card-footer { background: transparent; border-top: 1px solid var(--line); }
/* Tables that end a panel follow its rounded corners (the scroller clips) */
.card > .table-scroll:last-child { border-radius: 0 0 calc(var(--radius-panel) - 1px) calc(var(--radius-panel) - 1px); }
.card-note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-1) var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.card-note a { font-weight: 500; }
.card-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-raised);
}

/* Status-coloured headers are retired from the templates; JS-built
   technician report markup still uses them, so keep them legible and
   quiet: neutral fill, status hue only on the title text. */
.card-header.bg-danger,
.card-header.bg-warning,
.card-header.bg-success,
.card-header.bg-info,
.card-header.bg-dark,
.card-header.bg-primary { background: var(--surface-raised) !important; color: var(--text) !important; }
.card-header.bg-danger  :is(h1,h2,h3,h4,h5,h6) { color: var(--bad); }
.card-header.bg-warning :is(h1,h2,h3,h4,h5,h6) { color: var(--warn); }
.card-header.bg-success :is(h1,h2,h3,h4,h5,h6) { color: var(--good); }
.card-header.bg-info    :is(h1,h2,h3,h4,h5,h6) { color: var(--accent); }

/* ================================================================
   Status vocabulary — shape + word + hue, everywhere
   ================================================================ */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
  color: var(--text-2);
  background: var(--surface-raised);
}
.status-glyph {
  flex: none;
  width: 0.7em;
  height: 0.7em;
  background: currentColor;
}
.status-tag--good    { color: var(--good); background: var(--good-tint); border-color: oklch(77% 0.14 152 / 0.28); }
.status-tag--warning { color: var(--warn); background: var(--warn-tint); border-color: oklch(82% 0.135 78 / 0.30); }
.status-tag--bad     { color: var(--bad);  background: var(--bad-tint);  border-color: oklch(71% 0.175 27 / 0.34); }
.status-tag--unknown { color: var(--text-2); border-color: var(--line-strong); }
/* Good = circle, Warning = triangle, Bad = octagon (stop), Unknown = ring */
.status-tag--good .status-glyph    { border-radius: 50%; }
.status-tag--warning .status-glyph { clip-path: polygon(50% 4%, 100% 96%, 0 96%); width: 0.8em; }
.status-tag--bad .status-glyph     { clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.status-tag--unknown .status-glyph { background: transparent; border: 1.5px solid currentColor; border-radius: 50%; }
/* Missing: derived silence (staleness.py), never a stored status. Dashed ring = "no signal". */
.status-tag--missing { color: var(--text-2); border-style: dashed; border-color: var(--line-strong); }
.status-tag--missing .status-glyph { background: transparent; border: 1.5px dashed currentColor; border-radius: 50%; }
/* Quiet: glyph in its hue plus the word, no pill. For tables where status
   is one column among many (Recent activity, system Reports). The tinted
   pill stays only in the triage list, where status is the point. */
.status-tag.status-tag--quiet { background: transparent; border-color: transparent; padding-left: 0; padding-right: 0; color: var(--text-2); }
.status-tag--quiet.status-tag--good .status-glyph    { color: var(--good); }
.status-tag--quiet.status-tag--warning .status-glyph { color: var(--warn); }
.status-tag--quiet.status-tag--bad .status-glyph     { color: var(--bad); }
/* Muted: shape and word only (critical queue, where the urgency tag is the
   row's one red and the status is context) */
.status-tag.status-tag--muted { background: transparent; border-color: transparent; padding-left: 0; padding-right: 0; color: var(--text-3); }

/* Urgency: L2 solid, L1 outlined. Fill vs outline + the words carry it. */
.urgency-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  border: 1px solid var(--bad);
}
.urgency-tag__level { font-family: var(--font-mono); font-weight: 500; }
.urgency-tag--l2 { background: var(--bad-fill); color: var(--on-status); border-color: var(--bad-fill); font-weight: 600; }
.urgency-tag--l1 { background: transparent; color: var(--bad); }
.urgency-tag--other { border-color: var(--line-strong); color: var(--text-2); }

/* Neutral classification chip (failure category, tier, flags) */
.chip {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  background: transparent;
  white-space: nowrap;
}
.chip--accent { border-color: oklch(73% 0.12 var(--hue-accent) / 0.45); color: var(--accent); }
.chip--warn { border-color: oklch(82% 0.135 78 / 0.45); color: var(--warn); }

.stale { color: var(--warn); font-weight: 500; }

/* Inline status text (e.g. "Last good backup" past due) */
.text-bad  { color: var(--bad) !important; }
.text-warn { color: var(--warn) !important; }

/* Status-change flash after a soft refresh: one brief ring, no scale */
.status-pill-flash { animation: status-flash 1.2s var(--ease-out); }
@keyframes status-flash {
  0%   { box-shadow: 0 0 0 0 var(--pill-flash-color, var(--accent)); }
  100% { box-shadow: 0 0 0 6px transparent; }
}

/* ================================================================
   Status strip (dashboard summary + filter)
   ================================================================ */
.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  margin-bottom: var(--s-4);
  overflow: hidden;
}
.status-strip__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  color: var(--text-2);
  font-size: var(--fs-md);
  font-weight: 500;
  border-right: 1px solid var(--line);
  position: relative;
  transition: background-color var(--t-fast) var(--ease-out);
}
.status-strip__item:last-child { border-right: 0; }
.status-strip__item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.status-strip__item[aria-current="true"] { background: var(--surface-raised); color: var(--text); }
.status-strip__item[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--accent);
}
.status-strip__label { display: inline-flex; align-items: center; gap: var(--s-2); }
.status-strip__label .status-glyph { width: 0.65rem; height: 0.65rem; }
.status-strip__item--bad .status-glyph { color: var(--bad); clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.status-strip__item--warning .status-glyph { color: var(--warn); clip-path: polygon(50% 4%, 100% 96%, 0 96%); width: 0.75rem; }
.status-strip__item--good .status-glyph { color: var(--good); border-radius: 50%; }
.status-strip__item--all .status-glyph { color: var(--text-3); background: transparent; border: 1.5px solid currentColor; border-radius: 50%; }
.status-strip__count {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}
.status-strip__item--bad .status-strip__count.is-nonzero { color: var(--bad); }
@media (max-width: 575.98px) {
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-strip__item:nth-child(2) { border-right: 0; }
  .status-strip__item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

/* ================================================================
   Tables
   ================================================================ */
.table,
.table-dark {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--line);
  --bs-table-hover-bg: var(--surface-hover);
  --bs-table-hover-color: var(--text);
  --bs-table-striped-bg: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  margin-bottom: 0;
}
.table > :not(caption) > * > * {
  background: transparent;
  color: inherit;
  border-color: var(--line);
  padding: var(--s-3);
  vertical-align: middle;
}
.table > :not(caption) > * > *:first-child { padding-left: var(--s-4); }
.table > :not(caption) > * > *:last-child { padding-right: var(--s-4); }
.table thead th,
.table-dark thead th {
  background: var(--surface-raised);
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  padding-block: var(--s-2);
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table-hover tbody tr:hover > * { background: var(--surface-hover) !important; color: var(--text) !important; }
.table .cell-id {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}
.table a.cell-id { color: var(--accent); }
.table .cell-sub { display: block; color: var(--text-3); font-size: var(--fs-xs); margin-top: 2px; }
.table .cell-time { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
/* Relative times ("3h ago") read as words: sans with tabular figures. Mono
   stays for system IDs, absolute timestamps and counts. */
time[data-reltime] { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.table .cell-analysis { min-width: 16rem; max-width: 32rem; }
.table .cell-num { font-family: var(--font-mono); text-align: right; }
.table .cell-muted { color: var(--text-3); }
.table .truncate {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* position: relative so visually-hidden (absolute) labels inside cells are
   clipped by the scroller instead of widening the whole page */
.table-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Bootstrap row-state utilities (JS-built markup) */
.table-info    > td, .table-info    > th { background: var(--accent-tint) !important; color: var(--text); }
.table-warning > td, .table-warning > th { background: var(--warn-tint) !important; color: var(--text); }
.table-danger  > td, .table-danger  > th { background: var(--bad-tint)  !important; color: var(--text); }
.table-success > td, .table-success > th { background: var(--good-tint) !important; color: var(--text); }
/* Same-hue text inside a same-hue tint falls back to ink so it stays legible */
.table-success > td.text-success, .table-success > td .text-success,
.table-success > th.text-success, .table-success > th .text-success,
.table-warning > td.text-warning, .table-warning > td .text-warning,
.table-warning > th.text-warning, .table-warning > th .text-warning,
.table-danger  > td.text-danger,  .table-danger  > td .text-danger,
.table-danger  > th.text-danger,  .table-danger  > th .text-danger,
.table-info    > td.text-info,    .table-info    > td .text-info,
.table-info    > th.text-info,    .table-info    > th .text-info { color: var(--text-primary) !important; }

/* Pinned (flagged) rows: a quiet accent wash plus the "Pinned" chip */
tr[data-pinned="true"] > * { background: var(--accent-tint) !important; }

/* ---- Triage + queue tables stack into rows on phones ------------- */
@media (max-width: 767.98px) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody { display: block; }
  .table-stack tbody tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "lead main side"
      "lead meta act";
    gap: var(--s-1) var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
  }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack tbody tr > * { border: 0 !important; padding: 0 !important; display: block; }
  .table-stack tbody tr > [data-cell="lead"] { grid-area: lead; padding-top: 2px !important; }
  .table-stack tbody tr > [data-cell="main"] { grid-area: main; min-width: 0; }
  .table-stack tbody tr > [data-cell="side"] { grid-area: side; justify-self: end; }
  .table-stack tbody tr > [data-cell="meta"] { grid-area: meta; }
  .table-stack tbody tr > [data-cell="act"]  { grid-area: act; justify-self: end; align-self: end; }
  .table-stack tbody tr > [data-cell="wide"] { grid-column: 1 / -1; }
  /* Tables with no lead cell (system Reports) */
  .table-stack--nolead tbody tr {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "main side" "wide wide" "meta act";
  }
  .table-stack--nolead tbody tr > [data-cell="wide"] { grid-area: wide; min-width: 0; max-width: none; }
  .table-stack tbody tr > [data-cell="meta-inline"] { display: none; }
  .table-stack tbody tr > [data-cell="meta"] .meta-line { font-size: var(--fs-xs); }
  .table-stack tbody tr[data-search-empty] { display: block; }
  .table-stack .hide-stacked { display: none !important; }
}
@media (min-width: 768px) {
  .table-stack [data-cell="meta"] { display: none; }
}

/* ---- Row actions: one quiet vocabulary, labelled ----------------- */
.row-actions { display: inline-flex; gap: var(--s-1); flex-wrap: nowrap; }
.btn.btn-icon {
  --size: 32px;
  width: var(--size);
  height: var(--size);
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--line-strong);
}
.row-actions .dropdown { display: inline-flex; }
.btn.btn-icon:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
/* The overflow button reads as secondary to Resolve: no outline until used */
.btn.btn-icon.row-actions__more { border-color: transparent; }
.btn.btn-icon.row-actions__more:hover,
.btn.btn-icon.row-actions__more[aria-expanded="true"] { border-color: var(--line-strong); background: var(--surface-hover); color: var(--text); }
/* One icon size and stroke everywhere (feather, 16px at 1.5) */
.btn svg.feather, .btn.btn-icon svg, .dropdown-item svg.feather {
  width: var(--icon); height: var(--icon); flex: none; stroke-width: 1.5;
}

/* ================================================================
   Buttons
   ================================================================ */
.btn {
  --bs-btn-font-size: var(--fs-md);
  border-radius: var(--radius);
  font-weight: 500;
  border: 1px solid transparent;
  padding: var(--s-2) var(--s-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  line-height: 1.3;
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.btn-sm { padding: var(--s-1) var(--s-3); font-size: var(--fs-sm); }
.btn:disabled, .btn.disabled { opacity: 0.55; }
.btn-primary,
.btn-info {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-ink);
}
.btn-primary:hover, .btn-info:hover,
.btn-primary:focus-visible, .btn-info:focus-visible {
  background: oklch(78% 0.115 var(--hue-accent));
  border-color: oklch(78% 0.115 var(--hue-accent));
  color: var(--accent-ink);
  transform: none;
}
.btn-primary:active, .btn-info:active { background: oklch(68% 0.12 var(--hue-accent)) !important; color: var(--accent-ink) !important; }
.btn-secondary,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-info,
.btn-outline-success,
.btn-outline-warning {
  background: var(--surface-raised);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-secondary:hover,
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-info:hover,
.btn-outline-success:hover,
.btn-outline-warning:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
  transform: none;
}
.btn-outline-primary.show, .btn-outline-primary:active { background: var(--surface-hover) !important; color: var(--text) !important; border-color: var(--border-strong) !important; }
.btn-success, .btn-warning, .btn-danger {
  border-color: transparent;
  color: var(--on-status);
}
.btn-success { background: var(--good); }
.btn-warning { background: var(--warn); }
.btn-danger  { background: var(--bad-fill); }
.btn-success:hover, .btn-warning:hover, .btn-danger:hover { filter: brightness(1.06); color: var(--on-status); transform: none; }
.btn-outline-danger { background: transparent; border-color: oklch(71% 0.175 27 / 0.55); color: var(--bad); }
.btn-outline-danger:hover, .btn-outline-danger:focus { background: var(--bad-tint); border-color: var(--bad); color: var(--bad); box-shadow: none; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-link { color: var(--accent); }
.btn-close { filter: invert(1) grayscale(1); opacity: 0.7; }
.btn-close:hover { opacity: 1; }

/* Loading */
.btn-loading { position: relative; pointer-events: none; opacity: 0.75; }
.btn-loading .btn-spinner,
.btn-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
.spinner { animation: spin 1s linear infinite; }
.spinner-border { color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }


/* ================================================================
   Forms
   ================================================================ */
.form-label {
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: var(--s-1);
}
.form-control, .form-select {
  background-color: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--fs-md);
  padding: var(--s-2) var(--s-3);
  transition: border-color var(--t-fast) var(--ease-out);
}
.form-select { padding-right: var(--s-6); }
.form-control-sm, .form-select-sm { font-size: var(--fs-sm); padding: var(--s-1) var(--s-2); }
.form-select-sm { padding-right: var(--s-6); }
.form-control::placeholder { color: var(--text-3); opacity: 1; }
.form-control:focus, .form-select:focus {
  background-color: var(--surface-raised);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(73% 0.12 var(--hue-accent) / 0.22);
  color: var(--text);
}
.form-control[readonly] { background: var(--surface-panel); color: var(--text-2); }
.form-text { color: var(--text-3); font-size: var(--fs-sm); }
.form-check-input { background-color: var(--surface-raised); border-color: var(--border-strong); }
.form-check-input:checked, .form-check-input:indeterminate { background-color: var(--accent-strong); border-color: var(--accent-strong); }
.form-check-input:focus { box-shadow: 0 0 0 3px oklch(73% 0.12 var(--hue-accent) / 0.25); border-color: var(--accent); }
.input-group > .btn { border-radius: var(--radius); }
.input-group > :not(:first-child):not(.dropdown-menu) { margin-left: -1px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > :not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.search-field { position: relative; }
.search-field input { padding-right: var(--s-6); width: 15rem; max-width: 100%; }
.search-field kbd { position: absolute; right: var(--s-2); top: 50%; transform: translateY(-50%); pointer-events: none; }
.search-field input:focus + kbd, .search-field input:not(:placeholder-shown) + kbd { display: none; }

.filter-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); }
.filter-form .filter-field { min-width: 9rem; }
.filter-form .form-label { font-size: var(--fs-xs); color: var(--text-3); }
.filter-form__buttons { display: flex; gap: var(--s-2); }
/* The Filters disclosure exists only on phones */
.filters-toggle { display: none; }
@media (max-width: 575.98px) {
  .filters-toggle { display: inline-flex; min-height: 36px; }
  .filters-panel:not(.is-open) { display: none; }
  .filter-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .filter-form .filter-field { min-width: 0; }
  .filter-form .form-select { width: 100%; }
  .filter-form__buttons { grid-column: 1 / -1; }
}

/* ================================================================
   Facts (definition grid on system detail)
   ================================================================ */
.facts {
  /* Four facts, four columns (two on phones): every row is full, so no
     empty cells. Hairlines come from the 1px gap over the line colour. */
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
  border-top: 1px solid var(--line);
  border-radius: 0 0 calc(var(--radius-panel) - 1px) calc(var(--radius-panel) - 1px);
  overflow: hidden;
}
.facts:not(:last-child) { border-radius: 0; }
.facts > div { padding: var(--s-3) var(--s-4); background: var(--surface-panel); }
@media (max-width: 767.98px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.facts dt { font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); margin-bottom: var(--s-1); }
.facts dd { margin: 0; font-family: var(--font-mono); font-size: var(--fs-md); color: var(--text); }
.facts dd .cell-sub { font-family: var(--font-sans); color: var(--text-3); font-size: var(--fs-xs); display: block; margin-top: 2px; }

.action-bar { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-4); }

/* Lanes (critical page) */
.lane-list { list-style: none; margin: 0; padding: 0; }
.lane-list > li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.lane-list > li:last-child { border-bottom: 0; }
.lane-list .lane-note { font-size: var(--fs-sm); color: var(--text-2); margin-top: var(--s-1); overflow-wrap: anywhere; }
.lane-list .lane-actions { display: flex; flex-direction: column; gap: var(--s-1); flex: none; }
.lane-scroll { max-height: 22rem; overflow-y: auto; }

/* ================================================================
   Empty / loading / error states
   ================================================================ */
.empty-state {
  padding: var(--s-6) var(--s-4);
  text-align: center;
  max-width: 46ch;
  margin-inline: auto;
}
.empty-state--compact { padding: var(--s-4); text-align: left; max-width: none; }
.empty-state__title { font-size: var(--fs-base); font-weight: 500; margin: 0 0 var(--s-1); color: var(--text); }
.empty-state p { color: var(--text-3); font-size: var(--fs-md); margin: 0 0 var(--s-3); }
.empty-state p:last-child { margin-bottom: 0; }
.empty-state .status-tag { margin-bottom: var(--s-3); }

.state-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 12rem;
  color: var(--text-3);
  font-size: var(--fs-md);
  text-align: center;
  padding: var(--s-4);
}
.state-msg--error { color: var(--text-2); }
.state-msg--error::before {
  content: "";
  width: 0.7em; height: 0.7em;
  background: var(--bad);
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
}

/* Soft auto-refresh: a calm sweep over the rows being replaced */
.skeleton-loading { position: relative; }
.skeleton-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  background: linear-gradient(90deg, transparent, oklch(80% 0.01 80 / 0.06), transparent);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
  pointer-events: none;
}
@keyframes skeleton-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ================================================================
   Charts
   ================================================================ */
.chart-container { position: relative; height: 260px; margin: 0; padding: 0; background: transparent; border: 0; }
canvas { background: transparent; }
@media (max-width: 767.98px) { .chart-container { height: 220px; } }

/* Failure reasons (narrow) beside Recent failures (wide) */
.split-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--s-4); align-items: start; }
.split-grid > .card { margin: 0; }
@media (max-width: 991.98px) { .split-grid { grid-template-columns: minmax(0, 1fr); } }

/* Recent failure list (charts.js markup) */
#recent-errors-list strong { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 500; }
.lane-time { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }

/* Failure reasons: a ranked list with thin bars. Neutral bars; only the
   largest reason takes the Bad hue. */
.rank-list { list-style: none; margin: 0; padding: var(--s-2) var(--s-4) var(--s-4); }
.rank-list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 3.5ch;
  align-items: baseline;
  column-gap: var(--s-3);
  padding-top: var(--s-3);
  font-size: var(--fs-md);
}
.rank-list__label { color: var(--text); overflow-wrap: anywhere; }
.rank-list__value { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text); }
.rank-list__share { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); text-align: right; }
.rank-list__bar { grid-column: 1 / -1; height: 4px; margin-top: var(--s-1); background: var(--n-2); border-radius: 2px; overflow: hidden; }
.rank-list__bar > span { display: block; height: 100%; background: var(--ink-3); border-radius: 2px; }
.rank-list__item.is-top .rank-list__bar > span { background: var(--bad); }

/* ================================================================
   Run grid: "Last 14 nights". One row per system, one cell per Central-
   time night, the status glyph as the cell mark. Every colour in it is a
   run result; the accent marks today's column only.
   ================================================================ */
.run-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-4);
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.run-legend li { display: inline-flex; align-items: center; gap: 6px; }

.run-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--n-2);
  vertical-align: middle;
}
/* 12-14px glyphs: at 10px the octagon rendered as a dot, so Bad and Good
   differed only by hue. In the grid Bad is a solid square (the octagon's
   stop block, without corners that blur into a circle at this size), so
   circle, triangle and square stay apart in grayscale. */
.run-cell .status-glyph { width: 12px; height: 12px; }
.run-cell--good    { color: var(--good); }
.run-cell--warning { color: var(--warn); }
.run-cell--bad     { color: var(--bad); }
.run-cell--unknown { color: var(--text-2); }
.run-cell--good .status-glyph    { border-radius: 50%; }
.run-cell--warning .status-glyph { clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 14px; height: 13px; }
.run-cell--bad .status-glyph     { clip-path: none; border-radius: 1px; width: 12px; height: 12px; }
.run-cell--good .status-glyph    { width: 13px; height: 13px; }
.run-cell--unknown .status-glyph { background: transparent; border: 1.5px solid currentColor; border-radius: 50%; }
/* No report that night: an empty hairline square (>= 3:1 on the panel) */
.run-cell--none { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
/* Every report that night was marked false positive: shape stays, hue goes */
.run-cell.is-flagged { color: var(--text-3); }

.run-grid { width: 100%; border-collapse: collapse; font-size: var(--fs-md); table-layout: fixed; }
.run-grid th, .run-grid td { padding: 0; border: 0; vertical-align: middle; }
.run-grid thead th {
  position: relative;
  padding: var(--s-2) 2px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  text-align: center;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}
.run-grid thead th.run-grid__sys { font-family: var(--font-sans); font-weight: 500; text-align: left; padding-left: var(--s-4); }
.run-grid thead th.run-grid__age { font-family: var(--font-sans); font-weight: 500; text-align: right; padding-right: var(--s-4); }
.run-grid thead th.is-today { color: var(--accent); }
.run-grid thead th.is-today::before {
  content: "";
  position: absolute;
  left: 4px; right: 4px; top: 0;
  height: 2px;
  background: var(--accent);
}
.run-grid .run-grid__sys { width: 15rem; text-align: left; }
.run-grid .run-grid__age { width: 6.5rem; text-align: right; }
.run-grid tbody th.run-grid__sys { padding: 6px var(--s-3) 6px var(--s-4); font-weight: 400; min-width: 0; }
.run-grid tbody td.run-grid__night { padding: 6px 2px; text-align: center; }
.run-grid tbody td.run-grid__age {
  padding: 6px var(--s-4) 6px var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.run-grid tbody td.run-grid__age.is-overdue { color: var(--bad); font-weight: 500; }
.run-grid tbody tr { border-bottom: 1px solid var(--line); }
.run-grid tbody tr:last-child { border-bottom: 0; }
.run-grid tbody tr:hover > * { background: var(--surface-hover); }
.run-grid .cell-id { display: block; font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 500; color: var(--text); }
/* IDs are ink; the accent appears only on hover/focus, so today's column
   stays the grid's one accent at rest */
.run-grid .cell-id:hover, .run-grid .cell-id:focus-visible { color: var(--accent); }
.run-grid .cell-sub { display: block; color: var(--text-3); font-size: var(--fs-xs); margin-top: 2px; }
.run-grid .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Phones: system and age on one line, the 14 nights full width below */
@media (max-width: 767.98px) {
  .run-grid, .run-grid thead, .run-grid tbody { display: block; }
  .run-grid tr {
    display: grid;
    grid-template-columns: repeat(14, minmax(0, 1fr));
    column-gap: 3px;
    padding: var(--s-2) var(--s-3);
  }
  .run-grid thead tr { padding-block: 0; background: var(--surface-raised); border-bottom: 1px solid var(--line); }
  .run-grid thead th { border-bottom: 0; background: transparent; padding: var(--s-2) 0; }
  /* Pin every cell to its row so header and body nights share columns:
     system and age on row 1, the 14 nights on row 2 in order. */
  .run-grid .run-grid__sys { grid-row: 1; grid-column: 1 / 11; width: auto; padding: 0 0 var(--s-1) !important; }
  .run-grid .run-grid__age { grid-row: 1; grid-column: 11 / 15; width: auto; padding: 0 0 var(--s-1) !important; align-self: start; }
  .run-grid thead th.run-grid__sys, .run-grid thead th.run-grid__age { padding-block: var(--s-2) 0 !important; }
  .run-grid .run-grid__night { grid-row: 2; }
  .run-grid tbody td.run-grid__night { padding: 0; }
  /* "Today" is wider than a phone column: let it overhang, centred */
  .run-grid thead th.is-today::before { top: auto; bottom: 0; }
  .run-grid thead th.is-today { display: flex; justify-content: center; overflow: visible; white-space: nowrap; font-family: var(--font-sans); font-size: 11px; }
}

/* System detail: the last good backup, large, above its 14-night strip */
.vital {
  display: grid;
  grid-template-columns: minmax(14rem, auto) minmax(0, 1fr);
  gap: var(--s-4) var(--s-6);
  align-items: end;
  padding: var(--s-5) var(--s-4) var(--s-4);
  border-top: 0;
}
.vital__label { margin: 0 0 var(--s-2); color: var(--text-3); font-size: var(--fs-xs); font-weight: 500; }
.vital__label .hint { font-weight: 400; margin-left: var(--s-2); }
.vital__value {
  margin: 0;
  font-size: 1.75rem;            /* 28 */
  font-weight: 500;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.vital__value.is-overdue { color: var(--bad); }
.vital__value.is-pending { color: var(--warn); }
.vital__sub {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-3);
  margin: var(--s-2) 0 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.run-strip {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: var(--s-1);
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 44rem;
}
.run-strip__night { display: flex; flex-direction: column; align-items: center; gap: var(--s-1); }
.run-strip .run-cell { width: 100%; height: 28px; }
.run-strip__day { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); line-height: 1; }
.run-strip__night.is-today .run-strip__day { color: var(--accent); }
.run-strip__night.is-today .run-cell { box-shadow: inset 0 2px 0 var(--accent); }
.run-strip__night.is-today .run-cell--none { box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 2px 0 var(--accent); }
@media (max-width: 767.98px) {
  .vital { grid-template-columns: minmax(0, 1fr); padding-top: var(--s-4); }
  .run-strip { gap: 3px; }
  .run-strip__night { min-width: 0; }
  .run-strip__night.is-today .run-strip__day { font-family: var(--font-sans); font-size: 11px; white-space: nowrap; }
}

/* ================================================================
   Bootstrap components in the world
   ================================================================ */
.badge {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: 0;
  border-radius: var(--radius-sm);
  padding: var(--s-1) var(--s-2);
}
.badge.bg-success   { background: var(--good) !important;     color: var(--on-status) !important; }
.badge.bg-warning   { background: var(--warn) !important;     color: var(--on-status) !important; }
.badge.bg-danger    { background: var(--bad-fill) !important; color: var(--on-status) !important; }
.badge.bg-info      { background: var(--accent) !important;   color: var(--accent-ink) !important; }
.badge.bg-primary   { background: var(--accent-strong) !important; color: var(--accent-ink) !important; }
.badge.bg-secondary,
.badge.bg-dark      { background: var(--surface-hover) !important; color: var(--text-2) !important; border: 1px solid var(--line-strong); }

.status-good,    .text-success { color: var(--good) !important; }
.status-warning, .text-warning { color: var(--warn) !important; }
.status-bad,     .text-danger  { color: var(--bad)  !important; }
.text-info, .text-primary      { color: var(--accent) !important; }
.text-muted                    { color: var(--text-3) !important; }
.text-light, .text-white       { color: var(--text) !important; }
.bg-white, .bg-light { background: var(--surface-raised) !important; color: var(--text) !important; }

.status-icon-good    { color: var(--good); }
.status-icon-warning { color: var(--warn); }
.status-icon-bad     { color: var(--bad); }
.priority-critical, .priority-high, .priority-normal { border-left: 0; }

.alert {
  background: var(--surface-panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--fs-md);
}
.alert-info    { background: var(--accent-tint); border-color: oklch(73% 0.12 var(--hue-accent) / 0.4); }
.alert-success { background: var(--good-tint);   border-color: oklch(77% 0.14 152 / 0.4); }
.alert-warning { background: var(--warn-tint);   border-color: oklch(82% 0.135 78 / 0.4); }
.alert-danger  { background: var(--bad-tint);    border-color: oklch(71% 0.175 27 / 0.45); }

.dropdown-menu {
  --bs-dropdown-bg: var(--surface-raised);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-md);
  padding: var(--s-1);
}
.dropdown-item { color: var(--text); border-radius: var(--radius-sm); padding: var(--s-2) var(--s-3); display: flex; align-items: center; gap: var(--s-2); }
.dropdown-item svg.feather { color: var(--text-3); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-hover); color: var(--text); }
.dropdown-item--danger:hover, .dropdown-item--danger:focus { background: var(--bad-tint); color: var(--text); }
.dropdown-item--danger:hover svg.feather, .dropdown-item--danger:focus svg.feather { color: var(--bad); }
.dropdown-divider { border-color: var(--line); }

.pagination { --bs-pagination-font-size: var(--fs-sm); gap: var(--s-1); }
.page-link { background: var(--surface-panel); border-color: var(--line); color: var(--text-2); border-radius: var(--radius) !important; }
.page-link:hover { background: var(--surface-hover); border-color: var(--line-strong); color: var(--text); }
.page-item.active .page-link { background: var(--surface-raised); border-color: var(--accent); color: var(--text); font-weight: 500; }
.page-item.disabled .page-link { background: transparent; color: var(--text-3); border-color: transparent; }

.modal-content { background: var(--surface-panel); border: 1px solid var(--line-strong); border-radius: var(--radius-panel); color: var(--text); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-header .modal-title { font-size: var(--fs-lg); display: flex; align-items: center; gap: var(--s-2); }
.modal-footer { border-top: 1px solid var(--line); }
.modal-header.bg-info, .modal-header.bg-primary, .modal-header.bg-success,
.modal-header.bg-warning, .modal-header.bg-danger, .modal-header.bg-dark { background: var(--surface-panel) !important; color: var(--text) !important; }
.modal-backdrop.show { opacity: 0.7; }

.tooltip .tooltip-inner {
  background-color: var(--surface-raised) !important;
  color: var(--text) !important;
  border: 1px solid var(--line-strong);
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
}

.progress { background: var(--surface-hover); height: 6px; }
.progress-bar { background: var(--accent-strong); }

pre.raw-email-pre, pre.code-block, #rawContentText {
  background: var(--ink-900);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
  max-height: 60vh;
  overflow: auto;
}

/* ---- Toasts --------------------------------------------------- */
.ww-toast {
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  min-width: 300px;
  max-width: 420px;
  animation: toast-in 220ms var(--ease-out);
}
.ww-toast .toast-header {
  background: transparent;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 500;
  font-size: var(--fs-sm);
  padding: var(--s-2) var(--s-3);
  gap: var(--s-2);
}
.ww-toast .toast-header::before {
  content: "";
  width: 0.65rem; height: 0.65rem;
  background: var(--accent);
  border-radius: 50%;
}
.ww-toast.toast-success .toast-header::before { background: var(--good); }
.ww-toast.toast-warning .toast-header::before { background: var(--warn); clip-path: polygon(50% 4%, 100% 96%, 0 96%); border-radius: 0; }
.ww-toast.toast-error   .toast-header::before { background: var(--bad); clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); border-radius: 0; }
.ww-toast .toast-body { padding: var(--s-3); font-size: var(--fs-md); color: var(--text-2); }
@keyframes toast-in { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Row removal after "ignore": a 4px lift and a fade, not a slide */
.removing-item { overflow: hidden; transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out); }
.removing-item.fade-out { opacity: 0; transform: translateY(-4px); }

.pinned-indicator { display: inline-flex; margin-right: 4px; color: var(--accent); }

/* Error pages */
.error-page { max-width: 38rem; margin: var(--s-7) auto; }
.error-page__code { font-family: var(--font-mono); color: var(--text-3); font-size: var(--fs-sm); margin-bottom: var(--s-4); }
.error-page h1 { margin-bottom: var(--s-2); }
.error-page p { color: var(--text-2); }
.error-page ul { padding-left: 1.1rem; color: var(--text-2); }

/* Utility */
.visually-hidden-focusable:not(:focus):not(:focus-within) { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; }
.gap-section { margin-top: var(--s-6); }
@media (max-width: 575.98px) {
  .app-main { padding-block: var(--s-4) var(--s-6); }
  .container { padding-left: var(--s-3); padding-right: var(--s-3); }
  .card-header { padding: var(--s-3); }
  .search-field input { width: 100%; }
  .page-head__actions { width: 100%; }
  .ww-toast { min-width: 0; max-width: calc(100vw - 2rem); }
}

/* ================================================================
   Reduced motion: no loops, no slides. Spinners keep turning (they
   are state, not decoration), just slower.
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover, .btn-primary:hover, .btn-login:hover, .card:hover { transform: none !important; }
  .status-pill-flash,
  .pinned-indicator,
  .skeleton-loading::after { animation: none !important; }
  .removing-item.fade-out { transform: none; }
  .spinner, .btn-spinner, .spinner-border {
    animation-duration: 1.8s !important;
    animation-iteration-count: infinite !important;
  }
}

/* Toast stack sits under the sticky nav, never on top of it */
.toast-stack { top: var(--nav-h, 56px); z-index: 1090; display: flex; flex-direction: column; gap: var(--s-2); }
main:focus { outline: none; }
.min-w-0 { min-width: 0; }
.lane-list .cell-id { font-size: var(--fs-sm); }
.facts dd.font-sans-cell { font-family: var(--font-sans); }
/* Strip items carry .card for the filter hook; undo the panel chrome */
.status-strip > .card.status-strip__item { flex-direction: row; background: transparent; border: 0; border-right: 1px solid var(--line); border-radius: 0; margin: 0; }
.status-strip > .card.status-strip__item:last-child { border-right: 0; }
.status-strip > .card.status-strip__item:hover { background: var(--surface-hover); }
.status-strip > .card.status-strip__item[aria-current="true"] { background: var(--surface-raised); }
@media (max-width: 575.98px) {
  .status-strip > .card.status-strip__item:nth-child(2) { border-right: 0; }
  .status-strip > .card.status-strip__item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

/* Queue header counts: plain text, the rows carry the colour */
.queue-counts { margin: 0; color: var(--text-2); font-size: var(--fs-sm); }

/* Stopped-reporting card: collapsed list of long-silent (likely retired) systems */
.silent-retired { padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line); }
.silent-retired summary { cursor: pointer; }
