/* ==========================================================================
   AutoTrader UI: shared shell + components.

   SHARED CLASSES OTHER PAGES CAN USE (all theme-aware, all work at 320px):
     layout    .page-head (.page-title .page-sub + actions)  .stack  .cluster  .grid-auto  .scroll-x  .sticky-th
     surfaces  .panel  .panel-flat  .notice(.warn|.bad|.ok)  .verdict(.ok|.warn|.bad)  .empty-state  .skeleton
     numbers   .num/.mono  .pos/.neg/.muted/.faint  .delta(.pos|.neg)  .kpi  .kpi-grid  .stat  .stat-grid
     status    .pill(.ok|.warn|.bad|.info|.neutral)  .health(.h-ok|.h-warn|.h-bad|.h-idle)  .dot(.ok|.bad|.warn|.off)
     help      .term (glossary tooltip)  .hint  .kbd
     tables    .table  .table-wraphead  table caption.sr-only  th[scope]  [data-sortable]  input[data-filter-table]
     actions   .btn  .btn-touch  .is-loading  form[data-no-lock]
     a11y      .visually-hidden / .sr-only  .skip-link  :focus-visible ring
     charts    .chart-box(.tall|.xtall)  .chart-fallback  (colours: read CSS vars or AT.colors())
   THEME TOKENS (CSS variables): --bg --panel --panel-2 --panel-3 --line --text --muted --faint --accent --pos --neg --warn
                                 --pos-bg --neg-bg --warn-bg --info-bg --neutral-bg --c1 .. --c10 --chart-text --chart-grid
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root, [data-bs-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e13;
  --panel: #111821;
  --panel-2: #0d131b;
  --panel-3: #18222e;
  --line: #243141;
  --line-strong: #34465c;
  --text: #dde6ef;
  --muted: #9aa8b9;          /* 7.3:1 on --panel */
  --faint: #8a99ab;          /* 5.8:1 on --panel (was 3.1:1) */
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --on-accent: #04202e;
  --pos: #34d399;
  --neg: #f87171;
  --warn: #fbbf24;
  --pos-bg: rgba(52,211,153,.14);
  --neg-bg: rgba(248,113,113,.14);
  --warn-bg: rgba(251,191,36,.13);
  --info-bg: rgba(56,189,248,.14);
  --neutral-bg: rgba(148,163,184,.16);
  --neutral-ink: #cbd5e1;
  --ok-ink: #bbf7d0;
  --bad-ink: #fecaca;
  --warn-ink: #fde68a;
  --info-ink: #bae6fd;
  --track: #1b2531;
  --shadow: 0 12px 32px rgba(0,0,0,.45);
  --focus: #7dd3fc;
  --mode-backtest: #4f46e5;
  --mode-paper: #b45309;
  --mode-paper-2: #92400e;
  --mode-live: #dc2626;
  --mode-live-2: #991b1b;
  --chart-text: #9aa8b9;
  --chart-grid: rgba(148,163,184,.14);
  --c1: #38bdf8; --c2: #f59e0b; --c3: #a78bfa; --c4: #34d399; --c5: #f472b6;
  --c6: #facc15; --c7: #60a5fa; --c8: #fb7185; --c9: #2dd4bf; --c10: #c084fc;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --tabbar-h: 0px;
  --banner-h: 36px;
}
[data-bs-theme="light"] {
  color-scheme: light;
  --bg: #f2f5f8;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --panel-3: #e9eef3;
  --line: #d3dce6;
  --line-strong: #b4c2d1;
  --text: #16202b;
  --muted: #465769;          /* 7.6:1 on white */
  --faint: #596b7e;          /* 5.4:1 on white, 4.9:1 on --bg */
  --accent: #0369a1;
  --accent-strong: #0284c7;
  --on-accent: #ffffff;
  --pos: #03684a;
  --neg: #b91c1c;
  --warn: #974609;
  --pos-bg: rgba(3,104,74,.10);
  --neg-bg: rgba(185,28,28,.09);
  --warn-bg: rgba(151,70,9,.11);
  --info-bg: rgba(3,105,161,.10);
  --neutral-bg: rgba(70,87,105,.12);
  --neutral-ink: #334155;
  --ok-ink: #065f46;
  --bad-ink: #7f1d1d;
  --warn-ink: #78350f;
  --info-ink: #075985;
  --track: #dbe3ec;
  --shadow: 0 12px 32px rgba(20,35,55,.18);
  --focus: #0369a1;
  --chart-text: #465769;
  --chart-grid: rgba(70,87,105,.16);
  --c1: #0284c7; --c2: #c2410c; --c3: #7c3aed; --c4: #047857; --c5: #db2777;
  --c6: #a16207; --c7: #2563eb; --c8: #e11d48; --c9: #0f766e; --c10: #9333ea;
}

/* ---------------------------------------------------------------- base */
html { scroll-padding-top: calc(var(--banner-h) + 12px); -webkit-text-size-adjust: 100%; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
*, *::before, *::after { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased;
  min-height: 100vh; overflow-wrap: break-word; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:hover, a:focus-visible { color: var(--accent); }
h1, h2, h3, h4 { color: var(--text); }
.num, .mono, td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; white-space: nowrap; }
.pos { color: var(--pos) !important; }
.neg { color: var(--neg) !important; }
.muted { color: var(--muted) !important; }
.faint { color: var(--faint) !important; }
.text-muted { color: var(--muted) !important; }
.small-caps { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
hr.border-secondary { border-color: var(--line) !important; opacity: 1; }
mark { background: var(--warn-bg); color: var(--text); padding: 0 2px; border-radius: 3px; }
code, kbd, samp { font-family: var(--mono); }
.kbd, kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 6px; background: var(--panel-2); color: var(--text); font-size: 12px; text-align: center; line-height: 1.5; }

/* ---------------------------------------------------------------- accessibility */
.visually-hidden, .sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 2000; background: var(--accent); color: var(--on-accent) !important; padding: 10px 16px;
  border-radius: 8px; font-weight: 700; text-decoration: none !important; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.form-control:focus-visible, .form-select:focus-visible, .btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
main:focus { outline: none; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .mode-banner.live { animation: none !important; }
}
@media (forced-colors: active) { .pill, .health, .dot { border: 1px solid CanvasText; } }

/* ---------------------------------------------------------------- mode banner (always visible, never colour-only: it spells the mode out) */
.mode-banner { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap;
  padding: 6px 16px; font-weight: 700; letter-spacing: .06em; font-size: 13px; color: #fff; }
.mode-banner.backtest { background: var(--mode-backtest); }
.mode-banner.paper { background: repeating-linear-gradient(135deg, #92400e 0 14px, #b45309 14px 28px); }
.mode-banner.live { background: repeating-linear-gradient(135deg, #991b1b 0 14px, #dc2626 14px 28px); animation: livepulse 2s infinite; }
.mode-banner.unknown { background: repeating-linear-gradient(135deg, #334155 0 14px, #475569 14px 28px); }
@keyframes livepulse { 50% { filter: brightness(1.25); } }
.mode-banner .mode-word { font-size: 18px; letter-spacing: .18em; }
.mode-banner .sub { font-weight: 500; letter-spacing: 0; }
.mode-banner .flagchip { background: rgba(0,0,0,.4); border-radius: 999px; padding: 2px 10px; font-size: 11px; }
.mode-banner a { color: #fff; text-decoration: underline; }
.mode-banner .clock { margin-left: auto; font-family: var(--mono); font-weight: 500; letter-spacing: 0; opacity: .95; }
.at-offline { background: var(--warn-bg); border-bottom: 1px solid var(--warn); color: var(--warn-ink); padding: 8px 16px; font-size: 13px; text-align: center; }
.at-offline.bad { background: var(--neg-bg); border-color: var(--neg); color: var(--bad-ink); }
.at-cdn-note { background: var(--info-bg); border-bottom: 1px solid var(--line); color: var(--info-ink); padding: 6px 16px; font-size: 12px; text-align: center; }

/* ---------------------------------------------------------------- navigation (independent of Bootstrap JS and CSS) */
.at-nav { background: var(--panel-2); border-bottom: 1px solid var(--line); position: relative; }
.at-nav-bar { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 54px; padding-top: 4px; padding-bottom: 4px; }
.navbar-brand { display: inline-flex; align-items: center; min-height: 44px; flex: none; font-weight: 800; letter-spacing: .12em; color: var(--text) !important; padding: 8px 4px; margin-right: 8px; text-decoration: none !important; }
.at-nav-menu { display: none; flex: 1 1 100%; order: 3; }
.navbar-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.navbar .nav-link, .at-nav .nav-more > summary { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  color: var(--muted) !important; font-weight: 500; white-space: nowrap; text-decoration: none !important; cursor: pointer; border: 0; background: transparent; }
.navbar .nav-link:hover, .at-nav .nav-more > summary:hover { color: var(--text) !important; background: var(--panel-3); }
.navbar .nav-link.active, .navbar .nav-link[aria-current="page"], .at-nav .nav-more.active > summary { color: var(--text) !important; background: var(--panel-3);
  box-shadow: inset 3px 0 0 var(--accent); }
.nav-link.is-soon { opacity: .75; cursor: default; }
.nav-soon-tag { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 6px; color: var(--faint); }
.at-nav .nav-more { list-style: none; }
.at-nav .nav-more > summary { list-style: none; }
.at-nav .nav-more > summary::-webkit-details-marker { display: none; }
.at-nav .nav-more > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); margin-left: 2px; }
.at-nav .nav-more[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
html.js .at-nav .nav-more > summary { display: none; }                 /* phones: JS keeps More expanded inside the sheet */
.nav-more-panel { display: grid; grid-template-columns: 1fr; gap: 14px; padding: 6px 4px 10px; }
.nav-group-title { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 4px 12px; font-weight: 700; }
.dropdown-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; min-height: 44px; border-radius: 10px; color: var(--text) !important;
  text-decoration: none !important; }
.dropdown-item:hover { background: var(--panel-3); }
.dropdown-item[aria-current="page"] { background: var(--panel-3); box-shadow: inset 3px 0 0 var(--accent); }
.dropdown-item .ic { margin-top: 2px; color: var(--muted); flex: none; }
.dropdown-item .di-label { display: block; font-weight: 600; }
.dropdown-item .di-desc { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; white-space: normal; }
.dropdown-item.is-soon { opacity: .7; cursor: default; }
.at-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; order: 2; }
.nav-tool { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 10px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font: inherit; text-decoration: none !important; }
.nav-tool:hover { color: var(--text); background: var(--panel-3); }
.nav-tool .kbd { margin-left: 2px; }
.nav-tool-label { display: none; font-size: 13px; }
.nav-status { font-size: 12px; white-space: nowrap; }
.nav-status .nav-status-text { display: none; }
.nav-status .nav-status-ctl { font-weight: 600; font-size: 13px; color: var(--text); }   /* the Control center link is always named */
.navbar-toggler { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border: 1px solid var(--line-strong);
  border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; }
.navbar-toggler-icon { display: none; }
/* phone: the menu becomes a full-height sheet under the mode banner and above the tab bar */
@media (max-width: 991.98px) {
  .at-nav-menu.is-open { display: block; position: fixed; left: 0; right: 0; top: var(--banner-h); bottom: var(--tabbar-h); z-index: 1035; overflow-y: auto;
    background: var(--bg); padding: 12px 16px 28px; border-top: 1px solid var(--line); overscroll-behavior: contain; }
  html:not(.js) .at-nav-menu { display: block; }
  body.nav-open { overflow: hidden; }
  .nav-more-panel { padding-top: 12px; }
  .nav-sheet-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
}
@media (min-width: 992px) {
  .navbar-toggler, .nav-sheet-tools { display: none !important; }
  .at-nav-menu { display: flex !important; flex: 1 1 auto; order: 1; align-items: center; }
  .at-tools { order: 2; }
  .navbar-nav { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .navbar .nav-link, .at-nav .nav-more > summary { min-height: 40px; padding: 6px 12px; }
  .navbar .nav-link.active, .navbar .nav-link[aria-current="page"], .at-nav .nav-more.active > summary { box-shadow: inset 0 -2px 0 var(--accent); }
  html.js .at-nav .nav-more > summary { display: flex; }
  .at-nav .nav-more { position: static; }
  .nav-more-panel { position: absolute; right: 12px; top: calc(100% + 6px); z-index: 1040; width: max-content; max-width: min(900px, calc(100vw - 24px));
    grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 6px 18px; padding: 14px; background: var(--panel); border: 1px solid var(--line-strong);
    border-radius: 14px; box-shadow: var(--shadow); }
  .navbar-nav > .nav-item > .nav-link > .ic, .navbar-nav > .nav-item > .nav-more > summary > .ic { display: none; }   /* labels only in the top bar; icons live on phones */
}
@media (min-width: 992px) and (max-width: 1199.98px) { .nav-more-panel { grid-template-columns: repeat(2, minmax(200px, 1fr)); } }
@media (min-width: 1400px) { .nav-tool-label, .nav-status .nav-status-text { display: inline; } }
/* bottom tab bar (phones) */
.at-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; display: flex; background: var(--panel-2); border-top: 1px solid var(--line-strong);
  padding-bottom: env(safe-area-inset-bottom); }
.at-tabbar .tab { flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 2px;
  color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none !important; background: transparent; border: 0; cursor: pointer; font-family: inherit; }
.at-tabbar .tab[aria-current="page"] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.at-tabbar .tab:hover { color: var(--text); }
.at-tabbar .tab.is-soon { opacity: .6; }
@media (max-width: 991.98px) {
  :root { --tabbar-h: calc(56px + env(safe-area-inset-bottom)); }
  body { padding-bottom: var(--tabbar-h); }
}
@media (min-width: 992px) { .at-tabbar { display: none; } }

/* ---------------------------------------------------------------- page structure */
main.container-xl { padding-bottom: 8px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin: 18px 0 14px; }
.page-head .page-title { margin: 0 0 2px; }
.page-head .page-sub { margin: 0; }
.page-head .page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-title { font-size: 22px; font-weight: 700; margin: 18px 0 4px; }
.page-sub { color: var(--muted); margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.section-title { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }
footer { color: var(--faint); font-size: 12px; border-top: 1px solid var(--line); margin-top: 32px; padding: 14px 0 28px; }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; height: 100%; }
.panel-flat { background: transparent; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2, .panel h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 12px; }
.panel-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-title-row h2 { margin: 0; }
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-family: var(--mono); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .value.sm { font-size: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 18px; }
.status-grid, .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.status-tile, .stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.status-tile .label, .stat .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.status-tile .val, .stat .val { font-weight: 700; font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.status-tile .detail, .stat .detail { font-size: 12px; color: var(--faint); overflow-wrap: anywhere; }
.stat .val.big { font-size: 22px; font-family: var(--mono); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--pos); box-shadow: 0 0 6px var(--pos); }
.dot.bad { background: var(--neg); box-shadow: 0 0 6px var(--neg); }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--faint); }

/* health states: colour + shape + words (never colour alone) */
.health { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; letter-spacing: .03em; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.health .hs { font-size: 11px; line-height: 1; }
.health.h-ok { background: var(--pos-bg); color: var(--pos); }
.health.h-warn { background: var(--warn-bg); color: var(--warn); }
.health.h-bad { background: var(--neg-bg); color: var(--neg); }
.health.h-idle { background: var(--neutral-bg); color: var(--muted); }
.health-row { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
  border-left-width: 4px; }
.health-row.h-ok { border-left-color: var(--pos); } .health-row.h-warn { border-left-color: var(--warn); }
.health-row.h-bad { border-left-color: var(--neg); } .health-row.h-idle { border-left-color: var(--line-strong); }
.health-row .hr-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; grid-column: 1 / -1; }
.health-row .hr-value { font-weight: 700; }
.health-row .hr-detail { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.health-hero { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); border-left-width: 6px; }
.health-hero.h-ok { border-left-color: var(--pos); } .health-hero.h-warn { border-left-color: var(--warn); } .health-hero.h-bad { border-left-color: var(--neg); }
.health-hero .hh-title { font-size: 18px; font-weight: 800; }

/* ---------------------------------------------------------------- $ -> $100 track */
.track-wrap { padding: 34px 6px 28px; }
.track { position: relative; height: 10px; background: var(--track); border-radius: 999px; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, #0ea5e9, #34d399); }
.track .ms { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--line-strong); }
.track .ms.reached { background: var(--pos); }
.track .ms .lbl { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 10px; color: var(--faint); white-space: nowrap; }
.track .ms.reached .lbl { color: var(--pos); }
.track .cursor { position: absolute; top: -9px; width: 14px; height: 28px; margin-left: -7px; border-radius: 4px; background: var(--text); box-shadow: 0 0 0 3px var(--info-bg), 0 0 0 4px var(--accent); }
.track .cursor .lbl { position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--text); white-space: nowrap; }
.track-ends { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 22px; }

/* ---------------------------------------------------------------- tables */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--line); --bs-table-striped-bg: var(--panel-2);
  --bs-table-hover-bg: var(--info-bg); margin-bottom: 0; }
.table thead th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; border-bottom-color: var(--line-strong); white-space: nowrap; }
.table td { vertical-align: middle; }
.table-sm td, .table-sm th { padding: .3rem .45rem; }
.table-responsive { border-radius: 8px; }
.table caption { caption-side: top; color: var(--muted); font-size: 12px; padding: 0 0 6px; }
.table caption.sr-only { position: absolute; }
.sticky-th thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]::after { content: " \2195"; opacity: .4; font-size: 10px; }
th[aria-sort="ascending"]::after { content: " \25B2"; opacity: 1; }
th[aria-sort="descending"]::after { content: " \25BC"; opacity: 1; }
.table-filter { max-width: 320px; }
td.num a { color: inherit; text-decoration: underline dotted; }

/* ---------------------------------------------------------------- badges / pills / deltas */
.pill { white-space: nowrap; display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .05em; }
.pill.ok { background: var(--pos-bg); color: var(--pos); }
.pill.bad { background: var(--neg-bg); color: var(--neg); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--accent); }
.pill.neutral { background: var(--neutral-bg); color: var(--neutral-ink); }
.delta { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta .ar { font-size: .8em; margin-right: 2px; }
.verdict { border-radius: var(--radius); padding: 14px 18px; font-weight: 800; letter-spacing: .06em; font-size: 16px; }
.verdict.bad { background: var(--neg-bg); border: 1px solid var(--neg); color: var(--bad-ink); }
.verdict.ok { background: var(--pos-bg); border: 1px solid var(--pos); color: var(--ok-ink); }
.verdict.warn { background: var(--warn-bg); border: 1px solid var(--warn); color: var(--warn-ink); }

/* ---------------------------------------------------------------- glossary terms / tooltips */
.term { all: unset; cursor: help; color: inherit; font: inherit; display: inline; position: relative;
  text-decoration: underline dotted var(--muted); text-decoration-thickness: 1px; text-underline-offset: 3px; }
/* a 44px-tall touch target that adds no layout height and never paints a border across the next line of text */
@media (pointer: coarse), (max-width: 576px) { .term::after { content: ""; position: absolute; left: -4px; right: -4px; top: 50%; height: 44px; transform: translateY(-50%); } }
.term:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.at-tip { position: absolute; z-index: 3000; max-width: min(320px, calc(100vw - 24px)); background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.45; box-shadow: var(--shadow); font-weight: 400; letter-spacing: 0; text-transform: none; }
.at-tip b { display: block; margin-bottom: 2px; }
.hint { color: var(--faint); font-size: 12px; }

/* ---------------------------------------------------------------- forms / buttons */
.form-control, .form-select { background-color: var(--panel-2); border-color: var(--line-strong); color: var(--text); }
.form-control::placeholder { color: var(--faint); opacity: 1; }
.form-control:focus, .form-select:focus { background-color: var(--panel-2); color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 .15rem var(--info-bg); }
.form-control:disabled, .form-select:disabled { background-color: var(--panel-3); color: var(--faint); }
.form-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.form-text { color: var(--faint); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--neg); }
.field-error { color: var(--neg); font-size: 12px; margin-top: 4px; }
.btn { font-weight: 600; }
.btn-outline-light { --bs-btn-color: var(--text); --bs-btn-border-color: var(--line-strong); --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: var(--panel-3);
  --bs-btn-hover-border-color: var(--muted); --bs-btn-active-bg: var(--panel-3); --bs-btn-active-color: var(--text); --bs-btn-disabled-color: var(--faint); --bs-btn-disabled-border-color: var(--line); }
.btn-outline-warning { --bs-btn-color: var(--warn); --bs-btn-border-color: var(--warn); --bs-btn-hover-color: #111; --bs-btn-hover-bg: var(--warn); --bs-btn-hover-border-color: var(--warn); }
.btn-outline-success { --bs-btn-color: var(--pos); --bs-btn-border-color: var(--pos); --bs-btn-hover-color: #06281c; --bs-btn-hover-bg: var(--pos); --bs-btn-hover-border-color: var(--pos); }
.btn-outline-info { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-color: var(--on-accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); }
.btn-outline-danger { --bs-btn-color: var(--neg); --bs-btn-border-color: var(--neg); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c; }
.btn-info { --bs-btn-color: var(--on-accent); --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-color: var(--on-accent); --bs-btn-hover-bg: var(--accent-strong);
  --bs-btn-hover-border-color: var(--accent-strong); --bs-btn-disabled-color: var(--on-accent); }
.btn.is-loading { position: relative; pointer-events: none; opacity: .75; }
.btn.is-loading::after { content: ""; display: inline-block; width: 1em; height: 1em; margin-left: .55em; vertical-align: -.15em; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: at-spin .7s linear infinite; }
@keyframes at-spin { to { transform: rotate(360deg); } }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
form.htmx-request button[type=submit] { opacity: .6; pointer-events: none; }
.controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.danger-zone { border: 1px dashed var(--neg); border-radius: 8px; padding: 12px; }
.modal-content { background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.modal-header, .modal-footer { border-color: var(--line); }
.btn-close { filter: invert(1); }
[data-bs-theme="light"] .btn-close { filter: none; }
.nav-tabs { border-color: var(--line); }
.nav-tabs .nav-link { color: var(--muted); border: none; min-height: 44px; }
.nav-tabs .nav-link.active { background: transparent; color: var(--text); border-bottom: 2px solid var(--accent); }
.accordion { --bs-accordion-bg: var(--panel); --bs-accordion-border-color: var(--line); --bs-accordion-color: var(--text); --bs-accordion-btn-bg: var(--panel-2); --bs-accordion-active-bg: var(--panel-3);
  --bs-accordion-active-color: var(--text); --bs-accordion-btn-color: var(--text); }
.progress { background: var(--track); }

/* ---------------------------------------------------------------- charts / notices / misc blocks */
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 320px; }
.chart-box.xtall { height: 420px; }
.chart-fallback { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 120px; padding: 16px; border: 1px dashed var(--line-strong);
  border-radius: 10px; color: var(--muted); font-size: 13px; background: var(--panel-2); }
.chart-box > .chart-fallback { position: absolute; inset: 0; }
.notice { background: var(--info-bg); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; color: var(--info-ink); font-size: 13px; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn-ink); }
.notice.bad { background: var(--neg-bg); border-color: var(--neg); color: var(--bad-ink); }
.notice.ok { background: var(--pos-bg); border-color: var(--pos); color: var(--ok-ink); }
.notice a { color: inherit; text-decoration: underline; }
.empty-state { text-align: center; padding: 28px 16px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel-2); }
.empty-state .ic { width: 32px; height: 32px; color: var(--faint); margin-bottom: 8px; }
.empty-state .es-title { color: var(--text); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.empty-state .es-text { max-width: 46ch; margin: 0 auto 10px; font-size: 13px; }
.skeleton { background: linear-gradient(90deg, var(--panel-3) 25%, var(--panel-2) 37%, var(--panel-3) 63%); background-size: 400% 100%; animation: at-shimmer 1.4s ease infinite; border-radius: 6px; min-height: 1em; color: transparent; }
@keyframes at-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
pre.log { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; max-height: 420px; overflow: auto; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.report-md { line-height: 1.55; overflow-wrap: anywhere; }
.report-md table { width: 100%; margin: 10px 0 18px; font-size: 12.5px; display: block; overflow-x: auto; }
.report-md th, .report-md td { border: 1px solid var(--line); padding: 4px 7px; white-space: nowrap; }
.report-md th { color: var(--muted); background: var(--panel-2); }
.report-md h1 { font-size: 22px; } .report-md h2 { font-size: 17px; margin-top: 26px; color: var(--text); }
.report-md blockquote { border-left: 3px solid var(--warn); padding-left: 12px; color: var(--warn-ink); }
.report-md code { color: var(--accent); }

/* ---------------------------------------------------------------- toasts / progress / dialogs */
.at-toasts { position: fixed; right: 12px; bottom: calc(var(--tabbar-h) + 12px); z-index: 3500; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.at-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; background: var(--panel); border: 1px solid var(--line-strong); border-left-width: 4px; border-radius: 10px;
  padding: 10px 6px 10px 12px; box-shadow: var(--shadow); font-size: 13px; animation: at-toast-in .18s ease-out; }
.at-toast.t-success { border-left-color: var(--pos); } .at-toast.t-error { border-left-color: var(--neg); } .at-toast.t-warn { border-left-color: var(--warn); } .at-toast.t-info { border-left-color: var(--accent); }
.at-toast .tt-body { flex: 1; min-width: 0; overflow-wrap: anywhere; } .at-toast .tt-title { font-weight: 700; display: block; }
.at-toast button { min-width: 44px; min-height: 44px; margin: -10px 0 -10px 0; background: transparent; border: 0; color: var(--muted); cursor: pointer; border-radius: 8px; }
.at-toast button:hover { color: var(--text); }
@keyframes at-toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
#at-progress { position: fixed; left: 0; top: 0; height: 3px; width: 0; z-index: 4000; background: var(--accent); box-shadow: 0 0 8px var(--accent); opacity: 0; transition: width .25s ease, opacity .25s ease; pointer-events: none; }
#at-progress.on { opacity: 1; }
dialog.at-dialog { border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; box-shadow: var(--shadow); width: min(640px, calc(100vw - 20px)); max-height: calc(100vh - 20px); }
dialog.at-dialog::backdrop { background: rgba(2,6,12,.62); }
.at-palette { margin-top: 8vh; }
.pal-input { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.pal-input .ic { color: var(--muted); flex: none; }
.pal-input input { flex: 1; min-width: 0; min-height: 48px; background: transparent; border: 0; color: var(--text); font-size: 16px; outline: none; }
.pal-list { list-style: none; margin: 0; padding: 6px; max-height: min(56vh, 460px); overflow-y: auto; }
.pal-group { padding: 8px 10px 2px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.pal-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; min-height: 44px; border-radius: 10px; cursor: pointer; }
.pal-item .ic { flex: none; margin-top: 2px; color: var(--muted); }
.pal-item .pi-label { display: block; font-weight: 600; } .pal-item .pi-desc { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; }
.pal-item[aria-selected="true"] { background: var(--info-bg); box-shadow: inset 3px 0 0 var(--accent); }
.pal-empty { padding: 18px 14px; color: var(--muted); text-align: center; }
.pal-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); align-items: center; }
.at-help-body { padding: 16px 18px 18px; }
.at-help-body h2 { font-size: 18px; margin: 0 0 10px; }
.at-help-body table { width: 100%; font-size: 13px; } .at-help-body td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; } .at-help-body td:first-child { white-space: nowrap; width: 38%; }

/* ---------------------------------------------------------------- legacy page blocks (kept; now theme-aware) */
.decision-card { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 8px; padding: 10px 12px; }
.decision-card.buy { border-left-color: var(--pos); }
.dc-symbol { font-family: var(--mono); font-weight: 800; font-size: 16px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 10px; }
.big { font-size: 26px; font-weight: 800; }
.msbar { position: relative; height: 10px; border-radius: 999px; background: var(--track); margin-bottom: 38px; }
.msbar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--pos); }
.msbar-tick { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--line-strong); }
.msbar-tick.reached { background: var(--pos); }
.msbar-tick span { position: absolute; top: 18px; left: -12px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.calc-sentence { font-size: 15px; font-weight: 600; min-height: 1.4em; }
tr.calc-best > td { background: var(--pos-bg); }
tr.calc-chosen > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
details.fold { border-top: 1px solid var(--line); padding: 6px 0; }
details.fold > summary { cursor: pointer; color: var(--muted); font-size: 12px; letter-spacing: .04em; overflow-wrap: anywhere; min-height: 32px; }
details.fold > summary { list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "\25B8"; display: inline-block; width: 1.1em; color: var(--faint); transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary:hover, details.fold[open] > summary { color: var(--text); }
details.fold[open] > summary { margin-bottom: 8px; }
.year-list { display: flex; flex-wrap: wrap; gap: 2px 14px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.wrap-any { overflow-wrap: anywhere; }
tr.row-selected > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.table-wraphead thead th { white-space: normal; vertical-align: bottom; }
.table-wraphead th:first-child, .table-wraphead td:first-child { min-width: 170px; }
.table-gates th:first-child, .table-gates td:first-child { min-width: 170px; width: 55%; }
.table-gates th:nth-child(2), .table-gates td:nth-child(2) { white-space: nowrap; }
.planner-result { font-family: var(--mono); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.registry-table th, .registry-table td { vertical-align: top; }
.registry-table td.test { min-width: 160px; }
.registry-table td.plan { min-width: 140px; }
/* responsive guards: title rows wrap; bare tables inside panels scroll within the panel */
.panel-title-row select, .form-select.w-auto { max-width: 100%; }
.panel > .table, .accordion-body > .table, .panel > form > .table { display: block; overflow-x: auto; }
/* light-theme compatibility for the few hard-coded dark colours still inline in other pages */
[data-bs-theme="light"] [style*="#1b2531"] { background: var(--track) !important; }
[data-bs-theme="light"] [style*="#8796a8"] { color: var(--muted) !important; }
[data-bs-theme="light"] [style*="#94a3b8"] { color: var(--muted) !important; }
[data-bs-theme="light"] [style*="#1f2a37"] { border-color: var(--line) !important; }

/* ---------------------------------------------------------------- small screens, touch, zoom */
@media (max-width: 576px) {
  body { font-size: 13.5px; }
  .navbar-brand { font-size: 15px; letter-spacing: .08em; margin-right: 0; padding-left: 0; }
  .at-tools { gap: 2px; }
  .kpi .value { font-size: 18px; }
  .mode-banner { padding: 5px 12px; font-size: 12px; }
  .mode-banner .mode-word { font-size: 15px; }
  .page-title { font-size: 19px; }
  .track .ms .lbl { font-size: 9px; }
  .track .ms.hide-sm .lbl { display: none; }
  .panel { padding: 12px; }
  .pill { white-space: normal; max-width: 100%; }
  .panel-title-row select { width: 100% !important; }
  .chart-box.xtall { height: 460px; }
  .msbar-tick span { font-size: 9px; left: -9px; } .big { font-size: 20px; }
  .planner-result { font-size: 18px; }
  .form-control, .form-select { font-size: 16px; }
  .kv { grid-template-columns: 1fr; gap: 0 12px; } .kv dt { margin-top: 6px; }
}
@media (pointer: coarse), (max-width: 576px) {
  .btn, .form-control, .form-select { min-height: 44px; }
  .btn-sm { min-height: 44px; padding-left: .9rem; padding-right: .9rem; }
  .dropdown-item, .nav-link, .nav-tabs .nav-link { min-height: 44px; }
  details.fold > summary, details > summary { min-height: 44px; display: flex; align-items: center; }
  .form-check-input { width: 1.4em; height: 1.4em; }
  .table a, .panel a.stretch { padding: 4px 0; display: inline-block; }
}
@media (min-width: 992px) { .navbar-nav { flex-wrap: wrap; } }
@media print {
  .mode-banner { position: static; } .at-nav, .at-tabbar, .at-toasts, #at-progress, .skip-link, .at-offline { display: none !important; }
  body { background: #fff; color: #000; } .panel { border-color: #999; break-inside: avoid; }
}

/* ---------------------------------------------------------------- fallback when the Bootstrap CSS CDN is unreachable (html.no-bs) */
html.no-bs .container-xl { max-width: 1320px; margin-left: auto; margin-right: auto; padding-left: 16px; padding-right: 16px; }
html.no-bs .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
html.no-bs .row > * { min-width: 0; }
html.no-bs .d-flex { display: flex; } html.no-bs .flex-wrap { flex-wrap: wrap; } html.no-bs .flex-column { flex-direction: column; }
html.no-bs .justify-content-between { justify-content: space-between; } html.no-bs .align-items-center { align-items: center; } html.no-bs .align-items-end { align-items: flex-end; }
html.no-bs .gap-1 { gap: 4px; } html.no-bs .gap-2 { gap: 8px; } html.no-bs .gap-3 { gap: 16px; }
html.no-bs .d-none { display: none; } html.no-bs .w-100 { width: 100%; } html.no-bs .ms-auto { margin-left: auto; } html.no-bs .text-center { text-align: center; }
html.no-bs .mt-1 { margin-top: 4px; } html.no-bs .mt-2 { margin-top: 8px; } html.no-bs .mt-3 { margin-top: 16px; } html.no-bs .mb-2 { margin-bottom: 8px; } html.no-bs .mb-3 { margin-bottom: 16px; }
html.no-bs table { border-collapse: collapse; width: 100%; } html.no-bs th, html.no-bs td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }
html.no-bs .table-responsive { overflow-x: auto; }
html.no-bs .btn { display: inline-block; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 14px; }
html.no-bs .btn-danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
html.no-bs .btn-info { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
html.no-bs .btn:disabled { opacity: .5; cursor: not-allowed; }
html.no-bs .form-control, html.no-bs .form-select { display: block; width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 14px; }
html.no-bs .form-label { display: block; }
html.no-bs .modal { display: none; position: fixed; inset: 0; z-index: 1055; overflow: auto; background: rgba(0,0,0,.6); }
html.no-bs .modal.show { display: block; } html.no-bs .modal-dialog { max-width: 520px; margin: 10vh auto; } html.no-bs .modal-content { padding: 16px; border-radius: 12px; }
html.no-bs .modal-header, html.no-bs .modal-footer { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 8px 0; }
html.no-bs .btn-close { background: transparent; border: 0; color: var(--text); font-size: 20px; } html.no-bs .btn-close::before { content: "\00d7"; }
html.no-bs .collapse:not(.show) { display: none; }

/* ---------------------------------------------------------------- QA shell additions (new classes only) */
.foot-links { display: flex; flex-wrap: wrap; gap: 0 18px; margin-top: 4px; }
.foot-links a, footer .btn-link { display: inline-flex; align-items: center; min-height: 44px; font: inherit; color: var(--accent); text-decoration: none; padding: 0; border: 0; background: none; }
.foot-links a:hover, footer .btn-link:hover { text-decoration: underline; }
/* Settings: at-a-glance strip, lock list, audit list, phone-stacked tables */
.set-glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 12px; }
.sg-tile { display: flex; flex-direction: column; gap: 1px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); text-decoration: none !important; min-width: 0; }
.sg-tile:hover { border-color: var(--accent); }
.sg-k { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sg-v { font-weight: 800; font-size: 16px; overflow-wrap: anywhere; }
.sg-d { font-size: 12px; color: var(--muted); }
.sg-safe { border-color: var(--pos); } .sg-safe .sg-v { color: var(--pos); }
.sg-open { border-color: var(--neg); background: var(--neg-bg); } .sg-open .sg-v { color: var(--neg); }
.lock-list { list-style: none; margin: 0; padding: 0; }
.lock-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.lock-state { flex: 0 0 82px; padding-top: 1px; }
.lock-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.lock-plain { display: block; }
.lock-key { overflow-wrap: anywhere; }
.set-savebar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
details.danger-zone > summary.danger-sum { cursor: pointer; color: var(--neg); margin-bottom: 10px; list-style: none; }
details.danger-zone > summary.danger-sum::-webkit-details-marker { display: none; }
details.danger-zone > summary.danger-sum::before { content: "\25B8"; display: inline-block; width: 1.1em; }
details.danger-zone[open] > summary.danger-sum::before { transform: rotate(90deg); }
.audit-list { list-style: none; margin: 0; padding: 0; }
.audit-row { padding: 10px 0; border-top: 1px solid var(--line); }
.audit-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.audit-reason { margin-top: 4px; font-size: 13px; overflow-wrap: anywhere; }
.audit-val pre.log { max-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack th, .table-stack td { display: block; width: 100%; }
  .table-stack thead { display: none; }
  .table-stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
  .table-stack th[scope="row"] { grid-column: 1 / -1; padding: 0; border: 0; font-weight: 700 !important; }
  .table-stack td { padding: 0; border: 0; text-align: left !important; }
  .table-stack td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-family: system-ui, sans-serif; }
  .set-savebar { position: sticky; bottom: calc(var(--tabbar-h) + 4px); z-index: 5; background: var(--panel); padding: 8px 0; margin-top: 4px; border-top: 1px solid var(--line); }
}
.set-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.set-grid > .panel { height: auto; }
.set-danger { border-style: dashed; border-color: var(--neg); }
.set-danger details.danger-zone { border: 0; padding: 0; background: none; margin: 0; }
@media (min-width: 992px) {
  .set-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
  .set-form { grid-column: 1; grid-row: 1; } .set-locks { grid-column: 2; grid-row: 1 / span 2; } .set-danger { grid-column: 1; grid-row: 2; }
}
.table-stack th, .table-stack td { padding-left: .4rem; padding-right: .4rem; }
.table-stack thead th { white-space: normal; vertical-align: bottom; font-size: 11px; }
@media (min-width: 576px) { .sg-tile:last-child:nth-child(odd) { } }
@media (max-width: 575.98px) { .set-glance { grid-template-columns: 1fr 1fr; gap: 8px; } .sg-tile:last-child { grid-column: 1 / -1; } .sg-tile { padding: 8px 12px; } }
/* System: health grid, event list */
.health-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
.health-row { position: relative; }
.hr-label a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.health-calm > summary { min-height: 44px; }
.event-list { list-style: none; margin: 0; padding: 0; }
.event-row { display: grid; grid-template-columns: 112px 74px minmax(150px, 230px) 1fr; gap: 2px 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.event-row .pill { justify-self: start; }
.ev-msg { overflow-wrap: anywhere; }
@media (max-width: 767.98px) {
  .event-row { grid-template-columns: auto auto 1fr; }
  .event-row .ev-msg { grid-column: 1 / -1; }
  .event-row .ev-src { overflow-wrap: anywhere; }
}
/* Readiness: family list + checklist */
.fam-list, .check-list { list-style: none; margin: 0; padding: 0; }
.fam-row { padding: 10px 0; border-top: 1px solid var(--line); }
.fam-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.fam-name { font-weight: 600; flex: 1 1 200px; }
.fam-n { color: var(--muted); font-size: 12.5px; }
details.fam-missed { border-top: 0; padding: 0; }
.fam-missed ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.check-state { flex: 0 0 92px; }
.check-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.check-ev { margin-top: 2px; }
@media (max-width: 575.98px) { .check-row { flex-direction: column; gap: 4px; } .check-state { flex-basis: auto; } }
.il-h3 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 10px 0 6px; }
/* Home: reference folds sit in a row of their own so the two columns above stay balanced */
.il-refs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; align-items: start; }
@media (min-width: 992px) { .il-refs { grid-template-columns: repeat(3, minmax(0, 1fr)); } .il-refs > details.fold { border-top: 1px solid var(--line); } }
.il-charts-empty .il-h3, .il-charts-empty #il-bal-empty { display: none; }
@media (min-width: 992px) { .il-masonry { column-count: 2; column-gap: 16px; } .il-masonry > *, .il-masonry .panel { break-inside: avoid; } .il-masonry > .panel, .il-masonry > div { margin-bottom: 16px; } }
.il-jump { display: flex; gap: 8px; overflow-x: auto; margin: 10px -4px 0; padding: 2px 4px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.il-jump::-webkit-scrollbar { display: none; }
.il-jump a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none !important; background: var(--panel); white-space: nowrap; }
.il-jump a:hover, .il-jump a:focus-visible { border-color: var(--accent); color: var(--accent); }
[id^="il-"] { scroll-margin-top: calc(var(--banner-h) + 70px); }
@media (max-width: 575.98px) { .il-heat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } .il-tile { min-height: 80px; padding: 8px; } .il-tile-sym { font-size: 14px; } .il-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; } .il-card-grid .il-cap { font-size: 9px; letter-spacing: 0; } .il-card-grid { font-size: 12.5px; } .il-card { padding: 10px; min-height: 0; } }
/* Overview: what to do now */
.ns-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ns-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; background: var(--panel-2); flex-wrap: wrap; }
.ns-item.ns-bad { border-left-color: var(--neg); } .ns-item.ns-warn { border-left-color: var(--warn); } .ns-item.ns-info { border-left-color: var(--accent); } .ns-item.ns-ok { border-left-color: var(--pos); }
.ns-tag { flex: 0 0 76px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.ns-bad .ns-tag { color: var(--neg); } .ns-warn .ns-tag { color: var(--warn); } .ns-info .ns-tag { color: var(--accent); } .ns-ok .ns-tag { color: var(--pos); }
.ns-body { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 575.98px) { .ns-tag { flex-basis: 100%; } }
/* progress track: room for the end labels, and no tick label hidden under the cursor */
.track-wrap { padding-left: 30px; padding-right: 30px; }
.track .ms.under-cursor .lbl { display: none; }
@media (max-width: 575.98px) { .track-wrap { padding-left: 22px; padding-right: 22px; } }

/* ---------------------------------------------------------------- print: always ink-on-paper, no controls */
@media print {
  :root, [data-bs-theme="dark"], [data-bs-theme="light"] {
    color-scheme: light; --bg: #fff; --panel: #fff; --panel-2: #fff; --panel-3: #f3f3f3; --line: #aaa; --line-strong: #888; --text: #000; --muted: #333; --faint: #555;
    --track: #ddd; --pos: #065f46; --neg: #991b1b; --warn: #78350f; --accent: #075985; --info-ink: #000; --ok-ink: #000; --bad-ink: #000; --warn-ink: #000; --neutral-ink: #000;
    --pos-bg: #fff; --neg-bg: #fff; --warn-bg: #fff; --info-bg: #fff; --neutral-bg: #eee; --chart-text: #000; --chart-grid: #ccc;
  }
  body { padding-bottom: 0 !important; font-size: 11pt; }
  .at-header, .il-jump, .btn, .il-btn, .foot-links, .nav-tool, .set-savebar, .controls, .danger-zone, .at-cdn-note, dialog, .offcanvas, [data-copy], .il-heat-controls, .navbar-toggler { display: none !important; }
  .panel, .panel-flat, .notice, .health-row, .ns-item, .sg-tile { box-shadow: none !important; border: 1px solid #888 !important; background: #fff !important; break-inside: avoid; }
  .il-masonry { column-count: 1 !important; }
  .il-tile { break-inside: avoid; }
  a { color: #000 !important; text-decoration: underline; }
  details:not([open]) > :not(summary) { display: none; }
  .page-head { margin-top: 0; }
}
/* Bootstrap's text-* utilities are fixed bright colours (unreadable on white in the light theme): follow the theme tokens instead */
.text-warning { color: var(--warn) !important; }
.text-danger { color: var(--neg) !important; }
.text-success { color: var(--pos) !important; }
.text-info { color: var(--accent) !important; }
@media (max-width: 575.98px) {
  .il-page .page-head { flex-wrap: nowrap; align-items: flex-start; }
  .il-page .page-head .page-actions .btn { min-width: 44px; padding-left: .7rem; padding-right: .7rem; }
  .il-copy-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }   /* icon-only on phones, still named for screen readers */
}
.lock-text > span, .check-text > span.d-block { display: block; }   /* own rule, so the stacked lines survive when the Bootstrap CDN is blocked */
/* the header worker chip never relies on colour alone: when something is wrong, the state is spelled out wherever there is room */
@media (min-width: 576px) { .nav-status .dot.bad ~ .nav-status-text, .nav-status .dot.off ~ .nav-status-text { display: inline; } }

/* Narrow desktop (992-1119px): keep the nav on one row now that there are more top-level items. */
@media (min-width: 992px) and (max-width: 1119.98px) {
  .navbar .navbar-brand { font-size: 1rem; letter-spacing: .08em; margin-right: .5rem; }
  .navbar .nav-link { padding-left: .45rem; padding-right: .45rem; font-size: .92rem; }
  .navbar .navbar-nav { gap: 0; }
}
