/* NJS case review: shared stylesheet (ADR-0013, look and feel per ADR-0031 and docs/DESIGN.md).
   Reference: Apple Human Interface Guidelines (typography, colour, layout, accessibility), read 11 Oct 2026.
   Order: tokens (light, dark, increased contrast) → base → app shell → page furniture → components → page-specific → print.
   Mobile first: the sidebar becomes a top bar plus a bottom tab bar under 880px; tables marked .stack become
   grouped rows under 760px. No external resources (CSP font-src/img-src 'self'); no inline styles anywhere. */

/* ========== 1. Tokens ========== */
:root {
  color-scheme: light dark;

  /* Type: system font stack (SF Pro on Apple devices, Segoe UI on Windows, Roboto on Android). Nothing is downloaded. */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Type scale: Apple text styles, iOS "Large (default)" Dynamic Type step (size / line height, px at 100% zoom).
     rem so a reader's browser text size scales everything, as Dynamic Type does. Desktop steps down to "Small" (below). */
  --fs-large-title: 2.125rem;  --lh-large-title: 2.5625rem;  /* 34/41 */
  --fs-title1: 1.75rem;        --lh-title1: 2.125rem;        /* 28/34 */
  --fs-title2: 1.375rem;       --lh-title2: 1.75rem;         /* 22/28 */
  --fs-title3: 1.25rem;        --lh-title3: 1.5625rem;       /* 20/25 */
  --fs-headline: 1.0625rem;    --lh-headline: 1.375rem;      /* 17/22 semibold */
  --fs-body: 1.0625rem;        --lh-body: 1.375rem;          /* 17/22 */
  --fs-callout: 1rem;          --lh-callout: 1.3125rem;      /* 16/21 */
  --fs-subhead: .9375rem;      --lh-subhead: 1.25rem;        /* 15/20 */
  --fs-footnote: .8125rem;     --lh-footnote: 1.125rem;      /* 13/18 */
  --fs-caption1: .75rem;       --lh-caption1: 1rem;          /* 12/16 */
  --fs-caption2: .6875rem;     --lh-caption2: .8125rem;      /* 11/13: the floor; nothing smaller */

  /* Spacing: 8-pt grid with 4-pt half steps. */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* Shape. Cards 12px (14px desktop), controls 10px, capsules for buttons and pills. */
  --r-card: 12px; --r-control: 10px; --r-small: 6px; --r-capsule: 999px;
  --hit: 44px;           /* minimum touch target (HIG iOS 44x44 pt) */
  --hit-fine: 32px;      /* pointer devices: above HIG macOS 28 pt and WCAG 2.2 24 px */
  --sidebar: 248px;
  --hairline: 1px;

  /* Colour: semantic roles, Apple system values (HIG Color specifications, June 2025 values).
     Text colours that sit on tints use the "increased contrast" variants, darkened where needed for 4.5:1. */
  --bg: #f2f2f7;                 /* systemGroupedBackground */
  --surface: #ffffff;            /* secondarySystemGroupedBackground: cards */
  --surface-2: #f2f2f7;          /* tertiary: insets inside a card */
  --sidebar-bg: #e9e9ee;
  --bar-bg: rgba(249, 249, 251, .82); /* top and tab bars (translucent "regular" material) */
  --label: #1d1d1f;              /* label: 16.8:1 on white */
  --label-2: #6e6e73;            /* secondaryLabel (opaque): 5.1:1 on white, 4.5:1 on --bg */
  --label-3: #8e8e93;            /* tertiaryLabel: placeholders and decoration only, never essential text */
  --separator: #d1d1d6;          /* hairlines between rows */
  --control-border: #8e8e93;     /* input outlines: 3.3:1, WCAG 1.4.11 */
  --fill: rgba(118, 118, 128, .12);   /* tertiarySystemFill: hover, code, inset rows */
  --fill-2: rgba(118, 118, 128, .2);  /* systemFill: pressed, progress track */
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --shadow-raised: 0 8px 28px rgba(0, 0, 0, .14);

  /* Accent: Apple indigo (increased-contrast variant), continuous with the earlier NJS violet. White on it 6.1:1. */
  --accent: #564ade;
  --accent-hover: #4a3fcf;
  --accent-text: #564ade;        /* links and tinted-button labels */
  --accent-tint: #ecebfe;        /* 12% accent: selected nav, tinted buttons, notices */
  --on-accent: #ffffff;
  --focus: #564ade;

  /* Status: fill (dots, bars), text (labels, values), tint (pill backgrounds). */
  --green: #34c759;  --green-text: #007b2d;  --green-tint: #e7f8eb;
  --orange: #ff8d28; --orange-text: #b14b00; --orange-tint: #fff1e5;
  --red: #ff383c;    --red-text: #cd1228;    --red-tint: #ffe7e8;
  --blue: #0088ff;   --blue-text: #1a61d7;   --blue-tint: #e0f1ff;
  --gray: #8e8e93;   --gray-text: #68686c;   --gray-tint: #ececf0;
  --yellow-tint: #fff8d6;

  /* The status vocabulary (ADR-0013) mapped to system colours. */
  --done: var(--green);   --done-text: var(--green-text);   --done-tint: var(--green-tint);
  --working: var(--orange); --working-text: var(--orange-text); --working-tint: var(--orange-tint);
  --queued: var(--blue);  --queued-text: var(--blue-text);  --queued-tint: var(--blue-tint);
  --stuck: var(--red);    --stuck-text: var(--red-text);    --stuck-tint: var(--red-tint);
  --none: var(--gray);    --none-text: var(--gray-text);    --none-tint: var(--gray-tint);

  --ease: cubic-bezier(.25, .1, .25, 1);
  --dur: .2s;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;               /* systemGroupedBackground (dark, base) */
    --surface: #1c1c1e;          /* secondarySystemGroupedBackground */
    --surface-2: #2c2c2e;        /* tertiary */
    --sidebar-bg: #161618;
    --bar-bg: rgba(22, 22, 24, .82);
    --label: #f5f5f7;            /* 15.6:1 on #1c1c1e */
    --label-2: #98989d;          /* 5.9:1 on #1c1c1e */
    --label-3: #636366;
    --separator: #38383a;
    --control-border: #7c7c80;
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .36);
    --shadow: none;
    --shadow-raised: 0 8px 28px rgba(0, 0, 0, .6);

    --accent: #5e5ce6;           /* white on it 5.1:1 */
    --accent-hover: #6d6bf0;
    --accent-text: #a7aaff;      /* 8:1 on #1c1c1e */
    --accent-tint: rgba(109, 124, 255, .2);
    --focus: #a7aaff;

    --green: #30d158;  --green-text: #4ad968;  --green-tint: rgba(48, 209, 88, .18);
    --orange: #ff9230; --orange-text: #ffa056; --orange-tint: rgba(255, 146, 48, .18);
    --red: #ff4245;    --red-text: #ff7a7d;    --red-tint: rgba(255, 66, 69, .18);
    --blue: #0091ff;   --blue-text: #5cb8ff;   --blue-tint: rgba(0, 145, 255, .18);
    --gray: #8e8e93;   --gray-text: #aeaeb2;   --gray-tint: rgba(142, 142, 147, .2);
    --yellow-tint: rgba(255, 214, 0, .14);
  }
}

/* Increase Contrast: stronger separators and secondary text (HIG: supply an increased-contrast variant). */
@media (prefers-contrast: more) {
  :root { --label-2: #3a3a3c; --separator: #8e8e93; --control-border: #3a3a3c; --fill: rgba(118, 118, 128, .2); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --label-2: #d1d1d6; --separator: #8e8e93; --control-border: #d1d1d6; }
}

/* Laptop and desktop: Apple's "Small" Dynamic Type step (body 15/20) suits dense tables on a pointer device. */
@media (min-width: 880px) {
  :root {
    --fs-large-title: 2rem;  --lh-large-title: 2.4375rem;  /* 32/39 */
    --fs-title1: 1.625rem;   --lh-title1: 2rem;            /* 26/32 */
    --fs-title2: 1.25rem;    --lh-title2: 1.5625rem;       /* 20/25 */
    --fs-title3: 1.125rem;   --lh-title3: 1.4375rem;       /* 18/23 */
    --fs-headline: .9375rem; --lh-headline: 1.25rem;       /* 15/20 */
    --fs-body: .9375rem;     --lh-body: 1.25rem;           /* 15/20 */
    --fs-callout: .875rem;   --lh-callout: 1.1875rem;      /* 14/19 */
    --fs-subhead: .8125rem;  --lh-subhead: 1.125rem;       /* 13/18 */
    --fs-footnote: .75rem;   --lh-footnote: 1rem;          /* 12/16 */
    --fs-caption1: .6875rem; --lh-caption1: .8125rem;      /* 11/13 */
    --r-card: 14px;
  }
}

/* ========== 2. Base ========== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-body); line-height: var(--lh-body); color: var(--label);
  background: var(--bg); -webkit-font-smoothing: antialiased; font-optical-sizing: auto; font-kerning: normal;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); color: var(--label); }
h1 { font-size: var(--fs-title2); line-height: var(--lh-title2); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: 600; }
h3 { font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: 600; }
@media (min-width: 880px) { h1 { font-size: var(--fs-title1); line-height: var(--lh-title1); letter-spacing: -.015em; } }
p { margin: var(--s-2) 0; }
code, pre, kbd { font-family: var(--font-mono); }
code { font-size: .85em; background: var(--fill); padding: .1em .35em; border-radius: 4px; }
strong, b { font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-tint); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: var(--hairline) solid var(--separator); margin: var(--s-4) 0; }

.skip { position: absolute; left: var(--s-2); top: -100px; z-index: 50; background: var(--surface); color: var(--accent-text); padding: var(--s-2) var(--s-4); border-radius: var(--r-control); box-shadow: var(--shadow-raised); }
.skip:focus { top: var(--s-2); }

/* ========== 3. App shell ========== */
.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 600; color: var(--label); min-height: var(--hit); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--on-accent); font-size: .8125rem; font-weight: 700; }
.brand small { display: block; font-weight: 400; color: var(--label-2); font-size: var(--fs-caption1); line-height: var(--lh-caption1); }
.navicon { width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Phone: translucent top bar (brand + account sheet) and bottom tab bar. */
.topbar {
  display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); min-height: 52px;
  padding-top: env(safe-area-inset-top);
  background: var(--bar-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: var(--hairline) solid var(--separator); position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-size: var(--fs-headline); }
.sidebar { display: none; }
.main { padding: var(--s-4); padding-bottom: calc(var(--s-6) + 64px + env(safe-area-inset-bottom)); max-width: 1240px; width: 100%; margin: 0 auto; min-width: 0; }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 20;
  background: var(--bar-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: var(--hairline) solid var(--separator); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1 1 0; min-width: 0; min-height: 50px; display: grid; justify-items: center; align-content: start; gap: 2px;
  padding: 6px 0 4px; font-size: var(--fs-caption2); line-height: var(--lh-caption2); font-weight: 500; color: var(--label-2); text-align: center;
}
.bottomnav a span { overflow-wrap: normal; word-break: keep-all; letter-spacing: -.01em; }
.bottomnav a:hover { text-decoration: none; }
.bottomnav a.active { color: var(--accent-text); font-weight: 600; }
.bottomnav .navicon { width: 24px; height: 24px; }
/* "More" tab: a <details> sheet (no JavaScript needed) that opens above the bar. At most five tabs, so nothing scrolls out of sight. */
.bottomnav details.more { flex: 1 1 0; min-width: 0; position: static; }
.bottomnav details.more > summary {
  list-style: none; cursor: pointer; min-height: 50px; display: grid; justify-items: center; align-content: start; gap: 2px;
  padding: 6px 0 4px; font-size: var(--fs-caption2); line-height: var(--lh-caption2); font-weight: 500; color: var(--label-2); text-align: center;
}
.bottomnav details.more > summary::-webkit-details-marker { display: none; }
.bottomnav details.more.active > summary, .bottomnav details.more[open] > summary { color: var(--accent-text); font-weight: 600; }
.bottomnav details.more .sheet {
  position: absolute; right: var(--s-2); bottom: calc(100% + var(--s-2)); width: min(300px, calc(100vw - 2 * var(--s-2)));
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-raised); padding: var(--s-2); display: grid;
  border: var(--hairline) solid var(--separator);
}
.bottomnav details.more .sheet a { flex: none; display: flex; align-items: center; gap: var(--s-3); min-height: var(--hit); padding: 0 var(--s-3); border-radius: var(--r-control); color: var(--label); font-size: var(--fs-body); font-weight: 400; }
.bottomnav details.more .sheet a.active { color: var(--accent-text); font-weight: 600; background: var(--accent-tint); }
.bottomnav details.more .sheet a .navicon { width: 22px; height: 22px; }
.sheethead { padding: var(--s-2) var(--s-3) 0; font-size: var(--fs-caption1); font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 479px) { .topbar .brand span:last-child { display: none; } }

.userchip { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-2); min-width: 0; }
.avatar { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: var(--accent-tint); color: var(--accent-text); display: grid; place-items: center; font-weight: 600; font-size: var(--fs-footnote); }
.env-badge { font-size: var(--fs-caption2); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; background: var(--orange-tint); color: var(--orange-text); border-radius: var(--r-small); padding: 2px 6px; }

/* Account sheet in the phone top bar (<details>: works without JavaScript). */
.account { margin-left: auto; position: relative; }
.account > summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: var(--hit); height: var(--hit); border-radius: 50%; }
.account > summary::-webkit-details-marker { display: none; }
.account[open] > summary .avatar { background: var(--accent); color: var(--on-accent); }
.account .sheet {
  position: absolute; right: 0; top: calc(100% + var(--s-1)); width: min(320px, calc(100vw - 2 * var(--s-4)));
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-raised); padding: var(--s-2); display: grid; z-index: 30;
  border: var(--hairline) solid var(--separator);
}
.account .sheet .who { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: var(--hairline) solid var(--separator); margin-bottom: var(--s-1); overflow-wrap: anywhere; }
.account .sheet .who strong { display: block; font-size: var(--fs-subhead); color: var(--label); }
.account .sheet .who .note { display: block; }
.account .sheet a { display: flex; align-items: center; gap: var(--s-3); min-height: var(--hit); padding: 0 var(--s-3); border-radius: var(--r-control); color: var(--label); }
.account .sheet a:hover { background: var(--fill); text-decoration: none; }
.account .sheet a.destructive { color: var(--red-text); }

@media (min-width: 880px) {
  /* The sidebar column is painted by the grid background so it runs the full page height. */
  .app {
    grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: 1fr;
    background: linear-gradient(to right, var(--sidebar-bg) calc(var(--sidebar) - 1px), var(--separator) calc(var(--sidebar) - 1px), var(--separator) var(--sidebar), transparent var(--sidebar));
  }
  .topbar, .bottomnav { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: 2px; padding: var(--s-4) var(--s-3); position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; }
  .sidebar .brand { padding: 0 var(--s-2) var(--s-4); align-items: flex-start; font-size: var(--fs-headline); line-height: var(--lh-headline); }
  .sidebar a.navlink {
    display: flex; align-items: center; gap: var(--s-3); min-height: 36px; padding: 0 var(--s-3); border-radius: var(--r-control);
    color: var(--label); font-weight: 500; font-size: var(--fs-body);
  }
  .sidebar a.navlink .navicon { width: 20px; height: 20px; color: var(--accent-text); }
  .sidebar a.navlink:hover { background: var(--fill); text-decoration: none; }
  .sidebar a.navlink.active { background: var(--accent-tint); color: var(--accent-text); font-weight: 600; }
  .sidebar .spacer { flex: 1; }
  .sidebar .navgroup { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s-4); }
  .sidebar .navhead { padding: 0 var(--s-3) var(--s-1); font-size: var(--fs-caption1); line-height: var(--lh-caption1); font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; }
  .sidebar .userchip { margin: 0 0 var(--s-1); padding: var(--s-3) var(--s-2) var(--s-2); border-top: var(--hairline) solid var(--separator); overflow-wrap: anywhere; align-items: flex-start; color: var(--label); }
  .sidebar .userchip .note { font-size: var(--fs-caption1); line-height: var(--lh-caption1); }
  .sidebar a.navlink.signout { color: var(--label-2); font-weight: 400; font-size: var(--fs-subhead); min-height: 32px; }
  .sidebar a.navlink.signout .navicon { width: 18px; height: 18px; color: var(--label-2); }
  .main { padding: var(--s-8) var(--s-8) var(--s-10); }
}

/* ========== 4. Page furniture ========== */
.pagehead { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); margin-bottom: var(--s-6); }
.pagehead .sub { flex: 1 0 100%; margin: 0; color: var(--label-2); font-size: var(--fs-callout); line-height: var(--lh-callout); padding-right: max(0px, calc(100% - 80ch)); }
.pagehead .actions { margin-left: auto; display: flex; gap: var(--s-2); flex-wrap: wrap; }
@media (max-width: 879px) { .pagehead .actions { margin-left: 0; flex-basis: 100%; } }
.crumb { font-size: var(--fs-subhead); color: var(--accent-text); margin-bottom: var(--s-2); display: inline-flex; gap: var(--s-1); align-items: center; min-height: var(--hit-fine); }
footer.legal { padding: var(--s-6) var(--s-4) var(--s-2); font-size: var(--fs-caption1); line-height: var(--lh-caption1); color: var(--label-2); text-align: center; }

/* ========== 5. Components ========== */
/* Cards: grouped inset panels. Surface on the grouped background; no border in light, a hairline in dark. */
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: var(--s-4); margin-bottom: var(--s-4); min-width: 0; }
@media (prefers-color-scheme: dark) { .card, .tile, .live { box-shadow: inset 0 0 0 var(--hairline) rgba(255, 255, 255, .04); } }
@media (min-width: 880px) { .card { padding: var(--s-5) var(--s-6); margin-bottom: var(--s-5); } }
.card > h2 { margin-bottom: var(--s-3); display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2); }
.card > h2 .count { font-weight: 400; color: var(--label-2); font-size: var(--fs-subhead); font-family: var(--font); }
.cardhead { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-bottom: var(--s-3); }
.cardhead > h2 { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2); min-width: 0; }
.cardhead > h2 .count { font-weight: 400; color: var(--label-2); font-size: var(--fs-subhead); font-family: var(--font); }
.cardhead > .actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
@media (max-width: 479px) { .cardhead > .actions { margin-left: 0; flex-basis: 100%; } }
.card > .cardhead + .note { margin-top: calc(-1 * var(--s-2)); }
.card > h2 + .note { margin-top: calc(-1 * var(--s-2)); }
.card h3 { margin: var(--s-4) 0 var(--s-2); }

/* Tiles: a figure with a caption. Status shows as the value's colour plus a dot, never colour alone (the caption says what it is). */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
@media (max-width: 479px) { .tiles { grid-template-columns: 1fr 1fr; gap: var(--s-2); } .tile { padding: var(--s-3); } .tile .v { font-size: var(--fs-title2); line-height: var(--lh-title2); } }
.tile { background: var(--surface); border-radius: var(--r-card); padding: var(--s-3) var(--s-4); box-shadow: var(--shadow); min-width: 0; overflow-wrap: anywhere; }
.tile .k { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tile .v { font-family: var(--font-display); font-size: var(--fs-title1); line-height: var(--lh-title1); font-weight: 700; margin-top: var(--s-1); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile .v a { color: inherit; }
.tile .v small { font-size: var(--fs-subhead); font-weight: 400; color: var(--label-2); letter-spacing: 0; font-family: var(--font); }
.tile .v.small { font-size: var(--fs-headline); line-height: var(--lh-headline); }
.tile.done .k::before, .tile.working .k::before, .tile.stuck .k::before, .tile.queued .k::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--none); flex-shrink: 0; }
.tile.done .k::before { background: var(--done); } .tile.working .k::before { background: var(--working); }
.tile.stuck .k::before { background: var(--stuck); } .tile.queued .k::before { background: var(--queued); }
.tile.done .v { color: var(--done-text); } .tile.working .v { color: var(--working-text); } .tile.stuck .v { color: var(--stuck-text); } .tile.queued .v { color: var(--queued-text); }
.tile .v:has(> a) { color: var(--accent-text); }
.card .tiles .tile { background: var(--surface-2); box-shadow: none; }

/* Buttons: capsules. Primary = filled accent; default = tinted (secondary); .plain = text only (tertiary);
   .danger = destructive (tinted red). Every button has hover, press and focus states and a 44px target on touch. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: var(--hit); padding: 0 var(--s-4);
  border-radius: var(--r-capsule); border: 0; background: var(--accent-tint); color: var(--accent-text);
  font-size: var(--fs-body); font-weight: 600; line-height: 1.2; cursor: pointer; white-space: nowrap; text-align: center;
  transition: background-color var(--dur) var(--ease), filter var(--dur) var(--ease), transform var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn:active { filter: brightness(.9); transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); filter: none; }
.btn.plain { background: transparent; padding: 0 var(--s-2); }
.btn.plain:hover { background: var(--fill); filter: none; }
.btn.danger { background: var(--red-tint); color: var(--red-text); }
.btn.small { min-height: var(--hit-fine); padding: 0 var(--s-3); font-size: var(--fs-subhead); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .4; cursor: default; filter: none; transform: none; }
@media (pointer: coarse) { .btn.small { min-height: var(--hit); } }
@media (max-width: 479px) { .btn { white-space: normal; } }

/* Forms: label above control, 44px controls, visible focus. */
.field { display: grid; gap: 6px; font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--label-2); font-weight: 500; }
.field input, .field select,
.form-stack input[type=text], .form-stack input[type=email], .form-stack input[type=date], .form-stack input[type=number], .form-stack input[type=url],
.form-stack input[type=datetime-local], .form-stack select, .form-stack textarea,
.rv-lab textarea, .rv-lab input, .rv-lab select, .rv-sign textarea, .rv-add textarea,
.stage-form select, input.filter, .grid-form input, .grid-form select, .grid-form textarea {
  min-height: var(--hit); padding: 10px 12px; border: var(--hairline) solid var(--control-border); border-radius: var(--r-control);
  background: var(--surface); color: var(--label); font-size: var(--fs-body); line-height: var(--lh-body); min-width: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--label-3); }
.field input:focus, .field select:focus, .form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus,
.rv-lab textarea:focus, .rv-lab input:focus, .rv-lab select:focus, input.filter:focus, .stage-form select:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-tint), 0 0 0 1px var(--focus) inset;
}
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3) var(--s-4); align-items: end; }
.filters .check { display: flex; align-items: center; gap: var(--s-2); color: var(--label); min-height: var(--hit); font-size: var(--fs-body); grid-column: 1 / -1; }
.filters .buttons { display: flex; gap: var(--s-2); align-items: center; grid-column: 1 / -1; }
@media (min-width: 760px) { .filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3) var(--s-5); } .filters .field input { width: 10rem; } }
.form-stack { display: grid; gap: var(--s-4); max-width: 36rem; }
.form-stack label { font-weight: 600; font-size: var(--fs-subhead); line-height: var(--lh-subhead); display: block; margin-bottom: 6px; color: var(--label); }
.form-stack input[type=text], .form-stack input[type=email], .form-stack input[type=datetime-local], .form-stack input[type=date], .form-stack select, .form-stack textarea { width: 100%; max-width: 36rem; }
.form-stack .helptext { display: block; color: var(--label-2); font-size: var(--fs-footnote); line-height: var(--lh-footnote); margin-top: var(--s-1); }
.form-stack ul.errorlist { color: var(--red-text); font-size: var(--fs-footnote); margin: var(--s-1) 0 0; padding-left: 0; }
.form-stack div > div { display: grid; gap: var(--s-1); }
.form-stack div > div label { font-weight: 400; display: inline; }
.form-stack ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-1); }
.form-stack { grid-template-columns: minmax(0, 1fr); }
.form-stack input[type=file] { max-width: 100%; }
.form-stack ul li label { font-weight: 400; display: flex; gap: var(--s-2); align-items: center; min-height: var(--hit-fine); margin: 0; }
.grid-form { display: grid; gap: var(--s-3); max-width: 34rem; }
/* Firm knowledge: verify several entries at once (apps/knowledge/templates/knowledge/home.html). */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.bulkbar .note { margin-bottom: var(--s-3); }
.bulkbar-row { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); align-items: center; }
.bulkbar-row input.filter { flex: 1 1 14rem; }
@media (min-width: 880px) {
  .bulkbar { position: sticky; top: var(--s-3); z-index: 10; }
  /* a row that Back returns to must land below the sticky bar, not behind it */
  #bulk-verify tr[id] { scroll-margin-top: 200px; }
}
tr.subhead td { background: var(--surface-2); padding-top: var(--s-2); padding-bottom: var(--s-2); }
td.check-col { width: 2.5rem; }
a.pill { text-decoration: none; }
a.pill:hover { filter: brightness(.95); }
.inline-form { display: inline-flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.inline-form input.filter { min-width: 140px; }
input.filter { min-width: 220px; }
@media (max-width: 479px) { input.filter, .inline-form input.filter { min-width: 0; width: 100%; } }
/* An action that opens its form in place (<details>: works without JavaScript), e.g. the disbursement item actions. */
details.act > summary { list-style: none; width: fit-content; }
details.act > summary::-webkit-details-marker { display: none; }
details.act[open] > summary { margin-bottom: var(--s-2); }
.act-form { padding-top: var(--s-3); margin-top: var(--s-3); border-top: var(--hairline) solid var(--separator); }
.act-form label { display: grid; gap: var(--s-1); font-weight: 600; font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--label); }
.act-form label .note { font-weight: 400; }
.act-form input, .act-form select, .act-form textarea { width: 100%; font-weight: 400; }
.act-wrap { margin-top: var(--s-2); }
.act-form input[type=checkbox] { width: auto; }
.checklist { display: grid; gap: var(--s-1); max-height: 9rem; overflow-y: auto; padding: var(--s-2); border: var(--hairline) solid var(--separator); border-radius: var(--r-control); }
.act-form .checklist label { display: flex; gap: var(--s-2); align-items: center; font-weight: 400; }
.closeset { border: var(--hairline) solid var(--separator); border-radius: var(--r-control); padding: var(--s-3) var(--s-4); display: grid; gap: var(--s-3); margin: 0; min-width: 0; }
.closeset legend { font-weight: 600; padding: 0 var(--s-1); }
.act-form .closeset label.check { display: flex; gap: var(--s-2); align-items: flex-start; font-weight: 400; }
.stage-form { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.modes { border: var(--hairline) solid var(--separator); border-radius: var(--r-control); padding: var(--s-3) var(--s-4); display: grid; gap: var(--s-3); margin: 0; }
.modes legend { color: var(--label-2); font-size: var(--fs-footnote); padding: 0 var(--s-1); }
.mode { display: flex; gap: var(--s-3); align-items: flex-start; cursor: pointer; min-height: var(--hit-fine); }
.mode input { margin-top: 2px; }

/* Text helpers and notices. */
.note { color: var(--label-2); font-size: var(--fs-footnote); line-height: var(--lh-footnote); }
.muted { color: var(--label-2); }
.notice { border-radius: var(--r-control); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4); font-size: var(--fs-subhead); line-height: var(--lh-subhead); background: var(--accent-tint); color: var(--label); min-height: var(--hit); display: flex; align-items: center; }
.notice.error { background: var(--red-tint); color: var(--red-text); }
.notice:empty { display: none; }
/* Sticky so "Saved" (and an error) is still in view when the redirect lands on an anchor further down the page. */
.main > .notices { position: sticky; top: calc(52px + env(safe-area-inset-top) + var(--s-2)); z-index: 15; display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.main > .notices .notice { margin-bottom: 0; box-shadow: var(--shadow-raised); background: linear-gradient(var(--accent-tint), var(--accent-tint)), var(--surface); }
.main > .notices .notice.error { background: linear-gradient(var(--red-tint), var(--red-tint)), var(--surface); }
@media (min-width: 880px) { .main > .notices { top: var(--s-2); } }
.field-error { display: block; margin-top: var(--s-1); color: var(--red-text); font-size: var(--fs-footnote); line-height: var(--lh-footnote); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { outline: 2px solid var(--red-text); outline-offset: 1px; }
.inline-note { font-size: var(--fs-footnote); color: var(--orange-text); }
.stuck-text { color: var(--stuck-text); }

/* Status vocabulary: tinted capsules with the label in the status colour. The word carries the meaning; colour reinforces it. */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 5.5rem; padding: 3px 10px; border-radius: var(--r-capsule);
  font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; text-align: center; vertical-align: middle; white-space: nowrap;
  background: var(--none-tint); color: var(--none-text);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill.done, .pill.reviewed { background: var(--done-tint); color: var(--done-text); }
.pill.working, .pill.draft { background: var(--working-tint); color: var(--working-text); }
.pill.queued { background: var(--queued-tint); color: var(--queued-text); }
.pill.stuck, .pill.failed { background: var(--stuck-tint); color: var(--stuck-text); }
.pill.none { background: var(--none-tint); color: var(--none-text); }
.pill.wrap { white-space: normal; min-width: 0; text-align: left; }
.nowrap { white-space: nowrap; }
.chip { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--r-capsule); background: var(--accent-tint); color: var(--accent-text); font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; white-space: nowrap; }
.chip.neutral { background: var(--fill); color: var(--label-2); }
.chip.wrap { white-space: normal; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.lim-urgent { color: var(--red-text); font-weight: 700; } .lim-soon { color: var(--orange-text); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--none); margin-right: 6px; vertical-align: middle; }
.dot.done { background: var(--done); } .dot.working { background: var(--working); } .dot.queued { background: var(--queued); } .dot.stuck { background: var(--stuck); }

/* Tables: hairline rows, quiet headers, numbers right-aligned. .stack turns rows into grouped rows on phones. */
.tablewrap { container: tablewrap / inline-size; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--s-2)); padding: 0 var(--s-2); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--fs-body); line-height: var(--lh-body); }
table.grid th {
  text-align: left; font-weight: 600; color: var(--label-2); font-size: var(--fs-footnote); line-height: var(--lh-footnote);
  padding: var(--s-2); border-bottom: var(--hairline) solid var(--separator); white-space: nowrap;
}
table.grid th.num { text-align: right; }
table.grid td { padding: var(--s-3) var(--s-2); border-bottom: var(--hairline) solid var(--separator); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--fill); }
table.grid tbody tr:hover td:first-child { border-radius: var(--r-small) 0 0 var(--r-small); }
table.grid tbody tr:hover td:last-child { border-radius: 0 var(--r-small) var(--r-small) 0; }
table.grid td.primary { font-weight: 600; }
table.grid td.primary > a { white-space: nowrap; }
table.grid td.wrap { overflow-wrap: break-word; white-space: normal; min-width: 8rem; }
table.grid td.wrap code { display: inline-block; white-space: nowrap; margin: 1px 0; }
table.grid td.primary a { color: var(--accent-text); }
table.kv th { width: 60%; font-weight: 400; font-size: var(--fs-body); color: var(--label); white-space: normal; }
dl.facts { display: grid; grid-template-columns: 1fr; gap: var(--s-3) var(--s-6); margin: 0; }
dl.facts div { display: grid; gap: 2px; min-width: 0; }
dl.facts dt { color: var(--label-2); font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 500; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 760px) { dl.facts { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
@media (max-width: 759px) { .tablewrap { margin: 0; padding: 0; overflow: visible; } }
/* .stack tables become labelled rows when the space the table actually has is narrow (a container query on
   .tablewrap), not only on phones: beside the desktop sidebar a wide table gets as little as 536 px. */
@container tablewrap (max-width: 799px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-radius: var(--r-control); margin-bottom: var(--s-3); padding: 0 var(--s-3); background: var(--surface-2); }
  table.stack td {
    display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: var(--s-1) var(--s-2);
    border-bottom: var(--hairline) solid var(--separator); padding: var(--s-3) 0; text-align: right; min-height: var(--hit); white-space: normal;
  }
  table.stack td:last-child { border-bottom: 0; }
  table.stack td::before { content: attr(data-label); color: var(--label-2); font-size: var(--fs-subhead); font-weight: 400; text-align: left; flex-shrink: 0; margin-right: auto; padding-right: var(--s-3); }
  table.stack td[data-label=""]::before { content: none; }
  table.stack td.primary { font-size: var(--fs-headline); }
  table.stack td.primary::before { font-weight: 400; }
  table.stack td[colspan] { justify-content: flex-start; text-align: left; }
  table.stack td[colspan]::before { content: none; }
  table.stack tbody tr:hover td { background: transparent; }
  table.stack td.proc { flex-direction: column; align-items: flex-end; }
  table.stack td.proc::before { align-self: flex-start; margin: 0; }
  table.stack td.proc .progress { width: 100%; }
}
.empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--label-2); font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.empty a { display: inline-block; margin-top: var(--s-1); font-weight: 600; }
table.grid td.empty { padding: var(--s-6) var(--s-4); }
@container tablewrap (max-width: 799px) { table.stack td.empty { display: block; text-align: center; } }

/* Progress: determinate bar, accent fill on a capsule track. */
.hidden { display: none !important; }
.progress { height: 6px; background: var(--fill-2); border-radius: var(--r-capsule); overflow: hidden; margin-top: 6px; }
.progress .bar { width: 0; height: 100%; background: var(--accent); border-radius: var(--r-capsule); transition: width .4s var(--ease); }
.progress.big { height: 8px; margin: var(--s-3) 0; }

/* Progress card (apps/jobs/templates/jobs/progress_card.html, static/js/progress.js): a big overall bar with its
   percentage, the current step in words, then the stepper. Words carry every state as well as colour. */
.pbig { display: flex; align-items: center; gap: var(--s-4); }
.pbig .progress { flex: 1 1 auto; height: 12px; margin: 0; }
.pbig .pct { flex: 0 0 auto; min-width: 3.4rem; font-size: var(--fs-title2, 1.375rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.progress-card[data-state="done"] .progress .bar { background: var(--done); }
.progress-card[data-state="failed"] .progress .bar, .progress-card[data-state="stalled"] .progress .bar { background: var(--stuck); }
.progress-card[data-state="batch"] .progress .bar { background: var(--queued); }
.plabel { margin: var(--s-3) 0 0; font-size: var(--fs-headline); font-weight: 600; overflow-wrap: anywhere; }
.pdetail, .pmeta { margin: var(--s-1) 0 0; overflow-wrap: anywhere; }
.pnote { margin: var(--s-3) 0 0; }
.psteps { margin-top: var(--s-4); }
.psteps > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-subhead); padding: var(--s-1) 0; }
.pgroup { margin: var(--s-3) 0 var(--s-1); font-weight: 600; text-transform: none; }
ol.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 1.5rem 1fr auto; align-items: center; gap: var(--s-1) var(--s-3); padding: var(--s-2) 0; border-top: var(--hairline) solid var(--separator); }
.step:first-child { border-top: 0; }
.step-name { min-width: 0; overflow-wrap: anywhere; }
.step-detail { grid-column: 2 / -1; margin: 0; overflow-wrap: anywhere; }
.step .pill { white-space: nowrap; }
.step[data-state="waiting"] .step-name, .step[data-state="skipped"] .step-name { color: var(--label-2); }
.step[data-state="running"] .step-name, .step[data-state="batch"] .step-name, .step[data-state="stalled"] .step-name, .step[data-state="failed"] .step-name { font-weight: 600; }
.step-icon { width: 1.25rem; height: 1.25rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 0.8rem; font-weight: 700; line-height: 1; box-sizing: border-box; }
.step-icon::before { content: ""; }
.step[data-state="waiting"] .step-icon { border: 2px solid var(--none); }
.step[data-state="done"] .step-icon { background: var(--done-tint); color: var(--done-text); border: 2px solid var(--done); }
.step[data-state="done"] .step-icon::before { content: "\2713"; }
.step[data-state="skipped"] .step-icon { border: 2px dashed var(--none); }
.step[data-state="skipped"] .step-icon::before { content: "\2013"; color: var(--label-2); }
.step[data-state="failed"] .step-icon { background: var(--stuck-tint); color: var(--stuck-text); border: 2px solid var(--stuck); }
.step[data-state="failed"] .step-icon::before { content: "\2715"; }
.step[data-state="stalled"] .step-icon { background: var(--stuck-tint); color: var(--stuck-text); border: 2px solid var(--stuck); }
.step[data-state="stalled"] .step-icon::before { content: "!"; }
.step[data-state="person"] .step-icon { border: 2px solid var(--queued); color: var(--queued-text); }
.step[data-state="person"] .step-icon::before { content: "\00b7\00b7\00b7"; letter-spacing: -1px; }
.step[data-state="batch"] .step-icon { border: 2px solid var(--queued); color: var(--queued-text); }
.step[data-state="batch"] .step-icon::before { content: "\00b7\00b7\00b7"; letter-spacing: -1px; }
.step[data-state="running"] .step-icon { border: 2px solid var(--fill-2); border-top-color: var(--working); animation: step-spin 0.9s linear infinite; }
@keyframes step-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .step[data-state="running"] .step-icon { animation: none; border-color: var(--working); } }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.prow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-3) 0; border-top: var(--hairline) solid var(--separator); }
.prow:first-child { border-top: 0; }
.prow .pill { justify-self: start; }
.prow .progress { margin: 0; grid-column: 1 / -1; }
.prow[data-state="done"] .bar { background: var(--done); } .prow[data-state="stalled"] .bar, .prow[data-state="failed"] .bar { background: var(--stuck); } .prow[data-state="batch"] .bar { background: var(--queued); }
.prow-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.prow-label { grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; }
.prow-link { font-weight: 600; }
@media (max-width: 599px) {
  .pbig .pct { min-width: 2.9rem; }
  .step { gap: var(--s-1) var(--s-2); }
}
@media print { .progress-card .step-icon { animation: none; } }
.live { border-radius: var(--r-card); padding: var(--s-4); background: var(--surface); box-shadow: var(--shadow); }
.card .live { background: var(--surface-2); box-shadow: none; }
.live-head { display: flex; justify-content: space-between; gap: var(--s-4); align-items: baseline; flex-wrap: wrap; }
.live-head .note { word-break: break-all; }
.live-counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: var(--s-2); margin-top: var(--s-2); }
.live-counters div { display: grid; text-align: center; }
.live-counters .v { font-size: var(--fs-title3); line-height: var(--lh-title3); font-weight: 700; font-variant-numeric: tabular-nums; }
.live-counters .k { font-size: var(--fs-caption1); line-height: var(--lh-caption1); color: var(--label-2); }
td.proc { min-width: 12rem; } td.proc .counters { margin-top: var(--s-1); font-size: var(--fs-caption1); line-height: var(--lh-caption1); }

/* Uploads (ADR-0018). */
.dropzone { border: 2px dashed var(--control-border); border-radius: var(--r-card); padding: var(--s-6) var(--s-4); text-align: center; background: var(--surface-2); color: var(--label-2); }
.dropzone input[type=file] { width: 100%; max-width: 100%; min-height: var(--hit); }
.dropzone.over { border-color: var(--accent); background: var(--accent-tint); }
.dropzone.busy { border-style: solid; text-align: left; color: var(--label); }
.dropzone .live-head { margin-top: var(--s-1); }
.dropzone .btn + .btn { margin-top: var(--s-2); }
.resume-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.resume-list li { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); align-items: center; padding: var(--s-3) var(--s-4); border-radius: var(--r-control); background: var(--surface-2); }
.resume-list li .actions { margin-left: auto; display: flex; gap: var(--s-2); }

/* Live activity feed (ADR-0019). */
.activity { background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-3) var(--s-4); max-height: 320px; overflow: auto; font-family: var(--font-mono); font-size: var(--fs-footnote); line-height: 1.5; white-space: pre-wrap; margin: 0; }

/* Evidence icons (templates/doclinks.html): open the original, read the text. 16px monochrome line icons, 32px target (44px on touch). */
.doclinks { display: inline-flex; gap: 2px; vertical-align: middle; }
.iconlink { display: inline-grid; place-items: center; width: var(--hit-fine); height: var(--hit-fine); border-radius: var(--r-small); color: var(--accent-text); vertical-align: middle; flex-shrink: 0; }
.iconlink:hover { background: var(--accent-tint); text-decoration: none; }
.iconlink .icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
@media (pointer: coarse) { .iconlink { width: 40px; height: var(--hit); } }

/* ========== 6. Page-specific ========== */
/* Photo gallery (ADR-0041): large 4:3 thumbnails with a short name, date and file name, and the evidence icons. 2 columns on phones. */
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-3); }
@media (min-width: 560px) { .gallery { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-5) var(--s-4); } }
.gallery-item { min-width: 0; scroll-margin-top: var(--s-6); }
.gallery-item:target .gallery-thumb { box-shadow: 0 0 0 3px var(--focus); }
.gallery-thumb { display: block; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--r-control); background: var(--fill); }
.gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur) var(--ease); }
.gallery-thumb:hover img { transform: scale(1.03); }
.gallery-title { margin: var(--s-2) 0 0; font-weight: 600; font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--label); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow-wrap: anywhere; }
.gallery-sub { margin: 0; font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
.gallery-foot { min-width: 0; }
.gallery-meta { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label-2); font-size: var(--fs-footnote); line-height: var(--lh-footnote); }
@media (prefers-reduced-motion: reduce) { .gallery-thumb img { transition: none; } .gallery-thumb:hover img { transform: none; } }
@media print { .gallery { grid-template-columns: repeat(3, 1fr); } .gallery-thumb:hover img { transform: none; } }

/* Key information (ADR-0020). */
.keygroup { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; color: var(--label-2); margin: var(--s-4) 0 var(--s-2); }
.keylist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; background: var(--surface-2); border-radius: var(--r-control); overflow: clip; /* not hidden: that makes a scroll container, and a row anchor inside it would ignore its scroll-margin */ }
.keylist li { padding: var(--s-2) var(--s-3); font-size: var(--fs-body); border-bottom: var(--hairline) solid var(--separator); }
.keylist li:last-child { border-bottom: 0; }
.keynav { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-4); }
.keynav .chip { min-height: var(--hit-fine); padding: 0 var(--s-3); }
.keynav .chip.active { background: var(--accent); color: var(--on-accent); }
.keygroup a, .keylist li a { color: var(--accent-text); text-decoration: none; }
.keygroup a:hover, .keylist li a:hover, .keygroup a:focus-visible, .keylist li a:focus-visible { text-decoration: underline; text-underline-offset: 2px; }
.keylist li a:not(.iconlink)::after { content: " \203A"; color: var(--label-2); }
.srcdoc { display: inline-flex; align-items: center; gap: var(--s-1); margin-right: var(--s-3); }
tr.flash td { background: var(--accent-tint); }

/* Document view: original beside extracted text. */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.preview { max-width: 100%; height: auto; border-radius: var(--r-control); background: var(--surface-2); }
.preview-frame { width: 100%; height: 75vh; border: var(--hairline) solid var(--separator); border-radius: var(--r-control); background: var(--surface-2); }
.doctext { white-space: pre-wrap; font-size: var(--fs-subhead); line-height: 1.55; max-height: 75vh; overflow: auto; background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-3) var(--s-4); margin: 0; }

/* Document page: the Back control sits beside the case crumb; an email is a header block over its body. */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-3); }
.crumbs .crumb { margin-bottom: 0; }
.emailhead { display: grid; gap: var(--s-2); margin: 0 0 var(--s-3); padding: var(--s-3) var(--s-4); background: var(--surface-2); border-radius: var(--r-control); }
.emailhead div { display: grid; grid-template-columns: 5.5rem 1fr; gap: var(--s-2); min-width: 0; }
.emailhead dt { color: var(--label-2); font-size: var(--fs-footnote); line-height: var(--lh-subhead); font-weight: 600; }
.emailhead dd { margin: 0; overflow-wrap: anywhere; font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.attachlist { margin: var(--s-2) 0; padding-left: var(--s-5); font-size: var(--fs-subhead); overflow-wrap: anywhere; }
table.csvpreview { font-size: var(--fs-subhead); }
table.csvpreview td { white-space: nowrap; max-width: 24rem; overflow: hidden; text-overflow: ellipsis; }

/* Rows that a detail page's Back control returns to (docs/DESIGN.md, "Back is always where you were"): land below the sticky
   bar and show which row it is. Table rows and list items tint; a card, tile or block (class .backrow) gets an outline. */
[id] { scroll-margin-top: 72px; }
tr[id]:target, tr[id]:target td { background: var(--accent-tint); }
li[id]:target { background: var(--accent-tint); }
.backrow:target { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-small); }

/* Document chip and quick look (ADR-0044) */
[hidden] { display: none !important; }
.dchipwrap { text-align: left; display: inline-flex; align-items: center; gap: var(--s-1); max-width: 100%; vertical-align: middle; position: relative; }
.dchip { display: inline-flex; align-items: center; gap: var(--s-3); min-width: 0; padding: var(--s-1); border-radius: var(--r-control); color: var(--label); text-decoration: none; }
.dchip:hover { background: var(--fill); color: var(--label); text-decoration: none; }
.dthumb { flex: none; position: relative; display: grid; place-items: center; width: 48px; height: 60px; border-radius: 4px; overflow: hidden; background: #fff; border: var(--hairline) solid var(--separator); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.dthumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.dthumb.is-photo { height: 48px; margin: 6px 0; }
.dthumb.is-glyph { background: var(--surface-2); color: var(--label-2); align-content: center; gap: 2px; }
.dthumb .glyphicon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dthumb b { font-size: var(--fs-caption2); letter-spacing: .04em; line-height: 1; }
.dthumb.kind-mail { background: var(--blue-tint); color: var(--blue-text); }
.dthumb.kind-sheet { background: var(--green-tint); color: var(--green-text); }
.dthumb .dkind { position: absolute; right: 0; bottom: 0; font-style: normal; font-size: var(--fs-caption2); line-height: 1; font-weight: 700; padding: 2px 3px; background: var(--label); color: var(--surface); border-radius: 3px 0 0 0; letter-spacing: .03em; }
.dmeta { display: grid; min-width: 0; gap: 2px; }
.dchipwrap .dname { color: var(--label); }
.dchip-compact:hover .dname { color: var(--accent-text); }
.dname { font-size: var(--fs-callout); line-height: var(--lh-callout); font-weight: 600; overflow-wrap: anywhere; }
.dsub { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label); overflow-wrap: anywhere; }
.dfile { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-2); overflow-wrap: anywhere; }
.dchip-compact { gap: var(--s-2); padding: 2px var(--s-3) 2px 3px; border-radius: var(--r-capsule); background: var(--fill); min-height: var(--hit-fine); font-size: var(--fs-footnote); }
.dchip-compact:hover { background: var(--accent-tint); color: var(--accent-text); }
.dchip-compact .dthumb { width: 20px; height: 24px; border-radius: 3px; box-shadow: none; }
.dchip-compact .dthumb.is-photo { height: 20px; width: 20px; margin: 0; border-radius: 50%; }
.dchip-compact .dthumb .glyphicon { width: 13px; height: 13px; stroke-width: 2; }
.dchip-compact .dname { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
@media (pointer: coarse) { .dchip-compact { min-height: var(--hit); } }
.dmenu > summary { list-style: none; display: grid; place-items: center; width: var(--hit-fine); height: var(--hit-fine); border-radius: var(--r-small); color: var(--label-2); cursor: pointer; }
.dmenu > summary::-webkit-details-marker { display: none; }
.dmenu > summary:hover, .dmenu[open] > summary { background: var(--fill); color: var(--label); }
.dmenu .navicon { width: 18px; height: 18px; fill: currentColor; stroke: none; }
@media (pointer: coarse) { .dmenu > summary { width: var(--hit); height: var(--hit); } }
.dmenu-list { position: absolute; z-index: 20; right: 0; top: 100%; min-width: 11rem; display: grid; padding: var(--s-1); background: var(--surface); border: var(--hairline) solid var(--separator); border-radius: var(--r-control); box-shadow: var(--shadow-raised); }
.dmenu-list a { display: flex; align-items: center; min-height: var(--hit-fine); padding: 0 var(--s-3); border-radius: var(--r-small); color: var(--label); font-size: var(--fs-subhead); text-decoration: none; white-space: nowrap; }
.dmenu-list a:hover { background: var(--accent-tint); color: var(--accent-text); }
@media (pointer: coarse) { .dmenu-list a { min-height: var(--hit); } }

.rv-sources .dchipwrap { margin-right: var(--s-3); }
.dmenu-list a:focus-visible, .dmenu > summary:focus-visible, .dchip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Page images: a scrollable column of pages, the same on every browser. */
.pageimgs { display: grid; justify-items: center; gap: var(--s-3); }
.pageimg { display: block; width: 100%; max-width: 760px; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 2px 14px rgba(0, 0, 0, .18); }
.pageimgs .note { justify-self: stretch; }
/* Marketing pack (ADR-0051 amendment): wireframe screenshots. Phone screens sit in a responsive grid, desktop screens run full width. */
.shotgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--s-4); align-items: start; }
.shot { margin: 0; min-width: 0; }
.shot a { display: block; }
.shot img { display: block; width: 100%; height: auto; background: #fff; border-radius: var(--r-control); box-shadow: 0 1px 8px rgba(0, 0, 0, .18); }
.shot figcaption { margin-top: var(--s-2); }
@media (max-width: 899px) { .pdf-toggle { display: none; } }
.split.single { grid-template-columns: minmax(0, 1fr); }

/* Quick look: a modal panel from the right on a desktop, a full-height sheet on a phone. Closes with Esc. */
.quicklook { border: 0; padding: 0; background: var(--surface); color: var(--label); box-shadow: var(--shadow-raised); overscroll-behavior: contain;
  width: min(1040px, 92vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-radius: var(--r-card) 0 0 var(--r-card); }
.quicklook::backdrop { background: rgba(0, 0, 0, .4); }
.quicklook > div { display: flex; flex-direction: column; height: 100%; }
.ql-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-2) var(--s-4); padding: var(--s-3) var(--s-5); border-bottom: var(--hairline) solid var(--separator); }
.ql-titles { min-width: 0; }
.ql-head h2 { margin: 0; font-size: var(--fs-title3); line-height: var(--lh-title3); overflow-wrap: anywhere; }
.ql-sub { margin: 0; font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-2); overflow-wrap: anywhere; }
.ql-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; }
.ql-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.ql-body.single { grid-template-columns: minmax(0, 1fr); }
.ql-prev { background: var(--surface-2); padding: var(--s-5); overflow: auto; min-height: 0; }
.ql-text { padding: var(--s-5) var(--s-6); overflow: auto; min-height: 0; border-left: var(--hairline) solid var(--separator); }
.ql-text .doctext { max-height: none; background: transparent; padding: 0; }
.textpane-h { font-size: var(--fs-headline); margin: 0 0 var(--s-2); }
.ql-prev .preview-frame { height: calc(100dvh - 9rem); min-height: 50vh; }
@media (max-width: 599px) {
  .quicklook { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .ql-head { grid-template-columns: auto minmax(0, 1fr); padding: var(--s-2) var(--s-4); }
  .ql-actions { grid-column: 1 / -1; justify-content: stretch; }
  .ql-actions .btn { flex: 1 1 auto; }
  .ql-body, .ql-body.single { display: block; overflow: auto; }
  .ql-prev { padding: var(--s-3); max-height: 58dvh; }
  .ql-text { border-left: 0; border-top: var(--hairline) solid var(--separator); padding: var(--s-4); overflow: visible; }
}

/* Danger zone (test environments). */
.card.danger { box-shadow: inset 0 0 0 var(--hairline) var(--red); }

/* Policy and audit (ADR-0021). */
code.small { font-size: var(--fs-caption1); word-break: break-all; }

/* Review and sign-off (ADR-0024): each item is a row in a grouped list; required items carry an orange leading rule. */
.rv-item { border-top: var(--hairline) solid var(--separator); padding: var(--s-4) 0; scroll-margin-top: 72px; }
.card > .rv-item:first-of-type, .card > h2 + .rv-item, .card > .note + .rv-item, .card > h3 + .rv-item { border-top: 0; }
.rv-item.required { box-shadow: inset 3px 0 0 var(--working); padding-left: var(--s-4); border-top-left-radius: 2px; }
.rv-item:target { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: var(--r-small); }
.rv-head { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); justify-content: space-between; align-items: flex-start; }
.rv-text { flex: 1 1 18rem; min-width: 0; overflow-wrap: anywhere; }
.rv-text > .pill, .rv-text > .chip { margin-right: var(--s-2); }
.rv-flags { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.rv-flags .pill { min-width: 5rem; }
.chip.rv-req, .rv-req { background: var(--orange-tint); color: var(--orange-text); }
.rv-quote, .rv-facts, .rv-hint, .rv-sources, .rv-path { margin: var(--s-2) 0 0; overflow-wrap: anywhere; }
.rv-quote { border-left: 3px solid var(--separator); padding-left: var(--s-3); font-style: italic; }
.rv-sources { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) 0; }
.rv-block { margin: var(--s-5) 0 var(--s-1); font-size: var(--fs-subhead); color: var(--label-2); text-transform: capitalize; }
.rv-verdicts { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: var(--s-2); }
.rv-verdicts li { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); align-items: center; background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-2) var(--s-3); }
.rv-verdicts .pill { min-width: 4.5rem; padding: 2px 8px; }
.rv-note { overflow-wrap: anywhere; flex-basis: 100%; }
.rv-form-wrap { margin-top: var(--s-3); }
.rv-form-wrap > summary { cursor: pointer; color: var(--accent-text); font-weight: 600; font-size: var(--fs-subhead); min-height: var(--hit-fine); display: inline-flex; align-items: center; gap: var(--s-1); border-radius: var(--r-small); }
.rv-form-wrap > summary::marker { color: var(--label-3); }
.rv-form { display: grid; gap: var(--s-3); margin-top: var(--s-2); max-width: 40rem; padding: var(--s-4); background: var(--surface-2); border-radius: var(--r-control); }
.rv-form textarea, .rv-form input[type=text], .rv-form select { background: var(--surface); }
.rv-radios { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); border: 0; padding: 0; margin: 0; min-width: 0; }
details.about > summary { cursor: pointer; color: var(--label-2); font-size: var(--fs-subhead); min-height: var(--hit-fine); display: flex; align-items: center; }
details.about[open] > summary { margin-bottom: var(--s-2); }
.rv-radios label { display: inline-flex; gap: var(--s-2); align-items: center; font-weight: 600; min-height: var(--hit-fine); }
@media (pointer: coarse) { .rv-radios label { min-height: var(--hit); } }
.rv-lab { display: grid; gap: 6px; font-size: var(--fs-subhead); font-weight: 600; }
.rv-lab textarea, .rv-lab input, .rv-lab select, .rv-sign textarea, .rv-add textarea { width: 100%; font-weight: 400; }
.rv-more { display: none; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.rv-item[data-v="disagree"] .rv-more { display: grid; }
.rv-more .rv-wide { grid-column: 1 / -1; }
@media (max-width: 759px) { .rv-more { grid-template-columns: 1fr; } }
.rv-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.rv-withdraw { margin: calc(-1 * var(--s-2)) 0 var(--s-3); }
.rv-blockers { background: var(--orange-tint); border-radius: var(--r-control); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4); font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.rv-blockers p { margin: 0; }
.rv-blockers ul { margin: var(--s-2) 0 0; padding-left: var(--s-5); }
.rv-sign textarea { max-width: 36rem; }
.rv-assign { margin-top: var(--s-6); padding-top: var(--s-4); border-top: var(--hairline) solid var(--separator); }

/* Utilities that replace inline style="" attributes (CSP: style-src has no 'unsafe-inline', ADR-0013). */
.ml-auto { margin-left: auto; }
form.inline { display: inline; }
.sub-h { margin: var(--s-3) 0 var(--s-1); font-size: var(--fs-subhead); text-transform: capitalize; }
p.tight { margin: var(--s-1) 0; }
tr.strong-row td { font-weight: 600; }
tr.uplift td { background: var(--yellow-tint); font-weight: 700; }
.w-full { width: 100%; }

/* Quiet text link to the JSON twin at a page's foot (templates/_json_link.html). */
.jsonlink { margin: var(--s-4) 0 0; text-align: right; font-size: var(--fs-caption1); line-height: var(--lh-caption1); }
.jsonlink a { color: var(--label-2); }

/* ========== 7. Motion ========== */
/* Same-origin page navigations cross-fade instead of flashing white (progressive enhancement; ignored where unsupported). */
@media not (prefers-reduced-motion: reduce) { @view-transition { navigation: auto; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .btn:active { transform: none; }
}

/* Continuous ("squircle") corners where the browser supports corner-shape; plain rounded corners elsewhere. */
@supports (corner-shape: superellipse(1.5)) {
  .card, .tile, .live, .notice, .rv-form, .rv-verdicts li, .rv-blockers, table.stack tr, .keylist, .account .sheet, .brand .logo, .sidebar a.navlink { corner-shape: superellipse(1.5); }
}

/* ========== 8. Print (the review page and the case page are printed for supervision files) ========== */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --label: #000; --label-2: #444; --separator: #bbb; --shadow: none; color-scheme: light; }
  body { background: #fff; font-size: 10.5pt; line-height: 1.4; }
  .sidebar, .topbar, .bottomnav, .skip, .pagehead .actions, .rv-form-wrap, .rv-withdraw, .inline-form, form.filters, .stage-form,
  .btn, .doclinks, .progress, .account, .more, .jsonlink { display: none !important; }
  .app { display: block; background: none; }
  .main { max-width: none; padding: 0; }
  .card, .tile { box-shadow: none; border: 1px solid #bbb; break-inside: avoid-page; }
  .card { padding: 10pt 12pt; margin-bottom: 10pt; }
  .rv-item { break-inside: avoid; }
  .rv-item.required { box-shadow: none; border-left: 3px solid #b14b00; }
  .pill, .chip { border: 1px solid currentColor; background: none !important; }
  a { color: inherit; text-decoration: none; }
  table.grid tbody tr:hover td { background: none; }
  h1 { font-size: 18pt; } h2 { font-size: 12pt; }
  footer.legal { font-size: 8pt; color: #000; border-top: 1px solid #bbb; margin-top: 12pt; }
  @page { margin: 16mm 14mm; }
}

/* Cross-case search (ADR-0032): the box in the sidebar and the phone top bar, and the results page. */
.searchbox { margin: 0; }
.searchbox input.filter { min-width: 0; width: 100%; }
.searchbox.top { flex: 1 1 auto; min-width: 0; }
.searchbox.side { padding: 0 var(--s-2) var(--s-3); }
.searchres .hit { display: grid; gap: var(--s-1); padding: var(--s-3) 0; border-top: var(--hairline) solid var(--separator); }
.searchres .hit:first-of-type { border-top: 0; }
.searchres .hit .meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.searchres mark { background: var(--accent-tint); color: var(--accent-text); border-radius: 3px; padding: 0 2px; }
.searchres .similar { color: var(--label-2); }

/* Case page: an email attachment listed under its email (ADR-0040). */
tr.attachment-row td.primary { padding-left: var(--s-6); }

/* Case page: "Where this case stands" and its one next step; the closed "Processing details" card; a notice with an action. */
.standing .nextstep { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); padding-bottom: var(--s-4); border-bottom: var(--hairline) solid var(--separator); }
.standing .nextstep-text { margin: 0; flex: 1 1 16rem; }
details.card > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-headline); }
details.card[open] > summary { margin-bottom: var(--s-3); }
details.about > summary { cursor: pointer; width: fit-content; }
.notice .btn { margin-left: auto; }
.pagehead ul.sub { padding-left: 1.25em; }

/* Case shell (ADR-0043): the case header, the tab row and the Overview tiles. Phone first; >= 880 px the header and tabs stick. */
.case-shell { min-width: 0; }
.case-top { display: contents; }
.case-head { margin: 0 0 var(--s-3); min-width: 0; }
.case-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-4); }
.case-head-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); min-width: 0; flex: 1 1 18rem; }
.case-head-title .crumbs { margin: 0; }
h1.case-ref { margin: 0; overflow-wrap: anywhere; }
.case-next { flex: 0 0 auto; min-width: 0; max-width: 100%; }
.case-next form { margin: 0; }
.case-head-facts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-3); min-width: 0; }
.case-head-facts a.pill { text-decoration: none; }
.case-fact { font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--label-2); }
.case-fact strong { color: var(--label); font-weight: 600; }
.case-fact strong.lim-urgent { color: var(--stuck-text); } .case-fact strong.lim-soon { color: var(--working-text); }
@media (max-width: 879px) {
  /* compact phone header: ref + stage on one line, small pills on one line, limitation and fee earner as one note line, a normal-size Next step */
  .case-head { margin-bottom: var(--s-2); }
  .case-head-row { gap: var(--s-2); }
  .case-head-title { flex: 1 1 auto; gap: var(--s-1) var(--s-2); }
  .case-head-title .chip.neutral { display: none; }
  .case-next .btn { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-subhead); }
  .case-next .note, .case-next .pill { font-size: var(--fs-footnote); }
  .case-head-facts { margin-top: var(--s-2); gap: var(--s-1) var(--s-2); }
  .case-head-facts .pill, .case-head-facts .chip { font-size: var(--fs-footnote); min-height: 0; padding-block: 1px; }
  .case-fact { font-size: var(--fs-footnote); line-height: var(--lh-footnote, 1.3); }
  .case-fact strong { font-weight: 500; }
  .case-tabs { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 12; margin: 0 calc(-1 * var(--s-4)) var(--s-4); background: var(--bar-bg);
               -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: var(--hairline) solid var(--separator); }
  .case-tabs ul { padding: var(--s-2) var(--s-8) var(--s-2) var(--s-4); }
  /* the current tab leads the row, so a phone opens with it in view and no script is needed */
  .case-tab.is-current { order: -1; scroll-margin-inline: var(--s-4); }
  .case-tab { min-height: var(--hit); padding: 0 var(--s-3); border-radius: var(--r-capsule); background: var(--fill); }
  .case-tab.is-current { background: var(--accent); color: var(--on-accent); }
  .case-tab.is-current .count { color: inherit; }
  .case-shell [id] { scroll-margin-top: 120px; }
}
@media (min-width: 880px) {
  .case-tabs { position: relative; }
  .case-top { display: block; position: sticky; top: 0; z-index: 12; margin: 0 calc(-1 * var(--s-8)) var(--s-5); padding: var(--s-2) var(--s-8) 0; background: var(--bg); border-bottom: var(--hairline) solid var(--separator); }
  .case-tab { min-height: 40px; padding: 0 var(--s-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
  .case-tab:hover { text-decoration: none; background: var(--fill); border-radius: var(--r-control) var(--r-control) 0 0; }
  .case-tab.is-current { border-bottom-color: var(--accent); color: var(--accent-text); font-weight: 600; }
  .case-shell [id] { scroll-margin-top: 160px; }
}
.case-tabs { overflow-x: clip; } /* the scrolling row inside must not widen the page */
.case-tabs ul { display: flex; gap: var(--s-1); list-style: none; margin: 0; padding: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.case-tabs li { flex: 0 0 auto; }
.case-tab { display: inline-flex; align-items: center; gap: var(--s-1); color: var(--label-2); font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: 500; white-space: nowrap; }
.case-tab:hover { color: var(--label); text-decoration: none; }
.case-tab .count { font-size: var(--fs-footnote); padding: 0 6px; border-radius: var(--r-capsule); background: var(--fill); color: var(--label-2); font-variant-numeric: tabular-nums; }
.case-tab.is-current .count { background: transparent; }
.tabdot { width: 8px; height: 8px; border-radius: 50%; background: var(--none); flex-shrink: 0; }
.tabdot.stuck { background: var(--stuck); } .tabdot.working { background: var(--working); }
.case-tabs::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: var(--s-8); pointer-events: none; background: linear-gradient(to right, transparent, var(--bg)); }
@media (max-width: 879px) { .case-tabs::after { background: linear-gradient(to right, transparent, var(--surface-2)); opacity: .9; } }
/* desktop: every tab is visible, the row wraps onto a second line rather than scrolling; the fade and the sideways scroll are for phones */
@media (min-width: 880px) { .case-tabs ul { flex-wrap: wrap; overflow: visible; } .case-tabs::after { display: none; } .case-tab { padding: 0 var(--s-2); } }
/* ADR-0075: the primary row scrolls (phone) or wraps (desktop) beside a "More" menu that always stays in view. The fade belongs to the
   scrolling part only, so it never covers "More". */
.case-tabbar { display: flex; align-items: flex-start; gap: var(--s-1); }
.case-tabscroll { position: relative; flex: 1 1 auto; min-width: 0; }
.case-tabs::after { display: none; }
.case-tabscroll::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: var(--s-6, 24px); pointer-events: none; background: linear-gradient(to right, transparent, var(--bg)); }
@media (max-width: 879px) { .case-tabscroll::after { background: linear-gradient(to right, transparent, var(--surface-2)); opacity: .9; } .case-tabbar { padding-right: var(--s-4); } .case-tabs ul { padding-right: var(--s-6, 24px); } }
@media (min-width: 880px) { .case-tabscroll::after { display: none; } }
.case-more { position: static; flex: 0 0 auto; }
.case-more > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--s-1); min-height: 40px; padding: 0 var(--s-3);
  color: var(--label-2); font-size: var(--fs-subhead); font-weight: 500; white-space: nowrap; border-radius: var(--r-capsule); }
.case-more > summary::-webkit-details-marker { display: none; }
.case-more > summary:hover { color: var(--label); background: var(--fill); }
.case-more.is-current > summary, .case-more[open] > summary { color: var(--accent-text); font-weight: 600; }
.case-more.is-current > summary { background: var(--accent-tint, var(--fill)); }
.case-more-caret { font-size: .75em; }
.case-more-sheet { position: absolute; right: var(--s-4); top: 100%; z-index: 20; width: min(560px, calc(100vw - 2 * var(--s-4))); max-height: 70vh; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s-2) var(--s-4); padding: var(--s-3);
  background: var(--surface); border: var(--hairline) solid var(--separator); border-radius: var(--r-card, 12px); box-shadow: var(--shadow-raised); }
.case-more-head { margin: 0 0 var(--s-1); font-size: var(--fs-footnote); font-weight: 600; color: var(--label-3, var(--label-2)); text-transform: uppercase; letter-spacing: .03em; }
.case-more-sheet ul { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 2px; padding: 0; margin: 0; overflow: visible; }
.case-more-sheet .case-tab { display: flex; min-height: var(--hit-fine, 36px); padding: 0 var(--s-2); border: 0; margin: 0; border-radius: var(--r-control); background: none; color: var(--label); white-space: normal; }
.case-more-sheet .case-tab:hover { background: var(--fill); }
.case-more-sheet .case-tab.is-current { background: var(--accent-tint, var(--fill)); color: var(--accent-text); font-weight: 600; }
@media (min-width: 880px) { .case-tabs { overflow: visible; } .case-more-sheet { right: 0; } }
.live-details > summary { cursor: pointer; padding: var(--s-1) 0; }
.progress-card.compact .pdetail, .progress-card.compact .pmeta, .progress-card.compact .pnote { display: none; }
.progress-card.compact .plabel { margin: var(--s-1) 0 0; font-size: var(--fs-subhead); font-weight: 500; }
.progress-card.compact .pbig .pct { font-size: var(--fs-headline, 1.0625rem); min-width: 2.6rem; }
.progress-card.compact .pbig .progress { height: 8px; }
.progress-card.compact { padding-block: var(--s-3); }
.progress-card.compact h2 { margin-bottom: var(--s-2); }
.progress-card.compact .psteps { margin-top: var(--s-2); }
.case-body { min-width: 0; }
.case-body .pagehead h2 { font-size: var(--fs-title2); line-height: var(--lh-title2); letter-spacing: -.01em; }
ul.plain { margin: 0; padding-left: 1.25em; }

.case-tiles { list-style: none; margin: 0 0 var(--s-4); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: var(--s-3); }
.case-tile-item { min-width: 0; }
.case-tile { --tone: var(--none); display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); height: 100%; padding: var(--s-4); min-width: 0;
             background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); border-top: 3px solid var(--tone); color: var(--label); text-decoration: none; }
.case-tile:hover { box-shadow: var(--shadow-raised); text-decoration: none; }
.case-tile.tone-done { --tone: var(--done); } .case-tile.tone-working { --tone: var(--working); } .case-tile.tone-stuck { --tone: var(--stuck); } .case-tile.tone-queued { --tone: var(--queued); }
.case-tile-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); width: 100%; }
.case-tile-title { font-family: var(--font-display); font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: 600; }
.case-tile-go { color: var(--accent-text); font-size: var(--fs-title3); line-height: 1; }
.case-tile-text { font-size: var(--fs-subhead); line-height: var(--lh-subhead); overflow-wrap: anywhere; }
.case-tile-legend { overflow-wrap: anywhere; }
.case-tile-figure { font-family: var(--font-display); font-size: var(--fs-title2); line-height: var(--lh-title2); font-weight: 700; margin-top: auto; font-variant-numeric: tabular-nums; }
.segbar { display: flex; gap: 3px; width: 100%; height: 6px; margin-top: auto; }
.seg { flex: 1 1 0; min-width: 2px; border-radius: 3px; background: var(--none); }
.seg.done { background: var(--done); } .seg.stuck { background: var(--stuck); } .seg.working { background: var(--working); } .seg.queued { background: var(--queued); }
.minibar { display: block; width: 100%; height: 8px; margin-top: auto; }
.minidots { display: block; width: 100%; height: auto; margin-top: auto; }
.minidots .spine { stroke: var(--separator); stroke-width: .5; }
.fill-done { fill: var(--done); } .fill-stuck { fill: var(--stuck); } .fill-working { fill: var(--working); } .fill-queued { fill: var(--queued); } .fill-none { fill: var(--none); }
.thumbstrip { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-top: auto; max-width: 100%; }
.thumbstrip img, .thumbmore { width: 56px; height: 42px; border-radius: var(--r-small); object-fit: cover; background: var(--fill); }
.thumbmore { display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-footnote); color: var(--label-2); font-weight: 600; }

.doctools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-bottom: var(--s-3); }
.doctools .filter { flex: 1 1 14rem; min-width: 0; }
.viewtoggle { display: inline-flex; gap: var(--s-1); }
.viewtoggle .chip, .keynav .chip .count { text-decoration: none; }
.viewtoggle .chip { min-height: var(--hit-fine); padding: 0 var(--s-3); }
.viewtoggle .chip.active { background: var(--accent); color: var(--on-accent); }
.keynav .chip .count { font-weight: 400; opacity: .8; margin-left: 4px; }
.docgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: var(--s-3); }
.docgrid > li { display: grid; gap: var(--s-2); align-content: start; padding: var(--s-3); background: var(--surface-2); border-radius: var(--r-control); min-width: 0; }
.docgrid > li.attachment { border-left: 3px solid var(--separator); }
.docgrid > li.empty { grid-column: 1 / -1; background: none; }
.docmeta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

/* Wide tables (the disbursement ledger, 9 columns): `.stack.stack-wide` is set in a smaller type and becomes labelled rows below 900 px of table
   space, so it never needs a sideways scroll. The rules are the `.stack` ones above with a higher threshold. */
table.grid.stack-wide { font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
@container tablewrap (max-width: 899px) {
  table.stack.stack-wide thead { display: none; }
  table.stack.stack-wide, table.stack.stack-wide tbody, table.stack.stack-wide tr, table.stack.stack-wide td { display: block; width: 100%; }
  table.stack.stack-wide tr { border-radius: var(--r-control); margin-bottom: var(--s-3); padding: 0 var(--s-3); background: var(--surface-2); }
  table.stack.stack-wide td {
    display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: var(--s-1) var(--s-2);
    border-bottom: var(--hairline) solid var(--separator); padding: var(--s-3) 0; text-align: right; min-height: var(--hit); white-space: normal;
  }
  table.stack.stack-wide td:last-child { border-bottom: 0; }
  table.stack.stack-wide td::before { content: attr(data-label); color: var(--label-2); font-size: var(--fs-subhead); font-weight: 400; text-align: left; flex-shrink: 0; margin-right: auto; padding-right: var(--s-3); }
  table.stack.stack-wide td[data-label=""]::before { content: none; }
  table.stack.stack-wide td.primary { font-size: var(--fs-headline); }
  table.stack.stack-wide td.primary::before { font-weight: 400; }
  table.stack.stack-wide td[colspan] { justify-content: flex-start; text-align: left; }
  table.stack.stack-wide td[colspan]::before { content: none; }
  table.stack.stack-wide tbody tr:hover td { background: transparent; }
  table.stack.stack-wide td.proc { flex-direction: column; align-items: flex-end; }
  table.stack.stack-wide td.proc::before { align-self: flex-start; margin: 0; }
  table.stack.stack-wide td.proc .progress { width: 100%; }
}

/* Supervision list (ADR-0046): a key date's "Why this date" panel is a second row under it; the pair reads as one card when the table stacks. */
table.grid tbody.kd tr.main td { border-bottom: 0; }
table.grid tbody.kd tr.why td { padding-top: 0; }
table.grid tbody.kd:last-child tr.why td { border-bottom: 0; }
.why-body { display: grid; gap: var(--s-2); padding: var(--s-2) 0; max-width: 56rem; }
.why-body h3 { margin: var(--s-2) 0 0; }
.why-body p { margin: 0; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
@container tablewrap (max-width: 799px) {
  table.stack tbody.kd tr.main { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  table.stack tbody.kd tr.why { border-top-left-radius: 0; border-top-right-radius: 0; }
  table.stack tbody.kd tr.why td { justify-content: flex-start; text-align: left; border-bottom: 0; padding-top: var(--s-2); }
}
/* Firm-knowledge keys are long dotted identifiers with no break points: let them wrap anywhere so a phone never scrolls sideways. */
.notice code, .keylist code, .why-body code, ul.plain code { overflow-wrap: anywhere; word-break: break-word; }

/* Staging preview pages (ADR-0051): a switched-off icon, a phone-width column for the client view, one-column cards on a phone. */
.iconlink[aria-disabled="true"] { opacity: .4; cursor: default; }
.iconlink[aria-disabled="true"]:hover { background: none; }
.preview-phone { max-width: 24rem; margin-inline: auto; }
@media (max-width: 479px) { .tiles.preview-cards { grid-template-columns: 1fr; } }

/* Staging preview pages, 13 Oct amendment (ADR-0051): hub groups, search snippets, the Ask panel, the Outlook inbox, the bundle list and Teams cards. */
.preview-group > .pagehead { margin-bottom: var(--s-3); }
.preview-group > .pagehead h2 { margin: 0; }
.split.preview-walks { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.preview-snippet mark { background: var(--yellow-tint); color: inherit; padding: 0 2px; border-radius: 3px; font-weight: 600; }
.preview-snippets li { margin-bottom: var(--s-2); }
.chat-turn { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.chat-q { background: var(--accent-tint); border-radius: var(--r-control); padding: var(--s-2) var(--s-3); justify-self: end; max-width: min(100%, 40rem); }
.chat-q p { margin: 0; }
.chat-a { background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-3); max-width: min(100%, 48rem); }
.chat-s { margin: 0 0 var(--s-2); overflow-wrap: anywhere; }
.chat-input { display: grid; gap: var(--s-2); margin-top: var(--s-4); }
.chat-input .btn { justify-self: start; }
.mail-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.mail-item { background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-3); min-width: 0; display: grid; gap: var(--s-1); }
.mail-head { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); align-items: baseline; overflow-wrap: anywhere; }
.mail-when { margin-left: auto; }
.mail-subject { font-weight: 600; overflow-wrap: anywhere; }
.mail-suggest { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.bundle-list { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: grid; gap: var(--s-1); }
.bundle-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-2) var(--s-3); min-width: 0; overflow-wrap: anywhere; }
.bundle-row.is-out { opacity: .65; }
.bundle-handle { color: var(--label-2); letter-spacing: -2px; cursor: grab; }
.teams-card { background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-3); min-width: 0; }
.teams-card h3 { margin-top: 0; }
.bundle-row .srcdoc, td.primary .srcdoc { flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }

/* Diary (ADR-0061): a critical date (limitation, a hard court date, an entry marked critical) carries a red bar at the row's start;
   today's card in the week view is outlined. */
tr.critical > td:first-child { box-shadow: inset 3px 0 0 var(--stuck); }
.card.today { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Client view (ADR-0074): the client's page in a phone-width column, on the client's own layout and in the staff preview. */
.client-phone { max-width: 24rem; margin-inline: auto; display: grid; gap: var(--s-3); min-width: 0; }
.client-phone .card { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.client-msg { background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-2) var(--s-3); margin-bottom: var(--s-2); }
.client-msg.is-mine { margin-left: var(--s-6); }
.client-msg p { margin: 0; }
.client-shell { max-width: 30rem; margin-inline: auto; padding: var(--s-4) var(--s-4) var(--s-8); }
.cv-grid { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .cv-grid { grid-template-columns: minmax(0, 24rem) minmax(0, 1fr); align-items: start; } }
.cv-row { border-top: var(--hairline) solid var(--separator); padding: var(--s-2) 0; min-width: 0; overflow-wrap: anywhere; }
.cv-row:first-child { border-top: 0; }
.cv-row.is-off { opacity: .65; }

/* AI search and Ask the case (ADR-0056) */
.chat-s .meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); margin-top: var(--s-1); }
.chat-s blockquote.quote { margin: var(--s-1) 0 0; padding-left: var(--s-2); border-left: 3px solid var(--separator); overflow-wrap: anywhere; }
.chat-a details.about { margin-top: var(--s-2); }
.aisearch-form .filters { margin-bottom: var(--s-2); }
.searchres .hit .wrap { overflow-wrap: anywhere; }

/* Court page (ADR-0062): the dated rows of the "record an order" form sit side by side where there is room. */
.order-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--s-2); padding: var(--s-2) 0; border-bottom: 1px solid var(--separator, transparent); min-width: 0; }
.order-rows { border: 0; padding: 0; margin: 0; min-width: 0; }
/* Letters and precedents (ADR-0063): the letter as composed, with the items a reviewer must look at highlighted. */
.letterpaper { background: var(--surface-2); border-radius: var(--r-control); padding: var(--s-4); max-width: 46rem; min-width: 0; overflow-wrap: anywhere; }
.letterpaper p { margin: 0 0 var(--s-3); }
.letterpaper p.lp-address, .letterpaper p.lp-meta, .letterpaper p.lp-signoff { margin: 0; }
.letterpaper p.lp-subject, .letterpaper p.lp-heading { font-weight: 700; }
.letterpaper p.lp-subject, .letterpaper p.lp-salutation, .letterpaper p.lp-gap { margin-top: var(--s-3); }
.letterpaper p.lp-bullet { padding-left: var(--s-4); text-indent: calc(-1 * var(--s-3)); }
.letterpaper .lp-banner { color: var(--red-text); font-weight: 700; font-size: var(--fs-footnote); margin-bottom: var(--s-3); }
mark.lm-missing, mark.lm-blank { background: var(--yellow-tint); color: inherit; font-weight: 700; border-radius: 3px; padding: 0 2px; }
mark.lm-verify { background: var(--yellow-tint); color: inherit; border-radius: 3px; padding: 0 2px; }
.lm-answer { text-decoration: underline dotted var(--label-3); }
.fieldsrc { display: flex; flex-wrap: wrap; gap: var(--s-1); align-items: center; min-width: 0; }
.letterpaper p.lp-address + p.lp-meta { margin-top: var(--s-3); }
