/* ========================================================== aidevops UI ===
   A calm, dense operations console. Light is the base palette; dark redefines
   only the tokens. Both are reachable via data-theme (an explicit choice) and
   prefers-color-scheme (the "auto" setting, which is the default).

   The rule this file follows: a colour is declared ONCE, on bare :root, and
   only redefined inside the two dark blocks. A colour whose only definition
   lives inside a media query renders as nothing in the other theme, which is
   the single most common way a themed stylesheet breaks.

   Contrast ratios here are MEASURED by tests/colours.test.mjs against the real
   token values, in both themes. A number written in a comment is not a check.
   Two of them moved because of it: the amber status dot was #f59e0b (2.15:1 on
   white, under the 3:1 a meaningful graphic needs) and the subtle text was
   #64748b, which passed on white and failed at 4.34:1 on the striped rows it
   is used on most.
   ======================================================================= */

:root {
  /* ------------------------------------------------------------ surfaces --- */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --sidebar: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* ---------------------------------------------------------------- text --- */
  --text: #0f172a;
  --text-muted: #475569;
  /* The lightest text in the system and the one most likely to be waved
     through as decorative — it carries table headings, hints and timestamps.
     MEASURED: #64748b gave 4.34:1 on --surface-2. This is the smallest step
     that clears 4.5 on all three surfaces (5.45 / 5.21 / 4.97). */
  --text-subtle: #5b6b7f;
  --text-on-fill: #ffffff;

  /* -------------------------------------------------------------- accent --- */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  /* Accent used as TEXT — links, selected tabs — as opposed to accent used as
     a FILL. The two pull in opposite directions in dark mode: a button
     background needs white to sit on it, a link needs contrast against the
     page. One shared token is how dark-mode links end up at 2.7:1. */
  --accent-text: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --accent-ring: rgba(37, 99, 235, .28);

  /* -------------------------------------------------------------- status ---
     Three tokens per status, and they are not interchangeable:
       -fill  a background that WHITE text sits on. Measured at 4.5:1.
       -text  the status written as words on a surface or on its own -soft.
       -dot   a small graphic carrying no text. Measured at 3:1, which is what
              a meaningful non-text graphic needs — brighter than -fill so the
              board reads at a glance, darker than the obvious choice because
              the obvious choice failed. */
  --ok-fill: #15803d;
  --ok-text: #15803d;
  --ok-dot: #16a34a;
  --ok-soft: #dcfce7;
  --ok-border: #bbf7d0;

  --warn-fill: #b45309;
  --warn-text: #b45309;
  --warn-dot: #d97706;
  --warn-soft: #fef3c7;
  --warn-border: #fde68a;

  --bad-fill: #b91c1c;
  --bad-text: #b91c1c;
  --bad-dot: #dc2626;
  --bad-soft: #fee2e2;
  --bad-border: #fecaca;

  --unknown-fill: #475569;
  --unknown-text: #5b6b7f;
  --unknown-dot: #64748b;
  --unknown-soft: #f1f5f9;
  --unknown-border: #cbd5e1;

  --violet: #6d28d9;
  --violet-soft: #f5f3ff;

  /* ------------------------------------------------------------ elevation --- */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
  --overlay: rgba(15, 23, 42, .45);

  /* -------------------------------------------------------------- metrics --- */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-w: 232px;
  --topbar-h: 68px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

/* Dark, for the "auto" setting. Guarded so an explicit light choice wins. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #131c31;
    --surface-2: #1a2540;
    --surface-3: #24304d;
    --sidebar: #0f1728;
    --border: #24304d;
    --border-strong: #35426b;

    --text: #e2e8f0;
    --text-muted: #a8b6c9;
    --text-subtle: #94a3b8;
    --text-on-fill: #ffffff;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-text: #60a5fa;
    --accent-soft: #16264a;
    --accent-border: #1e3a6d;
    --accent-ring: rgba(96, 165, 250, .34);

    --ok-fill: #15803d;
    --ok-text: #4ade80;
    --ok-dot: #4ade80;
    --ok-soft: #14321f;
    --ok-border: #1d5233;

    --warn-fill: #b45309;
    --warn-text: #fbbf24;
    --warn-dot: #fbbf24;
    --warn-soft: #3a2a0c;
    --warn-border: #5c4310;

    --bad-fill: #b91c1c;
    --bad-text: #f87171;
    --bad-dot: #f87171;
    --bad-soft: #3d1517;
    --bad-border: #6b2224;

    --unknown-fill: #475569;
    --unknown-text: #94a3b8;
    --unknown-dot: #94a3b8;
    --unknown-soft: #1a2540;
    --unknown-border: #35426b;

    --violet: #a78bfa;
    --violet-soft: #241b46;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    --overlay: rgba(2, 6, 18, .68);
  }
}

/* Dark, chosen explicitly. Identical to the block above by construction —
   tests/colours.test.mjs asserts the two define exactly the same tokens with
   exactly the same values, because a token that drifts between them means the
   toggle and the OS setting disagree about what dark looks like. */
:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131c31;
  --surface-2: #1a2540;
  --surface-3: #24304d;
  --sidebar: #0f1728;
  --border: #24304d;
  --border-strong: #35426b;

  --text: #e2e8f0;
  --text-muted: #a8b6c9;
  --text-subtle: #94a3b8;
  --text-on-fill: #ffffff;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #60a5fa;
  --accent-soft: #16264a;
  --accent-border: #1e3a6d;
  --accent-ring: rgba(96, 165, 250, .34);

  --ok-fill: #15803d;
  --ok-text: #4ade80;
  --ok-dot: #4ade80;
  --ok-soft: #14321f;
  --ok-border: #1d5233;

  --warn-fill: #b45309;
  --warn-text: #fbbf24;
  --warn-dot: #fbbf24;
  --warn-soft: #3a2a0c;
  --warn-border: #5c4310;

  --bad-fill: #b91c1c;
  --bad-text: #f87171;
  --bad-dot: #f87171;
  --bad-soft: #3d1517;
  --bad-border: #6b2224;

  --unknown-fill: #475569;
  --unknown-text: #94a3b8;
  --unknown-dot: #94a3b8;
  --unknown-soft: #1a2540;
  --unknown-border: #35426b;

  --violet: #a78bfa;
  --violet-soft: #241b46;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  --overlay: rgba(2, 6, 18, .68);
}

/* ================================================================ base === */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 25px; line-height: 1.2; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p { margin: 0; }
a { color: var(--accent-text); }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; display: block; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.center { text-align: center; }

/* ============================================================== layout === */

.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.sidebar-brand .icon { width: 24px; height: 24px; color: var(--accent); }

.nav { padding: 4px 10px; overflow-y: auto; flex: 1 1 auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.nav-item[aria-current="page"] .icon { color: var(--accent-text); }

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--bad-fill);
  color: var(--text-on-fill);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-badge-warn { background: var(--warn-fill); }

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
}

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 21px; }
.topbar-sub { font-size: 12.5px; color: var(--text-subtle); margin-top: 1px; }

.content { padding: 22px 24px 56px; flex: 1 1 auto; }
.content-narrow { max-width: 860px; }

.page-foot {
  padding: 16px 24px 28px;
  font-size: 12px;
  color: var(--text-subtle);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

/* ========================================================== components === */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 15.5px; }
.card-body { padding: 16px 18px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* ---------------------------------------------------------------- button --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-fill);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--bad-fill); border-color: var(--bad-fill); color: var(--text-on-fill); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; }

/* ----------------------------------------------------------------- pills --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 23px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: var(--ok-text); }
.pill-warn { background: var(--warn-soft); color: var(--warn-text); }
.pill-bad { background: var(--bad-soft); color: var(--bad-text); }
.pill-unknown { background: var(--unknown-soft); color: var(--unknown-text); }
.pill-accent { background: var(--accent-soft); color: var(--accent-text); }
.pill-plain { background: var(--surface-2); color: var(--text-muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-lg { width: 11px; height: 11px; }
.dot-ok { background: var(--ok-dot); }
.dot-warn { background: var(--warn-dot); }
.dot-bad { background: var(--bad-dot); }
.dot-unknown { background: var(--unknown-dot); }

.tile-letter {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-on-fill);
  background: var(--accent);
  flex: none;
}

/* ---------------------------------------------------------------- inputs --- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field .hint { font-size: 12px; color: var(--text-subtle); }
.req { color: var(--bad-text); }

.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--text-subtle); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-subtle);
  flex: 1 1 320px;
  max-width: 420px;
}
.search input {
  border: 0; background: transparent; outline: none; flex: 1 1 auto;
  min-width: 0; font-size: 13.5px; color: var(--text);
}

.toggle {
  width: 38px; height: 22px;
  border-radius: 999px;
  border: 0;
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
  flex: none;
  padding: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
.toggle[aria-checked="true"] { background: var(--ok-fill); }
.toggle[aria-checked="true"]::after { transform: translateX(16px); }
.toggle:disabled { opacity: .5; cursor: not-allowed; }

.checkbox-row { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.checkbox-row input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------------------------------------------------------------- tables --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-subtle);
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13.5px;
}

/* ------------------------------------------------------------------ tabs --- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0;
  background: transparent;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }

/* -------------------------------------------------------------- notices --- */
.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.notice .icon { margin-top: 1px; }
.notice-ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok-text); }
.notice-warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.notice-bad { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad-text); }
.notice-info { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-text); }

/* --------------------------------------------------------------- toasts --- */
.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 260px;
  max-width: 400px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  transition: opacity .2s ease, transform .2s ease;
}
.toast-ok { border-left: 3px solid var(--ok-fill); }
.toast-bad { border-left: 3px solid var(--bad-fill); }
.toast-warn { border-left: 3px solid var(--warn-fill); }

/* --------------------------------------------------------------- modals --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal-head { padding: 18px 20px 12px; }
.modal-body { padding: 0 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-foot {
  padding: 16px 20px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

/* ======================================================= status board === */
/* The one-glance page. Built mobile-first and then allowed to breathe on a
   desktop, rather than the other way round: this is the view someone opens on
   a phone at night, and every target on it is at least 44 pixels tall. */

.board-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.count-tile {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.count-tile .n {
  display: block;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.count-tile .label { display: block; font-size: 14px; font-weight: 500; margin-top: 2px; }
.count-ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok-text); }
.count-warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.count-bad { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad-text); }
.count-tile[aria-pressed="true"] { outline: 2px solid currentColor; outline-offset: 2px; }
.count-tile.is-empty { opacity: .55; }

.board { display: flex; flex-direction: column; gap: 10px; }

.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.board-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 17px 18px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  min-height: 72px;
}
.board-card-head:hover { background: var(--surface-2); }
.board-card-head .dot { width: 12px; height: 12px; }
.board-name {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.25;
}
.board-line { font-size: 14.5px; line-height: 1.35; margin-top: 1px; }
.board-line-ok { color: var(--text-subtle); }
.board-line-warn { color: var(--warn-text); }
.board-line-bad { color: var(--bad-text); }
.board-chev { color: var(--text-subtle); transition: transform .15s ease; }
.board-card-head[aria-expanded="true"] .board-chev { transform: rotate(180deg); }

.board-detail { padding: 0 18px 18px; border-top: 1px solid var(--border); }
.board-detail h4 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-subtle);
  margin: 16px 0 8px;
}
.board-ep {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}
.board-ep:last-of-type { border-bottom: 0; }
.board-ep .path { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-ep .val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.val-ok { color: var(--ok-text); }
.val-warn { color: var(--warn-text); }
.val-bad { color: var(--bad-text); }

.board-summary { font-size: 13.5px; color: var(--text-subtle); margin-top: 10px; }

.log-block {
  margin-top: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-muted);
  overflow-x: auto;
  white-space: pre;
}

.board-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.board-foot .state { font-size: 13.5px; font-weight: 550; }

/* ====================================================== summary cards === */

.stat {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--text-on-fill);
}
.stat-ok { background: var(--ok-fill); }
.stat-warn { background: var(--warn-fill); }
.stat-bad { background: var(--bad-fill); }
.stat-accent { background: var(--accent); }
.stat-violet { background: var(--violet); }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 550; }
.stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.stat-delta { font-size: 12px; color: var(--text-subtle); display: flex; align-items: center; gap: 3px; margin-top: 3px; }
.delta-up { color: var(--bad-text); }
.delta-down { color: var(--ok-text); }

/* ======================================================== service map === */

.svcmap { width: 100%; border-collapse: collapse; font-size: 13px; }
.svcmap th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-subtle);
  padding: 8px 6px;
  text-align: center;
  white-space: nowrap;
}
.svcmap th:first-child { text-align: left; padding-left: 0; min-width: 150px; }
.svcmap td { padding: 9px 6px; text-align: center; border-top: 1px solid var(--border); }
.svcmap td:first-child { text-align: left; padding-left: 0; color: var(--text-muted); }
.svcmap .dot { margin: 0 auto; }
.svcmap-cat { display: flex; align-items: center; gap: 8px; }
.svcmap-cat .icon { color: var(--text-subtle); }

/* ========================================================== timeline === */

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 14px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex: none; width: 28px; }
.tl-node {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-on-fill);
  flex: none;
}
.tl-node .icon { width: 14px; height: 14px; }
.tl-ok { background: var(--ok-fill); }
.tl-warn { background: var(--warn-fill); }
.tl-bad { background: var(--bad-fill); }
.tl-info { background: var(--accent); }
.tl-line { width: 2px; flex: 1 1 auto; background: var(--border); min-height: 14px; }
.tl-body { padding-bottom: 18px; flex: 1 1 auto; min-width: 0; }
.tl-time { font-size: 12px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.tl-text { font-size: 13.5px; color: var(--text); margin-top: 1px; word-break: break-word; }
.tl-item:last-child .tl-line { display: none; }
.tl-item:last-child .tl-body { padding-bottom: 0; }

/* ============================================================ sparkline === */

.spark { display: block; width: 100%; height: 42px; }
.spark-line { fill: none; stroke-width: 1.8; }
.spark-ok { stroke: var(--ok-dot); }
.spark-bad { stroke: var(--bad-dot); }
.spark-accent { stroke: var(--accent-text); }
.spark-area-ok { fill: var(--ok-soft); }
.spark-area-bad { fill: var(--bad-soft); }
.spark-area-accent { fill: var(--accent-soft); }

.metric-card { padding: 14px 15px; }
.metric-label { font-size: 12px; color: var(--text-subtle); font-weight: 550; }
.metric-value {
  font-size: 22px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; margin-top: 1px;
}

/* ============================================================== wizard === */

.stepper { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: 4px 0 2px; }
.stepper::-webkit-scrollbar { display: none; }
.step { display: flex; align-items: flex-start; flex: 1 1 0; min-width: 92px; }
.step-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  padding: 0 4px;
  flex: none;
  width: 92px;
}
.step-n {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--text-subtle);
  border: 1px solid var(--border-strong);
}
.step-btn[data-state="active"] .step-n {
  background: var(--accent); color: var(--text-on-fill); border-color: var(--accent);
}
.step-btn[data-state="done"] .step-n {
  background: var(--ok-fill); color: var(--text-on-fill); border-color: var(--ok-fill);
}
.step-label {
  font-size: 11.5px;
  color: var(--text-subtle);
  text-align: center;
  line-height: 1.3;
}
.step-btn[data-state="active"] .step-label { color: var(--accent-text); font-weight: 650; }
.step-line { flex: 1 1 auto; height: 2px; background: var(--border); margin-top: 15px; min-width: 8px; }
.step-line.done { background: var(--ok-fill); }

.wizard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.wizard-rail { display: flex; flex-direction: column; gap: 14px; position: sticky; top: calc(var(--topbar-h) + 22px); }

.progress-track { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.check-row:last-child { border-bottom: 0; }
.check-mark {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  flex: none;
  color: transparent;
}
.check-row[data-state="ok"] .check-mark {
  background: var(--ok-fill); border-color: var(--ok-fill); color: var(--text-on-fill);
}
.check-row[data-state="bad"] .check-mark {
  background: var(--bad-fill); border-color: var(--bad-fill); color: var(--text-on-fill);
}
.check-state { margin-left: auto; font-size: 12px; color: var(--text-subtle); }
.check-row[data-state="ok"] .check-state { color: var(--ok-text); }
.check-row[data-state="bad"] .check-state { color: var(--bad-text); }

/* ============================================================ auth view === */

.auth-root {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 30px 28px;
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.auth-brand .icon { width: 26px; height: 26px; color: var(--accent); }
.auth-card h1 { font-size: 19px; margin-bottom: 6px; }
.auth-card .lead { font-size: 13.5px; color: var(--text-muted); margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--text-subtle); text-align: center; }

.link-btn {
  border: 0; background: transparent; padding: 0;
  color: var(--accent-text); font-size: 13px; cursor: pointer; text-decoration: underline;
}

/* Approval page: reachable with no session at all. Wider and calmer than the
   sign-in card, because it is read once, on a phone, under pressure. */
.approval-card { max-width: 520px; }
.approval-actions { display: flex; gap: 10px; margin-top: 22px; }
.approval-actions .btn { flex: 1 1 0; height: 46px; font-size: 15px; }

/* =========================================================== responsive === */

@media (max-width: 1180px) {
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wizard-layout { grid-template-columns: minmax(0, 1fr); }
  .wizard-rail { position: static; }
}

@media (max-width: 860px) {
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 16px 14px 72px; }
  .topbar { padding: 0 14px; height: auto; min-height: 60px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .topbar h1 { font-size: 19px; }
  .search { flex-basis: 100%; max-width: none; order: 10; }

  /* The sidebar becomes a bottom bar. Not a hamburger: this app is opened to
     answer one question fast, and a menu that has to be opened first is a menu
     in the way. The five destinations that matter fit; the rest live behind
     the last one. */
  .shell { flex-direction: column; }
  .sidebar {
    order: 10;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: auto;
    height: auto;
    border-right: 0;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 30;
  }
  .sidebar-brand, .sidebar-foot { display: none; }
  .nav {
    display: flex;
    padding: 6px 6px;
    gap: 2px;
    overflow-x: auto;
  }
  .nav-item {
    flex-direction: column;
    gap: 3px;
    padding: 7px 4px;
    font-size: 10.5px;
    text-align: center;
    min-width: 62px;
    margin-bottom: 0;
  }
  .nav-item .nav-text { white-space: nowrap; }
  .nav-badge { position: absolute; margin: 0; transform: translate(14px, -4px); }
  .nav-item { position: relative; }

  .board-counts { gap: 8px; }
  .count-tile { padding: 14px 14px; border-radius: var(--radius); }
  .count-tile .n { font-size: 27px; }
  .board-card-head { padding: 15px 15px; gap: 12px; }
  .board-name { font-size: 17.5px; }
  .board-line { font-size: 13.5px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
  .modal { max-height: 92vh; }
  .toast-root { left: 14px; right: 14px; bottom: 78px; }
  .toast { max-width: none; }
}

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

/* The one animation in the app: the refresh button while a fetch is in flight.
   Without it a slow load is indistinguishable from a dead button. */
@keyframes spin { to { transform: rotate(360deg); } }
.spinning { animation: spin 1s linear infinite; }
