/* TrustHouse Platform Management Console: the shared design system for the prototype.
   Tokens follow DESIGN.md section 2. No inline styles anywhere: pages use these classes only.
   Colour means health and nothing else; every state is an icon plus a word. Gold is never text on white. */

/* ================================================================== 1. Tokens */
:root {
  --navy:#0F1F4B; --navy-hover:#1A2B5E; --navy-tint:#E6E9F2; --gold:#FDC700; --gold-soft:#FFF4BF;
  --teal:#244855; --teal-tint:#E3ECEE; --coral:#E64833; --sage:#90AEAD; --sage-tint:#E8EFEF;
  --slate-brand:#90A1B9; --red:#C10104;
  --bg:#F8FAFC; --surface:#FFFFFF; --surface-2:#F1F5F9; --line:#E2E8F0; --text:#0F172A; --muted:#475569;
  --ok:#15803D; --ok-bg:#DCFCE7; --warn:#B45309; --warn-bg:#FEF3C7; --bad:#C10104; --bad-bg:#FEE2E2;
  --run:#244855; --run-bg:#E3ECEE; --wait:#0F1F4B; --wait-bg:#FFF4BF; --off:#475569; --off-bg:#F1F5F9;
  --font:"Manrope","Segoe UI",system-ui,sans-serif; --mono:ui-monospace,"Cascadia Mono",Consolas,monospace;
  --r-chip:999px; --r-btn:8px; --r-card:12px; --r-dialog:16px; --raise:0 8px 24px rgb(15 31 75 / .12);
  /* Component tokens (not in the brand table): navy things that must flip in night mode. */
  --ink:#0F1F4B; --ink-hover:#1A2B5E; --on-ink:#FFFFFF;      /* primary buttons, Production chip, done segments, bar fills */
  --on-teal:#FFFFFF; --on-red:#FFFFFF;
  --focus:#0F1F4B; --track:#E2E8F0; --field-line:#64748B; --hover:rgb(15 31 75 / .04);
  --frozen:#0F1F4B; --band-client:#244855; --band-client-text:#FFFFFF;
  --scrim:rgb(10 20 51 / .55);
  --header-h:56px; --fleet-h:40px; --side-w:232px; --side-folded:64px; --gutter:24px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy-hover:#22356E; --navy-tint:#1A2747; --gold-soft:#2A2610; --teal:#7FC4CF; --teal-tint:#12323A;
    --coral:#FF7A63; --sage:#5E7E7D; --sage-tint:#17282B; --slate-brand:#5B6B85; --red:#F87171;
    --bg:#0A1433; --surface:#13224F; --surface-2:#1A2B5E; --line:#2A3A6B; --text:#E2E8F0; --muted:#A9B4C8;
    --ok:#4ADE80; --ok-bg:#0F2E1D; --warn:#FBBF24; --warn-bg:#33270A; --bad:#F87171; --bad-bg:#3A1214;
    --run:#7FC4CF; --run-bg:#12323A; --wait:#FDC700; --wait-bg:#2A2610; --off:#A9B4C8; --off-bg:#1A2B5E;
    --raise:0 8px 24px rgb(0 0 0 / .4); color-scheme: dark;
    --ink:#C7D3F7; --ink-hover:#E2E8F0; --on-ink:#0F1F4B; --on-teal:#0A1433; --on-red:#1A0505;
    --focus:#FDC700; --track:#24356B; --field-line:#6B7BA8; --hover:rgb(255 255 255 / .04);
    --frozen:#E2E8F0; --band-client:#12323A; --band-client-text:#E2E8F0; --scrim:rgb(0 0 0 / .6);
  }
}
:root[data-theme="dark"] {
  --navy-hover:#22356E; --navy-tint:#1A2747; --gold-soft:#2A2610; --teal:#7FC4CF; --teal-tint:#12323A;
  --coral:#FF7A63; --sage:#5E7E7D; --sage-tint:#17282B; --slate-brand:#5B6B85; --red:#F87171;
  --bg:#0A1433; --surface:#13224F; --surface-2:#1A2B5E; --line:#2A3A6B; --text:#E2E8F0; --muted:#A9B4C8;
  --ok:#4ADE80; --ok-bg:#0F2E1D; --warn:#FBBF24; --warn-bg:#33270A; --bad:#F87171; --bad-bg:#3A1214;
  --run:#7FC4CF; --run-bg:#12323A; --wait:#FDC700; --wait-bg:#2A2610; --off:#A9B4C8; --off-bg:#1A2B5E;
  --raise:0 8px 24px rgb(0 0 0 / .4); color-scheme: dark;
  --ink:#C7D3F7; --ink-hover:#E2E8F0; --on-ink:#0F1F4B; --on-teal:#0A1433; --on-red:#1A0505;
  --focus:#FDC700; --track:#24356B; --field-line:#6B7BA8; --hover:rgb(255 255 255 / .04);
  --frozen:#E2E8F0; --band-client:#12323A; --band-client-text:#E2E8F0; --scrim:rgb(0 0 0 / .6);
}

/* ================================================================== 2. Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + var(--fleet-h) + 48px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/24px var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 8px; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 24px; line-height: 32px; font-weight: 700; }
h2 { font-size: 18px; line-height: 26px; font-weight: 600; }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
h4 { font-size: 14px; line-height: 20px; font-weight: 600; }
h1:focus { outline: none; }
p { margin: 0 0 8px; }
ul, ol { margin: 0 0 8px; padding-left: 20px; }
a { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, samp, .th-mono { font-family: var(--mono); font-size: 13px; line-height: 20px; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
::selection { background: var(--gold-soft); color: var(--text); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.th-on-navy :focus-visible, .th-band--prod :focus-visible { outline-color: var(--gold); }

.th-display { font-size: 28px; line-height: 36px; font-weight: 700; letter-spacing: -0.02em; }
.th-caption { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--muted); }
.th-small { font-size: 14px; line-height: 20px; }
.th-muted { color: var(--muted); }
.th-num, .th-facts dd, .th-table td, .th-count, .th-progress__value { font-variant-numeric: tabular-nums; }
.th-nowrap { white-space: nowrap; }
.th-bad-text { color: var(--bad); font-weight: 600; }
.th-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.th-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Icons: one sprite, <svg class="th-i"><use href="#id"/></svg>, or TH.icon('id'). */
.th-i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.th-i--sm { width: 14px; height: 14px; }
.th-i--lg { width: 24px; height: 24px; }
.th-pill--run .th-i, .th-i--spin, .th-env__run .th-i, .th-stage.is-current .th-stage__name .th-i { animation: th-spin 1.2s linear infinite; }
@keyframes th-spin { to { transform: rotate(360deg); } }

.th-skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); color: var(--text); padding: 10px 16px; border-radius: 8px; box-shadow: var(--raise); }
.th-skip:focus { left: 16px; }

/* ================================================================== 3. Shell: header, fleet strip, sidebar, phone tab bar */
#th-shell { display: contents; }

.th-header { position: sticky; top: 0; z-index: 40; height: var(--header-h); display: flex; align-items: center; gap: 16px;
  padding: 0 16px 0 20px; background: var(--navy); color: #FFFFFF; border-bottom: 1px solid rgb(255 255 255 / .08); }
.th-logo { display: flex; align-items: center; flex: none; padding: 4px 0; border-radius: 4px; }
.th-logo img { display: block; height: 32px; width: auto; }
.th-header__divider { width: 1px; height: 24px; background: var(--slate-brand); flex: none; }
.th-appname { font-weight: 600; font-size: 15px; white-space: nowrap; color: #FFFFFF; }
.th-header .th-header__search { display: none; }
.th-header__right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.th-search { position: relative; flex: 1 1 360px; max-width: 480px; margin: 0 auto; }
.th-search input { width: 100%; height: 40px; padding: 0 40px 0 38px; border-radius: var(--r-btn); border: 1px solid rgb(255 255 255 / .2);
  background: rgb(255 255 255 / .08); color: #FFFFFF; font: 500 14px var(--font); }
.th-search input::placeholder { color: #CBD5E1; }
.th-search input:focus { background: rgb(255 255 255 / .14); outline: 3px solid var(--gold); outline-offset: 1px; }
.th-search__icon { position: absolute; left: 11px; top: 11px; color: #CBD5E1; }
.th-search__key { position: absolute; right: 8px; top: 9px; background: rgb(255 255 255 / .1); color: #CBD5E1; border-color: rgb(255 255 255 / .2); }
.th-search__results { position: absolute; left: 0; right: 0; top: calc(100% + 8px); margin: 0; padding: 6px; list-style: none; z-index: 50;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--raise); }
.th-search__results a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.th-search__results a:hover, .th-search__results a:focus-visible { background: var(--surface-2); }
.th-search__kind { color: var(--muted); font-size: 13px; }
.th-search__none { padding: 10px 12px; color: var(--muted); font-size: 14px; }

.th-oncall { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: var(--r-chip);
  background: rgb(255 255 255 / .08); border: 1px solid rgb(255 255 255 / .16); color: #FFFFFF; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.th-oncall:hover { background: rgb(255 255 255 / .14); }
.th-oncall .th-i { color: var(--gold); width: 16px; height: 16px; }

.th-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border-radius: var(--r-btn);
  border: 0; background: transparent; color: var(--text); cursor: pointer; position: relative; }
.th-iconbtn:hover { background: var(--surface-2); }
.th-iconbtn--sm { width: 32px; height: 32px; }
.th-iconbtn--navy { color: #FFFFFF; }
.th-iconbtn--navy:hover { background: rgb(255 255 255 / .1); }
.th-bell__count { position: absolute; top: 6px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--gold); color: #0F1F4B; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

/* Pop menus: native <details>; console.js closes them on outside click and Escape. */
.th-pop { position: relative; }
.th-pop > summary { list-style: none; cursor: pointer; }
.th-pop > summary::-webkit-details-marker { display: none; }
.th-pop__panel { position: absolute; right: 0; top: calc(100% + 10px); z-index: 50; width: 320px; max-width: calc(100vw - 32px); padding: 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--raise); }
.th-pop__title { font-weight: 600; margin-bottom: 8px; }
.th-pop__label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.th-pop__list { list-style: none; margin: 0; padding: 0; }
.th-pop__list a { display: grid; gap: 4px; padding: 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.th-pop__list a:hover { background: var(--surface-2); }
.th-pop__meta { font-size: 13px; color: var(--muted); }
.th-me { display: flex; align-items: center; gap: 8px; height: 44px; white-space: nowrap; padding: 0 8px 0 4px; border-radius: var(--r-btn); color: #FFFFFF; font-weight: 600; font-size: 14px; }
.th-me:hover { background: rgb(255 255 255 / .1); }
.th-me .th-i { width: 16px; height: 16px; color: #CBD5E1; }
.th-me__card { display: flex; gap: 12px; align-items: center; }
.th-me__full { font-weight: 600; margin: 0 0 4px; }
.th-me__line { display: flex; gap: 8px; align-items: center; margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.th-me__line .th-i { color: var(--ok); }
.th-avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; flex: none;
  background: rgb(255 255 255 / .16); color: #FFFFFF; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.th-avatar--lg { width: 44px; height: 44px; font-size: 15px; background: var(--navy); color: #FFFFFF; }
.th-pop__panel .th-btn--block { margin-top: 16px; }

/* Fleet strip: one pill per environment, broken first. */
.th-fleet { position: sticky; top: var(--header-h); z-index: 35; height: var(--fleet-h); display: flex; align-items: center;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
/* The end fades when the strip scrolls; the 32 px end padding lets the last pill scroll clear of the fade. */
.th-fleet__list { display: flex; gap: 8px; margin: 0; padding: 0 32px 0 0; list-style: none; overflow-x: auto; scrollbar-width: none;
  mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
.th-fleet__list::-webkit-scrollbar { display: none; }
.th-fleet__summary { display: none; }
.th-fpill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px; border-radius: var(--r-chip);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.th-fpill:hover { background: var(--surface-2); }
.th-fpill .th-i { width: 15px; height: 15px; }
.th-fpill__name { font-weight: 600; }
.th-fpill__word { color: var(--muted); }
.th-fpill--ok .th-i { color: var(--ok); } .th-fpill--warn .th-i { color: var(--warn); } .th-fpill--bad .th-i { color: var(--bad); }
.th-fpill--run .th-i { color: var(--run); animation: th-spin 1.2s linear infinite; } .th-fpill--wait .th-i { color: var(--wait); }
.th-fpill--off .th-i, .th-fpill--unknown .th-i, .th-fpill--noaccess .th-i, .th-fpill--stopped .th-i { color: var(--off); }
.th-fpill.is-broken { border: 2px solid var(--bad); padding: 0 9px 0 7px; }
.th-fpill.is-broken .th-fpill__word { color: var(--bad); font-weight: 600; }

/* Sidebar: navy, gold bar on the active item. */
.th-side { position: fixed; z-index: 30; top: calc(var(--header-h) + var(--fleet-h)); bottom: 0; left: 0; width: var(--side-w);
  display: flex; flex-direction: column; justify-content: space-between; padding: 12px 0 16px; overflow-y: auto;
  background: var(--navy); color: #CBD5E1; border-right: 1px solid rgb(255 255 255 / .06); }
.th-nav { list-style: none; margin: 0; padding: 0 8px; }
.th-nav a { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px;
  color: #CBD5E1; font-weight: 500; font-size: 14px; text-decoration: none; }
.th-nav a:hover { background: rgb(255 255 255 / .06); color: #FFFFFF; }
.th-nav a[aria-current="page"] { background: rgb(255 255 255 / .1); color: #FFFFFF; font-weight: 700; }
.th-nav a[aria-current="page"]::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gold); }
.th-nav .th-i { width: 20px; height: 20px; }
.th-nav__label { flex: 1; }
.th-nav__count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: rgb(255 255 255 / .14); color: #FFFFFF;
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.th-nav__count--bad { background: #C10104; color: #FFFFFF; }
.th-nav__count--gold { background: var(--gold); color: #0F1F4B; }
.th-nav--small a { min-height: 40px; font-size: 13px; }
.th-side__foot { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid rgb(255 255 255 / .08); margin: 16px 8px 0; }
.th-side__foot .th-nav { padding: 0; }
.th-side__status { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 0 12px; font-size: 12px; line-height: 18px; color: #CBD5E1; }
.th-side__status .th-i { color: #4ADE80; width: 16px; height: 16px; margin-top: 1px; }
.th-side__bb { display: flex; gap: 8px; align-items: flex-start; padding: 0 12px; font-size: 12px; line-height: 18px; color: #FFFFFF; }
.th-side__bb .th-i { width: 16px; height: 16px; margin-top: 1px; }
.th-side__wordmark { display: block; height: 24px; width: auto; margin: 6px 12px 0; }

.th-tabbar, .th-scrim { display: none; }

/* Main area */
.th-main { margin-left: var(--side-w); padding: var(--gutter); min-height: calc(100vh - var(--header-h) - var(--fleet-h)); }
.th-main > * { max-width: 1440px; }
.th-main > .th-band { max-width: none; }

/* Context band: names the target on every page that acts. Sticky under the fleet strip. */
.th-band { position: sticky; top: calc(var(--header-h) + var(--fleet-h)); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  margin: calc(var(--gutter) * -1) calc(var(--gutter) * -1) 0; padding: 10px var(--gutter); font-size: 14px; line-height: 20px; font-weight: 600;
  border-bottom: 1px solid var(--line); }
.th-band__name { font-weight: 700; font-size: 15px; }
.th-band__sep { opacity: .6; }
.th-band span > .th-band__sep { margin-left: 10px; } /* the dot ends its part, so a wrapped line never starts with one */
.th-band__icon { width: 18px; height: 18px; }
.th-band--internal { background: var(--sage-tint); color: var(--text); }
.th-band--demo { background: var(--navy-tint); color: var(--text); }
.th-band--client { background: var(--band-client); color: var(--band-client-text); }
.th-band--prod { background: var(--navy); color: #FFFFFF; border-bottom-color: rgb(255 255 255 / .1); }
.th-band--prod .th-band__icon { color: var(--gold); }
.th-band + *, .th-band + .th-proto { margin-top: 16px; }
.th-band--static { position: static; margin: 0; border-radius: var(--r-btn); border-bottom: 0; }

.th-crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 16px 0 8px; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.th-crumbs li + li::before { content: "/"; margin-right: 4px; color: var(--line); }
.th-crumbs a { color: var(--muted); }
.th-crumbs [aria-current] { color: var(--text); font-weight: 600; }

.th-pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 8px 0 24px; }
.th-pagehead__title { display: grid; gap: 8px; min-width: 0; }
.th-pagehead__title h1 { margin: 0; overflow-wrap: anywhere; }
.th-pagehead__meta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; color: var(--muted); font-size: 14px; }
.th-pagehead__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Prototype state switcher (top right of the main area). */
.th-proto { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin: 0 0 8px auto; font-size: 13px; }
.th-proto__tag { padding: 2px 8px; border: 1px dashed var(--muted); border-radius: var(--r-chip); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.th-proto__label { color: var(--muted); font-weight: 600; }

/* ================================================================== 4. Layout helpers */
.th-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; } /* one column that never grows past its parent */
.th-stack--lg { gap: 24px; }
/* A narrow column on the left (a queue, a step rail) beside the content; one column, left part first, under 1024 px. */
.th-leftcol { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; align-items: start; }
.th-leftcol--narrow { grid-template-columns: 272px minmax(0, 1fr); }
.th-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.th-row--between { justify-content: space-between; }
.th-grid { display: grid; gap: 16px; }
.th-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.th-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.th-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.th-grid--auto { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.th-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.th-split__aside { position: sticky; top: calc(var(--header-h) + var(--fleet-h) + 64px); }
.th-rail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.th-section { margin: 32px 0 0; }
.th-section > h2 { margin-bottom: 12px; }
.th-section__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.th-section__head h2 { margin: 0; }

/* ================================================================== 5. Cards and facts */
.th-card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; }
.th-card--flat { padding: 16px; }
.th-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.th-card__title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; overflow-wrap: anywhere; }
.th-card__title a { color: var(--text); text-decoration: none; }
.th-card__title a:hover { text-decoration: underline; }
.th-card__meta { margin: 0; color: var(--muted); font-size: 14px; line-height: 20px; }
.th-card__foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px -20px -20px; padding: 12px 20px;
  border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-card) var(--r-card); }
.th-card--firing { box-shadow: inset 4px 0 0 var(--bad); }
.th-card--accent { border-top: 3px solid var(--ink); }
.th-card--quiet { position: relative; overflow: hidden; background: #EEF4FB url("trusthouse-background.png") center / cover no-repeat; color: #0F172A; border-color: #DCE6F2; }
.th-card--quiet h2, .th-card--quiet h3 { color: #0F172A; }
.th-card--quiet .th-muted { color: #475569; }
:root[data-theme="dark"] .th-card--quiet { background: linear-gradient(135deg, #13224F, #0F1F4B 60%, #12323A); color: var(--text); border-color: var(--line); }
:root[data-theme="dark"] .th-card--quiet h2, :root[data-theme="dark"] .th-card--quiet h3 { color: var(--text); }
:root[data-theme="dark"] .th-card--quiet .th-muted { color: var(--muted); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .th-card--quiet { background: linear-gradient(135deg, #13224F, #0F1F4B 60%, #12323A); color: var(--text); border-color: var(--line); }
  :root:not([data-theme="light"]) .th-card--quiet h2, :root:not([data-theme="light"]) .th-card--quiet h3 { color: var(--text); }
  :root:not([data-theme="light"]) .th-card--quiet .th-muted { color: var(--muted); }
}

.th-facts { display: grid; grid-template-columns: fit-content(50%) minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 14px; line-height: 20px; }
.th-facts dt { color: var(--muted); }
.th-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.th-facts--keys { grid-template-columns: 120px 1fr; align-items: center; }

/* Environment card */
.th-env { position: relative; display: grid; gap: 12px; align-content: start; }
/* The whole tile opens its environment: the title link stretches over the card; the run link stays on top of it. */
.th-env .th-card__title a::after { content: ""; position: absolute; inset: 0; }
.th-env__run a { position: relative; z-index: 1; }
.th-env__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.th-env.is-broken { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.th-env--noaccess, .th-env--off { background: var(--surface-2); }
.th-env__run { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); }
.th-env__run .th-i { color: var(--run); width: 14px; height: 14px; margin-right: 6px; }
.th-env__note { margin: 0; font-size: 14px; color: var(--muted); }
.th-env__foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid var(--line); }
.th-health-words { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; font-size: 14px; color: var(--muted); }
.th-firing-word { display: inline-flex; gap: 6px; align-items: center; color: var(--bad); font-weight: 700; font-size: 13px; }
.th-firing-word .th-i { width: 15px; height: 15px; }
.th-runcard, .th-inc { display: grid; gap: 12px; align-content: start; }
.th-inc .th-card__foot { margin-top: 4px; }

/* Stat tiles */
.th-stat { display: grid; gap: 2px; min-width: 0; align-content: start; }
.th-stat__value { font-size: 28px; line-height: 36px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.th-stat__label { color: var(--muted); font-size: 13px; line-height: 18px; font-weight: 500; }
.th-stat__value .th-i { width: 24px; height: 24px; vertical-align: -2px; }

/* Summary line (Now): display size, each part a link with its icon. */
.th-summary { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; margin: 0; font-size: 28px; line-height: 36px; font-weight: 700; letter-spacing: -0.02em; }
.th-summary a { display: inline-flex; gap: 8px; align-items: center; color: var(--text); text-decoration: none; }
.th-summary a:hover { text-decoration: underline; }
.th-summary .th-i { width: 26px; height: 26px; stroke-width: 2; }
.th-summary__sep { color: var(--line); font-weight: 400; }
.th-summary .is-bad .th-i { color: var(--bad); } .th-summary .is-wait .th-i { color: var(--warn); } .th-summary .is-run .th-i { color: var(--run); }

/* ================================================================== 6. Pills, chips, badges, counts */
.th-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 7px; border-radius: var(--r-chip);
  border: 1px solid transparent; font-size: 13px; line-height: 18px; font-weight: 600; white-space: nowrap; vertical-align: middle;
  background: var(--x-bg, var(--off-bg)); color: var(--x, var(--off)); }
.th-pill .th-i { width: 15px; height: 15px; stroke-width: 2; }
.th-pill--lg { height: 32px; padding: 0 14px 0 10px; font-size: 14px; }
.th-pill--lg .th-i { width: 18px; height: 18px; }
/* A long word that may wrap in a narrow column (a customer's urgency: "Sev 3 · One person or a workaround exists",
   a pill in a compact chain node). */
.th-pill--wrap, .th-chip.th-chip--wrap, .th-chain__node .th-pill { white-space: normal; height: auto; min-height: 24px; max-width: 100%; padding-top: 2px; padding-bottom: 2px; }
.th-pill--wrap .th-i, .th-chain__node .th-pill .th-i { flex: none; }
.th-pill--ok { --x: var(--ok); --x-bg: var(--ok-bg); }
.th-pill--warn { --x: var(--warn); --x-bg: var(--warn-bg); }
.th-pill--bad { --x: var(--bad); --x-bg: var(--bad-bg); }
.th-pill--run, .th-pill--inrun { --x: var(--run); --x-bg: var(--run-bg); }
.th-pill--wait { --x: var(--wait); --x-bg: var(--wait-bg); border-color: var(--gold); }
.th-pill--off, .th-pill--noaccess, .th-pill--stopped { --x: var(--off); --x-bg: var(--off-bg); }
.th-pill--unknown { --x: var(--off); --x-bg: var(--off-bg); border: 1px dashed var(--off); }
.th-pill--frozen { --x: var(--frozen); --x-bg: var(--navy-tint); }

.th-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.th-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: var(--r-chip); border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.th-chip .th-i { width: 14px; height: 14px; }
.th-chip--arhasi { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }
.th-chip--client { border-color: var(--ink); color: var(--ink); }
.th-chip--prod { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.th-chip--staging, .th-chip--dev { border-color: var(--field-line); color: var(--text); }
.th-chip--demo { background: var(--navy-tint); border-color: var(--line); color: var(--frozen); }
.th-chip--internal { background: var(--sage-tint); border-color: var(--sage); color: var(--text); }
.th-chip--hipaa, .th-chip--soc2 { border-color: var(--ink); color: var(--ink); }
.th-chip--region { border-color: transparent; padding: 0 4px; color: var(--muted); }
.th-chip--size { border: 1px dashed var(--field-line); color: var(--muted); }
.th-chip--frozen { background: var(--navy-tint); border-color: var(--line); color: var(--frozen); }
.th-chip--role { background: var(--surface-2); color: var(--text); }
.th-chip--emergency { background: var(--bad); border-color: var(--bad); color: var(--on-red); }
.th-chip--mono { font-family: var(--mono); font-weight: 400; color: var(--text); }

.th-risk { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px 0 7px; border-radius: var(--r-chip); border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--text); background: var(--surface); }
.th-risk .th-i { width: 14px; height: 14px; stroke-width: 2; }
.th-risk--low .th-i { color: var(--muted); }
.th-risk--medium { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.th-risk--high { border: 1.5px solid var(--coral); }
.th-risk--high .th-i { color: var(--coral); }

.th-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 700; }
.th-count--bad { background: var(--bad); color: var(--on-red); }
.th-count--gold { background: var(--gold); color: #0F1F4B; }
.th-count--run { background: var(--run-bg); color: var(--run); }

.th-age { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--muted); }
.th-age .th-i { width: 14px; height: 14px; }
.th-age--old { color: var(--warn); font-weight: 600; }
.th-age--stale { color: var(--bad); font-weight: 600; }

.th-kbd { display: inline-block; min-width: 22px; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  background: var(--surface); color: var(--text); font: 600 12px/20px var(--mono); text-align: center; }
.th-person { display: inline-flex; align-items: center; gap: 8px; }
.th-person .th-avatar { width: 28px; height: 28px; font-size: 11px; background: var(--surface-2); color: var(--text); }
.th-btnid { display: flex; gap: 6px; align-items: center; margin: 0; font: 400 12px/16px var(--mono); color: var(--muted); }

/* ================================================================== 7. Buttons */
.th-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--r-btn); border: 1px solid transparent; background: var(--surface); color: var(--text);
  font: 600 15px/20px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
.th-btn .th-i { width: 18px; height: 18px; }
.th-btn--primary { background: var(--ink); color: var(--on-ink); }
.th-btn--primary:hover { background: var(--ink-hover); }
.th-btn--secondary { border-color: var(--teal); color: var(--teal); }
.th-btn--secondary:hover { background: var(--teal-tint); }
.th-btn--outline { border-color: var(--field-line); color: var(--text); }
.th-btn--outline:hover { background: var(--surface-2); }
.th-btn--ghost { background: transparent; color: var(--teal); }
.th-btn--ghost:hover { background: var(--surface-2); }
.th-btn--danger { background: var(--red); color: var(--on-red); }
.th-btn--danger:hover { filter: brightness(.92); }
.th-btn--sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.th-btn--block { width: 100%; }
.th-btn--wrap { white-space: normal; text-align: left; padding-top: 10px; padding-bottom: 10px; }
.th-btn:disabled, .th-btn[aria-disabled="true"] { background: var(--surface-2); border-color: var(--line); color: var(--muted); cursor: not-allowed; filter: none; }
.th-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (pointer: coarse) {
  .th-btn--sm { min-height: 44px; }
  /* Small text links get a thumb sized box: section heading links, breadcrumbs, a name link in a table (.th-tap). */
  .th-section__head > a:not(.th-btn) { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; margin: 0 -8px; }
  .th-crumbs a, .th-tap { display: inline-flex; align-items: center; min-height: 32px; }
}

/* A greyed control always says why, in text. */
.th-action { display: grid; gap: 8px; justify-items: start; }
.th-why { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.th-why .th-i { width: 16px; height: 16px; margin-top: 2px; }
.th-why.is-ready { color: var(--ok); font-weight: 600; }

/* ================================================================== 8. Forms */
.th-field { display: grid; gap: 6px; margin: 0 0 20px; min-width: 0; }
.th-label { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--text); }
.th-label__opt { font-weight: 400; color: var(--muted); }
.th-help { margin: 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.th-input, .th-select, .th-textarea { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-btn); border: 1px solid var(--field-line);
  background: var(--surface); color: var(--text); font: 400 15px/22px var(--font); }
.th-textarea { min-height: 96px; resize: vertical; }
.th-select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.th-input--mono { font-family: var(--mono); font-size: 14px; }
.th-input:hover, .th-select:hover, .th-textarea:hover { border-color: var(--text); }
.th-input::placeholder, .th-textarea::placeholder { color: var(--muted); opacity: .8; }
.th-field--error .th-input, .th-field--error .th-select, .th-field--error .th-textarea { border: 2px solid var(--bad); }
.th-error { display: flex; gap: 6px; align-items: flex-start; margin: 0; color: var(--bad); font-size: 14px; line-height: 20px; font-weight: 600; }
.th-error .th-i { width: 16px; height: 16px; margin-top: 2px; }
.th-field--locked .th-input, .th-field--locked .th-select, .th-input:disabled, .th-select:disabled, .th-textarea:disabled {
  background: var(--surface-2); border-style: dashed; color: var(--muted); cursor: not-allowed; }
.th-fixed { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--navy-tint); color: var(--text); font-size: 14px; line-height: 20px; }
.th-fixed .th-i { width: 16px; height: 16px; margin-top: 2px; color: var(--ink); }
.th-fieldset { border: 0; margin: 0 0 20px; padding: 0; min-width: 0; }
.th-fieldset legend { padding: 0; margin-bottom: 6px; font-size: 14px; font-weight: 600; }

.th-check { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 10px 0; cursor: pointer; font-size: 15px; line-height: 22px; }
.th-check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--ink); cursor: pointer; }
.th-check--off { color: var(--muted); cursor: not-allowed; }
.th-check__note { display: block; color: var(--muted); font-size: 13px; line-height: 18px; }

/* Switch: the word On or Off is inside the track, so it never relies on colour. */
.th-switch { position: relative; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 600; font-size: 15px; }
.th-switch input { position: absolute; opacity: 0; width: 64px; height: 32px; margin: 0; cursor: pointer; }
.th-switch__track { position: relative; flex: none; width: 64px; height: 32px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--field-line); transition: background-color .15s; }
.th-switch__track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 999px; background: var(--surface); border: 1px solid var(--field-line); transition: transform .15s; }
.th-switch__track::after { content: "Off"; position: absolute; right: 9px; top: 6px; font-size: 12px; line-height: 18px; font-weight: 700; color: var(--muted); }
.th-switch input:checked + .th-switch__track { background: var(--ink); border-color: var(--ink); }
.th-switch input:checked + .th-switch__track::before { transform: translateX(32px); border-color: var(--ink); }
.th-switch input:checked + .th-switch__track::after { content: "On"; left: 10px; right: auto; color: var(--on-ink); }
.th-switch input:focus-visible + .th-switch__track { outline: 3px solid var(--focus); outline-offset: 2px; }
.th-switch input:disabled + .th-switch__track { opacity: .55; }

/* Segmented control: theme, cards or table, the prototype state switcher. */
.th-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.th-seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font: 600 13px var(--font); cursor: pointer; }
.th-seg button .th-i { width: 15px; height: 15px; }
.th-seg button:hover { color: var(--text); }
.th-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(15 31 75 / .12), 0 0 0 1px var(--line); }
.th-seg--full { display: flex; }
.th-seg--full button { flex: 1; justify-content: center; }

/* Typed confirm: coral left edge because it guards a high risk action. */
.th-confirm { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--line); border-left: 4px solid var(--coral); border-radius: var(--r-btn); background: var(--surface); }
.th-confirm label { font-weight: 600; font-size: 14px; }
.th-confirm__row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.th-confirm__row .th-input { flex: 1 1 220px; font-family: var(--mono); }
.th-confirm__ok { display: none; gap: 6px; align-items: center; color: var(--ok); font-weight: 700; font-size: 14px; }
.th-confirm.is-match .th-confirm__ok { display: inline-flex; }
.th-confirm.is-match .th-input { border-color: var(--ok); }
/* Ticket note guard: the passed line shows until the note looks like personal data, then the blocked line. */
.th-guard { display: grid; gap: 8px; }
.th-guard__ok, .th-guard__bad { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 14px; line-height: 20px; }
.th-guard__bad { display: none; }
.th-guard.is-bad .th-guard__ok { display: none; }
.th-guard.is-bad .th-guard__bad { display: flex; }
.th-guard.is-bad .th-textarea { border: 2px solid var(--bad); }

/* ================================================================== 9. Tables (cards on a phone) */
.th-table-wrap { overflow-x: auto; border-radius: var(--r-card); }
.th-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-card); }
.th-table th { position: relative; padding: 10px 16px; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.th-table thead th:first-child { border-top-left-radius: var(--r-card); }
.th-table thead th:last-child { border-top-right-radius: var(--r-card); }
.th-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.th-table tbody tr:last-child td { border-bottom: 0; }
.th-table tbody tr:hover td { background: var(--hover); }
.th-table tr.is-broken td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.th-table tr.is-coral td:first-child { box-shadow: inset 4px 0 0 var(--coral); }
.th-table th button { display: inline-flex; gap: 4px; align-items: center; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.th-table th[aria-sort="ascending"] button::after { content: "↑"; }
.th-table th[aria-sort="descending"] button::after { content: "↓"; }
.th-table--dense td { padding: 8px 12px; }
.th-table--dense th { padding-left: 12px; padding-right: 12px; }
.th-table .th-num, .th-table .is-num { text-align: right; }
.th-table .th-stagebar--mini { min-width: 120px; }

/* ================================================================== 10. Tabs */
.th-tabs { display: flex; gap: 4px; margin: 0 0 20px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.th-tabs::-webkit-scrollbar { display: none; }
.th-tabs [role="tab"] { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; margin-bottom: -1px; border: 0;
  border-bottom: 3px solid transparent; background: none; color: var(--muted); font: 600 14px var(--font); white-space: nowrap; cursor: pointer; }
.th-tabs [role="tab"]:hover { color: var(--text); }
.th-tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--ink); }
.th-tabs .th-count { min-width: 20px; height: 20px; }

/* A reference section that folds: <details class="th-fold" data-th="fold" open>. Open on a desktop; console.js
   closes it on a phone, so a long page reaches its last sections sooner. */
.th-fold > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; cursor: pointer; list-style: none; }
.th-fold > summary::-webkit-details-marker { display: none; }
.th-fold > summary > * { margin: 0; }
.th-fold > summary::after { content: ""; flex: none; width: 8px; height: 8px; margin: 0 6px 4px 0; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.th-fold[open] > summary { margin-bottom: 12px; }
.th-fold[open] > summary::after { margin: 4px 6px 0 0; transform: rotate(-135deg); }

/* ================================================================== 11. Progress: native <progress> and <meter>, numbers in words beside */
.th-progress { display: grid; gap: 6px; min-width: 0; }
.th-progress__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 13px; line-height: 18px; font-weight: 600; }
.th-progress__value { color: var(--muted); font-weight: 500; }
.th-progress__note { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); }
.th-bar, .th-meter { --fill: var(--ink); display: block; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--track); overflow: hidden; appearance: none; -webkit-appearance: none; }
.th-bar--lg { height: 12px; }
.th-bar::-webkit-progress-bar { background: var(--track); border-radius: 999px; }
.th-bar::-webkit-progress-value { background: var(--fill); border-radius: 999px; transition: width .15s ease; }
.th-bar::-moz-progress-bar { background: var(--fill); border-radius: 999px; }
.th-bar--run { --fill: var(--run); } .th-bar--ok { --fill: var(--ok); } .th-bar--warn { --fill: var(--warn); } .th-bar--bad { --fill: var(--bad); }
.th-bar--wait { --fill: var(--gold); }
/* Indeterminate: the moving stripe, never a made-up percent. */
.th-bar:indeterminate { background: repeating-linear-gradient(-45deg, var(--run-bg) 0 8px, var(--run) 8px 16px); background-size: 22.63px 100%; animation: th-stripe 1s linear infinite; }
.th-bar:indeterminate::-webkit-progress-bar { background: transparent; }
.th-bar:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes th-stripe { to { background-position: 22.63px 0; } }
.th-meter::-webkit-meter-bar { background: var(--track); border: 0; border-radius: 999px; height: 8px; }
.th-meter::-webkit-meter-optimum-value, .th-meter::-webkit-meter-suboptimum-value, .th-meter::-webkit-meter-even-less-good-value { background: var(--fill); border-radius: 999px; }
.th-meter::-moz-meter-bar { background: var(--fill); border-radius: 999px; }
.th-meter--ok { --fill: var(--ok); } .th-meter--warn { --fill: var(--warn); } .th-meter--bad { --fill: var(--bad); } .th-meter--ink { --fill: var(--ink); }
.th-meter--run { --fill: var(--run); }

/* Stage bar: one segment per step. done navy+check, current teal stripe, wait gold+hourglass, fail red+octagon, not run grey. */
.th-stagebar { display: grid; gap: 8px; min-width: 0; }
.th-stages { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin: 0; padding: 0; list-style: none; }
.th-stage { display: grid; gap: 6px; min-width: 0; align-content: start; }
.th-stage__seg { display: block; height: 8px; border-radius: 999px; background: var(--track); }
.th-stage__name { display: flex; gap: 4px; align-items: flex-start; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); min-width: 0; }
.th-stage__name > span:not(.th-sr) { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.th-stage__name .th-i { width: 14px; height: 14px; flex: none; margin-top: 1px; stroke-width: 2; }
.th-stage.is-done .th-stage__seg { background: var(--ink); }
.th-stage.is-done .th-stage__name .th-i { color: var(--ink); }
.th-stage.is-current .th-stage__seg { background: repeating-linear-gradient(-45deg, var(--run) 0 6px, color-mix(in srgb, var(--run) 55%, var(--surface)) 6px 12px); background-size: 16.97px 100%; animation: th-stripe-sm 1s linear infinite; }
@keyframes th-stripe-sm { to { background-position: 16.97px 0; } }
.th-stage.is-current .th-stage__name { color: var(--text); font-weight: 700; }
.th-stage.is-current .th-stage__name .th-i { color: var(--run); }
.th-stage.is-wait .th-stage__seg { background: var(--gold); }
.th-stage.is-wait .th-stage__name { color: var(--text); font-weight: 700; }
.th-stage.is-wait .th-stage__name .th-i { color: var(--wait); }
.th-stage.is-fail .th-stage__seg { background: var(--bad); }
.th-stage.is-fail .th-stage__name { color: var(--bad); font-weight: 700; }
.th-stage.is-skip .th-stage__seg { background: repeating-linear-gradient(90deg, var(--line) 0 4px, transparent 4px 7px); }
.th-stage.is-todo .th-stage__seg { background: var(--track); }
.th-stagebar__now { margin: 0; font-size: 14px; line-height: 20px; font-weight: 600; }
.th-stagebar--mini .th-stages { gap: 3px; }
.th-stagebar--mini .th-stage__seg { height: 6px; }
.th-stagebar--mini .th-stage { gap: 0; }

.th-runprog { display: grid; gap: 16px; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.th-runprog__head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.th-runprog__title { font-size: 16px; line-height: 24px; font-weight: 600; }

/* Step rail (the wizard): Done, Has problems, Not started, with icon and word. */
.th-steprail { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: rail; }
.th-steprail li { counter-increment: rail; }
.th-steprail a { display: grid; grid-template-columns: 28px 1fr; gap: 2px 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.th-steprail a:hover { background: var(--surface-2); }
.th-steprail__num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; border: 1.5px solid var(--field-line); font-size: 12px; font-weight: 700; grid-row: span 2; }
.th-steprail__num::before { content: counter(rail); }
.th-steprail__name { font-weight: 600; font-size: 14px; line-height: 20px; }
.th-steprail__state { display: flex; gap: 4px; align-items: center; font-size: 12px; line-height: 16px; color: var(--muted); }
.th-steprail__state .th-i { width: 13px; height: 13px; }
.th-steprail .is-done .th-steprail__num { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.th-steprail .is-done .th-steprail__state { color: var(--ok); }
.th-steprail .is-problem .th-steprail__num { border-color: var(--bad); color: var(--bad); }
.th-steprail .is-problem .th-steprail__state { color: var(--bad); font-weight: 600; }
.th-steprail [aria-current="step"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--ink); }
.th-steprail [aria-current="step"] .th-steprail__num { border-color: var(--ink); color: var(--ink); border-width: 2px; }

/* Chain: a client's environments in the order a version moves, or the release path. Arrows carry words. */
.th-chain { display: flex; align-items: stretch; gap: 0; margin: 0; padding: 0; list-style: none; }
.th-chain__node { flex: 1 1 0; min-width: 0; display: grid; gap: 8px; align-content: start; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.th-chain__node.is-current { border-color: var(--ink); box-shadow: inset 0 3px 0 var(--ink); }
.th-chain__node.is-locked { background: var(--surface-2); }
.th-chain__name { margin: 0; font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.th-chain__words { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); }
.th-chain__arrow { flex: 0 0 112px; display: grid; place-items: center; align-content: center; gap: 4px; padding: 0 8px; text-align: center; color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 600; }
.th-chain__arrow .th-i { width: 22px; height: 22px; color: var(--ink); }
.th-chain--compact .th-chain__arrow { flex-basis: 36px; padding: 0 4px; }

/* Window fit strip: the window as a band, a now marker, the run's estimate as a block. Positions come from data-at / data-span. */
.th-window { display: grid; gap: 6px; }
.th-window__track { position: relative; height: 36px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.th-window__open { position: absolute; top: 0; bottom: 0; left: var(--at, 0); width: var(--span, 0); background: var(--teal-tint);
  border-left: 2px solid var(--teal); border-right: 2px solid var(--teal); }
.th-window__est { position: absolute; top: 9px; height: 16px; left: var(--at, 0); width: var(--span, 0); border-radius: 4px; background: var(--ink); }
.th-window.is-late .th-window__est { background: repeating-linear-gradient(-45deg, var(--warn) 0 5px, var(--warn-bg) 5px 10px); }
.th-window__now { position: absolute; top: 0; bottom: 0; left: var(--at, 0); width: 2px; background: var(--bad); }
.th-window__now::before { content: "Now"; position: absolute; top: 1px; left: 4px; font-size: 10px; font-weight: 700; color: var(--bad); }
.th-window__scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.th-window__words { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; font-size: 14px; }

/* Power week grid */
.th-week { display: grid; gap: 10px; min-width: 0; }
.th-week__grid { display: grid; gap: 3px; }
.th-week__row { display: grid; grid-template-columns: 36px repeat(24, minmax(0, 1fr)); gap: 2px; align-items: center; }
.th-week__hours span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.th-week__day { font-size: 12px; font-weight: 600; color: var(--muted); }
.th-week__cell { display: block; height: 20px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); }
.th-week__cell.is-on { background: var(--ink); border-color: var(--ink); }
.th-week__cell.is-testers { background-image: repeating-linear-gradient(-45deg, transparent 0 3px, color-mix(in srgb, var(--gold) 70%, transparent) 3px 5px); }
.th-week__cell.is-now { outline: 2px solid var(--bad); outline-offset: 1px; }
.th-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.th-legend li { display: inline-flex; gap: 6px; align-items: center; }
.th-legend__key { width: 16px; height: 12px; }

/* ================================================================== 12. Check list and timeline */
.th-checks { display: grid; gap: 12px; container-type: inline-size; }
.th-checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.th-checkrow { display: grid; grid-template-columns: 172px minmax(0, 1fr); gap: 4px 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.th-checkrow:first-child { border-top: 0; }
.th-checkrow__state { padding-top: 1px; }
.th-checkrow__name { margin: 0; font-weight: 600; font-size: 14px; line-height: 20px; }
.th-checkrow__text { margin: 0; font-size: 14px; line-height: 20px; color: var(--text); }
.th-checkrow__meta { margin: 2px 0 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.th-checkrow__meta a { display: inline-block; padding: 8px 6px; margin: -8px -6px; } /* a 32 px tap area, same line height */
.th-checkrow__override { display: flex; gap: 6px; align-items: flex-start; margin: 4px 0 0; font-size: 13px; line-height: 18px; color: var(--muted); }
.th-checkrow__override .th-i { width: 14px; height: 14px; margin-top: 2px; }
.th-checkrow--warn { background: color-mix(in srgb, var(--warn-bg) 45%, var(--surface)); }
.th-checkrow--bad { background: var(--bad-bg); box-shadow: inset 4px 0 0 var(--bad); }
/* After the base rule, so rows stack whenever the list is narrower than 560 px (a side panel on a desktop too). */
@container (max-width: 560px) { .th-checkrow { grid-template-columns: minmax(0, 1fr); } }

.th-timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.th-tl { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; }
.th-tl:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.th-tl__dot { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--off-bg); color: var(--off); }
.th-tl__dot .th-i { width: 16px; height: 16px; stroke-width: 2; }
.th-tl--ok .th-tl__dot { background: var(--ok-bg); color: var(--ok); }
.th-tl--warn .th-tl__dot { background: var(--warn-bg); color: var(--warn); }
.th-tl--bad .th-tl__dot { background: var(--bad-bg); color: var(--bad); }
.th-tl--run .th-tl__dot, .th-tl--inrun .th-tl__dot { background: var(--run-bg); color: var(--run); }
.th-tl--wait .th-tl__dot { background: var(--wait-bg); color: var(--wait); box-shadow: inset 0 0 0 1px var(--gold); }
.th-tl__body { padding-top: 3px; }
.th-tl__time { margin: 0; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.th-tl__text { margin: 0; font-size: 14px; line-height: 20px; }
.th-tl__meta { margin: 0; font-size: 13px; color: var(--muted); }

/* ================================================================== 13. Banners, failure box, toasts, dialogs */
.th-banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-card); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 14px; line-height: 20px; }
.th-banner p { margin: 0; }
.th-banner__icon { flex: none; display: grid; place-items: center; }
.th-banner__icon .th-i { width: 20px; height: 20px; stroke-width: 1.75; }
.th-banner__body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.th-banner__title { font-weight: 700; }
.th-banner__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.th-banner--incident { background: var(--bad-bg); border-color: var(--bad); }
.th-banner--incident .th-banner__icon, .th-banner--emergency .th-banner__icon { color: var(--bad); }
.th-banner--emergency { border: 2px solid var(--bad); }
.th-banner--warn { background: var(--warn-bg); border-color: var(--warn); }
.th-banner--warn .th-banner__icon { color: var(--warn); }
.th-banner--freeze { background: var(--navy-tint); border-color: var(--navy-tint); }
.th-banner--freeze .th-banner__icon { color: var(--frozen); }
.th-banner--info { background: var(--surface-2); }
.th-banner--info .th-banner__icon { color: var(--muted); }
.th-banner--window { background: var(--teal-tint); border-color: var(--teal); }
.th-banner--window .th-banner__icon { color: var(--teal); }
.th-banner--ok { background: var(--ok-bg); border-color: var(--ok); }
.th-banner--ok .th-banner__icon { color: var(--ok); }
.th-banner--quiet { padding: 20px 24px; background: #EEF4FB url("trusthouse-background.png") center / cover no-repeat; border-color: #DCE6F2; color: #0F172A; }
.th-banner--quiet .th-banner__icon { color: #15803D; }
.th-banner--quiet .th-banner__title { font-size: 18px; line-height: 26px; }
:root[data-theme="dark"] .th-banner--quiet { background: linear-gradient(135deg, #13224F, #0F1F4B 60%, #12323A); color: var(--text); border-color: var(--line); }
:root[data-theme="dark"] .th-banner--quiet .th-banner__icon { color: var(--ok); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .th-banner--quiet { background: linear-gradient(135deg, #13224F, #0F1F4B 60%, #12323A); color: var(--text); border-color: var(--line); }
  :root:not([data-theme="light"]) .th-banner--quiet .th-banner__icon { color: var(--ok); }
}
/* Data boundary: slim navy outline with a shield, expands to the two lists. */
.th-banner--boundary { display: block; padding: 0; border: 1px solid var(--ink); }
.th-banner--boundary > summary { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 10px 16px; cursor: pointer; list-style: none; }
.th-banner--boundary > summary::-webkit-details-marker { display: none; }
.th-banner--boundary .th-banner__icon { color: var(--ink); }
.th-banner--boundary .th-banner__title { flex: 1 1 260px; }
.th-banner__more { display: inline-flex; gap: 4px; align-items: center; color: var(--teal); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.th-banner--boundary[open] .th-banner__more .th-i { transform: rotate(180deg); }
.th-boundary { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 4px 16px 16px 46px; }
.th-boundary ul { margin: 0; padding-left: 18px; }
.th-boundary__head { display: flex; gap: 6px; align-items: center; font-weight: 700; margin: 0 0 4px; }
.th-boundary__head .th-i { width: 16px; height: 16px; }
.th-boundary > div:first-child .th-boundary__head .th-i { color: var(--ok); }

.th-failbox { display: grid; gap: 12px; padding: 20px; border: 2px solid var(--bad); border-radius: var(--r-card); background: var(--surface); }
.th-failbox__title { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--bad); font-size: 18px; line-height: 26px; font-weight: 700; }
.th-failbox__title .th-i { width: 22px; height: 22px; }
.th-failbox__sentence { margin: 0; padding: 12px; border-radius: 8px; background: var(--bad-bg); font: 400 13px/20px var(--mono); overflow-wrap: anywhere; }
.th-failbox__next { margin: 0; }

.th-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.th-toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 8px 12px 14px; border-radius: var(--r-card); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); box-shadow: var(--raise); animation: th-fade .15s ease-out; }
.th-toast p { flex: 1; margin: 2px 0 0; font-size: 14px; line-height: 20px; }
@keyframes th-fade { from { opacity: 0; transform: translateY(4px); } }

.th-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 0; border-radius: var(--r-dialog);
  background: var(--surface); color: var(--text); box-shadow: var(--raise); }
.th-dialog[open] { display: flex; flex-direction: column; animation: th-fade .15s ease-out; }
.th-dialog::backdrop { background: var(--scrim); }
.th-dialog__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 20px 8px 24px; }
.th-dialog__head h2 { margin: 6px 0 0; }
.th-dialog__body { padding: 8px 24px 16px; overflow-y: auto; }
.th-dialog__foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; padding: 16px 24px; border-top: 1px solid var(--line); }
.th-dialog__foot > p { margin: 0 auto 0 0; }
.th-dialog--drawer { width: min(520px, 100vw); max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0 0 0 auto; border-radius: var(--r-dialog) 0 0 var(--r-dialog); }
.th-dialog--drawer .th-dialog__body { flex: 1; }
.th-dialog--drawer[open] { animation: th-slide .15s ease-out; }
@keyframes th-slide { from { transform: translateX(24px); opacity: 0; } }

/* ================================================================== 14. Empty and loading states */
.th-empty { position: relative; display: grid; justify-items: center; gap: 8px; padding: 48px 24px; text-align: center; overflow: hidden;
  border: 1px dashed var(--line); border-radius: var(--r-card); background: var(--surface); }
.th-empty::before, .th-empty::after { content: ""; position: absolute; border: 1px solid var(--sage); border-radius: 999px; opacity: .55; pointer-events: none; }
.th-empty::before { width: 220px; height: 220px; right: -60px; top: -90px; }
.th-empty::after { width: 140px; height: 140px; left: -40px; bottom: -70px; }
.th-empty__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.th-empty__icon .th-i { width: 26px; height: 26px; }
.th-empty h2, .th-empty h3 { margin: 4px 0 0; font-size: 16px; line-height: 24px; } /* h2 when the empty state is the page's main content */
.th-empty p { margin: 0; max-width: 46ch; color: var(--muted); }
.th-empty .th-btns { margin-top: 8px; justify-content: center; }

.th-skel { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 0, var(--line) 40%, var(--surface-2) 80%);
  background-size: 300% 100%; animation: th-shimmer 1.4s ease-in-out infinite; }
.th-skel--title { height: 22px; width: 55%; }
.th-skel--pill { height: 24px; width: 96px; border-radius: 999px; }
.th-skel--bar { height: 8px; border-radius: 999px; }
.th-skel--block { height: 120px; border-radius: var(--r-card); }
.th-skel--short { width: 40%; } .th-skel--mid { width: 70%; }
.th-loading { display: grid; gap: 12px; }
.th-loading__words { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--muted); font-size: 14px; }
@keyframes th-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ================================================================== 15. Component gallery (components.html only) */
.cg-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.cg-toc a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; }
.cg-toc a:hover { background: var(--surface-2); }
.cg-section { margin-top: 40px; padding-top: 8px; }
.cg-section > h2 { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; font-size: 20px; }
.cg-section > h2 span { font-size: 13px; font-weight: 600; color: var(--muted); font-family: var(--mono); }
.cg-lead { max-width: 80ch; color: var(--muted); margin-bottom: 16px; }
.cg-label.th-section { margin-top: 32px; }
.cg-label { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cg-swatch { border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; background: var(--surface); }
.cg-swatch__chip { display: block; height: 56px; border-bottom: 1px solid var(--line); }
.cg-swatch p { margin: 0; padding: 8px 10px 0; font-size: 13px; font-weight: 700; }
.cg-swatch code { display: block; margin: 0 10px 10px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; }
.cg-navy { background: var(--navy); } .cg-gold { background: var(--gold); } .cg-teal { background: var(--teal); } .cg-coral { background: var(--coral); }
.cg-sage { background: var(--sage); } .cg-slate-brand { background: var(--slate-brand); } .cg-red { background: var(--red); } .cg-navy-tint { background: var(--navy-tint); }
.cg-gold-soft { background: var(--gold-soft); } .cg-teal-tint { background: var(--teal-tint); } .cg-sage-tint { background: var(--sage-tint); }
.cg-bg { background: var(--bg); } .cg-surface { background: var(--surface); } .cg-surface-2 { background: var(--surface-2); } .cg-line { background: var(--line); }
.cg-text { background: var(--text); } .cg-muted { background: var(--muted); } .cg-ok { background: var(--ok); } .cg-warn { background: var(--warn); } .cg-bad { background: var(--bad); } .cg-run { background: var(--run); }
.cg-logos { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cg-logo { display: grid; place-items: center; min-height: 140px; margin: 0; padding: 24px; border-radius: var(--r-card); border: 1px solid var(--line); }
.cg-logo img { height: 48px; width: auto; }
.cg-logo--navy { background: #0F1F4B; border-color: #0F1F4B; }
.cg-logo--white { background: #FFFFFF; }
.cg-logo--brand { background: #EEF4FB url("trusthouse-background.png") center / cover no-repeat; }
.cg-logo--wordmark img { height: 40px; }
.cg-logo figcaption { margin-top: 12px; font-size: 12px; color: #CBD5E1; text-align: center; }
.cg-logo--white figcaption, .cg-logo--brand figcaption { color: #475569; }
.cg-type > * { margin: 0 0 6px; }
.cg-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.cg-icon { display: grid; justify-items: center; gap: 6px; padding: 14px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: 400 11px/14px var(--mono); color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.cg-icon .th-i { width: 24px; height: 24px; color: var(--text); animation: none; }
.cg-navydemo { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 16px; border-radius: var(--r-card); background: var(--navy); }

/* ================================================================== 16. Responsive */
@media (max-width: 1199px) {
  :root { --side-w: var(--side-folded); }
  .th-side .th-nav__label, .th-side__status span, .th-side__bb span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .th-side .th-nav a { justify-content: center; padding: 0; }
  .th-side .th-nav__count { position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 11px; line-height: 18px; }
  .th-side__foot { margin: 16px 6px 0; }
  .th-side__status, .th-side__bb { justify-content: center; padding: 0; }
  .th-side__wordmark { margin: 6px auto 0; height: 18px; }
  .th-oncall span { display: none; }
  .th-oncall { width: 40px; padding: 0; justify-content: center; }
  .th-split, .th-rail { grid-template-columns: minmax(0, 1fr); }
  .th-split__aside { position: static; }
  .th-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1279px) { .th-me__name { display: none; } }
@media (max-width: 1023px) { .th-grid--3, .th-leftcol { grid-template-columns: minmax(0, 1fr); } .th-leftcol { gap: 16px; } }
@media (max-width: 767px) {
  :root { --gutter: 16px; --side-w: 0px; }
  body { padding-bottom: 72px; }
  .th-header { gap: 8px; padding: 0 8px 0 12px; }
  .th-header__divider, .th-appname, .th-oncall { display: none; }
  .th-header .th-header__search { display: inline-flex; }
  .th-search { display: none; position: absolute; left: 8px; right: 8px; top: 8px; max-width: none; margin: 0; z-index: 2; }
  .th-search-open .th-search { display: block; }
  .th-search-open .th-search input { background: #1A2B5E; }
  .th-search__key { display: none; }
  .th-pop__panel { position: fixed; left: 16px; right: 16px; top: calc(var(--header-h) + 8px); width: auto; max-width: none; }

  .th-fleet { height: auto; min-height: var(--fleet-h); padding: 0; display: block; }
  .th-fleet__summary { display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--fleet-h); padding: 0 16px; border: 0; background: none;
    color: var(--text); font: 600 13px var(--font); text-align: left; cursor: pointer; }
  .th-fleet__summary > span { flex: 1; min-width: 0; line-height: 18px; } /* two lines fit the 40 px strip, so "1 no access" is never cut */
  .th-fleet__summary .th-i { width: 16px; height: 16px; }
  .th-fleet__warn { color: var(--warn); }
  .th-fleet__list { display: none; }
  .th-fleet.is-open .th-fleet__list { display: flex; flex-wrap: wrap; padding: 4px 16px 12px; overflow: visible; mask-image: none; }
  .th-fleet.is-open .th-fleet__summary > .th-i:last-child { transform: rotate(180deg); }

  .th-side { top: 0; z-index: 60; width: 280px; transform: translateX(-100%); transition: transform .15s ease-out; }
  .th-nav-open .th-side { transform: none; }
  .th-side .th-nav__label, .th-side__status span, .th-side__bb span { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .th-side .th-nav a { justify-content: flex-start; padding: 0 12px; min-height: 48px; }
  .th-side .th-nav__count { position: static; }
  .th-side__status, .th-side__bb { justify-content: flex-start; padding: 0 12px; }
  .th-side__wordmark { margin: 6px 12px 0; height: 24px; }
  .th-scrim { position: fixed; inset: 0; z-index: 55; background: var(--scrim); }
  .th-nav-open .th-scrim { display: block; }

  .th-tabbar { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .th-tabbar a, .th-tabbar button { display: grid; justify-items: center; gap: 2px; min-height: 56px; padding: 6px 0 4px; border: 0; background: none;
    color: var(--muted); font: 600 11px/14px var(--font); text-decoration: none; cursor: pointer; }
  .th-tabbar [aria-current="page"] { color: var(--text); }
  .th-tabbar [aria-current="page"] .th-tabbar__icon::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: -6px; height: 3px; border-radius: 3px; background: var(--gold); }
  .th-tabbar__icon { position: relative; display: grid; place-items: center; width: 40px; height: 28px; }
  .th-tabbar__icon .th-i { width: 22px; height: 22px; }
  .th-nav__count--dot { position: absolute; top: -4px; right: -2px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 11px; line-height: 18px; }
  .th-tabbar .th-nav__count:not(.th-nav__count--bad):not(.th-nav__count--gold) { background: var(--ink); color: var(--on-ink); } /* the sidebar's fill is white on white here */

  .th-main { margin-left: 0; }
  .th-band { font-size: 13px; }
  /* The sticky band stays one 40 px line: the name first, the rest scrolls sideways under the fleet strip's end fade. */
  .th-band:not(.th-band--static) { flex-wrap: nowrap; white-space: nowrap; overflow-x: auto; scrollbar-width: none; padding-right: 32px;
    mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
  .th-band::-webkit-scrollbar { display: none; }
  .th-grid--2, .th-grid--4 { grid-template-columns: minmax(0, 1fr); }
  .th-grid--4:has(> .th-stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* stat tiles stay two across */
  .th-pagehead__actions { width: 100%; }
  .th-summary { font-size: 22px; line-height: 30px; }
  .th-summary__sep { display: none; } /* the parts stack, so a dot would end a line */
  .th-tabs { flex-wrap: wrap; } /* every tab shows: a hidden scrollbar gave no sign of the rest */
  .th-tabs [role="tab"] { padding: 0 12px; }
  .th-facts--stack { grid-template-columns: minmax(0, 1fr); } /* label above value, so a long address fits whole */
  .th-facts--stack dd + dt { margin-top: 6px; }
  .th-facts--stack ul { padding-left: 0; list-style: none; }
  .th-facts--stack .th-mono { display: block; }
  .th-chain { flex-direction: column; }
  .th-chain__arrow { flex-basis: auto; padding: 6px 0; grid-auto-flow: column; }
  .th-chain__arrow .th-i { transform: rotate(90deg); }
  .th-boundary { grid-template-columns: 1fr; padding-left: 16px; }
  .th-checkrow { grid-template-columns: minmax(0, 1fr); }
  .th-stage__name { display: none; }
  .th-stagebar--labels .th-stage__name { display: flex; }
  .th-banner { flex-wrap: wrap; }
  .th-banner__actions { margin-left: 0; width: 100%; }
  .th-dialog.th-dialog--drawer { width: 100vw; max-height: 100vh; border-radius: 0; }
  .th-dialog { max-height: calc(100vh - 32px); }
  .th-toasts { bottom: 84px; }
  .th-btn--block-phone { width: 100%; }
  .th-week__row { grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 1px; }
  .th-week__cell { height: 16px; border-radius: 2px; }

  /* Tables become one card per row; console.js copies each column name into data-label. */
  .th-table:not(.th-table--keep), .th-table:not(.th-table--keep) tbody, .th-table:not(.th-table--keep) tr, .th-table:not(.th-table--keep) td { display: block; }
  .th-table:not(.th-table--keep) { border: 0; background: none; }
  .th-table:not(.th-table--keep) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .th-table:not(.th-table--keep) tr { margin-bottom: 12px; padding: 8px 0; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
  .th-table:not(.th-table--keep) tr.is-broken { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
  .th-table:not(.th-table--keep) td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; padding: 6px 16px; border: 0; text-align: left; }
  .th-table:not(.th-table--keep) td::before { content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 600; }
  .th-table:not(.th-table--keep) td:empty { display: none; } /* no bare label for an empty cell */
  .th-table:not(.th-table--keep) td > .th-pill, .th-table:not(.th-table--keep) td > .th-risk { justify-self: start; } /* a badge, not a bar */
  .th-table:not(.th-table--keep) tr.is-broken td:first-child { box-shadow: none; }
  .th-table:not(.th-table--keep) tbody tr:hover td { background: none; }
}

/* ================================================================== 17. Motion and print */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  #th-shell, .th-proto, .th-tabbar, .th-toasts, .th-btn, .th-btns { display: none !important; }
  .th-main { margin: 0; padding: 0; }
  body { background: #FFFFFF; color: #000000; padding: 0; }
  .th-band { position: static; }
  .th-card, .th-table { break-inside: avoid; }
}

/* The power week grid's half hours (a viewer whose zone is offset from IST by 30 minutes) and the Cost tables' total row. */
.th-week__cell.is-half-a { background: linear-gradient(90deg, var(--ink) 50%, var(--surface-2) 50%); }
.th-week__cell.is-half-b { background: linear-gradient(90deg, var(--surface-2) 50%, var(--ink) 50%); }
.th-week__day.is-today { color: var(--text); font-weight: 700; }
.th-table tr.th-total td { border-top: 2px solid var(--line); }
.th-week__row { grid-template-columns: 56px repeat(24, minmax(0, 1fr)); }
@media (max-width: 767px) { .th-week__row { grid-template-columns: 46px repeat(24, minmax(0, 1fr)); } }
