/*
 * IDEAL GROUP LMS — design system v2 (docs/development/22_LMS_Admin_UI_Design_System.md; spec/57 is the brand basis).
 * Brand green #199A7B is the identity colour; deeper steps of the same hue carry text, controls and the navigation.
 * Supporting hues exist only as categorical tints for icons and figures, never as a second brand colour.
 * Inter is provisional until an official typeface is supplied. All values below are tokens; components use only tokens.
 */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand: one hue, several steps */
  --brand: #199a7b;
  --brand-strong: #13765f;
  --brand-deep: #0e5846;
  --brand-night: #0b2b24;          /* navigation surface */
  --brand-night-2: #103a31;        /* hover on navigation */
  --brand-tint-1: #f2f8f6;
  --brand-tint-2: #e3f2ed;
  --brand-tint-3: #c6e5db;
  --brand-glow: rgba(25, 154, 123, 0.18);

  /* Neutrals: one ink family */
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #14201c;
  --ink-2: #2a3833;
  --ink-muted: #4a5853;
  --ink-faint: #66746f;
  --line: rgba(20, 32, 28, 0.09);
  --line-strong: rgba(20, 32, 28, 0.2);
  --on-brand: #ffffff;
  --on-night: #e4efeb;
  --on-night-muted: #93aaa2;

  /* Status (status only; always with an icon or text) */
  --success: var(--brand-strong);
  --success-tint: var(--brand-tint-2);
  --warning: #8a5a00;
  --warning-tint: #fdf3e0;
  --danger: #b3261e;
  --danger-tint: #fbeceb;
  --info: #1f5f99;
  --info-tint: #e9f1f9;
  --held: #8a5a00;
  --held-tint: #fdf3e0;

  /* Supporting categorical tints (figures and icon chips; never actions) */
  --hue-sky: #2563a8;      --hue-sky-tint: #e6f0fb;
  --hue-amber: #9a5b00;    --hue-amber-tint: #fdf1dd;
  --hue-rose: #b4234a;     --hue-rose-tint: #fde8ee;
  --hue-violet: #5b3fb8;   --hue-violet-tint: #efebfc;

  /* Type */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", SFMono-Regular, Consolas, monospace;
  --fs-label: 0.75rem;     /* 12 */
  --fs-small: 0.8125rem;   /* 13 */
  --fs-ui: 0.875rem;       /* 14 */
  --fs-body: 1rem;         /* 16 */
  --fs-h3: 1rem;
  --fs-h2: 1.125rem;
  --fs-h1: 1.625rem;
  --fs-figure-md: 1.375rem;
  --fs-figure-lg: 1.875rem;
  --fs-figure-xl: 2.625rem;

  /* Space (4 px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* Shape and depth */
  --r-control: 10px;
  --r-card: 16px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(11, 43, 36, 0.05), 0 1px 1px rgba(11, 43, 36, 0.03);
  --shadow-2: 0 10px 30px -12px rgba(11, 43, 36, 0.18), 0 2px 6px rgba(11, 43, 36, 0.05);
  --shadow-3: 0 30px 70px -20px rgba(11, 43, 36, 0.35);
  --ring: 0 0 0 3px var(--brand-glow);

  /* Motion */
  --dur-micro: 140ms;
  --dur-ui: 220ms;
  --dur-panel: 360ms;
  --dur-reveal: 520ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-emph: cubic-bezier(0.16, 1, 0.3, 1);

  /* Layers */
  --z-sticky: 20; --z-header: 30; --z-drawer: 60; --z-modal: 80; --z-toast: 90;

  --nav-width: 264px;
  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  font-feature-settings: "tnum" 1, "cv11" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -0.015em; color: var(--ink); text-wrap: balance; }
h1 { font-size: var(--fs-h1); letter-spacing: -0.022em; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
p { margin: 0 0 var(--s-3); text-wrap: pretty; }
a { color: var(--brand-strong); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: color var(--dur-micro) var(--ease-out); }
a:hover { color: var(--brand-deep); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--s-4); top: -60px; background: var(--surface); padding: var(--s-2) var(--s-3); z-index: var(--z-toast); border-radius: var(--r-control); box-shadow: var(--shadow-2); }
.skip-link:focus { top: var(--s-2); }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

/* Environment banner: always visible outside production. */
.env-banner {
  display: flex; align-items: center; gap: var(--s-2); justify-content: center;
  background: var(--warning-tint); color: var(--warning); border-bottom: 1px solid rgba(138, 90, 0, 0.2);
  font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.01em; padding: 6px var(--s-4); text-align: center;
}

/* Wordmark (placeholder until the high-resolution logo is supplied, spec/57 §0.5). */
.wordmark { display: inline-flex; align-items: center; gap: var(--s-3); color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: 0.02em; }
.wordmark__mark {
  width: 36px; height: 36px; border-radius: 11px; background: var(--brand); display: inline-grid; place-items: center;
  color: var(--on-brand); font-size: 0.85rem; font-weight: 800; letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 16px -6px rgba(25, 154, 123, 0.6);
}
.wordmark__sub { display: block; color: var(--ink-muted); font-weight: 500; font-size: var(--fs-small); letter-spacing: 0; }

/* ---------- Application shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); min-height: calc(100vh - 30px); }
.nav {
  background: var(--brand-night); color: var(--on-night); padding: var(--s-5) var(--s-4) var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-5); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.nav .wordmark { color: #fff; padding: 0 var(--s-2); }
.nav .wordmark__sub { color: var(--on-night-muted); }
.nav__group { display: grid; gap: 2px; }
.nav__heading { margin: 0 0 var(--s-1); padding: 0 var(--s-3); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-night-muted); }
.nav__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: 42px; padding: 0 var(--s-3);
  border-radius: var(--r-control); color: var(--on-night); text-decoration: none; font-weight: 500; font-size: var(--fs-ui);
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.nav__link .icon { color: var(--on-night-muted); transition: color var(--dur-micro) var(--ease-out); }
.nav__link:hover { background: var(--brand-night-2); color: #fff; }
.nav__link:hover .icon { color: #fff; }
.nav__link:active { transform: scale(0.985); }
.nav__link[aria-current="page"] { background: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 8px 20px -10px rgba(25, 154, 123, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.nav__link[aria-current="page"] .icon { color: #fff; }
.nav__link:focus-visible { outline-color: #8ee0c8; }
.nav__foot { margin-top: auto; display: grid; gap: var(--s-3); padding: var(--s-3); border-radius: 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }
.nav__user { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.nav__user-name { color: #fff; font-weight: 600; font-size: var(--fs-ui); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__user-role { color: var(--on-night-muted); font-size: var(--fs-label); }
.nav__actions { display: flex; gap: var(--s-2); }
.nav__actions a, .nav__actions .btn { color: var(--on-night); }
.nav__foot form { margin: 0; }
.nav-scrim { display: none; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-deep) 100%); color: #fff; font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.02em;
}
.avatar--light { background: var(--brand-tint-2); color: var(--brand-deep); }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-header); height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-6); background: rgba(243, 245, 244, 0.86); border-bottom: 1px solid var(--line);
}
@supports (backdrop-filter: blur(8px)) {
  .topbar { background: rgba(243, 245, 244, 0.72); backdrop-filter: saturate(160%) blur(12px); }
}
.topbar__menu { display: none; }
.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-ui); color: var(--ink-muted); min-width: 0; }
.crumbs a { color: var(--ink-muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .icon { width: 14px; height: 14px; color: var(--ink-faint); }
.crumbs__current { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }
.topbar__date { font-size: var(--fs-small); color: var(--ink-muted); white-space: nowrap; }
.topbar__chip { display: inline-flex; align-items: center; gap: var(--s-2); padding: 4px 12px 4px 4px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); font-size: var(--fs-small); font-weight: 600; color: var(--ink); }
.topbar__chip .avatar { width: 28px; height: 28px; font-size: 0.6875rem; }

.main { padding: var(--s-6) var(--s-6) var(--s-8); max-width: 1320px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); }
.page-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.page-head__lead { color: var(--ink-muted); margin: var(--s-2) 0 0; max-width: 72ch; font-size: 0.9375rem; }
.page-head__eyebrow { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-small); font-weight: 600; color: var(--brand-strong); margin-bottom: var(--s-2); }
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* One-time entrance: content settles in once per page; never on scroll, never looping. */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.main > * { animation: rise var(--dur-reveal) var(--ease-emph) both; }
.main > *:nth-child(2) { animation-delay: 40ms; }
.main > *:nth-child(3) { animation-delay: 80ms; }
.main > *:nth-child(4) { animation-delay: 120ms; }
.main > *:nth-child(5) { animation-delay: 160ms; }
.main > *:nth-child(n+6) { animation-delay: 200ms; }

/* ---------- Surfaces ---------- */
.grid { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid > * { min-width: 0; }
.grid--2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid--wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-5); box-shadow: var(--shadow-1); min-width: 0; }
.panel h2 { font-size: var(--fs-h3); margin-bottom: var(--s-4); display: flex; align-items: center; gap: var(--s-2); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.panel__head h2 { margin: 0; }
.panel--narrow { max-width: 560px; }
.panel--flush { padding: 0; overflow: hidden; }
.panel__note { color: var(--ink-muted); font-size: var(--fs-small); }
.panel + .panel, .grid + .panel, .panel + .grid, .notice + .grid, .table-wrap + .panel, .grid + .grid, .stats + .grid, .stats + .panel { margin-top: var(--s-5); }
.kv { display: grid; grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr); gap: var(--s-3) var(--s-5); margin: 0; }
.kv dt { color: var(--ink-muted); font-size: var(--fs-ui); }
.kv dd { margin: 0; font-weight: 550; color: var(--ink); overflow-wrap: anywhere; font-size: var(--fs-ui); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.chip { font-size: var(--fs-label); font-family: var(--mono); color: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px 10px; background: var(--surface-2); }
.mono { font-family: var(--mono); font-size: 0.8125rem; color: var(--ink-2); overflow-wrap: anywhere; letter-spacing: -0.01em; }
.money { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink); letter-spacing: -0.01em; white-space: nowrap; }
.code { font-family: var(--mono); font-size: var(--fs-label); color: var(--ink-faint); }
hr.rule { border: 0; border-top: 1px solid var(--line); margin: var(--s-5) 0; }

/* ---------- Status badges: colour + text (+ dot), never colour alone ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.6875rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 3px 10px; border-radius: var(--r-pill); border: 1px solid transparent; white-space: nowrap; line-height: 1.4;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--success); background: var(--success-tint); border-color: rgba(19, 118, 95, 0.18); }
.badge--held { color: var(--held); background: var(--held-tint); border-color: rgba(138, 90, 0, 0.2); }
.badge--off { color: var(--ink-muted); background: var(--surface-2); border-color: var(--line); }
.badge--danger { color: var(--danger); background: var(--danger-tint); border-color: rgba(179, 38, 30, 0.2); }
.badge--info { color: var(--info); background: var(--info-tint); border-color: rgba(31, 95, 153, 0.2); }
.badge--provisional { color: var(--warning); background: transparent; border: 1px dashed rgba(138, 90, 0, 0.55); }

/* ---------- Tables (stacked cards below tablet width) ---------- */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-1); }
.table-wrap--scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); }
.table th, .table td { text-align: left; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: middle; font-size: var(--fs-ui); }
.table th { color: var(--ink-muted); font-weight: 600; font-size: var(--fs-label); letter-spacing: 0.02em; background: var(--surface-2); white-space: nowrap; }
.table tbody tr { transition: background-color var(--dur-micro) var(--ease-out); }
.table tbody tr:hover { background: var(--brand-tint-1); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td a { font-weight: 600; text-decoration: none; }
.table td a:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: var(--s-4); min-width: 0; }
.field label { font-weight: 600; font-size: var(--fs-ui); color: var(--ink-2); }
.field__hint { color: var(--ink-faint); font-size: var(--fs-small); }
.input, .select {
  width: 100%; min-height: 44px; padding: 0 var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.9375rem;
  transition: border-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
select.input, .select { padding-right: var(--s-6); }
.input::placeholder { color: var(--ink-faint); }
.input:hover, .select:hover { border-color: rgba(20, 32, 28, 0.38); }
.input:focus-visible, .select:focus-visible { outline: none; border-color: var(--brand-strong); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.12); }
.input:disabled { background: var(--surface-2); color: var(--ink-faint); cursor: not-allowed; }
.field__error { display: inline-flex; align-items: center; gap: 6px; color: var(--danger); font-size: var(--fs-small); font-weight: 550; }
.form-grid { display: grid; gap: 0 var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }

/* ---------- Buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-5);
  border-radius: var(--r-control); border: 1px solid transparent; font: inherit; font-size: var(--fs-ui); font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn--primary {
  background: linear-gradient(180deg, #168d71 0%, var(--brand-strong) 100%); color: var(--on-brand);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 16px -8px rgba(19, 118, 95, 0.75);
}
.btn--primary:hover { background: var(--brand-deep); color: var(--on-brand); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px -10px rgba(14, 88, 70, 0.8); }
.btn--quiet { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.btn--quiet:hover { background: var(--brand-tint-1); border-color: rgba(19, 118, 95, 0.35); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--brand-tint-2); }
.btn--block { width: 100%; }
.btn--compact { min-height: 38px; padding: 0 var(--s-4); }
.btn--icon { width: 40px; min-height: 40px; padding: 0; border-radius: 12px; }
.btn--danger { background: var(--surface); color: var(--danger); border-color: rgba(179, 38, 30, 0.45); }
.btn--danger:hover { background: var(--danger-tint); color: var(--danger); border-color: var(--danger); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff; animation: spin 700ms linear infinite; }
.btn--quiet.is-busy::after, .btn--danger.is-busy::after { border-color: var(--line-strong); border-top-color: var(--brand-strong); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Notices ---------- */
.notice {
  display: flex; align-items: flex-start; gap: var(--s-3); border: 1px solid; border-radius: 12px; padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4); font-size: var(--fs-ui); line-height: 1.5; position: relative; overflow-wrap: anywhere;
}
.notice::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: currentColor; }
.notice { padding-left: calc(var(--s-4) + 4px); }
.notice--info { color: var(--info); background: var(--info-tint); border-color: rgba(31, 95, 153, 0.18); }
.notice--ok { color: var(--brand-deep); background: var(--brand-tint-2); border-color: rgba(19, 118, 95, 0.2); }
.notice--danger, .notice--error { color: var(--danger); background: var(--danger-tint); border-color: rgba(179, 38, 30, 0.2); }
.notice--held { color: var(--held); background: var(--held-tint); border-color: rgba(138, 90, 0, 0.22); }

/* ---------- Dashboard: stat tiles (real figures only) ---------- */
.stats { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.stat {
  position: relative; display: grid; gap: var(--s-1); padding: var(--s-4) var(--s-5); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-1); color: var(--ink); text-decoration: none; min-width: 0;
  transition: transform var(--dur-ui) var(--ease-out), box-shadow var(--dur-ui) var(--ease-out), border-color var(--dur-ui) var(--ease-out);
}
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: rgba(19, 118, 95, 0.25); color: var(--ink); }
.stat__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-2); }
.stat__label { font-size: var(--fs-small); color: var(--ink-muted); font-weight: 550; }
.stat__value { font-size: var(--fs-figure-lg); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__sub { font-size: var(--fs-small); color: var(--ink-faint); }
.stat__chip { width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; }
.chip--brand { background: var(--brand-tint-2); color: var(--brand-strong); }
.chip--sky { background: var(--hue-sky-tint); color: var(--hue-sky); }
.chip--amber { background: var(--hue-amber-tint); color: var(--hue-amber); }
.chip--rose { background: var(--hue-rose-tint); color: var(--hue-rose); }
.chip--violet { background: var(--hue-violet-tint); color: var(--hue-violet); }

/* Greeting band: the one inverse surface on the dashboard */
.hello {
  position: relative; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-5);
  padding: var(--s-6); border-radius: 20px; color: #fff; margin-bottom: var(--s-5);
  background: radial-gradient(120% 140% at 100% 0%, rgba(25, 154, 123, 0.55) 0%, rgba(25, 154, 123, 0) 55%), var(--brand-night);
  box-shadow: var(--shadow-2);
}
.hello h1 { color: #fff; font-size: 1.75rem; }
.hello p { color: var(--on-night); margin: var(--s-2) 0 0; max-width: 60ch; }
.hello__meta { display: grid; gap: var(--s-2); justify-items: end; text-align: right; }
.hello__date { font-size: var(--fs-small); color: var(--on-night-muted); }
.hello .badge--ok { background: rgba(255, 255, 255, 0.1); color: #c9f1e3; border-color: rgba(255, 255, 255, 0.18); }

/* Lists inside panels: queues and recent activity */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list__item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list__item:last-child { border-bottom: 0; }
.list__body { min-width: 0; flex: 1; }
.list__title { font-weight: 600; font-size: var(--fs-ui); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__title a { color: inherit; text-decoration: none; }
.list__title a:hover { color: var(--brand-strong); }
.list__meta { font-size: var(--fs-small); color: var(--ink-faint); }
.list__end { margin-left: auto; text-align: right; flex: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-tint-2); }
.dot--denied { background: var(--held); box-shadow: 0 0 0 4px var(--held-tint); }
.dot--failed { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-tint); }

/* ---------- Amount block: the Signature (spec/57) — the figure is the hero ---------- */
.amount { display: grid; gap: var(--s-2); }
.amount__label { font-size: var(--fs-small); font-weight: 600; color: var(--ink-muted); display: flex; align-items: center; gap: var(--s-2); }
.amount__value { font-size: var(--fs-figure-xl); font-weight: 750; letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
.amount__value small { font-size: 0.45em; font-weight: 600; color: var(--ink-muted); letter-spacing: 0; margin-right: 6px; vertical-align: 0.35em; }
.amount__parts { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-top: var(--s-2); padding: 0; list-style: none; }
.amount__part { display: grid; gap: 2px; min-width: 6.5rem; }
.amount__part dt, .amount__part span:first-child { font-size: var(--fs-label); color: var(--ink-muted); display: flex; align-items: center; gap: 6px; }
.amount__part dd, .amount__part strong { margin: 0; font-size: var(--fs-figure-md); font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.swatch { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.swatch--principal { background: var(--brand); }
.swatch--interest { background: var(--hue-sky); }
.swatch--penalty { background: var(--hue-amber); }
.swatch--credit { background: var(--hue-violet); }
.bar { display: flex; height: 8px; border-radius: var(--r-pill); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); margin-top: var(--s-3); }
.bar span { height: 100%; transform-origin: left center; animation: grow var(--dur-panel) var(--ease-emph) both; }
.bar--share { display: block; margin-top: 0; min-width: 6rem; }
.bar--share span { display: block; width: 0; background: var(--brand-strong); }   /* the script sets the width; a zero share stays empty (DEF-056) */
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.hero-card { display: grid; gap: var(--s-5); grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }

/* Allocation rows for posted payments */
.alloc { display: flex; flex-wrap: wrap; gap: 6px; }
.alloc__part { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-label); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- Timeline (history) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.timeline__item { position: relative; display: grid; gap: 2px; padding: 0 0 var(--s-4) 32px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before { content: ""; position: absolute; left: 3px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }
.timeline__item--denied::before { border-color: var(--held); }
.timeline__item--failed::before { border-color: var(--danger); }
.timeline__title { font-weight: 600; font-size: var(--fs-ui); }
.timeline__meta { font-size: var(--fs-small); color: var(--ink-faint); }

/* ---------- Empty, loading ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-2); padding: var(--s-6) var(--s-4); color: var(--ink-muted); }
.empty__icon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-tint-2); color: var(--brand-strong); margin-bottom: var(--s-2); }
.empty__title { font-weight: 650; color: var(--ink); }
.skeleton { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--brand-tint-1) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; min-height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Dialog (confirmations restate exact values) ---------- */
.dialog { border: 0; padding: 0; border-radius: 20px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); }
.dialog::backdrop { background: rgba(11, 43, 36, 0.42); }
@supports (backdrop-filter: blur(2px)) { .dialog::backdrop { backdrop-filter: blur(3px); } }
.dialog[open] { animation: dialog-in var(--dur-panel) var(--ease-emph) both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog__body { padding: var(--s-6) var(--s-6) var(--s-5); }
.dialog__icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-tint-2); color: var(--brand-strong); margin-bottom: var(--s-4); }
.dialog--danger .dialog__icon { background: var(--danger-tint); color: var(--danger); }
.dialog__title { font-size: 1.125rem; margin-bottom: var(--s-2); }
.dialog__text { color: var(--ink-muted); font-size: var(--fs-ui); margin: 0; }
.dialog__summary { margin: var(--s-4) 0 0; display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); padding: var(--s-4); border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.dialog__summary dt { color: var(--ink-muted); font-size: var(--fs-small); }
.dialog__summary dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6) var(--s-5); border-top: 1px solid var(--line); background: var(--surface-2); }

/* ---------- Toast (session status) ---------- */
.toast-stack { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: var(--z-toast); display: grid; gap: var(--s-2); width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: 14px; background: var(--brand-night); color: #fff;
  box-shadow: var(--shadow-3); font-size: var(--fs-ui); animation: toast-in var(--dur-panel) var(--ease-emph) both;
}
.toast .icon { color: #7fdcbf; margin-top: 1px; }
.toast__close { margin-left: auto; background: none; border: 0; color: var(--on-night-muted); cursor: pointer; padding: 2px; border-radius: 6px; }
.toast__close:hover { color: #fff; }
.toast.is-leaving { animation: toast-out var(--dur-ui) var(--ease-out) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Sign-in page ---------- */
.auth { min-height: calc(100vh - 30px); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth__aside {
  position: relative; overflow: hidden; color: var(--on-brand); padding: var(--s-8) var(--s-7); display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-6);
  background: radial-gradient(90% 70% at 85% 10%, rgba(25, 154, 123, 0.6) 0%, rgba(25, 154, 123, 0) 60%), radial-gradient(70% 60% at 0% 100%, rgba(25, 154, 123, 0.28) 0%, rgba(25, 154, 123, 0) 60%), var(--brand-night);
}
.auth__aside .wordmark, .auth__aside .wordmark__sub { color: var(--on-brand); }
.auth__aside .wordmark__sub { color: var(--on-night-muted); }
.auth__statement { font-size: 2.25rem; font-weight: 650; line-height: 1.15; max-width: 16ch; letter-spacing: -0.03em; margin: 0; }
.auth__figure { display: grid; gap: var(--s-2); padding: var(--s-5); border-radius: 18px; max-width: 360px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); }
@supports (backdrop-filter: blur(8px)) { .auth__figure { backdrop-filter: blur(10px); } }
.auth__figure .amount__label { color: var(--on-night-muted); }
.auth__figure .amount__value { color: #fff; font-size: 2.25rem; }
.auth__figure .amount__parts { color: var(--on-night); }
.auth__figure .amount__part span:first-child { color: var(--on-night-muted); }
.auth__figure .amount__part strong { font-size: 1.0625rem; color: #fff; }
.auth__small { color: var(--on-night); font-size: var(--fs-small); max-width: 46ch; margin: 0; }
.auth__main { display: grid; place-items: center; padding: var(--s-7) var(--s-5); }
.auth__card { width: 100%; max-width: 400px; }
.auth__card h1 { margin-bottom: var(--s-1); font-size: 1.875rem; }
.auth__card .page-head__lead { margin-bottom: var(--s-6); }
.auth__card .btn--block { margin-top: var(--s-2); min-height: 48px; }
.auth__foot { margin-top: var(--s-6); font-size: var(--fs-small); color: var(--ink-faint); display: flex; align-items: center; gap: var(--s-2); }

/* ---------- Checkbox groups, matrices, action forms ---------- */
fieldset { border: 0; margin: 0 0 var(--s-4); padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: var(--fs-ui); padding: 0; margin-bottom: var(--s-2); }
.check { display: flex; align-items: center; gap: var(--s-2); min-height: 40px; font-size: var(--fs-ui); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-strong); margin: 0; }
.matrix { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: var(--s-4); }
.matrix__group { border: 1px solid var(--line); border-radius: 12px; padding: var(--s-2) var(--s-3); margin: 0; background: var(--surface-2); }
.matrix__group legend { padding: 0 var(--s-1); margin: 0; font-size: var(--fs-small); color: var(--ink-muted); }
.action-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); border: 1px solid var(--line); border-radius: 14px; padding: var(--s-4); background: var(--surface-2); margin: 0; }
.action-form > .field { margin: 0; flex: 1 1 180px; }
.action-form .input { flex: 1 1 200px; width: auto; min-width: 0; }
.action-form label:not(.visually-hidden) { width: 100%; font-weight: 600; font-size: var(--fs-ui); }
.action-form h3 { width: 100%; font-size: var(--fs-ui); margin-bottom: 0; }
.action-form + .action-form, .panel .action-form + .panel__note { margin-top: var(--s-3); }
.pay-form { display: grid; gap: var(--s-3) var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); align-items: end; padding: var(--s-4); border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); margin: var(--s-4) 0 var(--s-2); }
.pay-form .field { margin: 0; }
.pay-form .btn { grid-column: 1 / -1; justify-self: start; }

.pagination { display: flex; gap: var(--s-2); margin-top: var(--s-4); align-items: center; flex-wrap: wrap; }
details.disclosure { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-1); }
details.disclosure > summary { cursor: pointer; list-style: none; padding: var(--s-4) var(--s-5); font-weight: 650; display: flex; align-items: center; gap: var(--s-2); }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .icon { transition: transform var(--dur-ui) var(--ease-out); }
details.disclosure[open] > summary .icon { transform: rotate(90deg); }
details.disclosure > .disclosure__body { padding: 0 var(--s-5) var(--s-5); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid--2-1, .hero-card { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100%; z-index: var(--z-drawer);
    transform: translateX(-104%); transition: transform var(--dur-panel) var(--ease-emph); box-shadow: var(--shadow-3);
  }
  body.nav-open .nav { transform: none; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: rgba(11, 43, 36, 0.45); opacity: 0; pointer-events: none; transition: opacity var(--dur-panel) var(--ease-out); }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .topbar { padding: 0 var(--s-4); }
  .topbar__menu { display: inline-flex; }
  .topbar__date { display: none; }
  .main { padding: var(--s-5) var(--s-4) var(--s-7); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__aside { padding: var(--s-5) var(--s-4); gap: var(--s-4); }
  .auth__statement { font-size: 1.5rem; }
  .auth__figure { display: none; }
  .hello { padding: var(--s-5); }
  .hello__meta { justify-items: start; text-align: left; }
}
@media (max-width: 720px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: var(--s-2) 0; }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: var(--s-1) var(--s-4); display: grid; grid-template-columns: minmax(0, 8rem) minmax(0, 1fr); gap: var(--s-2); overflow-wrap: anywhere; }
  .table td::before { content: attr(data-label); color: var(--ink-muted); font-size: var(--fs-label); font-weight: 600; }
  .table td.num { text-align: left; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px var(--s-4); }
  .kv dd { margin-bottom: var(--s-2); }
  .topbar__chip span:last-child { display: none; }
  .amount__value { font-size: 2.25rem; }
  .toast-stack { right: var(--s-4); bottom: var(--s-4); }
  .dialog__summary { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .badge, .btn, .panel, .stat { border: 1px solid CanvasText; }
}

/* Two-line cells (title + meta) in tables and lists */
.table .list__title, .table .list__meta, .table .code { display: block; }
.table .list__title { white-space: normal; }
.page-head .badge .icon { width: 13px; height: 13px; }
.badge .icon { margin-left: -2px; }
.badge:has(.icon)::before { display: none; }

/* Review fixes (first visual pass, 20 Oct 2026) */
@media (min-width: 961px) {
  /* the navigation colour runs the full height of the page, not only the first viewport */
  .shell { background: linear-gradient(90deg, var(--brand-night) 0, var(--brand-night) var(--nav-width), transparent var(--nav-width)); }
}
.topbar .topbar__menu { display: none; }
@media (max-width: 960px) { .topbar .topbar__menu { display: inline-flex; } }
.nav__user .list__body { display: grid; min-width: 0; }
.nav__user-name, .nav__user-role { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-1); }
.nav__actions form { display: contents; }
.nav__actions .btn { color: var(--on-night); padding: 0 var(--s-2); min-height: 36px; font-size: var(--fs-small); justify-content: flex-start; }
.nav__actions .btn:hover { background: var(--brand-night-2); color: #fff; }
.stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 185px), 1fr)); }
.grid--2-1 { align-items: start; }

/* Review fixes (second visual pass, 20 Oct 2026) */
.nav__actions { grid-template-columns: 1fr; }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); } .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; } }
td.money { text-align: right; }th.num { text-align: right; }
@media (max-width: 720px) { td.money { text-align: left; } }

/* Contrast fixes (20 Oct 2026): white text needs >= 4.5:1, which #199A7B gives only for large text (3.53:1).
   Text-bearing fills use brand-strong (5.55:1); the brand step stays for marks, rules, dots and the focus glow. */
:root { --ink-faint: #606e69; }   /* 4.88:1 on --bg (was 4.47:1) */
.wordmark__mark, .nav__link[aria-current="page"] { background: var(--brand-strong); }
.avatar { background: linear-gradient(140deg, var(--brand-strong) 0%, var(--brand-deep) 100%); }
.btn--primary { background: linear-gradient(180deg, var(--brand-strong) 0%, #0f6a55 100%); }

/* =====================================================================================================================
   INC-12a UI foundations (owner authorisation of 24 Oct 2026). Provisional visual layer: built on the existing tokens
   only, so a later redesign can restyle these components without touching their markup or behaviour.
   ===================================================================================================================== */

/* DEF-024: in a list row the title and the description stack; they never run together on one line. */
.list__body { display: grid; gap: 2px; }
.list__sub { padding: 0 0 var(--s-3); border-bottom: 1px solid var(--line); }
.list__sub .action-form { padding: var(--s-3); }

/* ---------- Register (P-1): toolbar, table, pager ---------- */
.register { display: grid; gap: var(--s-3); }
.segments + .register { margin-top: var(--s-3); }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-1); margin: 0;
}
.toolbar .input { min-height: 40px; font-size: var(--fs-ui); }
.toolbar__search { position: relative; flex: 1 1 280px; min-width: 0; }
.toolbar__search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); pointer-events: none; }
.toolbar__search .input { padding-left: 36px; }
.toolbar__field { display: grid; gap: 4px; flex: 0 1 170px; min-width: 120px; }
.toolbar__field label { font-size: var(--fs-label); font-weight: 600; color: var(--ink-muted); }
.toolbar__actions { display: flex; gap: var(--s-2); align-items: center; }
.toolbar__count { flex-basis: 100%; margin: 0; font-size: var(--fs-small); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.toolbar__narrowed { color: var(--brand-strong); font-weight: 600; }

.th-sort { padding: 0 !important; }
.th-sort__link { display: flex; align-items: center; gap: 4px; padding: var(--s-3) var(--s-4); color: inherit !important; text-decoration: none !important; font-weight: 600 !important; }
.th-sort.num .th-sort__link { justify-content: flex-end; }
.th-sort__link .icon { opacity: 0.45; transition: opacity var(--dur-micro) var(--ease-out); }
.th-sort__link:hover { color: var(--ink) !important; }
.th-sort__link:hover .icon, .th-sort[aria-sort="ascending"] .icon, .th-sort[aria-sort="descending"] .icon { opacity: 1; color: var(--brand-strong); }
.th-sort[aria-sort="ascending"], .th-sort[aria-sort="descending"] { color: var(--ink); }

.table--wide { min-width: 860px; }
.table__actions { width: 1%; text-align: right; white-space: nowrap; }
.table__empty td { padding: 0; }
.table tbody tr.table__empty:hover { background: transparent; }
.table tfoot th, .table tfoot td { background: var(--surface-2); border-top: 1px solid var(--line-strong); border-bottom: 0; font-size: var(--fs-small); }
.table tfoot th { text-align: left; color: var(--ink-2); }
.table__foot-note { color: var(--ink-muted); font-size: var(--fs-small); }
.table td .badge + .list__meta { display: block; margin-top: 4px; }

/* Row actions: a disclosure menu (keyboard and touch; app.js closes it on an outside click and on Esc). */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__toggle { width: 36px; min-height: 36px; }
.menu[open] > .menu__toggle { background: var(--brand-tint-2); }
.menu__list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: var(--z-sticky); min-width: 200px; margin: 0; padding: var(--s-1); list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-2); text-align: left;
  animation: menu-in var(--dur-ui) var(--ease-emph) both;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.table td a.menu__item, .menu__item {
  display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: 8px; min-height: 40px;
  color: var(--ink); font-weight: 550; font-size: var(--fs-ui); text-decoration: none; white-space: nowrap;
}
.menu__item .icon { color: var(--ink-faint); }
.table td a.menu__item:hover, .menu__item:hover, .menu__item:focus-visible { background: var(--brand-tint-1); text-decoration: none; }

/* Pagination */
.pager { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; align-items: center; }
.pager__link {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 var(--s-2); border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: var(--fs-ui); font-weight: 600; text-decoration: none; font-variant-numeric: tabular-nums;
}
a.pager__link:hover { border-color: rgba(19, 118, 95, 0.35); background: var(--brand-tint-1); color: var(--ink); }
.pager__link.is-current { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.pager__link.is-disabled { opacity: 0.4; }
.pager__gap { padding: 0 4px; color: var(--ink-faint); }

/* Status segments above a register (application status) */
.segments { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.segments__item {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s-3); border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: var(--fs-small); font-weight: 600; text-decoration: none;
}
.segments__item:hover { border-color: rgba(19, 118, 95, 0.35); color: var(--ink); }
.segments__item[aria-current="page"] { background: var(--brand-night); border-color: var(--brand-night); color: #fff; }
.segments__item[aria-current="page"] .tabs__count { background: rgba(255, 255, 255, 0.16); border-color: transparent; color: #fff; }

/* ---------- Record pages (P-2): summary, tabs, drawers ---------- */
.record-context { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-2); margin: var(--s-2) 0 0; color: var(--ink-muted); font-size: var(--fs-ui); }
.record-context a { font-weight: 650; }
.summary { padding: var(--s-4) var(--s-5); }
.summary__grid { display: grid; gap: var(--s-3) var(--s-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); margin: 0; }
.summary__grid dt { font-size: var(--fs-label); color: var(--ink-muted); font-weight: 600; }
.summary__grid dd { margin: 2px 0 0; font-weight: 650; font-size: var(--fs-ui); overflow-wrap: anywhere; }
.summary__note { margin: var(--s-3) 0 0; }

.tabs { margin-top: var(--s-5); }
.tabs__list { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line-strong); margin-bottom: var(--s-4); scrollbar-width: none; }
.tabs__tab {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--s-4); white-space: nowrap; text-decoration: none;
  color: var(--ink-muted); font-weight: 600; font-size: var(--fs-ui); border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out);
}
.tabs__tab:hover { color: var(--ink); }
.tabs__tab[aria-selected="true"] { color: var(--brand-deep); border-bottom-color: var(--brand-strong); }
.tabs__count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: 0.6875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tabs__tab[aria-selected="true"] .tabs__count { background: var(--brand-tint-2); border-color: transparent; color: var(--brand-deep); }
.tabs.is-enhanced .tabs__panel[hidden] { display: none; }
.tabs.is-enhanced .tabs__panel + .tabs__panel { margin-top: 0; }
.tabs__panel:focus { outline: none; }
.panel__head--pad { padding: var(--s-4) var(--s-5) 0; }
.panel__note--pad { padding: 0 var(--s-5) var(--s-4); margin: var(--s-3) 0 0; }
.panel--flush .table th:first-child, .panel--flush .table td:first-child { padding-left: var(--s-5); }

/* Drawer: a side panel for one focused task (post a payment, change a status). Without JavaScript it opens through :target. */
.drawer { position: fixed; inset: 0; z-index: var(--z-modal); display: none; justify-content: flex-end; background: rgba(11, 43, 36, 0.42); }
.drawer:target, .drawer.is-open { display: flex; animation: fade-in var(--dur-ui) var(--ease-out) both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.drawer__panel {
  width: min(520px, 100vw); height: 100%; background: var(--surface); box-shadow: var(--shadow-3); display: flex; flex-direction: column; overflow-y: auto;
  animation: drawer-in var(--dur-panel) var(--ease-emph) both;
}
@keyframes drawer-in { from { transform: translateX(32px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-4); border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-size: 1.125rem; margin: 0; }
.drawer__head .panel__note { margin: var(--s-1) 0 0; }
.drawer__body { padding: var(--s-5); display: grid; gap: var(--s-2); align-content: start; }
.drawer__body .form__actions { margin-top: var(--s-3); }
body.drawer-open { overflow: hidden; }

/* ---------- Forms (P-4) ---------- */
.form { display: grid; gap: var(--s-5); max-width: 880px; }
.form__section { margin: 0; padding: 0 0 var(--s-5); border-bottom: 1px solid var(--line); }
.form__section:last-of-type { border-bottom: 0; padding-bottom: 0; }
.form__legend { display: grid; gap: 2px; margin-bottom: var(--s-4); font-size: var(--fs-h3); font-weight: 650; color: var(--ink); }
.form__help { font-size: var(--fs-small); font-weight: 400; color: var(--ink-muted); }
.form__grid { display: grid; gap: 0 var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.form__note { margin: 0; color: var(--ink-muted); font-size: var(--fs-small); }
.form__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); }
.req { color: var(--danger); font-weight: 700; margin-left: 2px; }
.opt { color: var(--ink-faint); font-weight: 400; font-size: var(--fs-small); margin-left: 4px; }
.input--area { min-height: 96px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: 1.5; }
.notice[data-autofocus]:focus { outline: 2px solid var(--danger); outline-offset: 2px; }

/* ---------- Roles: one disclosure per role ---------- */
details.role + details.role { margin-top: var(--s-3); }
.role > summary { flex-wrap: wrap; }
.role__name { font-size: var(--fs-h3); }
.role__count { margin-left: auto; font-size: var(--fs-small); font-weight: 500; color: var(--ink-muted); }

/* ---------- Collapsible sidebar (desktop). The preference is a display cookie only. ---------- */
.nav__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.nav__collapse { color: var(--on-night-muted); width: 34px; min-height: 34px; }
.nav__collapse:hover { background: var(--brand-night-2); color: #fff; }
@media (min-width: 961px) {
  body.nav-collapsed { --nav-width: 76px; }
  body.nav-collapsed .nav { padding-left: var(--s-3); padding-right: var(--s-3); }
  body.nav-collapsed .nav__top { flex-direction: column; }
  body.nav-collapsed .nav .wordmark { padding: 0; }
  body.nav-collapsed .nav__label, body.nav-collapsed .wordmark__sub { display: none; }
  body.nav-collapsed .nav__heading { font-size: 0; height: 1px; margin: var(--s-1) var(--s-2) var(--s-2); background: rgba(255, 255, 255, 0.12); padding: 0; }
  body.nav-collapsed .nav__link { justify-content: center; padding: 0; }
  body.nav-collapsed .nav__foot { padding: var(--s-2); justify-items: center; }
  body.nav-collapsed .nav__user { justify-content: center; }
  body.nav-collapsed .nav__actions .btn { justify-content: center; padding: 0; }
  body.nav-collapsed .nav__collapse .icon { transform: scaleX(-1); }
}
@media (max-width: 960px) { .nav__collapse { display: none; } }

/* ---------- Responsive: registers and records on small screens ---------- */
@media (max-width: 720px) {
  .toolbar { padding: var(--s-3); }
  .toolbar__field { flex: 1 1 140px; }
  .table--wide { min-width: 0; }
  .table td.table__actions { display: flex; justify-content: flex-end; width: 100%; }
  .table td.table__actions::before { content: none; }
  .table tfoot, .table tfoot tr, .table tfoot th, .table tfoot td { display: block; width: 100%; }
  .table tfoot td::before { content: none; }
  /* Report totals: each figure in the footer keeps its label (INC-R1). */
  .table--totals tfoot td[data-label] { display: grid; grid-template-columns: minmax(0, 8rem) minmax(0, 1fr); gap: var(--s-2); }
  .table--totals tfoot td[data-label]::before { content: attr(data-label); color: var(--ink-muted); font-size: var(--fs-label); font-weight: 600; }
  .table td.table__foot-note { display: block; }
  .pager { justify-content: center; }
  .drawer__panel { width: 100vw; }
  .form__actions .btn { flex: 1 1 auto; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1 1 auto; }
  .summary__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (forced-colors: active) {
  .tabs__tab[aria-selected="true"] { border-bottom-color: Highlight; }
}
.js .drawer:target:not(.is-open) { display: none; }

/* INC-12a review fixes (24 Oct 2026, first screenshot pass) */
.menu__list.is-floating { position: fixed; right: auto; z-index: var(--z-drawer); }
.table--wide td > a:first-child, .table time { white-space: nowrap; }
.form__grid, .form-grid { align-items: start; }
.field { align-content: start; }
/* The entrance animation must not keep a transform after it ends: a lingering transform makes the section the
   containing block for fixed-position layers (row menus would be offset). Same visual, no lingering transform. */
.main > * { animation-fill-mode: backwards; }

/* ---------- INC-R2a review fixes (DEF-032) ---------- */
/* Report tables: headers may wrap; figures, dates, codes and badges never do; tighter cells on narrower screens. */
.table--report th { white-space: normal; vertical-align: bottom; }
.table--report tbody th, .table--report tfoot th { white-space: nowrap; vertical-align: middle; }
.table--report th, .table--report td { padding-left: var(--s-3); padding-right: var(--s-3); }
.table--report .money, .table--report .mono, .table--report .badge, .table--report .nowrap { white-space: nowrap; }
@media (max-width: 1100px) {
  .table--report th, .table--report td { padding-left: var(--s-2); padding-right: var(--s-2); }
}
/* The row's identity stays in view while a wide table scrolls sideways. */
.table--sticky > * > tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: inset -1px 0 0 var(--line); }
.table--sticky > thead > tr > :first-child, .table--sticky > tfoot > tr > :first-child { background: var(--surface-2); }
.table--sticky > tbody > tr:hover > :first-child { background: var(--brand-tint-1); }
/* A table wider than its panel (app.js adds the frame): it says so in words, shows an edge cue on each side that has
   more columns, and its panel is a labelled region that scrolls with the arrow keys. Without JavaScript it scrolls. */
.scroll-frame { min-width: 0; }
.scroll-frame__body { position: relative; }
.scroll-hint { display: none; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2); color: var(--ink-2); font-size: var(--fs-small); }
.scroll-frame.is-overflowing > .scroll-hint { display: flex; }
.scroll-frame__edge { position: absolute; top: 1px; bottom: 1px; width: 36px; display: none; align-items: center; justify-content: center; padding: 0;
  border: 0; color: var(--brand-strong); cursor: pointer; z-index: 2; }
.scroll-frame__edge--right { right: 1px; border-radius: 0 var(--r-card) var(--r-card) 0; background: linear-gradient(to left, var(--surface) 35%, transparent); }
.scroll-frame__edge--left { left: 1px; border-radius: var(--r-card) 0 0 var(--r-card); background: linear-gradient(to right, var(--surface) 35%, transparent); }
.scroll-frame.has-more-right .scroll-frame__edge--right, .scroll-frame.has-more-left .scroll-frame__edge--left { display: flex; }
.scroll-frame.is-overflowing .table-wrap--scroll:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* The left cue would cover the pinned first column; a sticky table shows only the right cue. */
.scroll-frame--sticky .scroll-frame__edge--left { display: none !important; }
@media (max-width: 720px) {
  .table--sticky > * > tr > :first-child { position: static; box-shadow: none; }
  .scroll-frame .scroll-hint, .scroll-frame .scroll-frame__edge { display: none !important; }
}
/* A person's name stays on one line in a report table that scrolls; on a phone card it wraps. */
.table--report .person { white-space: nowrap; }
@media (max-width: 720px) { .table--report .person { white-space: normal; } }
/* The edge cue carries a visible control shape, not only a fade. */
.scroll-frame__edge .icon { width: 28px; height: 28px; padding: 5px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-1); }
/* A payment dated after the as-of date of a historical position: listed, marked, not counted. */
.table tr.is-after td { color: var(--ink-muted); }
.table tr.is-after td .badge { display: table; margin-top: 4px; }

/* ---------- R2b: PAR trend chart (one series; the table is the accessible version) ---------- */
.trend-chart { margin: 0; }
.trend-chart svg { display: block; width: 100%; height: auto; max-height: 260px; }
.column-chart__bar { fill: var(--brand-strong); }
.trend-chart__grid { stroke: var(--line-strong); stroke-width: 1; }
.trend-chart__axis { fill: var(--ink-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.trend-chart__line { fill: none; stroke: var(--brand-strong); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart__point { fill: var(--brand-strong); stroke: var(--surface); stroke-width: 2; }
.trend-chart__point--to-date { fill: var(--surface); stroke: var(--brand-strong); stroke-width: 2; }
@media (forced-colors: active) {
  .trend-chart__line, .trend-chart__point--to-date { stroke: CanvasText; }
  .trend-chart__point { fill: CanvasText; }
}
