/* AGRD Ops — UI stylesheet (tokens + components). Served at /static/ui.css.
   Brand: AGRD "calm authority" (web-main DESIGN.md) tuned for an all-day, dense ops tool.
   Contract: no @import, no third-party requests, self-hosted fonts only (fonts/OFL.txt).
   Class reference + page patterns: docs/UX.md. Macros: templates/macros/ui.html. */

/* ---------- Fonts ---------- */
@font-face { font-family: "Hanken Grotesk"; src: url("fonts/hanken-grotesk-var.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "AGRD Display"; src: url("fonts/agrd-display-var.woff2") format("woff2"); font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Hanken Fallback"; src: local("Arial"), local("Helvetica Neue"), local("Helvetica"); size-adjust: 101.6%; ascent-override: 98.4%; descent-override: 29.8%; line-gap-override: 0%; }
@font-face { font-family: "AGRD Display Fallback"; src: local("Georgia"), local("Times New Roman"); size-adjust: 102.9%; ascent-override: 105.1%; descent-override: 24.4%; line-gap-override: 0%; }

/* ---------- Tokens (light) ----------
   Contrast (WCAG 2.x, measured): text #14201C on #FFF 16.9; muted #4E5A55 on #FFF 7.2, on paper 6.45;
   primary #1E4A40 on #FFF 9.96; danger #A12F26 7.1; success #2C6A47 6.4; warn #8A4113 7.4;
   placeholder #6B746F 4.8; sidebar #C9D6CF on #12302A 9.45; focus ring #2F7A68 vs #FFF 5.1. */
:root {
  color-scheme: light;
  --c-bg: #F6F2EA; --c-surface: #FFFFFF; --c-surface-alt: #FAF8F3; --c-sunken: #F1ECE2;
  --c-text: #14201C; --c-muted: #4E5A55; --c-placeholder: #6B746F;
  --c-primary: #1E4A40; --c-primary-strong: #12302A; --c-on-primary: #FFFFFF;
  --c-accent: #9C4A1A; --c-highlight: #E3B04B;
  --c-border: #DCD4C4; --c-border-soft: #E9E3D7; --c-border-strong: #857B69;
  --c-focus: #2F7A68; --c-tint: #E4ECE7;
  --c-row-hover: #F4F7F5; --c-row-selected: #E9F1EC;
  --c-success: #2C6A47; --c-warn: #8A4113; --c-danger: #A12F26;
  --c-nav-bg: #12302A; --c-nav-text: #C9D6CF; --c-nav-strong: #F6F2EA; --c-nav-hover: #1E4A40; --c-nav-current: #E3B04B;
  --c-track: #E8E2D5; --c-fill-low: #5E7A70; --c-fill-ok: #2C6A47; --c-fill-warn: #A8601F; --c-fill-bad: #A12F26;

  /* Badge tones: fg / bg — every pair >= 5.6:1 (light) and >= 7.5:1 (dark). */
  --b-neutral-fg: #3E4844;  --b-neutral-bg: #ECE7DC;   /* 7.69 */
  --b-info-fg: #2B4A66;     --b-info-bg: #E2EAF1;      /* 7.60 */
  --b-progress-fg: #1E4A40; --b-progress-bg: #E1ECE6;  /* 8.22 */
  --b-success-fg: #1F5A3A;  --b-success-bg: #DDEEE3;   /* 6.74 */
  --b-warning-fg: #7A3A12;  --b-warning-bg: #F8E8CF;   /* 7.14 */
  --b-danger-fg: #8E2820;   --b-danger-bg: #F7E0DB;    /* 6.72 */
  --b-critical-fg: #FFFFFF; --b-critical-bg: #A12F26;  /* 7.12 */
  --b-muted-fg: #59615D;    --b-muted-bg: #F3F0EA;     /* 5.61 */

  --font-heading: "AGRD Display", "AGRD Display Fallback", Georgia, serif;
  --font-body: "Hanken Grotesk", "Hanken Fallback", Arial, system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --text-2xs: 0.6875rem; --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.875rem;
  --text-md: 1rem; --text-lg: 1.125rem; --text-xl: 1.5rem; --text-2xl: 1.875rem;
  --leading: 1.45; --leading-tight: 1.15;

  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem;
  --gutter: clamp(1rem, 0.6rem + 1.6vw, 2rem);
  --sidebar-w: 13.5rem; --facets-w: 13.5rem; --row-h: 2.375rem; --control-h: 2.25rem; --control-h-sm: 1.875rem;

  --r-sm: 4px; --r-md: 6px; --r-lg: 10px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(20, 32, 28, 0.06);
  --shadow-md: 0 2px 4px rgba(20, 32, 28, 0.04), 0 8px 24px rgba(20, 32, 28, 0.10);
  --shadow-up: 0 -2px 4px rgba(20, 32, 28, 0.04), 0 -8px 24px rgba(20, 32, 28, 0.10);
  --ring: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-focus);
  --t-fast: 120ms;
}
/* Dark mode: same token names. Both selectors, as on the marketing site. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --c-bg: #0D1714; --c-surface: #15221E; --c-surface-alt: #18261F; --c-sunken: #1B2B26;
  --c-text: #ECE7DD; --c-muted: #A9B5AF; --c-placeholder: #8A9893;
  --c-primary: #7FC3AE; --c-primary-strong: #A3D6C5; --c-on-primary: #0D1714;
  --c-accent: #E39A62; --c-highlight: #E3B04B;
  --c-border: #2A3A35; --c-border-soft: #22312C; --c-border-strong: #66807A;
  --c-focus: #7FC3AE; --c-tint: #17302A;
  --c-row-hover: #1A2A25; --c-row-selected: #1D3530;
  --c-success: #7CC59A; --c-warn: #E39A62; --c-danger: #F08A7E;
  --c-nav-bg: #0A1310; --c-nav-text: #C9D6CF; --c-nav-strong: #F6F2EA; --c-nav-hover: #17302A; --c-nav-current: #E3B04B;
  --c-track: #2A3A35; --c-fill-low: #7E958D; --c-fill-ok: #7CC59A; --c-fill-warn: #E39A62; --c-fill-bad: #F08A7E;
  --b-neutral-fg: #D5DBD7;  --b-neutral-bg: #25332E;   /* 9.39 */
  --b-info-fg: #A9C8E4;     --b-info-bg: #1A2A37;      /* 8.44 */
  --b-progress-fg: #8FD0BB; --b-progress-bg: #17302A;  /* 7.98 */
  --b-success-fg: #93D6AC;  --b-success-bg: #14301F;   /* 8.46 */
  --b-warning-fg: #F2B583;  --b-warning-bg: #3A2614;   /* 7.98 */
  --b-danger-fg: #F5A49A;   --b-danger-bg: #3F1C19;    /* 7.66 */
  --b-critical-fg: #1A0B09; --b-critical-bg: #F08A7E;  /* 7.89 */
  --b-muted-fg: #A9B5AF;    --b-muted-bg: #1A2420;     /* 7.53 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow-md: 0 2px 4px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
  --shadow-up: 0 -2px 4px rgba(0,0,0,.3), 0 -8px 24px rgba(0,0,0,.4);
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #0D1714; --c-surface: #15221E; --c-surface-alt: #18261F; --c-sunken: #1B2B26;
  --c-text: #ECE7DD; --c-muted: #A9B5AF; --c-placeholder: #8A9893;
  --c-primary: #7FC3AE; --c-primary-strong: #A3D6C5; --c-on-primary: #0D1714;
  --c-accent: #E39A62; --c-highlight: #E3B04B;
  --c-border: #2A3A35; --c-border-soft: #22312C; --c-border-strong: #66807A;
  --c-focus: #7FC3AE; --c-tint: #17302A;
  --c-row-hover: #1A2A25; --c-row-selected: #1D3530;
  --c-success: #7CC59A; --c-warn: #E39A62; --c-danger: #F08A7E;
  --c-nav-bg: #0A1310; --c-nav-text: #C9D6CF; --c-nav-strong: #F6F2EA; --c-nav-hover: #17302A; --c-nav-current: #E3B04B;
  --c-track: #2A3A35; --c-fill-low: #7E958D; --c-fill-ok: #7CC59A; --c-fill-warn: #E39A62; --c-fill-bad: #F08A7E;
  --b-neutral-fg: #D5DBD7;  --b-neutral-bg: #25332E;
  --b-info-fg: #A9C8E4;     --b-info-bg: #1A2A37;
  --b-progress-fg: #8FD0BB; --b-progress-bg: #17302A;
  --b-success-fg: #93D6AC;  --b-success-bg: #14301F;
  --b-warning-fg: #F2B583;  --b-warning-bg: #3A2614;
  --b-danger-fg: #F5A49A;   --b-danger-bg: #3F1C19;
  --b-critical-fg: #1A0B09; --b-critical-bg: #F08A7E;
  --b-muted-fg: #A9B5AF;    --b-muted-bg: #1A2420;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow-md: 0 2px 4px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
  --shadow-up: 0 -2px 4px rgba(0,0,0,.3), 0 -8px 24px rgba(0,0,0,.4);
}
@media (prefers-reduced-motion: reduce) { :root { --t-fast: 0ms; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--c-bg); color: var(--c-text); font-family: var(--font-body); font-size: var(--text-base); line-height: var(--leading); font-variant-numeric: lining-nums; }
h1, h2, h3, h4 { margin: 0 0 var(--s-3); line-height: var(--leading-tight); font-weight: 600; }
h1 { font-family: var(--font-heading); font-weight: 500; font-size: var(--text-2xl); letter-spacing: -0.015em; }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-base); }
p { margin: 0 0 var(--s-3); }
a { color: var(--c-primary); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--c-primary-strong); text-decoration-thickness: 2px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
img, svg { max-width: 100%; display: block; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.num, .tnum { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--c-muted); }
.small { font-size: var(--text-sm); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; z-index: 100; }
.skip:focus { left: var(--s-3); top: var(--s-3); background: var(--c-surface); color: var(--c-text); padding: var(--s-2) var(--s-4); border-radius: var(--r-md); }
.eyebrow { font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-accent); margin: 0 0 var(--s-1); }
hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--s-5) 0; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s-4); background: var(--c-nav-bg); border-right: 1px solid var(--c-border); color: var(--c-nav-text); padding: var(--s-4) var(--s-3); overflow-y: auto; }
.sidebar__brand { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-1) var(--s-2); color: var(--c-nav-strong); text-decoration: none; font-family: var(--font-heading); font-size: var(--text-md); font-weight: 600; }
.sidebar__brand:hover { color: var(--c-nav-strong); text-decoration: none; }
.sidebar__brand img, .sidebar__brand svg { width: 28px; height: 28px; flex: none; }
.sidebar__brand small { display: block; font-family: var(--font-body); font-size: var(--text-2xs); font-weight: 500; color: var(--c-nav-text); letter-spacing: 0.04em; }
.nav__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav__link { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 2.25rem; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); color: var(--c-nav-text); text-decoration: none; font-weight: 500; }
.nav__link:hover { background: var(--c-nav-hover); color: var(--c-nav-strong); text-decoration: none; }
.nav__link[aria-current="page"] { background: var(--c-nav-hover); color: var(--c-nav-strong); box-shadow: inset 3px 0 0 var(--c-nav-current); }
.nav__link:focus-visible { box-shadow: 0 0 0 2px var(--c-nav-current); }
.nav__count { font-size: var(--text-2xs); font-weight: 700; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: var(--r-pill); background: var(--b-critical-bg); color: var(--b-critical-fg); }
.nav__section { margin: var(--s-3) 0 var(--s-1); padding: 0 var(--s-3); font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-nav-text); }
.sidebar__user { margin-top: auto; padding: var(--s-3); border-top: 1px solid var(--c-nav-hover); font-size: var(--text-sm); }
.sidebar__user strong, .sidebar__role { display: block; }
.sidebar__role { font-size: var(--text-xs); text-transform: capitalize; }
.sidebar__user strong { color: var(--c-nav-strong); font-weight: 600; }
.sidebar__user form { margin-top: var(--s-2); }
.sidebar .btn--ghost { color: var(--c-nav-text); border-color: var(--c-nav-hover); }
.sidebar .btn--ghost:hover { color: var(--c-nav-strong); background: var(--c-nav-hover); }
.main { min-width: 0; padding: var(--s-5) var(--gutter) var(--s-7); }
.main--narrow { max-width: 60rem; }

@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); overflow: visible; }
  .sidebar__brand small { display: none; }
  .sidebar .nav { order: 3; flex: 1 0 100%; overflow-x: auto; scrollbar-width: none; }
  .nav__list { flex-direction: row; gap: var(--s-1); }
  .nav__link { white-space: nowrap; min-height: 2.75rem; }
  .nav__link[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--c-nav-current); }
  .nav__section { display: none; }
  .sidebar__user { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: var(--s-2); }
  .sidebar__user strong, .sidebar__user .sidebar__role { display: none; }
  .sidebar__user form { margin: 0; }
  .main { padding-top: var(--s-4); }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-5); margin-bottom: var(--s-5); }
.page-head h1, .page-title { margin: 0; }
.page-sub { margin: var(--s-1) 0 0; color: var(--c-muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.crumbs ol { list-style: none; margin: 0 0 var(--s-2); padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-1); font-size: var(--text-sm); color: var(--c-muted); }
.crumbs li + li::before { content: "/"; margin-right: var(--s-1); color: var(--c-border-strong); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin: var(--s-6) 0 var(--s-3); }
.section-title h2 { margin: 0; }
.count { font-size: var(--text-sm); color: var(--c-muted); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: var(--control-h); padding: 0 var(--s-4); border: 1px solid transparent; border-radius: var(--r-md); font: inherit; font-weight: 600; font-size: var(--text-base); line-height: 1; text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn--primary:hover { background: var(--c-primary-strong); color: var(--c-on-primary); }
.btn--secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn--secondary:hover { background: var(--c-sunken); color: var(--c-text); }
.btn--ghost { background: transparent; color: var(--c-primary); border-color: var(--c-border); }
.btn--ghost:hover { background: var(--c-tint); color: var(--c-primary-strong); }
.btn--danger { background: var(--c-surface); color: var(--c-danger); border-color: currentColor; }
.btn--danger:hover { background: var(--b-danger-bg); color: var(--b-danger-fg); }
.btn--link { background: none; border: 0; padding: 0; min-height: 0; color: var(--c-primary); font-weight: 500; text-decoration: underline; text-underline-offset: 0.18em; }
.btn--sm { min-height: var(--control-h-sm); padding: 0 var(--s-3); font-size: var(--text-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
form.inline, form.inline-form { display: inline; margin: 0; }
@media (pointer: coarse) { .btn, .btn--sm { min-height: 2.75rem; } }

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--s-4); max-width: 40rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--s-4); }
.form-grid .field--wide { grid-column: 1 / -1; }
.field { display: grid; gap: var(--s-1); align-content: start; }
.field__label, .label { font-size: var(--text-sm); font-weight: 600; color: var(--c-text); }
.field__label .req { color: var(--c-danger); margin-left: 2px; }
.field__hint { font-size: var(--text-xs); color: var(--c-muted); margin: 0; }
.field__error { font-size: var(--text-sm); color: var(--c-danger); font-weight: 600; margin: 0; }
.input, .select, .textarea { width: 100%; min-height: var(--control-h); padding: 0 var(--s-3); border: 1px solid var(--c-border-strong); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text); font: inherit; font-size: var(--text-base); }
.textarea { padding: var(--s-2) var(--s-3); min-height: 6rem; resize: vertical; line-height: var(--leading); }
.select { padding-right: var(--s-6); }
.input::placeholder, .textarea::placeholder { color: var(--c-placeholder); opacity: 1; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--c-focus); box-shadow: 0 0 0 3px var(--c-tint), 0 0 0 1px var(--c-focus); border-radius: var(--r-md); }
.input--sm, .select--sm { min-height: var(--control-h-sm); font-size: var(--text-sm); width: auto; }
.input--search { padding-left: 2rem; background-image: none; }
.field--invalid .input, .field--invalid .select, .field--invalid .textarea, .input[aria-invalid="true"] { border-color: var(--c-danger); }
.check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-base); cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--c-primary); cursor: pointer; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; padding-top: var(--s-2); }
fieldset { display: grid; gap: var(--s-3); align-content: start; min-width: 0; border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--s-4); margin: 0; background: var(--c-surface); }
/* Not 1 / -1: spanning keeps every auto-fit track alive and squeezes the fieldsets. */
.form-grid > .form-actions { grid-column: 1; }
.form-grid:has(> fieldset) { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
legend { padding: 0 var(--s-2); font-weight: 600; }

/* ---------- Flash messages ---------- */
.flashes { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.flash { margin: 0; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 0; border-left: 4px solid; font-weight: 500; }
.flash__kind { font-weight: 700; margin-right: var(--s-1); }
.flash--success { background: var(--b-success-bg); color: var(--b-success-fg); border-color: var(--b-success-fg); }
.flash--error { background: var(--b-danger-bg); color: var(--b-danger-fg); border-color: var(--b-danger-fg); }
.flash--warning { background: var(--b-warning-bg); color: var(--b-warning-fg); border-color: var(--b-warning-fg); }
.flash--info { background: var(--b-info-bg); color: var(--b-info-fg); border-color: var(--b-info-fg); }

/* ---------- Badges, tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 2px; border-radius: var(--r-pill); font-size: var(--text-xs); font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--b-neutral-bg); color: var(--b-neutral-fg); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--none { background: none; padding: 0; color: var(--c-muted); }
.badge--none::before { display: none; }
.badge--neutral { background: var(--b-neutral-bg); color: var(--b-neutral-fg); }
.badge--info { background: var(--b-info-bg); color: var(--b-info-fg); }
.badge--progress { background: var(--b-progress-bg); color: var(--b-progress-fg); }
.badge--success { background: var(--b-success-bg); color: var(--b-success-fg); }
.badge--warning { background: var(--b-warning-bg); color: var(--b-warning-fg); }
.badge--danger { background: var(--b-danger-bg); color: var(--b-danger-fg); }
.badge--critical { background: var(--b-critical-bg); color: var(--b-critical-fg); }
.badge--muted { background: var(--b-muted-bg); color: var(--b-muted-fg); box-shadow: inset 0 0 0 1px var(--c-border); }
.badge--muted::before { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
.tag-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 0 6px; border-radius: var(--r-sm); background: var(--c-sunken); color: var(--c-muted); font-size: var(--text-xs); font-weight: 500; line-height: 1.6; white-space: nowrap; }
.tag--warn { background: var(--b-warning-bg); color: var(--b-warning-fg); font-weight: 600; }
.tag--danger { background: var(--b-danger-bg); color: var(--b-danger-fg); font-weight: 600; }
a.tag { text-decoration: none; color: var(--c-text); }
a.tag:hover { background: var(--c-tint); }

/* ---------- Toolbar / search / saved views ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-bottom: var(--s-3); }
.search { position: relative; flex: 1 1 18rem; max-width: 34rem; }
.search::before { content: ""; position: absolute; left: 0.7rem; top: 50%; width: 0.65rem; height: 0.65rem; margin-top: -0.4rem; border: 2px solid var(--c-muted); border-radius: 50%; pointer-events: none; }
.search::after { content: ""; position: absolute; left: 1.3rem; top: 50%; width: 2px; height: 0.4rem; margin-top: 0.15rem; background: var(--c-muted); transform: rotate(-45deg); pointer-events: none; }
.search .input { padding-left: 2rem; }
.kbd, kbd { display: inline-block; min-width: 1.4em; padding: 0 4px; border: 1px solid var(--c-border); border-bottom-width: 2px; border-radius: var(--r-sm); background: var(--c-surface); color: var(--c-muted); font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 1.5; text-align: center; }
.search__hint { position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
.views { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); margin: 0 0 var(--s-3); padding: 0; list-style: none; border-bottom: 1px solid var(--c-border); }
.view-tab { display: inline-block; padding: var(--s-2) var(--s-3); color: var(--c-muted); text-decoration: none; font-weight: 600; font-size: var(--text-sm); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.view-tab:hover { color: var(--c-text); text-decoration: none; }
.view-tab[aria-current="page"] { color: var(--c-text); border-bottom-color: var(--c-primary); }
.views__save { margin-left: auto; }
.view-tab-group { display: inline-flex; align-items: center; }
.view-delete { display: inline-flex; margin: 0 0 0 -6px; }
.view-delete__btn.btn { min-height: 1.5rem; min-width: 1.5rem; padding: 0 6px; border-color: transparent; color: var(--c-muted); font-size: var(--text-md); line-height: 1; }
.view-delete__btn.btn:hover { color: var(--c-danger); background: var(--b-danger-bg); }
.popover { position: relative; }
.popover > summary { list-style: none; cursor: pointer; }
.popover > summary::-webkit-details-marker { display: none; }
.popover__panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; width: 18rem; padding: var(--s-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-md); display: grid; gap: var(--s-3); }

/* ---------- List layout: facets + table ---------- */
.list-layout { display: grid; grid-template-columns: var(--facets-w) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.list-main { min-width: 0; }
.facets { position: sticky; top: var(--s-4); max-height: calc(100vh - 2rem); overflow-y: auto; padding-right: var(--s-2); }
.facets > summary { display: none; }
.facet { padding: var(--s-3) 0; border-bottom: 1px solid var(--c-border-soft); }
.facet:first-of-type { padding-top: 0; }
.facet__title { margin: 0 0 var(--s-2); font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c-muted); }
.facet__list { list-style: none; margin: 0; padding: 0; }
.facet__item { display: flex; align-items: center; gap: var(--s-2); padding: 3px var(--s-2); margin: 0 calc(-1 * var(--s-2)); border-radius: var(--r-sm); color: var(--c-text); text-decoration: none; font-size: var(--text-sm); }
.facet__item:hover { background: var(--c-row-hover); color: var(--c-text); text-decoration: none; }
.facet__check { flex: none; width: 14px; height: 14px; border: 1.5px solid var(--c-border-strong); border-radius: 3px; background: var(--c-surface); }
.facet__item.is-active { font-weight: 600; }
.facet__item.is-active .facet__check { background: var(--c-primary); border-color: var(--c-primary); box-shadow: inset 0 0 0 2px var(--c-surface); }
.facet__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet__count { flex: none; color: var(--c-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.facet__more > summary { cursor: pointer; padding: 3px 0; color: var(--c-primary); font-size: var(--text-sm); font-weight: 500; }
.facet__none { margin: 0; color: var(--c-muted); font-size: var(--text-sm); }
@media (max-width: 899px) {
  .list-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
  .facets { position: static; max-height: none; overflow: visible; padding: 0; border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
  .facets > summary { display: flex; align-items: center; justify-content: space-between; min-height: 2.75rem; padding: 0 var(--s-4); cursor: pointer; font-weight: 600; }
  .facets[open] > summary { border-bottom: 1px solid var(--c-border); }
  .facets .facet { padding: var(--s-3) var(--s-4); }
}

/* ---------- Filter chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; margin: 0 0 var(--s-3); padding: 0; }
.chip { display: inline-flex; align-items: center; gap: var(--s-1); min-height: 1.75rem; padding: 0 var(--s-2) 0 var(--s-3); border: 1px solid var(--c-border-strong); border-radius: var(--r-pill); background: var(--c-surface); color: var(--c-text); font-size: var(--text-sm); text-decoration: none; }
.chip:hover { background: var(--c-tint); border-color: var(--c-primary); color: var(--c-text); text-decoration: none; }
.chip__key { color: var(--c-muted); }
.chip__x { margin-left: 2px; font-size: 1.1em; line-height: 1; color: var(--c-muted); }
.chip:hover .chip__x { color: var(--c-danger); }
.chip--clear { border-style: dashed; padding-right: var(--s-3); color: var(--c-primary); }
@media (pointer: coarse) { .chip { min-height: 2.25rem; } }

/* ---------- Data table ---------- */
.table-scroll { position: relative; overflow: auto; border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
@media (min-width: 900px) { .table-scroll { max-height: calc(100vh - var(--table-offset, 15rem)); } .table-scroll--free { max-height: none; } }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-base); font-variant-numeric: tabular-nums lining-nums; }
.data-table th, .data-table td { height: var(--row-h); padding: var(--s-1) 0.625rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--c-border-soft); }
.data-table thead th { position: sticky; top: 0; z-index: 2; background: var(--c-sunken); color: var(--c-muted); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--c-border); }
.data-table tbody th { font-weight: 600; min-width: 12rem; max-width: 22rem; white-space: nowrap; }
.data-table tbody th .cell-link, .data-table tbody th .cell-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .mono { font-size: 0.85em; }
.data-table td { white-space: nowrap; }
.data-table td.wrap, .data-table tbody th.wrap { white-space: normal; }
.data-table tbody th.num { min-width: 0; }
.data-table td:has(> .diff, > .row-errors) { white-space: normal; min-width: 18rem; }
.data-table .tag-list { flex-wrap: nowrap; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody tr:hover > * { background: var(--c-row-hover); }
.data-table tbody tr.is-selected > *, .data-table tbody tr:has(.row-check:checked) > * { background: var(--c-row-selected); }
.data-table tbody tr.is-cursor > * { box-shadow: inset 0 1px 0 var(--c-focus), inset 0 -1px 0 var(--c-focus); }
.data-table tbody tr.is-cursor > :first-child { box-shadow: inset 3px 0 0 var(--c-focus), inset 0 1px 0 var(--c-focus), inset 0 -1px 0 var(--c-focus); }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table .date { white-space: nowrap; }
.data-table--selectable tbody th { padding-left: var(--s-2); }
.data-table .col-check { width: 2.5rem; padding-right: 0; text-align: center; }
.data-table .col-actions { text-align: right; white-space: nowrap; width: 1%; }
.data-table tr.is-overdue .date, .data-table td.is-overdue, .data-table span.is-overdue { color: var(--c-danger); font-weight: 600; }
.cell-item { display: block; }
.data-table tr.is-error > * { background: var(--b-danger-bg); }
.data-table tr.is-muted > * { color: var(--c-muted); }
.sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.sort:hover { color: var(--c-text); text-decoration: none; }
.sort.is-sorted { color: var(--c-text); }
.sort__icon { font-size: 0.95em; opacity: 0.45; }
.sort.is-sorted .sort__icon { opacity: 1; color: var(--c-primary); }
/* Bare links in a row header look like .cell-link (saves bytes on 200-row pages). */
.cell-link, .data-table tbody th > a:not([class]) { color: var(--c-text); font-weight: 600; text-decoration: none; }
.cell-link:hover, .data-table tbody th > a:not([class]):hover { color: var(--c-primary); text-decoration: underline; }
.cell-sub { display: block; font-size: var(--text-xs); font-weight: 400; color: var(--c-muted); line-height: 1.3; }
.cell-nil { color: var(--c-muted); }
.data-table__empty td { height: auto; padding: var(--s-6) var(--s-4); text-align: center; color: var(--c-muted); }
.check-all { visibility: hidden; }
.js .check-all { visibility: visible; }
.row-errors { margin: 0; padding-left: 1.1em; color: var(--b-danger-fg); font-size: var(--text-sm); }
.diff { font-size: var(--text-xs); color: var(--c-muted); }
.diff__field { font-weight: 600; color: var(--c-text); }
.diff del { color: var(--c-danger); }
.diff ins { color: var(--c-success); text-decoration: none; }
.table-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-3); }
@media (max-width: 1679px) { .hide-lg { display: none; } }
@media (max-width: 1199px) { .hide-md { display: none; } }
@media (max-width: 599px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi__value { font-size: var(--text-xl); } .data-table tbody th { min-width: 10rem; max-width: 13rem; }
  .hide-sm { display: none; } .data-table th, .data-table td { padding: var(--s-1) var(--s-2); } }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); margin-top: var(--s-3); font-size: var(--text-sm); }
.pagination__summary { margin: 0; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.pagination__summary strong { color: var(--c-text); font-weight: 600; }
.pagination__pages { display: flex; flex-wrap: wrap; gap: 2px; list-style: none; margin: 0; padding: 0; }
.pagination__link { display: inline-flex; gap: 4px; align-items: center; justify-content: center; min-width: 2rem; height: 2rem; padding: 0 var(--s-2); border-radius: var(--r-md); color: var(--c-text); text-decoration: none; font-variant-numeric: tabular-nums; }
a.pagination__link:hover { background: var(--c-sunken); color: var(--c-text); text-decoration: none; }
.pagination__link.is-current { background: var(--c-primary); color: var(--c-on-primary); font-weight: 700; }
.pagination__link.is-disabled { color: var(--c-muted); opacity: 0.6; }
.pagination__gap { display: inline-flex; align-items: center; padding: 0 4px; color: var(--c-muted); }
.pagination__per-page { display: flex; align-items: center; gap: 2px; margin: 0; }
.pagination__per-label { color: var(--c-muted); margin-right: var(--s-1); }
@media (max-width: 599px) { .pagination__num { display: none; } .pagination { justify-content: center; } }

/* ---------- Bulk action bar ---------- */
.bulk-bar { position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); margin-top: var(--s-3); padding: var(--s-2) var(--s-4); background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-up); }
/* Hidden until a row is ticked, from the first paint (no JS needed, no flash). Browsers without :has()
   always show the bar; ui.js then hides it while the selection is empty. */
@supports selector(:has(*)) { body:not(:has(.row-check:checked, [data-bulk-all]:checked)) .bulk-bar[data-bulk-bar] { display: none; } }
.js .bulk-bar.is-empty { display: none; }
.bulk-bar__status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-4); }
.bulk-bar__count { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.bulk-bar__all { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--c-primary); font-weight: 600; cursor: pointer; }
.bulk-bar__all[hidden] { display: none; }
.bulk-bar__actions { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); align-items: center; }
.bulk-bar__group { display: inline-flex; gap: var(--s-1); align-items: center; }
.bulk-bar__group[hidden] { display: none; }
.bulk-bar__field { display: inline-flex; align-items: center; gap: var(--s-1); }
.bulk-bar__field-label { font-size: var(--text-sm); color: var(--c-muted); white-space: nowrap; }
@media (max-width: 599px) { .bulk-bar { border-radius: 0; margin: var(--s-3) calc(-1 * var(--gutter)) 0; } .bulk-bar__group { flex: 1 1 100%; } .bulk-bar__group .input--sm { flex: 1; width: 100%; } }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.kpi-hold { display: grid; min-width: 0; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: var(--s-3) var(--s-4) var(--s-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); color: var(--c-text); text-decoration: none; box-shadow: inset 0 3px 0 var(--kpi-accent, transparent); }
a.kpi:hover { border-color: var(--c-border-strong); box-shadow: inset 0 3px 0 var(--kpi-accent, transparent), var(--shadow-sm); color: var(--c-text); text-decoration: none; }
.kpi__label { font-size: var(--text-xs); font-weight: 600; color: var(--c-muted); }
.kpi__value { font-family: var(--font-heading); font-size: var(--text-2xl); font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.01em; }
.kpi__hint { font-size: var(--text-xs); color: var(--c-muted); }
.kpi--good { --kpi-accent: var(--c-fill-ok); }
.kpi--warn { --kpi-accent: var(--c-fill-warn); }
.kpi--warn .kpi__value { color: var(--c-warn); }
.kpi--bad { --kpi-accent: var(--c-fill-bad); }
.kpi--bad .kpi__value { color: var(--c-danger); }

/* ---------- Panels (cards), key-value lists, grids ---------- */
.panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); margin-bottom: var(--s-4); }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-border-soft); }
.panel__title { margin: 0; font-size: var(--text-md); font-weight: 700; }
.panel__actions { display: flex; gap: var(--s-2); }
.panel__body { padding: var(--s-4); }
.panel__body > :last-child { margin-bottom: 0; }
.panel--flush .panel__body { padding: 0; }
.panel > details > summary { padding: var(--s-3) var(--s-4); cursor: pointer; font-weight: 600; color: var(--c-primary); }
.panel > details[open] > summary { border-bottom: 1px solid var(--c-border-soft); }
.panel--flush .table-scroll { border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); max-height: none; }
.panel--alert { border-color: var(--b-danger-fg); }
.panel--alert .panel__head { background: var(--b-danger-bg); color: var(--b-danger-fg); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.kv { display: grid; grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr); gap: var(--s-2) var(--s-4); margin: 0; }
.kv dt { color: var(--c-muted); font-size: var(--text-sm); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr); gap: var(--s-4); align-items: start; }
.dash-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(18rem, 2fr); gap: var(--s-4); align-items: start; }
@media (max-width: 1099px) { .detail-layout, .dash-layout, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 699px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } .kv { grid-template-columns: minmax(0, 1fr); gap: 0 var(--s-4); } .kv dd { margin-bottom: var(--s-2); } }

/* ---------- Start cards (home fallback, empty dashboards) ---------- */
.start-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--s-3); }
.start-card { display: grid; gap: 2px; padding: var(--s-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); color: var(--c-text); text-decoration: none; }
.start-card:hover { border-color: var(--c-primary); box-shadow: var(--shadow-sm); color: var(--c-text); text-decoration: none; }
.start-card__title { font-weight: 700; font-size: var(--text-md); color: var(--c-primary); }
.start-card__body { font-size: var(--text-sm); color: var(--c-muted); }

/* ---------- Status stepper ---------- */
.stepper { display: flex; list-style: none; margin: 0; padding: 0; counter-reset: step; }
.stepper__step { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--s-1); min-width: 0; font-size: var(--text-xs); color: var(--c-muted); text-align: center; }
.stepper__step::before { content: ""; position: absolute; top: 6px; left: -50%; width: 100%; height: 2px; background: var(--c-border); z-index: 0; }
.stepper__step:first-child::before { display: none; }
.stepper__dot { position: relative; z-index: 1; width: 14px; height: 14px; border-radius: 50%; background: var(--c-surface); border: 2px solid var(--c-border-strong); }
.stepper__step.is-todo { color: var(--c-muted); }
.stepper__step.is-done { color: var(--c-text); }
.stepper__step.is-done::before, .stepper__step.is-current::before { background: var(--c-primary); }
.stepper__step.is-done .stepper__dot { background: var(--c-primary); border-color: var(--c-primary); }
.stepper__step.is-current { color: var(--c-text); font-weight: 700; }
.stepper__step.is-current .stepper__dot { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-tint); background: var(--c-surface); border-width: 4px; }
.stepper__label { max-width: 100%; }
@media (max-width: 599px) { .stepper__step:not(.is-current) .stepper__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }

/* ---------- Utilisation bar ---------- */
.util { display: flex; align-items: center; gap: var(--s-2); min-width: 9rem; }
.util__track { flex: 1; height: 8px; border-radius: var(--r-pill); background: var(--c-track); overflow: hidden; min-width: 4rem; }
.util__fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--c-fill-ok); }
.util--low .util__fill { background: var(--c-fill-low); }
.util--warn .util__fill { background: var(--c-fill-warn); }
.util--bad .util__fill { background: var(--c-fill-bad); }
.util__text { flex: none; font-size: var(--text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.util__pct { color: var(--c-muted); margin-left: 2px; }
.util--bad .util__pct { color: var(--c-danger); font-weight: 700; }
.util--warn .util__pct { color: var(--c-warn); font-weight: 700; }
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }

/* ---------- Bar list (dashboard: companies by status/state) ---------- */
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.bar-list__row { display: grid; grid-template-columns: 7rem minmax(0, 1fr) 4rem; align-items: center; gap: var(--s-3); font-size: var(--text-sm); }
.bar-list__row a { color: var(--c-text); text-decoration: none; }
.bar-list__row a:hover { color: var(--c-primary); text-decoration: underline; }
.bar-list__track { height: 10px; background: var(--c-track); border-radius: var(--r-sm); overflow: hidden; }
.bar-list__fill { display: block; height: 100%; background: var(--c-primary); border-radius: var(--r-sm); }
.bar-list__val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-list__row > a, .bar-list__row > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list--util .bar-list__row { grid-template-columns: minmax(6rem, 9rem) minmax(0, 1fr) 4rem; }
.bar-list__head { color: var(--c-muted); font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.bar-list__head > :last-child { text-align: right; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item { position: relative; display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 0 var(--s-3); padding: var(--s-2) 0 var(--s-2) var(--s-4); border-left: 2px solid var(--c-border); margin-left: 5px; }
.timeline__item::before { content: ""; position: absolute; left: -6px; top: 0.85rem; width: 10px; height: 10px; border-radius: 50%; background: var(--c-surface); border: 2px solid var(--c-primary); }
.timeline__ts { grid-row: span 2; font-size: var(--text-xs); color: var(--c-muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.timeline__what { margin: 0; }
.timeline__action { font-weight: 600; }
.timeline__who { margin: 0; font-size: var(--text-xs); color: var(--c-muted); }
.timeline--compact .timeline__item { grid-template-columns: minmax(0, 1fr); padding-top: var(--s-1); padding-bottom: var(--s-1); }
.timeline--compact .timeline__ts { grid-row: auto; }
@media (max-width: 599px) { .timeline__item { grid-template-columns: minmax(0, 1fr); } .timeline__ts { grid-row: auto; } }

/* ---------- Notes ---------- */
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.note { padding: var(--s-3); border: 1px solid var(--c-border-soft); border-radius: var(--r-md); background: var(--c-surface-alt); }
.note--pinned { border-color: var(--c-highlight); box-shadow: inset 3px 0 0 var(--c-highlight); }
.note__meta { margin: 0 0 var(--s-1); font-size: var(--text-xs); color: var(--c-muted); }
.note__body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Deadlines grouped by week ---------- */
.week-group { margin-bottom: var(--s-5); }
.week-head { display: flex; align-items: baseline; gap: var(--s-3); margin: 0 0 var(--s-2); font-size: var(--text-md); }
.week-head .count { margin-left: auto; }
.week-group--overdue .week-head { color: var(--c-danger); }
.week-group--overdue .table-scroll { border-color: var(--b-danger-fg); }
.data-table .is-past { color: var(--c-danger); font-weight: 600; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2); font-size: var(--text-sm); color: var(--c-muted); }
.pager strong { color: var(--c-text); }
.show-more { margin: var(--s-3) 0 0; }
.week-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--s-2); }
.week-list li { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) var(--s-3); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); }
.week-list a { font-weight: 600; text-decoration: none; }
.week-list a:hover { text-decoration: underline; }
.days-left { font-variant-numeric: tabular-nums; white-space: nowrap; }
.days-left--overdue { color: var(--c-danger); font-weight: 700; }
.days-left--soon { color: var(--c-warn); font-weight: 600; }

/* ---------- Import wizard ---------- */
.wizard { display: flex; gap: var(--s-2); list-style: none; margin: 0 0 var(--s-5); padding: 0; counter-reset: wiz; }
.wizard li { counter-increment: wiz; display: flex; align-items: center; gap: var(--s-2); color: var(--c-muted); font-weight: 600; font-size: var(--text-sm); }
.wizard li::before { content: counter(wiz); display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1.5px solid var(--c-border-strong); font-size: var(--text-xs); }
.wizard li + li { padding-left: var(--s-2); border-left: 1px solid var(--c-border); }
.wizard li[aria-current="step"] { color: var(--c-text); }
.wizard li[aria-current="step"]::before { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on-primary); }
.wizard li.is-done::before { content: "✓"; background: var(--c-tint); border-color: var(--c-primary); color: var(--c-primary); }
.upload { display: grid; gap: var(--s-3); justify-items: start; padding: var(--s-6); border: 2px dashed var(--c-border-strong); border-radius: var(--r-lg); background: var(--c-surface); }
.upload:focus-within { border-color: var(--c-focus); }
.upload input[type="file"] { font: inherit; font-size: var(--text-sm); max-width: 100%; min-height: 0; height: auto; padding: var(--s-2); }
.commit-bar { position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-4); padding: var(--s-3) var(--s-4); background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-up); }
.commit-bar p { margin: 0; }

/* ---------- Empty / loading / error states ---------- */
.empty-state { display: grid; justify-items: center; gap: var(--s-1); padding: var(--s-7) var(--s-4); text-align: center; border: 1px dashed var(--c-border-strong); border-radius: var(--r-lg); background: var(--c-surface-alt); }
.empty-state__title { margin: 0; font-family: var(--font-heading); font-size: var(--text-lg); font-weight: 500; }
.empty-state__body { margin: 0; max-width: 46ch; color: var(--c-muted); }
.empty-state__action { margin: var(--s-3) 0 0; }
.empty-state--empty, .empty-state--no-results { color: var(--c-text); }
.empty-state--error { border-style: solid; border-color: var(--b-danger-fg); background: var(--b-danger-bg); }
.empty-state--error .empty-state__title, .empty-state--error .empty-state__body { color: var(--b-danger-fg); }
.is-loading { position: relative; pointer-events: none; }
.is-loading::after { content: ""; position: absolute; inset: 0; background: var(--c-bg); opacity: 0.5; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -0.15em; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-right-color: currentColor; opacity: 0.6; } }

/* ---------- Auth (login) ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5) var(--gutter); background: var(--c-bg); }
.auth__card { width: 100%; max-width: 24rem; padding: var(--s-6); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-md); }
.auth__brand { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-5); font-family: var(--font-heading); font-size: var(--text-lg); font-weight: 600; }
.auth__brand img, .auth__brand svg { width: 32px; height: 32px; }
.auth__card h1 { font-size: var(--text-xl); }
.auth__card .form { max-width: none; }
.auth__card .btn--primary { width: 100%; min-height: 2.75rem; }
.demo-banner { margin: 0 0 var(--s-4); padding: var(--s-3); border-radius: var(--r-md); border-left: 4px solid var(--b-info-fg); background: var(--b-info-bg); color: var(--b-info-fg); font-size: var(--text-sm); line-height: 1.5; overflow-wrap: anywhere; }
.auth__foot { margin: var(--s-4) 0 0; font-size: var(--text-xs); color: var(--c-muted); text-align: center; }

/* ---------- Error pages ---------- */
.error-page { max-width: 36rem; padding: var(--s-7) 0; }
.error-page__code { font-family: var(--font-heading); font-size: 3.5rem; line-height: 1; color: var(--c-accent); margin: 0 0 var(--s-3); }

/* ---------- Print ---------- */
@media print {
  .sidebar, .facets, .bulk-bar, .pagination, .page-actions, .toolbar, .views, .chips, .col-check, .commit-bar { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .table-scroll { max-height: none; overflow: visible; border: 0; }
  .data-table thead th { position: static; }
  body { background: #fff; color: #000; }
}

/* deadlines */
/* The overdue row's red due date used to ride on the per-row tr.is-overdue class;
   the group wrapper carries it now so lean rows can skip the class attribute.
   The When cell says "N days overdue" in words, so it needs no per-row class. */
.week-group--overdue .data-table tbody td:has(+ th) { color: var(--c-danger); font-weight: 600; }
/* The Item column hides on phones like .hide-sm, but from one rule instead of a
   class on every row cell (page weight). Only the header cell keeps .hide-sm. */
@media (max-width: 599px) { .week-group .data-table tbody td.compact-order-3 { display: none; } }

/* Owner & growth panel, Today, Solvency (schema v3) */
.panel__subtitle { font-size: 0.875rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
.plain-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.75rem; }
.plain-list li { line-height: 1.45; }
#growth details { margin-top: 0.5rem; }
#growth details > summary { cursor: pointer; list-style: none; }
#growth .inline-form { margin-top: 0.5rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.page-actions select.input { min-width: 12rem; }

/* ---------- Round 2: statutory tiles, Today, attention, banners ---------- */
.kpi-row-title { margin: 0 0 var(--s-2); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-muted); }
.kpis--statutory { margin-bottom: var(--s-4); }
.kpi--current { border-color: var(--c-primary); box-shadow: inset 0 3px 0 var(--kpi-accent, var(--c-primary)), 0 0 0 1px var(--c-primary); }
.kpi--current .kpi__label { color: var(--c-text); }
.kpis--tabs a.kpi:not(.kpi--current) { opacity: 0.92; }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--b-warning-fg); border-radius: var(--r-lg); background: var(--b-warning-bg); color: var(--b-warning-fg); }
.banner p { margin: 0; }
.js .js-hide { display: none; }
.field__label--inline { margin: 0; align-self: center; }
.empty-state--clear .empty-state__title { color: var(--c-success); }
.reason { font-weight: 600; }
.reason--t0 { color: var(--c-danger); }
.reason--t1 { color: var(--c-warn); }
.reason--t2, .reason--t3 { color: var(--c-text); font-weight: 500; }
.today-list td.wrap { min-width: 14rem; }
.today-list .col-actions .btn + .inline-form { margin-left: var(--s-1); }
.show-more { margin: var(--s-3) 0 0; }
.attention__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.attention__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 2.25rem; padding: var(--s-1) var(--s-3); border-radius: var(--r-md); border-left: 3px solid var(--c-border); background: var(--c-surface-alt); }
.attention__row a { color: var(--c-text); font-weight: 600; text-decoration: none; }
.attention__row a:hover { color: var(--c-primary); text-decoration: underline; }
.attention__row--bad { border-left-color: var(--c-fill-bad); }
.attention__row--warn { border-left-color: var(--c-fill-warn); }
.attention__val { font-family: var(--font-heading); font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.attention__row--bad .attention__val { color: var(--c-danger); }
.filter-note { margin: 0 0 var(--s-3); color: var(--c-muted); }
.table-tools { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-2) var(--s-4); margin: 0 0 var(--s-2); }
.table-tools p { margin: 0; }
.sort-links { font-size: var(--text-sm); color: var(--c-muted); }
.sort-links strong { color: var(--c-text); }
.form-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-2); }
.form-row .field__label { margin: 0; }
.exempt-form { margin-top: var(--s-3); }
.exempt-form > summary { list-style: none; cursor: pointer; }
.exempt-form > summary::-webkit-details-marker { display: none; }
.assign__bar { position: sticky; top: 0; z-index: 5; background: var(--c-bg); padding: var(--s-2) 0; }
.nav-toggle, .nav-toggle__btn { display: none; }

/* ---------- Compact menu: below 900px the nav folds into a Menu button (no sideways scroll) ---------- */
@media (max-width: 899px) {
  .nav-toggle { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
  .nav-toggle__btn { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 2.75rem; margin-left: auto; padding: 0 var(--s-3); border: 1px solid var(--c-nav-hover); border-radius: var(--r-md); color: var(--c-nav-strong); font-weight: 600; cursor: pointer; }
  .nav-toggle__btn::before { content: "\2261"; font-size: 1.25rem; line-height: 1; }
  .nav-toggle:focus-visible + .nav-toggle__btn { box-shadow: 0 0 0 2px var(--c-nav-current); }
  .nav-toggle:checked + .nav-toggle__btn { background: var(--c-nav-hover); }
  .sidebar .nav { display: none; overflow: visible; }
  .sidebar .nav-toggle:checked ~ .nav { display: block; }
  .sidebar .nav .nav__list { flex-direction: column; gap: 2px; padding: var(--s-2) 0; }
  .sidebar .nav .nav__link { white-space: normal; }
  .sidebar .nav .nav__link[aria-current="page"] { box-shadow: inset 3px 0 0 var(--c-nav-current); }
  .sidebar .sidebar__user { display: none; order: 4; flex: 1 0 100%; margin: 0; padding: var(--s-2) 0 var(--s-1); border-top: 1px solid var(--c-nav-hover); }
  .sidebar .nav-toggle:checked ~ .sidebar__user { display: flex; flex-wrap: wrap; }
  .sidebar .nav-toggle:checked ~ .sidebar__user strong { display: block; flex: 1 0 100%; }
}

/* ---------- Mobile: table rows become stacked cards (data-label on each cell) ---------- */
@media (max-width: 767px) {
  .table-scroll:has(> .data-table--cards) { overflow: visible; border: 0; background: transparent; max-height: none; }
  .panel--flush .table-scroll:has(> .data-table--cards) { padding: var(--s-2); }
  .data-table--cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table--cards, .data-table--cards tbody, .data-table--cards tr { display: block; width: 100%; }
  .data-table--cards tr { margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
  .data-table--cards tr.is-overdue, .week-group--overdue .data-table--cards tr { border-left: 3px solid var(--c-fill-bad); }
  .data-table--cards tbody th, .data-table--cards tbody td { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); width: auto; height: auto; min-width: 0; max-width: none; padding: var(--s-1) 0; border: 0; white-space: normal; text-align: right; }
  .data-table--cards tbody tr > * { background: transparent !important; }
  .data-table--cards [data-label]::before { content: attr(data-label); flex: none; color: var(--c-muted); font-size: var(--text-xs); font-weight: 600; text-align: left; }
  .data-table--cards tbody th { justify-content: flex-start; text-align: left; font-size: var(--text-md); padding-bottom: var(--s-2); }
  .data-table--cards tbody th::before { content: none; }
  .data-table--cards tbody th .cell-link, .data-table--cards tbody th .cell-sub { white-space: normal; }
  .data-table--cards tbody th:has(+ td), .data-table--cards tbody td.col-check + th { border-bottom: 1px solid var(--c-border-soft); margin-bottom: var(--s-1); }
  .data-table--cards td.col-check { float: right; width: auto; padding: 0 0 0 var(--s-2); }
  .data-table--cards td.col-check::before { content: none; }
  .data-table--cards .col-actions { justify-content: flex-end; flex-wrap: wrap; width: auto; }
  .data-table--cards .col-actions::before { content: none; }
  .data-table--cards .hide-sm, .data-table--cards .hide-md, .data-table--cards .hide-lg { display: flex; }
  .data-table--cards .num { text-align: right; }
  .data-table--cards .inline-form { display: inline-flex; flex-wrap: wrap; gap: var(--s-1); justify-content: flex-end; }
  .data-table--cards .data-table__empty td { justify-content: center; }
  .page-actions { width: 100%; }
  .page-actions .input, .page-actions .select { flex: 1 1 10rem; min-width: 0; }
  .toolbar { flex-wrap: wrap; }
}

/* Deadlines rows carry no data-label (page weight budget): label by column from the end */
@media (max-width: 767px) {
  .data-table--deadlines tbody td.compact-order-2::before { content: "Due"; }
  .data-table--deadlines tbody td.compact-order-3::before { content: "Item"; }
  .data-table--deadlines tbody td.compact-order-1::before { content: "When"; }
  .data-table--deadlines tbody td:nth-last-child(n)::before { flex: none; color: var(--c-muted); font-size: var(--text-xs); font-weight: 600; text-align: left; }
  .data-table--deadlines tbody td.col-check::before { content: none; }
}
.week-group--overdue .data-table tbody td.num { color: var(--c-danger); font-weight: 600; }
@media (max-width: 767px) { .week-group .data-table--deadlines tbody td.compact-order-3 { display: flex; } }
.exempt-form > summary { white-space: normal; text-align: left; height: auto; max-width: 100%; }
@media (max-width: 767px) {
  .data-table--cards td.wrap { flex-wrap: wrap; }
  .data-table--cards td.wrap > .cell-sub { flex: 1 0 100%; text-align: right; }
}

/* ---------- Server pager with counts (Solvency, Assign owners) ---------- */
.pager--count { justify-content: space-between; margin: var(--s-2) 0; }
.pager__count, .pager__links { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.panel__note { margin: 0 0 var(--s-2); color: var(--c-muted); font-size: var(--text-sm); }

/* ---------- Mobile: compact two-line cards (name, then state pill + due date) ---------- */
@media (max-width: 767px) {
  .data-table--compact tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); padding: var(--s-2) var(--s-3); margin: 0 0 var(--s-2); }
  .data-table--compact tbody th { flex: 1 1 calc(100% - 3rem); order: 0; border-bottom: 0 !important; margin: 0 !important; padding: 0 !important; font-size: var(--text-md); }
  .data-table--compact tbody td { display: inline-flex; flex: 0 1 auto; order: 5; padding: 0; gap: var(--s-1); font-size: var(--text-sm); color: var(--c-muted); text-align: left; }
  .data-table--compact tbody td.col-check { order: -1; float: none; padding: 0; }
  .data-table--compact [data-label]::before { content: none; }
  .data-table--compact .compact-hide { display: none !important; }
  .data-table--compact .compact-order-1 { order: 1; color: var(--c-text); font-weight: 600; }
  .data-table--compact .compact-order-2 { order: 2; }
  .data-table--compact .compact-order-3 { order: 3; flex-basis: 100%; }
  .week-group .data-table--compact tbody td.compact-order-3 { display: inline-flex; }
}
.panel__pad { padding: var(--s-3) var(--s-4); }
.panel__pad > :last-child { margin-bottom: 0; }
@media (max-width: 767px) {
  .data-table--cards .cell-empty { display: none !important; }
  .data-table--cards td.wrap .inline-form { flex: 1 0 100%; justify-content: flex-end; }
}

/* ---------- Dashboard: act-on tiles, 12-week trend sparkline, facts line ---------- */
.kpis--act { grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); margin-bottom: var(--s-4); }
.trend__body { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5); }
.spark { flex: none; overflow: visible; }
.spark__line { fill: none; stroke: var(--c-primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark__dot { fill: var(--c-primary); }
.spark--bad .spark__line { stroke: var(--c-danger); } .spark--bad .spark__dot { fill: var(--c-danger); }
.spark--good .spark__line { stroke: var(--c-success); } .spark--good .spark__dot { fill: var(--c-success); }
.trend__text { flex: 1 1 18rem; margin: 0; }
.trend__now { font-size: var(--text-xl); font-variant-numeric: tabular-nums; }
.trend__dir { font-weight: 600; }
.trend__dir--bad { color: var(--c-danger); } .trend__dir--good { color: var(--c-success); } .trend__dir--neutral { color: var(--c-muted); }
.trend__data { flex: 1 1 100%; }
.trend__table { max-width: 20rem; }
.facts { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin: 0 0 var(--s-5); padding: 0; list-style: none; font-size: var(--text-sm); }
.facts__item a { color: var(--c-muted); text-decoration: none; }
.facts__item a:hover .facts__label { text-decoration: underline; }
.facts__value { color: var(--c-text); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-list__row > a { min-width: 0; overflow-wrap: anywhere; }
/* Deadlines keeps its bulk bar in view so the row checkboxes have a visible purpose. */
.bulk-bar.bulk-bar--persist { display: flex !important; }
.bulk-bar__hint { margin: 0; font-size: var(--text-sm); color: var(--c-muted); }
.bulk-bar.bulk-bar--persist { position: static; }
body:has(.row-check:checked) .bulk-bar.bulk-bar--persist { position: sticky; }
@media (max-width: 767px) {
  .data-table--compact.data-table--deadlines tbody td:nth-last-child(n)::before { content: none; }
  .data-table--compact.data-table--deadlines tbody td.compact-order-2::before { content: "Due"; margin-right: 0.25em; font-size: inherit; font-weight: 400; }
  .data-table--compact.data-table--deadlines tbody td.compact-order-3 { justify-content: flex-start; text-align: left; }
  .week-group--overdue .data-table--compact tbody td.compact-order-1 { color: var(--c-danger); }
}

/* ---------- Round 4: Today "Do first", section jump links, inline "more" ---------- */
.do-first { border-color: var(--c-primary); }
.do-first__list { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.do-first__item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--c-border-soft); }
.do-first__item:first-child { border-top: 0; }
.do-first__n, .do-first__badge { flex: none; display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--c-primary); color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.do-first__badge { width: 1.35rem; height: 1.35rem; font-size: var(--text-xs); vertical-align: 0.1em; }
.do-first__item.is-overdue .do-first__n { background: var(--c-danger); }
.do-first__what { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.do-first__what .cell-sub { white-space: normal; }
.today-jump { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-4); }
.today-jump__link { display: inline-flex; align-items: center; gap: var(--s-1); padding: var(--s-1) var(--s-3); border: 1px solid var(--c-border); border-radius: 999px; color: var(--c-text); text-decoration: none; font-size: var(--text-sm); font-weight: 600; background: var(--c-surface); }
.today-jump__link--bad { border-color: var(--c-fill-bad); color: var(--c-danger); }
.count--bad { color: var(--c-danger); }
.reason--late { color: var(--c-danger); font-weight: 600; }
.today-more { border-top: 1px solid var(--c-border-soft); }
.today-more > summary { margin: var(--s-3) var(--s-4); list-style: none; cursor: pointer; }
.today-more > summary::-webkit-details-marker { display: none; }
.today-more[open] > summary { margin-bottom: var(--s-2); }
@media (max-width: 599px) {
  .do-first__item { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr); gap: var(--s-2) var(--s-3); align-items: start; padding: var(--s-3); }
  .do-first__item > .btn { grid-column: 2; justify-self: start; }
}

/* ---------- Opportunities: next action stacks its date; overdue in red ---------- */
.opp-table .opp-next { min-width: 14rem; }
.opp-table td.opp-next { white-space: normal; }
.opp-next__what { display: block; }
.opp-table td.opp-next .cell-sub { display: block; }
.cell-sub.is-overdue, .page-sub .is-overdue { color: var(--c-danger); font-weight: 600; }
@media (min-width: 768px) { .opp-table tr.is-overdue > th { box-shadow: inset 3px 0 0 var(--c-fill-bad); } }
@media (min-width: 768px) and (max-width: 1279px) { .opp-table .opp-type { display: none; } }
@media (max-width: 767px) { .opp-table td.opp-next { flex-wrap: wrap; } .opp-table td.opp-next .cell-sub { flex: 1 0 100%; } }
.kpis__sum { margin: calc(-1 * var(--s-2)) 0 var(--s-4); font-size: var(--text-sm); color: var(--c-muted); }

/* ---------- Mobile: solvency cards keep owner and workings; stepper as text ---------- */
.compact-label { display: none; }
.stepper__text { display: none; margin: 0; font-weight: 600; }
@media (max-width: 767px) {
  .data-table--compact .compact-label { display: inline; color: var(--c-muted); font-weight: 400; }
  .data-table--compact .compact-order-4 { order: 4; flex-basis: 100%; }
  .data-table--compact td.compact-order-3.wrap { flex-wrap: wrap; }
}
@media (max-width: 599px) {
  .stepper__text { display: block; }
  .stepper { display: none; }
}

/* ---------- Desktop: the dark sidebar column runs the full height of tall pages ---------- */
@media (min-width: 900px) {
  .shell { background: linear-gradient(to right, var(--c-nav-bg) calc(var(--sidebar-w) - 1px), var(--c-border) calc(var(--sidebar-w) - 1px), var(--c-border) var(--sidebar-w), transparent var(--sidebar-w)); }
}
.form485 { margin: var(--s-3) 0; padding: var(--s-3); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface-alt); }
.form485 p { margin: 0 0 var(--s-2); }
a.badge { text-decoration: none; }
a.badge:hover { text-decoration: underline; }

/* ---------- Dashboard: Portfolio health headline (per type light, week on week, exposure) ---------- */
.health { margin: 0 0 var(--s-5); }
.health__exposure { margin: 0 0 var(--s-2); }
.health__exposure a { color: inherit; }
.health__exposure strong { font-variant-numeric: tabular-nums; }
.health__types { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.health__type a { display: inline-block; padding: .35em .8em; border-radius: 999px; line-height: 1.5;
  text-decoration: none; color: inherit; border: 1px solid transparent; }
.health__type a:hover, .health__type a:focus-visible { border-color: currentColor; }
.health__dot { display: inline-block; width: .6em; height: .6em; margin-right: .35em; border-radius: 50%; background: currentColor; vertical-align: .05em; }
@media (max-width: 599px) { .health__types { display: block; } .health__type + .health__type { margin-top: var(--s-2); }
  .health__type a { display: block; border-radius: var(--radius, 8px); } }
.health__n { font-variant-numeric: tabular-nums; }
.health__status { font-weight: 600; }
.health__status::before, .health__type .health__change::before { content: "· "; font-weight: 400; }
.health__change { font-size: var(--text-sm); }
.health__exposure .health__change { opacity: .8; }
/* Today: the "Do first" number sits on the same line as its task */
.task-line { display: flex; align-items: center; gap: var(--s-2); }
.task-line .cell-link { min-width: 0; }
.inline-label { font-size: var(--text-xs); color: var(--c-muted); white-space: nowrap; }

/* ---------- Round 5: solvency record form; Today rows of three lines ---------- */
.record-resolution { margin: var(--s-3) 0; padding: var(--s-3); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface-alt); }
.record-resolution p { margin: 0 0 var(--s-2); }
.record-resolution__form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-2) var(--s-3); }
.record-resolution__title { flex: 1 0 100%; margin: 0; font-size: var(--text-md); }
.record-resolution__form .field { margin: 0; }
.record-resolution__form .field__hint { flex: 1 0 100%; margin: 0; }
.today-order { font-size: var(--text-xs); color: var(--c-muted); }
.today-skip-note { margin: 0; padding: var(--s-2) var(--s-4); font-size: var(--text-sm); color: var(--c-muted); border-bottom: 1px solid var(--c-border-soft); }
.today-why { font-size: var(--text-sm); }
.today-co { font-size: var(--text-sm); }
.do-first__what .today-why, .do-first__what .today-co { display: block; }
.do-first__act { flex: none; }
@media (max-width: 767px) {
  /* three lines a task: what; why · due (red when late); company, with the one action inline */
  .today-list tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px var(--s-2); margin: 0 0 var(--s-2); padding: var(--s-2) var(--s-3); }
  .today-list tbody th, .today-list tbody td { display: block; padding: 0; text-align: left; border: 0; margin: 0; }
  .today-list [data-label]::before { content: none; }
  .today-list tbody th.today-task { grid-column: 1 / -1; font-size: var(--text-sm); padding: 0; border: 0; margin: 0; }
  .today-list tbody th:has(+ td) { border-bottom: 0; margin-bottom: 0; }
  .today-list td.today-why { grid-column: 1 / -1; min-width: 0; }
  .today-list td.today-co { grid-column: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .today-list td.col-actions { grid-column: 2; display: block; }
  .today-list .reason { font-weight: 500; }
  .panel--flush .table-scroll:has(> .today-list) { padding: var(--s-2) var(--s-2) 0; }
  .today-group .panel__head { padding-top: var(--s-2); padding-bottom: var(--s-2); }
  .today-order { display: none; }
}
@media (max-width: 599px) {
  .do-first__item { grid-template-columns: 1.5rem minmax(0, 1fr) auto; align-items: center; gap: 2px var(--s-2); padding: var(--s-2) var(--s-3); }
  .do-first__n { width: 1.5rem; height: 1.5rem; }
  .do-first__act { grid-column: 3; }
}
@media (max-width: 767px) {
  /* Today phone density: every task is three short lines (what; why and due on one
     line, the flag kept visible; company with the one action). Do first uses the
     same shape so the number sits beside the title. */
  .today-list tbody th.today-task .cell-link, .do-first__what > .cell-link { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .today-list td.today-why, .do-first__what .today-why { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--s-1); min-width: 0; }
  .today-why .reason { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .today-why .badge { flex: none; font-size: var(--text-xs); }
  .today-list tr { margin-bottom: 6px; padding-top: 6px; padding-bottom: 6px; gap: 1px var(--s-2); }
  .today-list td.col-actions .btn { min-height: 2.25rem; padding-top: 0; padding-bottom: 0; }
  .do-first__item { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; align-items: center; gap: 2px var(--s-2); padding: var(--s-2) var(--s-3); }
  .do-first__n { width: 1.5rem; height: 1.5rem; grid-row: 1; grid-column: 1; }
  .do-first__what { display: contents; }
  .do-first__what > .cell-link { grid-column: 2 / -1; grid-row: 1; }
  .do-first__what .today-why { grid-column: 1 / -1; grid-row: 2; }
  .do-first__what .today-co { grid-column: 1 / 3; grid-row: 3; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .do-first__act { grid-column: 3; grid-row: 3; }
}
.stage-hint { display: block; color: var(--c-warn); font-weight: 600; }
@media (max-width: 767px) {
  /* Companies phone cards: name (with client), status, risk and next review only */
  .data-table--cards .card-hide { display: none !important; }
  .data-table--selectable.data-table--cards tbody td:not(.card-hide):not(.col-check) { padding: 2px 0; }
}
/* Deadlines bulk bar (always shown): its actions appear once a row (or "all
   matching") is ticked, so nothing invites a click that would do nothing.
   ui.js also disables the buttons while nothing is selected; without JS or :has
   every action stays visible and the server checks the selection. */
@supports selector(:has(*)) {
  body:not(:has(.row-check:checked, [data-bulk-all]:checked)) .bulk-bar--persist .bulk-bar__actions { display: none; }
}
.js .bulk-bar--persist.is-empty .bulk-bar__actions { display: none; }
/* Dashboard: every figure is a link to its list; links keep the figure's look */
.page-sub a, .trend__text a, a.bar-list__val, a.attention__val { color: inherit; text-decoration: none; }
.page-sub a:hover, .trend__text a:hover, a.bar-list__val:hover, a.attention__val:hover { text-decoration: underline; }
.health__note { margin: 0 0 var(--s-2); font-size: var(--text-sm); color: var(--c-muted); }
.health__note a { color: var(--c-primary); }

/* ---------- Round 6: solvency stage chip + next step ---------- */
.stage-note { display: block; color: var(--c-danger); font-weight: 600; white-space: normal; }
.today-stage { margin-right: var(--s-1); }
@media (max-width: 767px) {
  .data-table--compact .compact-order-5 { order: 6; flex-basis: 100%; justify-content: flex-start; }
}
.today-split { font-size: var(--text-sm); color: var(--c-muted); margin-right: var(--s-2); }
/* Deadlines: overdue grouped by item type, owner column */
.kind-counts { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin: 0 0 var(--s-2); padding: 0; list-style: none; font-size: var(--text-sm); }
.kind-counts a { color: var(--c-text); font-weight: 600; }
.data-table tr.kind-head > th { background: var(--c-surface-alt); font-size: var(--text-sm); font-weight: 700; color: var(--c-danger); text-align: left; }
.input--search-dir { min-width: 14rem; }
@media (max-width: 767px) {
  .data-table--compact tbody tr.kind-head { display: block; padding: var(--s-1) var(--s-3); margin: var(--s-2) 0 var(--s-1); background: transparent; border: 0; }
  .data-table--compact tbody tr.kind-head > th { flex: none; background: transparent; }
}

/* ---------- Round 6: dashboard per-operator table ---------- */
.operators { margin-top: var(--s-4); }
.operators__table td.op-bad { color: var(--c-danger); font-weight: 600; }
.op-trend { white-space: nowrap; font-size: var(--text-sm); }
.op-trend--up { color: var(--c-danger); }
.op-trend--down { color: var(--c-success); }
.op-trend--flat { color: var(--c-muted); }
@media (max-width: 599px) {
  .operators__table thead { display: none; }
  .operators__table, .operators__table tbody { display: block; }
  .operators__table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-1) var(--s-2); padding: var(--s-2) 0; border-bottom: 1px solid var(--c-border-soft); }
  .operators__table th[scope="row"], .operators__table td:last-child { grid-column: 1 / -1; }
  .operators__table th, .operators__table td { display: block; height: auto; min-height: 0; padding: 0; border: 0; text-align: left; line-height: 1.4; }
  .operators__table .compact-label { display: inline; color: var(--c-muted); font-weight: 400; }
  .op-trend { white-space: normal; }
}

/* ---------- Round 6: company client header ---------- */
.client-head { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s-3) var(--s-5); margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); }
.client-head__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--s-2) var(--s-4); margin: 0; }
.client-head__fact dt { font-size: var(--text-sm); color: var(--c-muted); margin: 0; }
.client-head__fact dd { margin: 2px 0 0; font-weight: 600; }
.client-head__bad { color: var(--c-danger); }
.client-head__title { font-size: var(--text-sm); color: var(--c-muted); font-weight: 400; margin: 0 0 var(--s-1); }
.client-head__dates { list-style: none; margin: 0; padding: 0; }
.client-head__dates li { display: flex; gap: var(--s-2); padding: 2px 0; }
.client-head__dates time { flex: 0 0 auto; min-width: 7.5em; font-weight: 600; }
.client-head__item { color: var(--c-text); overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .client-head { grid-template-columns: minmax(0, 1fr); padding: var(--s-3); }
  .client-head__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Round 6: audit log as stacked cards on phones ---------- */
.data-table--audit tbody th { font-weight: 600; }
.data-table--audit .compact-label { display: none; }
@media (max-width: 767px) {
  .table-scroll:has(> .data-table--audit) { overflow: visible; border: 0; background: transparent; max-height: none; }
  .data-table--audit thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table--audit, .data-table--audit tbody { display: block; width: 100%; }
  .data-table--audit tbody tr { display: flex; flex-wrap: wrap; gap: 2px var(--s-2); margin: 0 0 var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
  .data-table--audit tbody th, .data-table--audit tbody td { display: block; height: auto; min-height: 0; padding: 0; border: 0 !important; background: transparent !important; white-space: normal; text-align: left; line-height: 1.4; }
  .data-table--audit tbody th { flex: 1 0 100%; font-size: var(--text-base); }
  .data-table--audit tbody td.compact-order-1, .data-table--audit tbody td.compact-order-2 { font-size: var(--text-sm); color: var(--c-muted); }
  .data-table--audit .compact-label { display: inline; }
  .data-table--audit tbody td.compact-order-3, .data-table--audit tbody td.compact-order-4 { flex: 1 0 100%; font-size: var(--text-sm); overflow-wrap: anywhere; }
}

/* ---------- Round 6: opportunities as compact tap-through cards on phones ---------- */
.opp-table tbody th .opp-co-sub { display: none; }
.opp-title .opp-card-link { color: inherit; }
@media (max-width: 767px) {
  .opp-table tbody tr { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px var(--s-2); margin: 0 0 var(--s-2); padding: var(--s-2) var(--s-3); }
  .opp-table tbody th.opp-title { grid-column: 1 / -1; display: block; padding: 0; margin: 0; border: 0 !important; font-size: var(--text-base); }
  .opp-table tbody th.opp-title .opp-co-sub { display: block; font-weight: 400; }
  .opp-table tbody th.opp-title::before { content: none; display: none; }
  .opp-table .opp-card-link { text-decoration: none; font-weight: 600; }
  .opp-table .opp-card-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-lg); }
  .opp-table .opp-card-link:focus-visible::after { outline: 2px solid var(--c-focus); outline-offset: -2px; }
  .opp-table td.opp-company, .opp-table td.opp-type, .opp-table td.opp-owner { display: none; }
  .opp-table td.opp-stage, .opp-table td.opp-value, .opp-table td.opp-next { padding: 0; }
  .opp-table td.opp-stage::before, .opp-table td.opp-value::before, .opp-table td.opp-next::before { content: none; }
  .opp-table td.opp-stage { justify-content: flex-start; }
  .opp-table td.opp-stage .inline-form, .opp-table td.opp-stage .stage-hint, .opp-table td.opp-stage .opp-stage-text { display: none; }
  .opp-table .opp-stage-pill { display: inline-flex; }
  .opp-table td.opp-value { justify-content: flex-end; font-weight: 600; }
  .opp-table td.opp-next { grid-column: 1 / -1; display: block; min-width: 0; text-align: left; font-size: var(--text-sm); }
  .opp-table td.opp-next .opp-next__what { display: inline; }
  .opp-table td.opp-next .cell-sub { display: inline; margin-left: var(--s-1); }
  .opp-table td.opp-next .cell-sub::before { content: "· "; }
  .opp-table td.opp-next .cell-sub.is-overdue { color: var(--c-danger); font-weight: 600; }
}

/* ---------- Round 7: Today when-first lines, folded sections, target dates ---------- */
.today-due { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.today-due--late { color: var(--c-danger); }
.today-due--target, .reason--target { color: var(--c-warn); }
.reason--t3.reason--target { font-weight: 600; }
.count--warn { color: var(--c-warn); }
.today-jump__link--warn { border-color: var(--c-warn); color: var(--c-warn); }
.today-fold > summary { list-style: none; cursor: pointer; }
.today-fold > summary::-webkit-details-marker { display: none; }
.today-fold > summary .panel__title::after { content: ""; display: inline-block; width: 0.45em; height: 0.45em; margin-left: var(--s-2); border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-0.2em); opacity: 0.6; }
.today-fold[open] > summary .panel__title::after { transform: rotate(-135deg) translateY(-0.05em); }
.today-fold:not([open]) > summary { border-bottom: 0; }
.do-first__item.is-form485 .do-first__n { background: var(--c-danger); }
@media (max-width: 767px) {
  /* when first, then what, then company and the one action; lines wrap, nothing is cut */
  .today-list td.today-why { grid-row: 1; }
  .today-list tbody th.today-task { grid-row: 2; }
  .today-list td.today-co, .today-list td.col-actions { grid-row: 3; }
  .today-list tbody th.today-task .cell-link, .do-first__what > .cell-link { white-space: normal; overflow: visible; text-overflow: clip; }
  .today-list td.today-why, .do-first__what .today-why { display: block; }
  .today-why .reason { white-space: normal; overflow: visible; }
  .today-list td.today-co, .do-first__what .today-co { white-space: normal; overflow: visible; text-overflow: clip; }
  /* round 9: a Do first card reads number and title first, then the red sentence */
  .do-first__what > .cell-link { grid-column: 2 / -1; grid-row: 1; font-weight: 600; }
  .do-first__what .today-why { grid-column: 2 / -1; grid-row: 2; }
  .do-first__n { grid-row: 1; }
  .do-first__what .today-co { grid-row: 3; }
  .do-first__act { grid-row: 3; }
  .today-why .badge { white-space: normal; }
}
.banner--danger { border-color: var(--c-danger); background: var(--b-danger-bg); color: var(--b-danger-fg); }
.banner__list { margin: var(--s-1) 0 0; padding-left: 1.2em; flex-basis: 100%; }
.banner__list a { color: inherit; font-weight: 600; }
.banner--danger p, .banner--danger li { color: inherit; }
.field--choice { border: 0; margin: 0; padding: 0; min-width: 0; background: none; display: block; }
.field--choice .choice { display: flex; gap: var(--s-2); align-items: flex-start; font-size: var(--text-sm); margin-top: var(--s-1); }
.field--choice .choice input { margin-top: 0.2em; flex: none; }
/* ---------- Round 7: dashboard hero line and one trend chip ---------- */
.hero { margin: 0 0 var(--s-5); padding: var(--s-3) var(--s-4); border: 1px solid var(--c-border); border-left-width: 6px; border-radius: var(--r-lg); background: var(--c-surface); }
.hero--bad { border-left-color: var(--c-danger); }
.hero--warn { border-left-color: var(--c-warn); }
.hero--good { border-left-color: var(--c-success); }
.hero__line { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-2); font-size: var(--text-lg, 1.125rem); }
.hero__fig { color: inherit; text-decoration: none; }
.hero__fig:hover { text-decoration: underline; }
.hero__fig strong { font-size: var(--text-xl); font-variant-numeric: tabular-nums; }
.hero--bad .hero__fig:first-child strong { color: var(--c-danger); }
.hero__sub { font-size: var(--text-sm); color: var(--c-muted); }
.hero__sep { color: var(--c-muted); }
.hero__act { align-self: center; }
.trend-chip { display: inline-flex; align-items: baseline; gap: .25em; padding: .1em .55em; border-radius: 999px; font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.trend-chip--bad { color: var(--b-danger-fg); background: var(--b-danger-bg); }
.trend-chip--good { color: var(--b-success-fg); background: var(--b-success-bg); }
.trend-chip--neutral { color: var(--c-muted); background: var(--c-surface-2, rgba(0,0,0,.05)); }
.health__type a { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); }
.health__type--good .health__dot { background: var(--c-success); }
.health__type--warn .health__dot { background: var(--c-warn); }
.health__type--bad .health__dot { background: var(--c-danger); }
.health__type { display: inline-flex; align-items: center; gap: var(--s-1); }
.health__exposure { font-size: var(--text-sm); color: var(--c-muted); }
.facts-more { margin: var(--s-4) 0 0; }
.facts-more > summary { list-style: none; cursor: pointer; }
.facts-more > summary::-webkit-details-marker { display: none; }
.facts-more .facts { margin-top: var(--s-2); }
@media (max-width: 767px) {
  /* Solvency cards: label and value side by side (two columns inside the card),
     never pushed to opposite edges of the phone */
  .data-table--compact td.compact-order-3, .data-table--compact td.compact-order-4 { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); justify-content: start; justify-items: start; align-items: center; text-align: left; }
  .data-table--compact td.compact-order-3 .compact-label, .data-table--compact td.compact-order-4 .compact-label { grid-column: 1; }
  .data-table--compact td.compact-order-3 > :not(.compact-label), .data-table--compact td.compact-order-4 > :not(.compact-label) { grid-column: 2; }
  .data-table--compact td.compact-order-1 .badge[data-flag] { margin-top: 2px; }
}
@media (max-width: 767px) {
  /* label/value cards: two compact columns (label, then its value beside it) */
  .data-table--kv tbody td { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); justify-content: start; justify-items: start; gap: var(--s-2); text-align: left; padding-top: 2px; padding-bottom: 2px; }
  .data-table--kv tbody td.num { text-align: left; }
  .data-table--kv [data-label]::before { grid-column: 1; }
}

/* Round 7: long solvency badges (exemption sentence) wrap inside the owner panel */
[data-solvency-state] .badge { white-space: normal; max-width: 100%; }
@media (max-width: 767px) {
  /* Solvency cards: the due date gets the same label column as Stage and Owner */
  .data-table--compact td.compact-order-2:has(> .compact-label) { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); justify-items: start; align-items: center; text-align: left; flex-basis: 100%; }
  .data-table--compact td.compact-order-2 > .compact-label { grid-column: 1; }
}

/* Round 7: a growth next action past its target date is amber, never breach red
   (it is the firm's own target, not a statutory deadline) */
.cell-sub.is-target, .page-sub .is-target, .opp-table td.opp-next .cell-sub.is-target { color: var(--c-warn); font-weight: 600; }
@media (min-width: 768px) { .opp-table tr.is-target > th { box-shadow: inset 3px 0 0 var(--c-fill-warn); } }
.data-table--cards tr.is-target { border-left: 3px solid var(--c-fill-warn); }
@media (max-width: 599px) {
  /* Hero on a phone: one fact per line, no dangling separators */
  .hero__sep { display: none; }
  .hero__sub { flex-basis: 100%; }
}
/* UX round 8: liability events (negative solvency resolution, prohibited risk with our
   director in place) lead Today as their own red rows. */
.do-first__item.is-liability { border-left: 4px solid var(--c-danger); background: color-mix(in srgb, var(--c-danger) 6%, transparent); }
.do-first__item.is-liability .do-first__n { background: var(--c-danger); }
.data-table tr.is-liability > th .cell-link { color: var(--c-danger); }
/* Opportunities: the stage changes through an explicit "Change stage" step. */
.stage-change { display: block; position: relative; z-index: 2; margin-top: var(--s-1); }
.stage-change > summary { list-style: none; cursor: pointer; }
.stage-change > summary::-webkit-details-marker { display: none; }
.stage-change__form { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); margin-top: var(--s-2); padding: var(--s-3); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius, 8px); }
/* Solvency list notes: plain, neutral sentences (s347B, s347C) beside one state chip */
.solv-notes { font-size: var(--text-sm); min-width: 14rem; }
.solv-next { max-width: 15rem; }
.solv-next .cell-sub { white-space: normal; }
@media (max-width: 767px) { .solv-notes { min-width: 0; } .solv-next { max-width: none; } }
.solv-note { display: block; color: var(--c-text-muted, var(--c-muted)); }
/* round 9: compact Notes (a Form 485 chip and an s347C icon) */
.solv-notes { white-space: nowrap; }
.solv-chip { text-decoration: none; white-space: nowrap; }
.solv-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; margin-left: var(--s-1); border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--c-muted); color: var(--c-muted); font-size: var(--text-2xs); font-weight: 700; text-decoration: none; vertical-align: middle; }
.solv-icon:hover, .solv-icon:focus-visible { color: var(--c-text); box-shadow: inset 0 0 0 1.5px var(--c-text); }
/* Phones: a two-line card. Line 1: tick, company, state chip (which already says
   how late or how soon). Line 2: notes, owner and the next-step button (the
   workings stage is its title). The full due date is on desktop and the company. */
@media (max-width: 599px) {
  .data-table--solvency tbody tr { gap: 6px var(--s-2); padding: var(--s-2) var(--s-3); margin: 0 0 var(--s-1); }
  .data-table--solvency tbody th { flex: 1 1 0; min-width: 0; font-size: var(--text-base); }
  /* Round 10: the company name wraps (two lines on a 390px phone for the longest
     seeded names), never an ellipsis. */
  .data-table--solvency tbody th .cell-link { display: block; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .data-table--solvency td.compact-order-1 { order: 0; flex: 0 0 auto; }
  .data-table--solvency td.compact-order-1 .cell-sub { display: none; }
  .data-table--solvency td.compact-order-2 { display: none !important; }
  .data-table--solvency tbody tr::after { content: none; }  /* the full-width owner line breaks the card now */
  .data-table--solvency td.compact-order-4, .data-table--solvency td.compact-order-5,
  .data-table--solvency td.compact-order-3 { display: inline-flex !important; flex: 0 1 auto !important; flex-basis: auto !important; grid-template-columns: none; align-items: center; font-size: var(--text-xs); }
  .data-table--solvency td.compact-order-5 { order: 2; }
  .data-table--solvency td.compact-order-5 .badge { font-size: var(--text-xs); padding-inline: 6px; }
  .data-table--solvency .solv-yr { display: none; }
  .data-table--solvency .solv-icon { margin-left: 4px; width: 1.125rem; height: 1.125rem; }
  .data-table--solvency td.compact-order-5:has(.solv-none) { display: none !important; }
  /* Round 10: the owner has a line of its own, in full (no ellipsis). */
  .data-table--solvency td.compact-order-4 { order: 1; flex: 0 0 100% !important; min-width: 0; display: block !important; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; color: var(--c-muted); }
  .data-table--solvency td.compact-order-4 .solv-owner__label { display: inline; }
  .data-table--solvency td.compact-order-5 { flex: 0 0 auto !important; }
  .data-table--solvency td.compact-order-3 { flex: 0 0 auto !important; }
  .data-table--solvency td.compact-order-3 { order: 4; margin-left: auto; }
  .data-table--solvency td.compact-order-3 .cell-sub { display: none; }
  .data-table--solvency td.compact-order-3 .btn { min-height: 1.75rem; padding: 0 var(--s-2); font-size: var(--text-xs); }
}

.solv-owner__label { display: none; }
.bulk-bar__type { font-weight: 400; color: var(--c-muted); }
.bulk-bar__type-note a { font-weight: 600; }
.moved-note { margin-top: var(--s-2); }
.solv-note a { color: inherit; }
.solv-note--bad, .solv-note--bad a { color: var(--c-danger); font-weight: 600; }
.toolbar--inline { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-3); }
/* Bulk bars appear only once a row is ticked; on phones they sit at the bottom and
   the page gains room below its content, so the bar never covers the last rows. */
@supports selector(:has(*)) {
  body:has(.row-check:checked) .main { padding-bottom: 9rem; }
}
@media (max-width: 599px) {
  .bulk-bar { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; max-height: 45vh; overflow-y: auto; padding-bottom: calc(var(--s-2) + env(safe-area-inset-bottom, 0px)); }
  @supports selector(:has(*)) {
    body:has(.row-check:checked) .main { padding-bottom: calc(45vh + var(--s-4)); }
  }
}
.week-list li:has(.week-list__kinds) { flex-wrap: wrap; }
.week-list__kinds { display: block; flex: 1 0 100%; font-size: var(--text-sm); color: var(--c-muted); }
sup.moved { color: var(--c-muted); cursor: help; margin-left: 1px; }
.page-sub a[data-audit-toggle] { color: var(--c-link, var(--c-primary)); text-decoration: underline; text-underline-offset: 2px; }
.cell-sub[data-moved] { white-space: normal; }
#deadlines .data-table th .cell-sub { white-space: normal; overflow: visible; text-overflow: clip; }
#deadlines .data-table td.date, #deadlines .data-table td[data-label="When"] { white-space: nowrap; }
.cell-nil[data-review="none"] { white-space: normal; }
@media (max-width: 767px) {
  #deadlines .data-table--cards tbody th { flex-wrap: wrap; }
  #deadlines .data-table--cards tbody th .cell-sub { flex: 1 0 100%; text-align: left; }
  #deadlines .data-table--cards td sup.moved { display: none; }
}

/* Round 10: per-director 12-week overdue trend on Directors */
.dir-trend { white-space: nowrap; }
.dir-trend__in { display: flex; align-items: center; gap: var(--s-2); }
.dir-trend .spark--mini { display: inline-block; }
.dir-trend__text { font-variant-numeric: tabular-nums; }
@media (max-width: 599px) { .dir-trend .spark--mini { display: none; } }

/* Round 10: dashboard strict-liability panel (counts only) */
.strict__lead { margin: 0 0 var(--s-3); }
.strict__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.strict__row { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); align-items: baseline; }
.strict__row--bad > a strong { color: var(--c-danger); }
.strict__meta { color: var(--c-muted); font-size: var(--text-sm); }
.strict .panel__note { margin-top: var(--s-3); }

/* ---- Round 11: Companies list fits 1440 px (no clipped columns) ---- */
.data-table th.col-name { max-width: 17rem; }
.data-table th.col-name .cell-sub { font-size: 0.6875rem; max-width: 17rem; }
.data-table .col-risk-rating .cell-sub--short { font-size: 0.6875rem; white-space: nowrap; }
.data-table .col-director-name, .data-table .col-owner-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table td.col-overdue { text-align: right; }
.cell-overdue { color: var(--c-danger); font-weight: 700; text-decoration: none; }
.cell-overdue:hover { text-decoration: underline; }
/* Round 11: one pagination style (ui.pager) everywhere, with the per-page choice on Companies */
.pager__per-page { margin: 0; display: flex; align-items: center; gap: var(--s-2); }
.pager__pp { padding: 0.125rem 0.5rem; border-radius: var(--r-md, 6px); }
.pager__pp.is-current { background: var(--c-primary); color: var(--c-on-primary); font-weight: 600; }
/* Round 11: Deadlines filters fold behind a Filters button on phones */
.filters-fold > summary { display: none; }
@media (max-width: 767px) {
  .filters-fold > summary { display: inline-flex; list-style: none; margin-bottom: var(--s-2); }
  .filters-fold > summary::-webkit-details-marker { display: none; }
  .filters-fold[open] > summary { margin-bottom: var(--s-3); }
}
/* Round 11: tighter phone cards (Companies, Directors, Work queue) */
@media (max-width: 767px) {
  .data-table--cards tr { padding: var(--s-1) var(--s-3); margin-bottom: var(--s-2); }
  .data-table--cards tbody th, .data-table--cards tbody td { padding: 2px 0; }
  .data-table--cards tbody th { padding-bottom: var(--s-1); }
  .data-table--cards .util { min-width: 0; flex: 1 1 auto; justify-content: flex-end; }
  .data-table--cards td.dir-trend .dir-trend__in { flex-wrap: wrap; justify-content: flex-end; }
}
/* Round 11: work queue triage table */
.work-table th[scope=row] .badge { margin-right: var(--s-2); }
.work-table .work-item { font-weight: 500; }
.work-filter { margin-bottom: var(--s-2); }
@media (max-width: 767px) {
  .work-table tbody th[scope=row] { flex-wrap: wrap; gap: var(--s-1); }
  .work-table .work-item { flex: 1 0 100%; }
}

/* Round 11: negative resolution checklist inside the danger banner */
.negative-checklist { flex-basis: 100%; }
.negative-checklist > summary { cursor: pointer; font-weight: 600; }
.negative-checklist .banner__list { list-style: decimal; }
.negative-checklist li + li { margin-top: var(--s-1); }

/* Round 11: strict-liability exposure by resident director (dashboard) */
.strict__sub { margin: var(--s-4) 0 var(--s-2); font-size: var(--fs-sm, 0.875rem); font-weight: 600; }
.strict__directors { width: 100%; }
.strict__directors th, .strict__directors td { padding: var(--s-1) var(--s-2); }
.bar-list--util .badge { margin-left: var(--s-1); font-size: 0.75em; vertical-align: middle; }

/* Round 11: the s347C note is a labelled pill, not a bare "C" */
.solv-icon, .data-table--solvency .solv-icon { width: auto; height: auto; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
.solv-icon--check { border-style: dashed; }

/* Round 11: rows the bulk bar cannot select say why (title and screen-reader text) */
.check-why { display: inline-block; width: 1rem; text-align: center; color: var(--c-muted); cursor: help; }

/* Round 11: Today task names are never cut off; they wrap at every width. */
.today-list tbody th.today-task .cell-link,
.do-first__what > .cell-link { display: block; overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }

/* Round 11: health pills line up in equal columns */
@media (min-width: 600px) {
  .health__types { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: var(--s-2); }
  .health__type { display: flex; }
  .health__type a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .35em; width: 100%; }
}

/* Round 11: Companies fits 1200 to 1679 px with every column in view (ACN shows from 1680 px) */
@media (min-width: 768px) and (max-width: 1679px) {
  .data-table--companies th, .data-table--companies td { padding-left: 0.375rem; padding-right: 0.375rem; }
  .data-table--companies th.col-name, .data-table--companies th.col-name .cell-sub { max-width: 15rem; }
  .data-table--companies thead th { white-space: normal; line-height: 1.2; }
}
@media (min-width: 768px) and (max-width: 1679px) {
  .data-table--companies th.col-name, .data-table--companies th.col-name .cell-sub { max-width: 14rem; }
  .data-table--companies .col-director-name { max-width: 8.5rem; }
}

/* Round 11: Directors fits 1440 px: headers wrap, number columns stay narrow */
@media (min-width: 768px) {
  .data-table--directors thead th { white-space: normal; line-height: 1.2; vertical-align: bottom; }
  .data-table--directors th, .data-table--directors td { padding-left: 0.5rem; padding-right: 0.5rem; }
}

/* Round 11: company Deadlines actions stack (date over button) so nothing is cut off */
@media (min-width: 768px) {
  .data-table--co-deadlines td.col-actions { white-space: normal; width: 12rem; }
  .data-table--co-deadlines .inline-form { display: flex; flex-direction: column; align-items: stretch; gap: var(--s-1); }
  .data-table--co-deadlines .inline-form .btn { white-space: normal; line-height: 1.2; text-align: center; height: auto; min-height: 2rem; }
  .data-table--co-deadlines th, .data-table--co-deadlines td { padding-left: 0.5rem; padding-right: 0.5rem; }
}
.strict__directors { table-layout: fixed; }
.strict__directors thead th { white-space: normal; line-height: 1.2; vertical-align: bottom; }
.strict__directors th:first-child { width: 50%; }
.strict__directors tbody th .cell-link { white-space: normal; }
.operators__imbalance { white-space: normal; }
@media (max-width: 599px) { .strict__directors th, .strict__directors td { font-size: var(--text-sm); } }
.data-table.strict__directors thead th, .data-table.strict__directors td, .data-table.strict__directors tbody th { white-space: normal; overflow-wrap: anywhere; height: auto; }
@media (max-width: 599px) {
  .data-table.operators__table th, .data-table.operators__table td { white-space: normal; padding-left: 0.375rem; padding-right: 0.375rem; font-size: var(--text-sm); }
}
/* Round 11 (after screenshots): health cards, not wrapped pills */
@media (min-width: 600px) {
  .health__types { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .health__type { flex-direction: column; align-items: flex-start; gap: var(--s-1); }
  .health__type a { display: block; border-radius: var(--r-lg, 10px); padding: .5em .8em; }
}
