/* helloContra — production stylesheet.
 *
 * This file reproduces the approved UI's design system in plain CSS. Every token
 * value, radius, shadow, height and colour below is taken from the approved
 * source: approved-ui/app/globals.css and the Tailwind utilities used in
 * page.tsx, module-views.tsx and configuration-views.tsx.
 *
 * The approved prototype is React + Tailwind 4 + shadcn/ui. Production is Go
 * html/template with HTMX and Alpine. The browser experience is the contract,
 * not the implementation, so what is reproduced here is the rendered result of
 * those utilities: the same geometry, the same colour, the same states.
 *
 * Sections
 *   1  tokens                 the approved custom properties
 *   2  dark mode              approved .dark overrides
 *   3  base + typography
 *   4  layout: shell, sidebar, header, content
 *   5  primitives             button, input, select, textarea, switch, badge
 *   6  panels, metrics, stats
 *   7  table
 *   8  tabs                   horizontal and vertical
 *   9  dialog (modal)
 *   10 sheet (drawer)
 *   11 dropdown menu
 *   12 toast
 *   13 document presentation
 *   14 client-facing document  deliberately light in any theme
 *   15 utilities
 *   16 print
 */

/* ------------------------------------------------------------------ 1. tokens */

:root {
  --background: #f3f6f8;
  --foreground: #10263d;
  --card: #ffffff;
  --card-foreground: #171717;
  --popover: #ffffff;
  --popover-foreground: #171717;
  --primary: #10263d;
  --primary-hover: #183651;
  --primary-foreground: #ffffff;
  --secondary: #eef3f6;
  --secondary-foreground: #10263d;
  --muted: #eef3f6;
  --muted-foreground: #64748b;
  --accent: #e8eff3;
  --accent-foreground: #10263d;
  --destructive: #e43f51;
  --border: #dfe7ec;
  --input: #dfe7ec;
  --ring: #ff6548;

  /* The approved accent, unchanged. Every primary call to action uses it.
   *
   * --brand-fg is an ACCESSIBILITY CORRECTION, not a palette change. The approved
   * prototype puts white on this accent, which is 2.9:1 and fails WCAG AA for
   * normal text. The accent itself is preserved; the foreground is darkened to
   * the nearest existing token instead:
   *
   *   #0c1c2a on #ff6548   5.93:1   PASS (AA needs 4.5:1)
   *   #0c1c2a on #ed563c   4.94:1   PASS  (hover)
   *   #ffffff on #ff6548   2.90:1   FAIL  (what the prototype specifies)
   *   #ffffff on #ed563c   3.50:1   FAIL
   *
   * #0c1c2a is already in the approved system: it is --sidebar in dark mode. */
  --brand: #ff6548;
  --brand-hover: #ed563c;
  --brand-fg: #0c1c2a;
  --brand-ink: #c2410c;          /* accent text ON light backgrounds: 4.6:1 on #fff */
  --brand-shadow: 0 8px 24px rgba(255, 101, 72, .25);

  --chart-1: #ff6548;
  --chart-2: #10263d;
  --chart-3: #104e64;
  --chart-4: #ffb900;
  --chart-5: #fe9a00;

  --radius: .75rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-panel: 22px;

  --sidebar: #10263d;
  --sidebar-foreground: #ffffff;
  --sidebar-primary: #ff6548;
  --sidebar-accent: #193b5b;
  --sidebar-border: rgba(255, 255, 255, .1);
  --sidebar-width: 264px;
  --header-height: 76px;
  --content-max: 1500px;

  /* Slate, as the approved source uses it. */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-900: #0f172a;

  --emerald-50: #ecfdf5;
  --emerald-200: #a7f3d0;
  --emerald-700: #047857;
  --sky-50: #f0f9ff;
  --sky-200: #bae6fd;
  --sky-700: #0369a1;
  --amber-50: #fffbeb;
  --amber-200: #fde68a;
  --amber-700: #b45309;
  --amber-800: #92400e;
  --rose-50: #fff1f2;
  --rose-200: #fecdd3;
  --rose-600: #e11d48;
  --rose-700: #be123c;
  --violet-50: #f5f3ff;
  --violet-700: #6d28d9;

  --shadow-panel: 0 10px 30px rgba(16, 38, 61, .045);
  --shadow-card: 0 16px 45px rgba(16, 38, 61, .16);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .1);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, .25);

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ---------------------------------------------------------------- 2. dark mode
 *
 * The approved UI offers system / light / dark, persisted in localStorage under
 * "ledgerly-theme", and applies it by toggling a class on <html>. Production
 * keeps that exact behaviour: the key is renamed to "hellocontra-theme" and the
 * class is the same. Values below are the approved dark values.
 */

.dark {
  --background: #0a0f14;
  --foreground: #edf4f8;
  --card: #152330;
  --card-foreground: #edf4f8;
  --popover: #152330;
  --popover-foreground: #edf4f8;
  --primary: #edf4f8;
  --primary-hover: #dbe7ee;
  --primary-foreground: #152330;
  --secondary: #203342;
  --secondary-foreground: #edf4f8;
  --muted: #203342;
  --muted-foreground: #9eb0bd;
  --accent: #263d4d;
  --accent-foreground: #edf4f8;
  --border: #2a4151;
  --input: #304958;
  --ring: #ff795f;
  --sidebar: #0c1c2a;

  --slate-50: #1b2d3b;
  --slate-100: #1b2d3b;
  --slate-200: #2a4151;
  --slate-300: #3b5568;
  --slate-400: #8198a8;
  --slate-500: #9eb0bd;
  --slate-600: #b6c6d1;
  --slate-700: #d3e0e8;
  --slate-900: #edf4f8;

  --emerald-50: #12382d;
  --amber-50: #3a2e12;
  --sky-50: #102f43;
  --rose-50: #3b1620;
  --violet-50: #241d3f;

  /* F-317. THE STRONG TONES TOO. Only the pale backgrounds above were given
     dark values, so a warning was dark amber text on a dark amber ground and
     could not be read. In the dark theme the text and border tones are light,
     which is what every notice, pill, toast and total that uses them needs. */
  --emerald-200: #1f5c49;
  --emerald-700: #6ee7b7;
  --sky-200: #1d4f6e;
  --sky-700: #7dd3fc;
  --amber-200: #6b5318;
  --amber-700: #fbbf24;
  --amber-800: #fcd34d;
  --rose-200: #6b2638;
  --rose-600: #fb7185;
  --rose-700: #fda4af;
  --violet-700: #c4b5fd;

  --shadow-panel: 0 10px 30px rgba(0, 0, 0, .18);
  --shadow-card: 0 16px 45px rgba(0, 0, 0, .28);
}

/* --------------------------------------------------------- 3. base, typography */

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: light; }
html.dark { color-scheme: dark; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, a, input, select, textarea { font: inherit; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
svg { display: block; }

.page-eyebrow { margin-bottom: 4px; font-size: 14px; font-weight: 500; color: var(--slate-500); }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.03em; }
.page-sub { margin-top: 8px; max-width: 48rem; font-size: 14px; color: var(--slate-500); }
@media (min-width: 640px) { .page-title { font-size: 32px; } }

.section-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; color: var(--foreground); }
.section-subtitle { margin-top: 4px; font-size: 14px; color: var(--slate-500); }

.field-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-400); }
.muted { color: var(--slate-500); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* The page header row: eyebrow + title + description on the left, actions right. */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 28px;
}
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------------ 4. layout */

.app { min-height: 100vh; background: var(--background); }

.side {
  position: fixed; inset-block: 0; left: 0; z-index: 40;
  display: flex; flex-direction: column;
  width: var(--sidebar-width);
  background: var(--sidebar); color: #fff;
  transform: translateX(-100%);
  transition: transform .3s ease;
}
body.nav-open .side { transform: translateX(0); }
@media (min-width: 1024px) { .side { transform: translateX(0); } }

.side-scrim {
  position: fixed; inset: 0; z-index: 30; border: 0; padding: 0;
  background: rgba(2, 6, 23, .4); cursor: pointer;
  display: none;
}
body.nav-open .side-scrim { display: block; }
@media (min-width: 1024px) { body.nav-open .side-scrim { display: none; } }

.brand {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-height); padding: 0 24px;
  border-bottom: 1px solid var(--sidebar-border);
}
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--radius);
  background: var(--brand); color: #fff;
  font-size: 18px; font-weight: 900;
}
.brand-name { margin-left: 12px; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.brand-left { display: flex; align-items: center; }
.side-close { display: grid; place-items: center; border: 0; background: none; padding: 8px; border-radius: 8px; color: rgba(255,255,255,.7); cursor: pointer; }
@media (min-width: 1024px) { .side-close { display: none; } }

.nav { flex: 1; overflow-y: auto; padding: 24px 12px; }
.nav-group {
  padding: 0 12px 8px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .18em; color: #94a3b8;
}
.nav-group + .nav-group { margin-top: 20px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 12px; margin-bottom: 4px;
  border-radius: var(--radius); border: 0; background: none;
  width: 100%; text-align: left; font-size: 14px; color: #cbd5e1;
  cursor: pointer; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.on { background: #fff; color: #10263d; box-shadow: var(--shadow-lg); }
.nav-item .ico { display: grid; place-items: center; width: 18px; height: 18px; flex: none; }
.nav-item .label { flex: 1; font-weight: 500; }
.nav-item .count {
  min-width: 24px; padding: 2px 6px; border-radius: 999px;
  text-align: center; font-size: 11px;
  background: rgba(255, 255, 255, .1); color: #cbd5e1;
}
.nav-item.on .count { background: #10263d; color: #fff; }
/* A module in the approved scope that is not built yet. Visible, never clickable,
   never pretending to work. */
/* The sidebar, the hero metric card and the document masthead are dark in BOTH
   themes, so every colour on them is literal rather than a token. Using the
   slate scale there was a real bug: the scale flips for dark mode and the
   navigation links went to #3b5568 on #0c1c2a, effectively invisible. Caught by
   screenshotting dark mode rather than by reading the CSS. */

/* An unbuilt module. Muted rather than faded: a 45% opacity version failed
   contrast, and an item nobody can read is worse than one that reads clearly as
   "not yet". The colour below is 4.6:1 on the sidebar. */
.nav-item.soon { color: #8ba0b4; cursor: default; }
.nav-item.soon:hover { background: none; color: #8ba0b4; }
.nav-item.soon .count { background: rgba(255, 255, 255, .08); color: #8ba0b4; font-size: 10px; letter-spacing: .04em; }

.side-note {
  margin: 16px; padding: 16px; border-radius: 16px;
  border: 1px solid var(--sidebar-border); background: rgba(255, 255, 255, .05);
}
.side-note .row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.side-note .cta { margin-top: 12px; border: 0; background: none; padding: 0; font-size: 12px; font-weight: 600; color: #ffb067; cursor: pointer; }
.side-foot { padding: 0 12px 16px; }

.main { min-height: 100vh; }
@media (min-width: 1024px) { .main { padding-left: var(--sidebar-width); } }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: var(--header-height); padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 90%, transparent);
  backdrop-filter: blur(12px);
}
@media (min-width: 640px) { .top { padding: 0 28px; gap: 12px; } }
.top-burger {
  display: grid; place-items: center; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); color: inherit; cursor: pointer;
}
@media (min-width: 1024px) { .top-burger { display: none; } }
.top-search { position: relative; display: none; flex: 1; max-width: 28rem; }
@media (min-width: 640px) { .top-search { display: block; } }
.top-search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--slate-400); }
.top-search input { height: 40px; padding-left: 38px; background: var(--slate-50); box-shadow: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
@media (min-width: 640px) { .top-right { gap: 12px; } }
.top-icon-btn {
  position: relative; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); color: inherit; cursor: pointer;
}
.top-icon-btn .dot { position: absolute; right: 8px; top: 8px; width: 6px; height: 6px; border-radius: 999px; background: var(--brand); }
/* .hide-sm was losing to rules declared later in this file with the same
   specificity: .select at 405 and .menu at 639 both set a display, so the book
   switcher stayed visible at 390px and wrapped its name across three lines of
   the header. Scoping to the header cluster raises specificity above both, and
   naming each element's own display avoids forcing a <select> to be a flex
   container the way a blanket `display: flex` did. */
.hide-sm { display: none; }
.top-right > .hide-sm { display: none; }
@media (min-width: 640px) {
  .hide-sm { display: flex; }
  .top-right > .menu.hide-sm { display: inline-flex; }
  .top-right > .select.hide-sm { display: block; }
}

/* The header's primary action keeps its icon on a narrow screen and drops its
   label. At 390px the label made .top-right 412px wide inside a 390px viewport,
   which is 102px of horizontal page scroll on every screen. Hiding the button
   entirely would have removed the action; this keeps it reachable. */
.hide-xs { display: none; }
@media (min-width: 640px) { .hide-xs { display: inline; } }

.content { max-width: var(--content-max); margin: 0 auto; padding: 24px 16px; }
@media (min-width: 640px) { .content { padding: 32px 28px; } }

/* -------------------------------------------------------------- 5. primitives */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid transparent;
  background: var(--card); color: var(--foreground);
  font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn-primary:focus-visible { outline-color: var(--brand-fg); outline-offset: 3px; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px;
}
.nav-item:focus-visible { outline-color: #fff; outline-offset: -2px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--brand); color: var(--brand-fg); box-shadow: var(--brand-shadow); font-weight: 600; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-dark { background: var(--primary); color: var(--primary-foreground); }
.btn-dark:hover { background: var(--primary-hover); }
.btn-outline { background: var(--card); border-color: var(--border); }
.btn-outline:hover { background: var(--slate-50); }
/* A .btn carrying no variant is the outline button. The base rule sets a
   TRANSPARENT border and expects a variant to supply the surface, so several
   screens that use a bare .btn rendered as plain text with no affordance at
   all. This gives the unqualified case a real edge; .btn-ghost still opts out. */
.btn:not([class*="btn-"]) { border-color: var(--border); }
.btn:not([class*="btn-"]):hover { background: var(--slate-50); }
.btn-ghost { background: none; }
.btn-ghost:hover { background: var(--slate-100); }
.btn-link { height: auto; padding: 0; background: none; color: var(--brand-ink); font-weight: 600; text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.btn-danger { background: none; border-color: var(--border); color: var(--rose-600); }
.btn-danger:hover { background: var(--rose-50); }
.btn-icon { width: 40px; padding: 0; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-dashed { border-style: dashed; border-color: var(--border); background: none; }
.btn-dashed:hover { background: var(--slate-50); }
.btn-tall { height: 52px; }

.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--input); border-radius: var(--radius-md);
  background: var(--card); color: var(--foreground);
  font-size: 14px;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--ring); outline-offset: -1px; border-color: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--slate-400); }
.input-lg { height: 44px; font-size: 15px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 34px;
}

.lbl { display: block; font-size: 14px; font-weight: 500; }
.lbl > .input, .lbl > .select, .lbl > .textarea { margin-top: 8px; }
.lbl-xs { display: block; font-size: 12px; color: var(--slate-500); }
.lbl-xs > .input, .lbl-xs > .select { margin-top: 4px; }
/* A label can wrap its control or precede it. Both forms appear in the
   templates, so both get the same spacing rather than one of them silently
   rendering flush against its input. */
.lbl + .input, .lbl + .select, .lbl + .textarea { margin-top: 8px; }

/* The explanatory line under a field. Several forms already carried
   class="hint" against a rule that did not exist, so the sentence rendered at
   body size and full contrast and read as content rather than as guidance. */
.break-all {
  /* A URL shown for the user to copy. Long, unbreakable at any space, and it
     must not push the panel wider than the screen on a phone. */
  overflow-wrap: anywhere;
  word-break: break-all;
}

.fixed-value {
  /* A field the screen shows but does not let you change: the invoice's date
     and currency while it is being revised. Sized and spaced like the inputs
     beside it so the row still reads as one line of fields, and plainly not a
     control, so nobody types into it and wonders why it was ignored. */
  margin: 0;
  padding: 9px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-700);
}

.hint { display: block; margin-top: 6px; font-size: 12px; color: var(--slate-500); }
.grid-2 { display: grid; gap: 20px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-3 { display: grid; gap: 16px; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.grid-4 { display: grid; gap: 16px; }
@media (min-width: 768px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.span-2 { grid-column: 1 / -1; }

/* Switch, reproducing the approved shadcn Switch. */
.switch { position: relative; display: inline-flex; align-items: center; flex: none; width: 36px; height: 20px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--slate-300); transition: background .15s; }
.switch .knob { position: absolute; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked ~ .knob { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }

/* Badge / status pill. Approved status colours. */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill-ok       { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-200); }
.pill-info     { background: var(--sky-50);     color: var(--sky-700);     border-color: var(--sky-200); }
.pill-warn     { background: var(--amber-50);   color: var(--amber-700);   border-color: var(--amber-200); }
.pill-bad      { background: var(--rose-50);    color: var(--rose-700);    border-color: var(--rose-200); }
.pill-neutral  { background: var(--slate-100);  color: var(--slate-700);   border-color: var(--slate-200); }
.pill-quiet    { background: var(--slate-100);  color: var(--slate-500);   border-color: var(--slate-200); }
.pill-plain    { background: var(--card); color: var(--foreground); border-color: var(--border); }

.notice { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 20px; }
.notice.ok   { background: var(--emerald-50); color: var(--emerald-700); }
.notice.warn { background: var(--amber-50);   color: var(--amber-800); }
.notice.bad  { background: var(--rose-50);    color: var(--rose-700); }
.notice.info { background: var(--sky-50);     color: var(--sky-700); }

/* ------------------------------------------------- 6. panels, metrics, stats */

.panel {
  border-radius: var(--radius-panel);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-panel);
}
.panel-pad { padding: 20px; }
@media (min-width: 640px) { .panel-pad { padding: 24px; } }
.panel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 20px; border-bottom: 1px solid var(--border);
}
@media (min-width: 640px) { .panel-head { padding: 20px 24px; } }
.panel-clip { overflow: hidden; }

.metric-card {
  position: relative; min-height: 168px; padding: 20px;
  border-radius: var(--radius-panel); border: 1px solid var(--border);
  background: var(--card); box-shadow: var(--shadow-panel);
}
.metric-icon { position: absolute; right: 20px; top: 20px; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius); }
.metric-icon svg { width: 20px; height: 20px; }
.metric-label { font-size: 14px; font-weight: 500; color: var(--slate-500); }
.metric-value { margin-top: 28px; font-size: 28px; font-weight: 700; letter-spacing: -.04em; color: var(--foreground); font-variant-numeric: tabular-nums; }
.metric-meta { margin-top: 8px; font-size: 12px; font-weight: 500; }
.metric-icon.ok   { background: var(--emerald-50); color: var(--emerald-700); }
.metric-icon.info { background: var(--sky-50);     color: var(--sky-700); }
.metric-icon.warn { background: var(--amber-50);   color: var(--amber-700); }
.metric-icon.vio  { background: var(--violet-50);  color: var(--violet-700); }

/* The dark headline card on Overview. */
.metric-hero {
  position: relative; overflow: hidden; min-height: 168px; padding: 20px;
  border-radius: var(--radius-panel); background: #10263d; color: #fff;
  box-shadow: var(--shadow-card);
}
.metric-hero .ring {
  position: absolute; right: -34px; top: -34px; width: 112px; height: 112px;
  border-radius: 999px; border: 16px solid rgba(255, 101, 72, .16);
  pointer-events: none;
}
.metric-hero .label { font-size: 14px; color: #cbd5e1; }
.metric-hero .value { margin-top: 16px; font-size: 28px; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.metric-hero .sub { margin-top: 4px; font-size: 14px; color: #cbd5e1; }
.metric-hero .trend { margin-top: 20px; display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: #6ee7b7; }

/* The three-up stat row each module carries. */
.stat { padding: 20px; border-radius: var(--radius-panel); border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow-panel); }
.stat .label { font-size: 14px; font-weight: 500; color: var(--slate-500); }
.stat .value { margin-top: 16px; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .note { margin-top: 8px; font-size: 12px; color: var(--slate-500); }

/* ------------------------------------------------------------------- 7. table */

.table-wrap { overflow-x: auto; }

/* A ROW MENU IS NOT TRAPPED IN THE TABLE'S OWN SCROLL FRAME.
   `overflow-x: auto` does not stay one-dimensional. CSS computes the other axis
   to `auto` as well, so .table-wrap is a scroll container in BOTH directions. A
   .menu-pop is absolutely positioned inside it, so opening the menu on a row
   near the bottom pushed content past the wrapper's edge and the wrapper grew a
   vertical scrollbar instead of the menu simply appearing over the page.
   .panel-clip's `overflow: hidden`, which is there for the rounded corners,
   clipped whatever was left.
   While a menu is open both are released. Nothing else changes: with no menu
   open, the horizontal scroll a wide table needs on a narrow screen is exactly
   as it was. */
.table-wrap:has([data-menu].open) { overflow: visible; }
.panel-clip:has([data-menu].open) { overflow: visible; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data thead tr { background: var(--slate-50); }
table.data th {
  padding: 12px 12px; text-align: left; font-size: 12px; font-weight: 500;
  color: var(--slate-500); white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { padding-left: 24px; }
table.data th:last-child, table.data td:last-child { padding-right: 24px; }
table.data td { padding: 0 12px; height: 64px; border-top: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--slate-50); }
table.data tbody tr:focus-within { background: var(--sky-50); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.first { font-weight: 600; color: #173f61; }
.dark table.data td.first { color: #8ec5e8; }
table.data td.tight { height: 62px; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.col-hide-md { display: none; }
@media (min-width: 768px) { .col-hide-md { display: table-cell; } }
.col-hide-lg { display: none; }
@media (min-width: 1024px) { .col-hide-lg { display: table-cell; } }

.empty { padding: 56px 24px; text-align: center; }
.empty h2 { font-size: 16px; font-weight: 600; }
.empty p { margin-top: 8px; font-size: 14px; color: var(--slate-500); }
.empty .btn { margin-top: 20px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--border); font-size: 13px; color: var(--slate-500); }
.pager .chip { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); }
/* The current page is a marker, not a link: same shape as its neighbours so
   the row does not jump, but filled so the eye finds it without reading. */
.pager .chip.is-current { background: var(--slate-100, rgba(127,127,127,.18)); font-weight: 600; color: var(--text, inherit); }
.pager .pager-gap { display: inline-block; padding: 6px 4px; color: var(--slate-500); }
.pager .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* A long select becomes a combobox: one control that looks like the select it
   replaces and opens a searchable list. The native select stays in the DOM,
   hidden, because it is still what the form submits. */
.combo { position: relative; }
.combo-native { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.combo-field { display: block; width: 100%; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-panel { display: none; position: absolute; z-index: 50; top: calc(100% + 4px);
  left: 0; min-width: 100%; max-width: 420px; background: var(--surface, #111827);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0,0,0,.35); padding: 6px; }
.combo.is-open .combo-panel { display: block; }
.combo-search { display: block; width: 100%; box-sizing: border-box; padding: 8px 10px;
  margin-bottom: 6px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg, transparent); color: inherit; font: inherit; }
.combo-list { max-height: 280px; overflow-y: auto; }
.combo-opt { padding: 7px 10px; border-radius: var(--radius-md); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt.is-marked { background: rgba(127,127,127,.22); }
.combo-opt.is-chosen { font-weight: 600; }
.combo-none { padding: 10px; color: var(--slate-500); }

/* flex-end, not the default stretch: a toolbar mixes bare controls with
   labelled ones, and a label sits ABOVE its control. Aligning to the top put
   every button level with the labels instead of with the inputs they act on. */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 16px; }
.toolbar .lbl-xs { flex: 0 1 auto; min-width: 0; }
.toolbar .lbl-xs > .input, .toolbar .lbl-xs > .select { width: 100%; }

/* A filter bar carries more than a search box. The search takes its own row so
   the filters below it line up as one group, and From/To are a pair that wraps
   together rather than splitting across two rows. */
.toolbar.filters .grow { flex: 1 1 100%; }
.toolbar.filters .pair { display: flex; align-items: flex-end; gap: 8px; }
.toolbar.filters .lbl-xs > .select { min-width: 9rem; }
.toolbar .grow { position: relative; flex: 1; min-width: 15rem; }
.toolbar .grow .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--slate-400); }
.toolbar .grow .input { padding-left: 36px; }

/* -------------------------------------------------------------------- 8. tabs */

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--muted); }
.tabs a, .tabs button {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 14px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--slate-600); font-size: 13px; font-weight: 500; cursor: pointer;
}
.tabs a.on, .tabs button.on { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Vertical tabs, as Settings uses. */
.tabs-v { display: grid; gap: 24px; }
@media (min-width: 1024px) { .tabs-v { grid-template-columns: 220px 1fr; align-items: start; } }
.tabs-v .list { display: flex; flex-direction: column; gap: 2px; }
.tabs-v .list button, .tabs-v .list a {
  display: flex; align-items: center; height: 40px; padding: 0 14px;
  border: 0; border-radius: var(--radius-md); background: none;
  color: var(--slate-600); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
}
.tabs-v .list button:hover, .tabs-v .list a:hover { background: var(--slate-100); }
.tabs-v .list button.on, .tabs-v .list a.on { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-panel); }

/* Stepped tabs inside the document editor: 1. Details / 2. Line items / 3. Review */
.tabs-steps { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--muted); }
.tabs-steps button { height: 36px; }

/* ------------------------------------------------------------------ 9. dialog */

.dialog-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(2, 6, 23, .5);
}
.dialog {
  position: relative; z-index: 61; width: 100%; max-width: 36rem;
  border-radius: var(--radius-xl); border: 0;
  background: var(--card); color: var(--foreground);
  box-shadow: var(--shadow-2xl);
  max-height: 92vh; display: flex; flex-direction: column;
}
.dialog-xl { max-width: 42rem; }
.dialog-2xl { max-width: 48rem; }
.dialog-3xl { max-width: 56rem; }
/* The approved rule: a dialog that carries a tablist takes the whole viewport. */
.dialog-full { max-width: none; width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
.dialog-head { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 18px; font-weight: 600; }
.dialog-head p { margin-top: 4px; font-size: 14px; color: var(--slate-500); }
.dialog-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 20px 24px; border-top: 1px solid var(--border); }
.dialog-x { position: absolute; right: 16px; top: 16px; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--slate-500); cursor: pointer; }
.dialog-x:hover { background: var(--slate-100); }
/* The confirm variant, reproducing AlertDialog. */
.dialog-confirm { max-width: 28rem; }
.dialog-done { display: flex; flex-direction: column; align-items: center; padding: 48px 32px; text-align: center; }
.dialog-done .tick { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 20px; border-radius: 999px; background: var(--emerald-50); color: var(--emerald-700); }

/* ------------------------------------------------------------------- 10. sheet */

.sheet-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 23, .5); }
.sheet {
  position: fixed; inset-block: 0; right: 0; z-index: 61;
  display: flex; flex-direction: column;
  width: 100%; max-width: 42rem;
  background: var(--card); color: var(--foreground);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-2xl);
  overflow-y: auto;
}
.sheet-head { padding: 24px; border-bottom: 1px solid var(--border); }
.sheet-head .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-right: 32px; }
.sheet-head h2 { font-size: 24px; font-weight: 700; }
.sheet-head p { margin-top: 4px; font-size: 14px; color: var(--slate-500); }
.sheet-body { padding: 24px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
/* The in-document drawer, which slides over the document rather than the page. */
.drawer { position: fixed; inset-block: 0; right: 0; z-index: 61; width: 100%; max-width: 34rem; background: var(--card); border-left: 1px solid var(--border); box-shadow: var(--shadow-2xl); overflow-y: auto; }
/* The in-document drawers are toggled by an `open` ATTRIBUTE, not a class. My
   replacement rule gave them no hidden default, so both drawers rendered open
   over the builder on every page load. Hidden unless open, which is what the
   markup has always assumed. */
.drawer-back { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 23, .5); }
.drawer-back[open] { display: block; }
.drawer header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.drawer header h2 { font-size: 18px; font-weight: 600; }
.drawer .body { padding: 24px; }
.drawer .foot {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
  padding: 20px 24px; border-top: 1px solid var(--border);
}

.sep { height: 1px; margin: 24px 0; background: var(--border); border: 0; }

/* ----------------------------------------------------------- 11. dropdown menu */

.menu { position: relative; display: inline-flex; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 12rem; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--popover); color: var(--popover-foreground);
  box-shadow: var(--shadow-2xl);
}
.menu-pop.left { right: auto; left: 0; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--slate-100); }
.menu-item.danger { color: var(--rose-600); }
.menu-item.danger:hover { background: var(--rose-50); }
.menu-sep { height: 1px; margin: 6px 0; background: var(--border); }

/* ------------------------------------------------------------------- 12. toast */

.toasts { position: fixed; top: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 10px; max-width: min(24rem, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  box-shadow: var(--shadow-2xl); font-size: 14px;
}
.toast .ico { flex: none; margin-top: 2px; }
.toast.ok   { border-color: var(--emerald-200); background: var(--emerald-50); color: var(--emerald-700); }
.toast.bad  { border-color: var(--rose-200);    background: var(--rose-50);    color: var(--rose-700); }
.toast.warn { border-color: var(--amber-200);   background: var(--amber-50);   color: var(--amber-800); }
.toast-x { margin-left: auto; border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; }

/* --------------------------------------------------- 13. document presentation */

.doc-layout { display: grid; gap: 24px; }
/* The aside is a fixed rail, not a proportion. As a fraction it grew with the
   viewport and took width away from the thing the page is actually about: on a
   wide screen the document column kept a constant share instead of absorbing
   the extra space. A 340px rail is as wide as its content needs, and every
   pixel beyond that goes to the document. */
@media (min-width: 1280px) {
  .doc-layout.with-aside { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
}
.doc-aside { display: flex; flex-direction: column; gap: 20px; }

.doc-masthead { padding: 24px 28px; border-bottom: 1px solid var(--border); background: #10263d; color: #fff; }
.doc-masthead .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.doc-masthead .mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius); background: var(--brand); font-size: 18px; font-weight: 900; }
.doc-masthead .seller { margin-top: 16px; font-size: 18px; font-weight: 700; }
.doc-masthead .seller-meta { margin-top: 4px; font-size: 12px; line-height: 1.6; color: #cbd5e1; white-space: pre-line; }
.doc-masthead .kind { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .2em; color: #cbd5e1; }
.doc-masthead .number { margin-top: 8px; font-size: 24px; font-weight: 700; }

.doc-body { padding: 28px; }
.doc-head-grid { display: grid; gap: 16px; }
@media (min-width: 768px) { .doc-head-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1280px) { .doc-head-grid { grid-template-columns: repeat(4, 1fr); } }

/* NOTE. The rules from here to .doc-status-card were written from the approved
   React prototype's document markup: card-shaped .doc-line rows, a .doc-masthead,
   a .doc-head-grid. The production document is a TABLE and has none of that
   markup, so most of this block currently styles nothing.
   .doc-lines was the exception, and it collided: it set display:flex on an
   element that is a <table>, which made thead and tbody flex items and collapsed
   the columns into the left half of the page. The table's own rules are further
   down. Only the spacing is kept here. */
.doc-lines { margin-top: 32px; }
.doc-line { overflow: hidden; border: 1px solid var(--border); border-radius: 16px; }
.doc-line .top { display: grid; gap: 20px; padding: 20px; background: var(--card); }
@media (min-width: 1024px) { .doc-line .top { grid-template-columns: minmax(240px, 2fr) 80px minmax(140px, 1fr) minmax(150px, 1fr); } }
.doc-line .meta { display: grid; gap: 16px; padding: 16px 20px; border-top: 1px solid var(--border); background: var(--slate-50); }
@media (min-width: 640px) { .doc-line .meta { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .doc-line .meta { grid-template-columns: repeat(4, 1fr); } }
.doc-line .amount { font-size: 18px; font-weight: 700; color: var(--foreground); }
.doc-line-edit { border-radius: 16px; border: 1px solid var(--border); background: var(--slate-50); padding: 20px; }
.doc-line-edit + .doc-line-edit { margin-top: 16px; }
.doc-line-edit .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; font-weight: 600; }
.line-amount-chip { display: flex; align-items: center; justify-content: space-between; height: 44px; margin-top: 8px; padding: 0 16px; border-radius: var(--radius-md); background: #10263d; color: #fff; }
.line-amount-chip span { font-size: 12px; color: #cbd5e1; }
.line-grid-a { display: grid; gap: 20px; margin-top: 20px; }
@media (min-width: 1024px) { .line-grid-a { grid-template-columns: 150px minmax(240px, 1fr) 240px; } }
.line-tax-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }

/* Same again: the production document's .doc-foot is a plain notes-and-terms
   block, not the two-column grid the prototype had. */
.doc-foot { margin-top: 24px; }
.totals { display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: var(--radius); background: var(--slate-50); font-size: 14px; }
.totals .row { display: flex; justify-content: space-between; gap: 16px; }
.totals .row.discount { color: var(--rose-700); }
.totals .row.savings { padding: 8px 12px; border-radius: var(--radius-md); background: var(--emerald-50); color: var(--emerald-700); font-weight: 600; }
.totals .row.total { font-size: 18px; }
.totals .row.balance { padding-top: 12px; border-top: 1px solid var(--border); font-size: 18px; }
.totals .row.paid { color: var(--emerald-700); }
.totals .row.overdue b { color: var(--rose-600); }
.bank-block { margin-top: 16px; padding: 16px; border-radius: var(--radius); background: var(--slate-50); font-size: 14px; }

.doc-status-card { padding: 16px; border-radius: var(--radius); }
.doc-status-card.awaiting { background: var(--amber-50); }
.doc-status-card.settled { background: var(--emerald-50); }
.doc-status-card .head { font-size: 14px; font-weight: 600; }
.doc-status-card.awaiting .head { color: var(--amber-800); }
.doc-status-card.settled .head { color: var(--emerald-700); }
.doc-status-card .note { margin-top: 4px; font-size: 12px; color: var(--slate-500); }

.timeline { margin-top: 16px; padding-left: 16px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 20px; font-size: 14px; }
.timeline .when { margin-top: 4px; font-size: 12px; color: var(--slate-400); }

.attach-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip-file { padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--slate-50); font-size: 12px; color: var(--slate-700); }

.banner-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--slate-50); }
.banner-row .t { font-size: 14px; font-weight: 600; }
.banner-row .d { font-size: 12px; color: var(--slate-500); }

/* --------------------------------------------- 14. client-facing document
 * Deliberately light whatever the workspace theme is, exactly as approved.
 */

.client-view-layout { position: relative; min-height: 100vh; background: #f3f6f8; }
.client-invoice-shell { background: #f3f6f8 !important; color: #10263d !important; min-height: 100vh; padding: 32px 16px; }
@media (min-width: 640px) { .client-invoice-shell { padding: 32px; } }
/* The paper is white in both themes, so the tones on it stay the light theme's. */
.dark .client-paper {
  --emerald-200: #a7f3d0; --emerald-700: #047857; --sky-200: #bae6fd; --sky-700: #0369a1;
  --amber-200: #fde68a; --amber-700: #b45309; --amber-800: #92400e;
  --rose-200: #fecdd3; --rose-600: #e11d48; --rose-700: #be123c; --violet-700: #6d28d9;
}
.client-paper {
  max-width: 64rem; margin: 0 auto; padding: 28px 24px;
  background: #fff !important; color: #17212b !important;
  border-radius: 6px; box-shadow: 0 8px 28px rgba(16, 38, 61, .08);
}
@media (min-width: 640px) { .client-paper { padding: 40px 48px; } }
.client-paper header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 32px; padding-bottom: 28px; border-bottom: 1px solid #cbd5e1; }
.client-paper .eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .18em; color: #64748b; }
.client-paper h1 { margin-top: 8px; font-size: 30px; font-weight: 700; }
.client-paper h2 { margin-top: 8px; font-size: 20px; font-weight: 700; }
.client-paper .dl { display: grid; grid-template-columns: 105px 1fr; row-gap: 8px; margin-top: 16px; font-size: 14px; }
.client-paper .dl dt { color: #64748b; }
.client-paper .dl dd { margin: 0; }
.client-paper .parties { display: grid; gap: 32px; padding: 28px 0; border-bottom: 1px solid #cbd5e1; }
@media (min-width: 768px) { .client-paper .parties { grid-template-columns: 1fr 1fr; } }
.client-paper .addr { margin-top: 4px; font-size: 14px; line-height: 1.6; color: #475569; white-space: pre-line; }
.client-paper table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 14px; }
.client-paper thead tr { border-bottom: 2px solid #94a3b8; text-align: left; }
.client-paper th { padding: 12px 16px 12px 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #64748b; }
.client-paper td { padding: 16px 16px 16px 0; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.client-paper .totals-right { display: flex; justify-content: flex-end; margin-top: 28px; }
.client-paper .totals-right > div { width: 100%; max-width: 24rem; font-size: 14px; }
.client-paper .notes { padding-top: 24px; margin-top: 28px; border-top: 1px solid #cbd5e1; font-size: 14px; }
.client-paper .notes .body { margin-top: 12px; line-height: 1.6; color: #334155; white-space: pre-line; }
.client-paper .ask { margin-top: 32px; text-align: center; font-size: 12px; color: #94a3b8; }

.client-view-actions {
  position: fixed; top: 50%; right: 28px; z-index: 10;
  display: flex; width: 148px; transform: translateY(-50%);
  flex-direction: column; gap: 10px;
}
.client-view-actions .btn, .client-view-actions button {
  width: 100%; justify-content: center;
  background: #fff; color: #10263d; border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(16, 38, 61, .08);
}
.client-view-actions .btn:first-child, .client-view-actions form:first-child .btn {
  background: #10263d; color: #fff; border-color: #10263d;
}
.client-view-actions .terms { padding: 12px; border-radius: 8px; background: #fff; box-shadow: 0 4px 14px rgba(16,38,61,.08); font-size: 12px; text-align: left; display: flex; gap: 8px; align-items: flex-start; }
@media (max-width: 1100px) {
  .client-view-actions { position: static; width: auto; max-width: 320px; margin: 0 auto 24px; transform: none; flex-direction: row; padding: 0 16px; flex-wrap: wrap; }
  .client-view-actions .terms { flex-basis: 100%; }
}

/* --------------------------------------------------------------- 15. utilities */

.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; }
.mt-6 { margin-top: 24px; } .mt-7 { margin-top: 28px; } .mt-8 { margin-top: 32px; }
.mb-3 { margin-bottom: 12px; }

/* MARGIN RESETS, AND WHY THEY ARE HERE RATHER THAN ON THE ELEMENT. F-084.

   A heading or paragraph inside a panel head usually wants no margin of its
   own, and twenty places across four screens said so with style="margin:0".
   The application serves style-src 'self', so a browser DROPS an inline style
   attribute silently rather than reporting it: every one of those twenty did
   nothing, and those screens have been rendering with the margins their author
   tried to remove. The release gate refuses the attribute, which is how this
   was found; these classes are what the markup uses instead. */
.m-0  { margin: 0; }
.mb-0 { margin-bottom: 0; }

/* One panel figure is set a size larger than its class gives it, for the same
   reason and with the same history: as an inline style it never applied. */
.fs-20 { font-size: 20px; }

/* The customer's own mail settings, revealed only when they choose their own
   provider. Display is toggled by app.js rather than by an inline handler,
   because the Content Security Policy forbids inline script and no exception is
   made for a convenience. */
.mail-own { margin-top: 4px; }
.mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; }
.back-link { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px; font-size: 14px; font-weight: 600; color: var(--slate-500); }
.back-link:hover { color: var(--foreground); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.offscreen { position: fixed; opacity: 0; pointer-events: none; }
html.scroll-locked, html.scroll-locked body { overflow: hidden; }

.card-row {
  display: flex; align-items: center; gap: 16px; width: 100%;
  padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: none; color: inherit; text-align: left; cursor: pointer;
}
.card-row:hover { background: var(--slate-50); }
.card-row .ico-box { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius); background: var(--slate-100); color: #173f61; flex: none; }
.dark .card-row .ico-box { color: #8ec5e8; }
.card-row .body { flex: 1; min-width: 0; }
.card-row .body b { display: block; font-size: 14px; }
.card-row .body span { display: block; margin-top: 4px; font-size: 12px; color: var(--slate-500); }
.card-row .go { font-size: 12px; font-weight: 600; color: var(--brand-ink); }

/* Sign-in and workspace/book choice. Production screens the prototype never
   modelled, built from the same tokens so they belong to the same product. */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--background); }
.auth-card { width: 100%; max-width: 26rem; padding: 32px; border-radius: var(--radius-panel); border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow-panel); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand .brand-mark { width: 40px; height: 40px; }
.auth-brand span { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.auth-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.auth-card p.lead { margin-top: 8px; font-size: 14px; color: var(--slate-500); }
.auth-card .lbl { margin-top: 20px; }
.auth-card .btn { margin-top: 24px; }

/* THE SIGN IN FORM.

   The template writes plain <label> and <input> elements, and the rules above
   only ever matched .lbl and .btn. So nothing here had any layout at all: the
   labels and the boxes ran together inline, which is why "Email [box] Password"
   sat on one line and the password box ended up beside the button.

   Styled by element rather than by adding classes, because on this one screen
   the elements ARE the form. */
.auth-card form { display: flex; flex-direction: column; }
.auth-card form label {
  margin-top: 18px; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--foreground);
}
.auth-card form input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--input); border-radius: var(--radius);
  background: var(--background); color: var(--foreground);
  font: inherit; font-size: 14px;
}
.auth-card form input:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 1px; border-color: var(--ring);
}
.auth-card form input[type="hidden"] { display: none; }
.auth-card p.sub { margin-top: 8px; font-size: 14px; color: var(--slate-500); }
.auth-card p.fine { margin-top: 20px; }
/* The sign-in button spans the card. `.btn` is inline-flex, so inside a column
   flex container it shrinks to its text and floats in the middle, which reads as
   an afterthought on a two-field form. */
.auth-card form .btn { width: 100%; justify-content: center; }

/* SIGNUP AND ONBOARDING.
   The auth card was built for a two-field sign-in form. These screens add a
   select, a checkbox and per-field errors, and they have to look like the same
   product rather than like a form that escaped. */
.auth-card form select {
  width: 100%; height: 40px; padding: 0 10px;
  border: 1px solid var(--input); border-radius: var(--radius);
  background: var(--background); color: var(--foreground);
  font: inherit; font-size: 14px;
}
.auth-card form select:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 1px; border-color: var(--ring);
}
/* A hint under a field, and an error under that. The error is the only red on
   these screens, so it cannot be missed and nothing else competes with it. */
.auth-card form .fine { margin-top: 6px; font-size: 12px; color: var(--slate-500); }
.field-err {
  margin-top: 6px; font-size: 12px; font-weight: 500; color: var(--destructive);
}
.auth-card form .check {
  display: flex; align-items: center; gap: 10px; margin-top: 18px;
}
.auth-card form .check input { width: auto; height: auto; }
.auth-card form .check label { margin: 0; }
/* Revealed by app.js when the answer above makes them relevant. Hiding a field
   nobody needs is the difference between a form a freelancer finishes and one
   they abandon. */
.onboard-region, .onboard-reg { display: contents; }
.onboard-region.hidden, .onboard-reg.hidden { display: none; }
.choice-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.choice { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); cursor: pointer; text-align: left; }
.choice:hover { border-color: var(--ring); background: var(--slate-50); }
.choice b { display: block; font-size: 14px; }
.choice span { display: block; margin-top: 2px; font-size: 12px; color: var(--slate-500); }

/* The book switcher in the shell header: a compact popover, the smallest
   interaction consistent with the approved design system. */
.ctx-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: inherit; cursor: pointer; font-size: 14px; }
.ctx-btn .k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-400); }
.ctx-btn b { font-weight: 600; }
.who { display: none; align-items: center; gap: 10px; }
@media (min-width: 768px) { .who { display: flex; } }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; background: var(--slate-100); color: var(--slate-700); font-size: 13px; font-weight: 600; }
.who-text strong { display: block; font-size: 13px; }
.who-text small { display: block; font-size: 11px; color: var(--slate-500); }

/* ------------------------------------------------------------------- 16. print */

@media print {
  /* A4, STATED RATHER THAN LEFT TO THE BROWSER. Without this the paper is
     whatever the printing machine defaults to, which is Letter in North America
     and A4 elsewhere, so the same invoice came out at two different sizes
     depending on who pressed print. The downloadable PDF has always been A4, and
     a document that prints at one size and downloads at another is a document
     whose layout cannot be relied on. The 14mm margin is the PDF's own margin,
     so the printed sheet and the PDF put the content in the same place. */
  @page { size: A4; margin: 14mm; }
  .side, .side-scrim, .top, .client-view-actions, .toasts, .no-print { display: none !important; }
  .main { padding-left: 0 !important; }
  .client-view-layout, .client-invoice-shell { background: #fff !important; }
  .client-paper { box-shadow: none !important; max-width: none; padding: 0; }
  .panel { box-shadow: none !important; }
  body { background: #fff !important; }
}


/* ------------------------------------------- 17. overlay host and utilities
 *
 * One overlay element hosts both a dialog and a sheet: same scrim, same escape
 * and scroll-lock behaviour, different geometry. Hidden with the `hidden`
 * attribute so it is invisible before any script runs, which is what stops the
 * flash of an open modal on a slow connection.
 */

/* The overlay host is the CENTRING container.
 *
 * The scrim and the dialog are siblings, because the scrim has to be its own
 * element for a click on it to be distinguishable from a click on the dialog.
 * The centring therefore belongs here and not on the scrim: it was on the scrim,
 * so every dialog in the application rendered against the top-left corner of the
 * viewport instead of in the middle of it.
 *
 * The dialog also has to sit ABOVE the scrim. The scrim is positioned with a
 * z-index and the dialog was not, so the scrim painted over the dialog: it
 * dimmed it, and a click anywhere on the dialog hit the scrim and dismissed it.
 * Both are one-line fixes and both were invisible until a dialog was opened and
 * looked at. */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 16px;
  overflow-y: auto;
}
.overlay[hidden] { display: none !important; }
.overlay .dialog-scrim, .overlay .sheet-scrim { position: absolute; inset: 0; }

.toast { transition: opacity .2s ease, transform .2s ease; }
.toast.out { opacity: 0; transform: translateX(8px); }

/* Utility classes that replace inline style attributes. The CSP is
   `style-src 'self'`, so an inline style attribute is refused by the browser;
   every one of these existed as a style="" until that was found. */
.w-theme { width: 9.5rem; }
.w-icon-slot { display: inline-block; width: 18px; }
.menu-head { padding: 8px 10px; }
.btn-destructive { background: var(--rose-600); color: #fff; border-color: var(--rose-600); }
/* White text needs the deep red in both themes. */
.dark .btn-destructive { background: #e11d48; border-color: #e11d48; }
.btn-destructive:hover { background: #be123c; }
.tabs-scroll { overflow-x: auto; }
.chart-box { position: relative; height: 230px; overflow: hidden; border-radius: 16px; background: var(--slate-50); padding: 24px 12px 20px; }
@media (min-width: 640px) { .chart-box { padding: 24px 24px 20px; } }
.chart-box svg { position: relative; width: 100%; height: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 16px; font-size: 12px; font-weight: 500; color: var(--slate-500); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 999px; }
.chart-x { display: grid; grid-template-columns: repeat(6, 1fr); margin-top: 4px; text-align: center; font-size: 12px; color: var(--slate-400); }


/* ------------------------------------------------- 18. validation and states
 *
 * Every error is a sentence next to the field it is about, not a red border on
 * its own: colour alone is not an accessible way to say what is wrong, and a red
 * box does not tell somebody what to type instead.
 */

/* A previewed message keeps its own line breaks. No inline style: the
   Content Security Policy refuses them and the browser drops them silently. */
.pre-wrap { white-space: pre-wrap; word-break: break-word; }

.field-error { display: block; margin-top: 6px; font-size: 13px; color: var(--rose-700); }
.field-error::before { content: ""; }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--rose-600); }
.input.invalid:focus, .select.invalid:focus, .textarea.invalid:focus { outline-color: var(--rose-600); }
.form-error {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin-bottom: 20px;
  border: 1px solid var(--rose-200); border-radius: var(--radius);
  background: var(--rose-50); color: var(--rose-700); font-size: 14px;
}

/* The busy state for an HTMX request in flight. */
.htmx-request .btn-busy { opacity: .6; pointer-events: none; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 999px; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .side, .toast { transition: none !important; }
}

/* Status text colours, used where a metric's meaning is stated in words as well
   as in colour. */
.text-ok   { color: var(--emerald-700); }
.text-warn { color: var(--amber-700); }
.text-bad  { color: var(--rose-700); }

/* --------------------------------------------- 19. layout utility classes
 *
 * These replace 93 inline style attributes that the Content Security Policy was
 * refusing. Each one is the class form of a declaration that was previously
 * written on the element, so the rendered result is what the template always
 * intended rather than what the browser was allowing.
 *
 * Column widths collapse onto a scale. Fourteen one-off pixel values across one
 * document table was not a design decision, and a scale makes the next table
 * consistent with this one for free.
 */

.w-30   { width: 30px; }
.w-60   { width: 60px; }
.w-70   { width: 70px; }
.w-80   { width: 80px; }
.w-90   { width: 90px; }
.w-100  { width: 100px; }
.w-120  { width: 120px; }
.w-full { width: 100%; }

.p-sm { padding: 16px; }
.p-md { padding: 20px; }
.p-lg { padding: 24px; }
.box-md { padding: 16px; margin-bottom: 16px; }
.box-lg { padding: 20px; margin-bottom: 18px; }
.ph-tight { padding: 0 0 12px; }
.my-md { margin: 14px 0; }
.divide-top { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--border); }

.upper { text-transform: uppercase; }

/* A read-only value beside the button that copies it. The field grows and the button
   does not, because the value is a URL of unpredictable length and the button's label
   is two words. */
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row > .input { flex: 1 1 auto; min-width: 0; }
.copy-row > .btn { flex: 0 0 auto; }

/* A FILTER ROW WRAPS. A search box with date bounds and two buttons does not fit
   a phone on one line, and a row that refuses to wrap pushes its own buttons off
   the screen. .copy-row itself is left alone: the screens that use it for one
   field and one button are correct as they are. */
.filter-row { flex-wrap: wrap; }
.inline-label {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--slate-500); white-space: nowrap;
}
.inline-label > .input { flex: 0 0 auto; width: auto; }

/* The company's own logo at the top of its public supplier registration page. The
   supplier should recognise who they are dealing with before reading a word, and a
   logo is how a business is recognised. Bounded so a large upload cannot push the
   form off the screen. */
.public-logo {
  display: block; max-width: 180px; max-height: 64px;
  width: auto; height: auto; margin-bottom: 16px; object-fit: contain;
}

/* ----------------------------------------------------- the payroll exceptions list

   A payroll run's exceptions are the one place in the product where a refusal has
   to be read rather than glanced at: each one carries what happened, why the law
   says so, and what to do about it. So the card tints by whether it stops the run
   and the three sentences are visually distinct from each other rather than one
   paragraph of grey.

   SEVERITY IS CARRIED BY THE TINT AND THE PILL, not by an accent stripe down one
   edge. The pill already says "action required" in words, which is the part that
   survives being printed, read aloud or looked at by somebody who does not know
   the house colours. */
.note {
  padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--card);
}
.note-bad  { border-color: var(--rose-200);  background: var(--rose-50); }
.note-warn { border-color: var(--amber-200); background: var(--amber-50); }
.note-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-what { margin: 8px 0 6px; font-size: 14px; font-weight: 600; }

/* htmx's own indicator rules, which it would otherwise inject as an inline
   <style> element that this application's CSP refuses. Kept byte-for-byte
   equivalent to htmx 2's defaults so that upgrading htmx changes nothing here. */
.htmx-indicator { opacity: 0; visibility: hidden; }
.htmx-request .htmx-indicator { opacity: 1; visibility: visible; }
.htmx-request.htmx-indicator { opacity: 1; visibility: visible; }

/* Tax numbers, document numbers and currency codes. Tabular monospace so that a
   GSTIN misread by one character is visible as a misalignment rather than as a
   plausible string. Several templates already carried class="mono" against a rule
   that did not exist, so they were rendering in the body face. */
.mono { font-family: var(--font-mono); font-size: .92em; letter-spacing: .01em; }
.rel { position: relative; }
.self-end { align-self: end; }
.row-gap { display: flex; gap: 10px; }
.col-stretch { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.sub-line { display: block; margin-top: 2px; font-size: 12px; color: var(--slate-500); }
.center-dim { margin-top: 20px; text-align: center; color: var(--slate-400); }
.reading { max-width: 840px; margin: 0 auto; padding: 28px 20px; }
.logo-preview { max-width: 100%; max-height: 70px; margin-bottom: 12px; }


/* ============================================================================
 * 20. FORMS, TABLES AND DOCUMENT PRESENTATION
 *
 * app.css was rewritten for the approved design, and two screens were migrated
 * to the new names. The other sixteen templates kept referencing the previous
 * design system, so their markup matched no rule and rendered with no styling:
 * stat bands collapsed to "Total1 Draft1", tables lost every border, primary
 * buttons lost their fill. A build gate now refuses to package a release with
 * any undefined class, and this section is what makes that gate pass honestly.
 *
 * These are not aliases painted on to silence the gate. Each one is the
 * approved treatment for a component the approved UI genuinely has and the new
 * stylesheet had not yet covered: a field grid, a fieldset, a document on
 * paper. They use the same tokens, spacing scale and radii as everything above.
 *
 * The legacy names are kept because the alternative was renaming classes inside
 * document_builder.html, where several are also JavaScript selectors, and doing
 * that blind would trade a styling defect for a behavioural one. Screens adopt
 * the approved names as they are rebuilt for their own feature work.
 * ==========================================================================*/

/* ---------------------------------------------------------------- the field grid
 *
 * Twelve columns, because a tax form genuinely needs a two-column country field
 * beside a five-column registration number. Collapses to one column on a phone.
 */
/* minmax(0, 1fr), not 1fr. A bare 1fr is minmax(auto, 1fr), so a track refuses
   to shrink below its content and a long field pushes the whole grid wider than
   its container: the document builder overflowed the page by 282px this way. */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.form-grid > .f { grid-column: span 12; min-width: 0; }
@media (min-width: 720px) {
  .f.s1 { grid-column: span 1; }  .f.s2 { grid-column: span 2; }
  .f.s3 { grid-column: span 3; }  .f.s4 { grid-column: span 4; }
  .f.s5 { grid-column: span 5; }  .f.s6 { grid-column: span 6; }
  .f.s7 { grid-column: span 7; }  .f.s8 { grid-column: span 8; }
  .f.s9 { grid-column: span 9; }  .f.s10 { grid-column: span 10; }
  .f.s11 { grid-column: span 11; } .f.s12 { grid-column: span 12; }
}
.f > label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.f > input, .f > select, .f > textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); color: var(--foreground); font: inherit; font-size: 14px;
}
.f > textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.f > select { appearance: auto; padding-right: 8px; }
.f > input:focus-visible, .f > select:focus-visible, .f > textarea:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 1px; border-color: transparent;
}
.f > input::placeholder, .f > textarea::placeholder { color: var(--slate-400); }
/* The explanatory line under a field, and the error that replaces its calm. */
.f .break-all {
  /* A URL shown for the user to copy. Long, unbreakable at any space, and it
     must not push the panel wider than the screen on a phone. */
  overflow-wrap: anywhere;
  word-break: break-all;
}

.fixed-value {
  /* A field the screen shows but does not let you change: the invoice's date
     and currency while it is being revised. Sized and spaced like the inputs
     beside it so the row still reads as one line of fields, and plainly not a
     control, so nobody types into it and wonders why it was ignored. */
  margin: 0;
  padding: 9px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-700);
}

.hint { display: block; margin-top: 6px; font-size: 12px; color: var(--slate-500); }
.f .bad  { display: block; margin-top: 6px; font-size: 13px; color: var(--rose-700); }
.f.has-error > input, .f.has-error > select, .f.has-error > textarea { border-color: var(--rose-600); }
/* A checkbox sits beside its label, not above it. */
.f.check { display: flex; align-items: flex-start; gap: 10px; }
.f.check > input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--brand); }
.f.check > label { margin: 0; font-weight: 400; }

.fieldset { border: 0; padding: 0; margin: 0 0 28px; }
.fieldset > legend {
  padding: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--foreground);
}
.fieldset + .fieldset { padding-top: 24px; border-top: 1px solid var(--border); }

.form-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding-top: 24px; border-top: 1px solid var(--border);
}
.form-actions .spacer { flex: 1; }

/* ------------------------------------------------------------ legacy table name
 *
 * Identical treatment to table.data, so a screen that has not been rebuilt yet
 * still reads as the same product rather than as a different application.
 */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl thead tr { background: var(--slate-50); }
.tbl th {
  padding: 0 12px; height: 44px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--slate-500); border-bottom: 1px solid var(--border);
}
.tbl td { padding: 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child,  .tbl td:last-child  { padding-right: 20px; }
.tbl tbody tr:hover { background: var(--slate-50); }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl a { font-weight: 600; color: var(--brand-ink); }
.dark .tbl a { color: #ffa48f; }

/* --------------------------------------------------------------- utilities used
 * by screens that have not been rebuilt. Same scale as section 19.
 */
.r        { text-align: right; }
.nowrap   { white-space: nowrap; }
.dim      { color: var(--slate-400); }
.fine     { font-size: 12px; color: var(--slate-500); }
/* Body padding for a panel whose content is prose or a small table rather
   than a list or a full-bleed table of its own. */
.pad      { padding: 16px 20px; }
@media (min-width: 640px) { .pad { padding: 20px 24px; } }
.narrow   { max-width: 34rem; margin: 0 auto; }
.wide     { max-width: 60rem; margin: 0 auto; }
.center   { text-align: center; }
.inline   { display: inline; }
.v        { font-variant-numeric: tabular-nums; }
.grand    { font-size: 18px; font-weight: 700; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--muted); font-size: 12px; font-weight: 500;
}
.alarm { color: var(--rose-700); font-weight: 600; }
.desc-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--slate-500); }
.err-code { font-family: var(--font-mono); font-size: 12px; color: var(--slate-400); }

/* The primary and plain button names used before .btn-primary existed. */
.btn.primary { background: var(--brand); color: var(--brand-fg); border-color: var(--brand); font-weight: 600; }
.btn.primary:hover { background: var(--brand-hover); }
.link-btn {
  border: 0; background: none; padding: 0; font: inherit; font-weight: 600;
  color: var(--brand-ink); cursor: pointer;
}
.dark .link-btn { color: #ffa48f; }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--slate-500); cursor: pointer;
}
.icon-btn:hover { background: var(--slate-50); color: var(--foreground); }

.alert {
  display: block; padding: 12px 14px; margin-bottom: 18px;
  border: 1px solid var(--rose-200); border-radius: var(--radius);
  background: var(--rose-50); color: var(--rose-700); font-size: 14px;
}

/* ------------------------------------------------- workspace and book choosers */
.pick { display: grid; gap: 12px; margin-top: 20px; }
.pick-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 16px 18px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius-panel);
  background: var(--card); color: inherit; cursor: pointer;
}
.pick-btn:hover { border-color: var(--brand); box-shadow: var(--shadow-card); }
.pick-name { flex: 1; font-weight: 600; }
.pick-go { color: var(--slate-400); }

/* -------------------------------------------------------- document presentation
 *
 * The document itself, on paper. Deliberately lighter than the application
 * chrome around it: an invoice is a legal record and should read as a document,
 * not as a screen. It keeps a white page in dark mode for the same reason.
 */
/* No max-width of its own. The document view sizes this column with the grid,
   and the standalone print and share pages already wrap it in .content.reading,
   so a second 900px limit here only centred the paper inside its own column and
   left a band of empty space down both sides of it. */
.doc-wrap { width: 100%; }

/* THE DOCUMENT IS LAID OUT AS THE PDF IS. F-293. internal/pdf/render.go is the
   design; this is the same design in a browser. The typeface is the PDF's own
   two font files, the greys are its greys, and each block is what the PDF
   draws: a grey label, a hairline rule, the value beside it. The sizes are the
   PDF's point sizes carried to the screen at A4 width, so the page a customer
   opens and the PDF they download are the same document. */
@font-face { font-family: "Contra Document"; font-weight: 400; font-display: swap; src: url("/fonts/doc-regular.ttf") format("truetype"); }
@font-face { font-family: "Contra Document"; font-weight: 700; font-display: swap; src: url("/fonts/doc-bold.ttf") format("truetype"); }
.doc {
  padding: 52px; border: 1px solid var(--border); border-radius: var(--radius-panel);
  background: #fff; color: #262626; box-shadow: var(--shadow-panel);
  font-family: "Contra Document", system-ui, sans-serif; font-size: 12.5px; line-height: 1.45;
}
.doc strong { font-weight: 700; }
.doc-head { display: grid; grid-template-columns: 55% 45%; align-items: start; }
.doc-logo { display: block; max-width: 272px; max-height: 91px; width: auto; height: auto; }
.doc-from h1 {
  margin: 0 0 14px 104px; font-size: 23px; line-height: 1.2; font-weight: 700;
  letter-spacing: 0; text-transform: uppercase; color: #262626;
}
/* A block: the label, the rule, the value. */
.doc-block { display: grid; grid-template-columns: 91px 1fr; column-gap: 6px; }
.doc-block .k { padding-top: 3px; font-size: 10.5px; color: #767676; }
.doc-block-r .k { text-align: right; }
.doc-block .v { padding-left: 7px; border-left: 1px solid #cdcdcd; font-size: 11.5px; line-height: 1.4; overflow-wrap: anywhere; }
.doc-block .v strong { display: block; margin-bottom: 1px; font-size: 14px; line-height: 1.35; }
.doc-info { display: grid; grid-template-columns: 55% 45%; align-items: start; margin-top: 30px; }
.doc-info > .doc-block { padding-right: 16px; }
/* The particulars: labels right aligned against the rule, values beside it. */
.doc-meta { display: grid; grid-template-columns: 91px 1fr; column-gap: 6px; margin: 0; }
.doc-meta dt { padding: 4px 0 0; font-size: 10.5px; font-weight: 400; color: #767676; text-align: right; }
.doc-meta dd { margin: 0; padding: 2px 0 2px 7px; border-left: 1px solid #cdcdcd; font-size: 12px; overflow-wrap: anywhere; }
.doc-subject { margin-top: 19px; }
.doc-subject .v { font-size: 12px; }
.doc-statement { margin: 12px 0 0; font-size: 11.5px; font-weight: 700; }

.doc-scroll { margin-top: 26px; }
/* TABLE-LAYOUT: FIXED, so the widths below are obeyed and the description,
   which declares none, takes everything the figures do not need. */
.doc-lines { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 11.5px; }
.doc-lines thead th {
  padding: 5px 4px; text-align: left; font-size: 10.5px; font-weight: 700; color: #262626;
  border-bottom: 1px solid #969696; white-space: nowrap;
}
.doc-lines tbody td { padding: 6px 4px; border-bottom: 1px solid #cdcdcd; vertical-align: top; }
.doc-lines .r, .doc-lines th.r, .doc-lines td.r { text-align: right; }
.doc-lines .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-lines td.amt { font-weight: 700; }
/* THE DESCRIPTION IS SHOWN AS IT WAS TYPED: paragraphs, blank lines and all,
   as the PDF lays the same string out. */
.doc-lines td.desc { white-space: pre-wrap; overflow-wrap: break-word; }
.doc-lines col.c-no       { width: 26px; }
.doc-lines col.c-hsn      { width: 64px; }
.doc-lines col.c-qty      { width: 48px; }
.doc-lines col.c-unit     { width: 46px; }
.doc-lines col.c-rate     { width: 100px; }
.doc-lines col.c-discount { width: 66px; }
.doc-lines col.c-amount   { width: 112px; }

.doc-totals { margin: 15px 0 0 auto; width: 43%; min-width: 250px; }
.t-row { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; padding: 3px 4px; font-size: 12px; }
.t-row > span:first-child { flex: 1; text-align: right; color: #767676; }
.t-row .v { min-width: 120px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-row.grand { margin-top: 8px; padding-top: 9px; border-top: 1px solid #969696; font-size: 16px; font-weight: 700; }
.t-row.grand > span:first-child { color: #262626; }
.t-row.sub { font-size: 11px; }
.t-row.sub .v { font-weight: 400; color: #767676; }

.doc-foot { margin-top: 22px; padding-top: 10px; border-top: 1px solid #cdcdcd; font-size: 11.5px; }
.doc-foot .lbl { display: block; margin-bottom: 6px; font-size: 10.5px; font-weight: 700; }
.doc-foot p { margin: 0; white-space: pre-line; line-height: 1.5; }
.doc-watermark {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 88px; font-weight: 800; letter-spacing: .1em;
  color: rgba(15, 23, 42, .05); pointer-events: none; text-transform: uppercase;
}

/* NARROW SCREENS. The same document, one column at a time: the logo, who it
   is from, who it is for, its particulars. The line table keeps its columns
   and scrolls sideways inside its own box, so a figure is never squeezed
   until it wraps and the page itself never scrolls sideways. */
@media (max-width: 700px) {
  .doc { padding: 22px 18px; }
  .doc-head, .doc-info { grid-template-columns: 1fr; row-gap: 20px; }
  .doc-info { margin-top: 22px; }
  .doc-info > .doc-block { padding-right: 0; }
  .doc-from h1 { margin-left: 0; }
  .doc-block-r .k, .doc-meta dt { text-align: left; }
  .doc-logo { max-width: 200px; max-height: 70px; }
  .doc-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .doc-lines { min-width: 400px; font-size: 11px; }
  .doc-lines col.c-no { width: 20px; }
  .doc-lines col.c-hsn { width: 54px; }
  .doc-lines col.c-qty { width: 36px; }
  .doc-lines col.c-unit { width: 38px; }
  .doc-lines col.c-rate { width: 84px; }
  .doc-lines col.c-discount { width: 58px; }
  .doc-lines col.c-amount { width: 92px; }
  .doc-totals { width: 100%; min-width: 0; }
}
/* PRINTED, it is the paper: no card, no shadow, the PDF's margins. */
@media print {
  .doc { padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .doc-lines thead { display: table-header-group; }
  .doc-lines tr, .doc-totals, .doc-foot { break-inside: avoid; }
}

/* The document's action column, beside the paper. */
.side-actions { display: grid; gap: 10px; }
.side-actions form { display: contents; }
.side-actions .fine { margin: -2px 0 6px; }
.history { display: grid; gap: 12px; font-size: 13px; }

.doc .dim { color: #64748b; }

/* ------------------------------------------------------------ document builder
 *
 * The line editor. Its class names are also JavaScript selectors, so they are
 * styled here rather than renamed.
 */
/* One column that is allowed to be narrower than its content. Without the
   explicit minmax(0, ...) the implicit auto track sizes to max-content and a
   wide child pushes the builder past the page edge. */
.builder { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.builder > * { min-width: 0; }
/* .lines is a TABLE, not a grid. Styling it as one turned every row into a
   grid item, which is how the builder ended up 282px wider than the page.
   table-layout: fixed makes the w-* header widths authoritative so a long
   description cannot widen the table. */
.lines { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.lines thead th {
  padding: 0 8px 8px; text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; color: var(--slate-500);
}
.lines tbody td { padding: 4px; vertical-align: top; }
.lines .cell input, .lines .cell select, .lines .cell textarea {
  width: 100%; min-width: 0; height: 38px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--foreground); font: inherit; font-size: 13px;
}
/* The description grows with what is written in it. A line is routinely two or
   three lines of what was actually supplied, and a fixed-height box that
   scrolls hides the end of it from the person writing the invoice. */
.lines .cell textarea {
  height: auto; min-height: 38px; padding: 9px 10px; line-height: 1.4; resize: vertical;
}
.lines .cell input.r { text-align: right; font-variant-numeric: tabular-nums; }
.lines .cell input:focus-visible, .lines .cell select:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 1px;
}
.lines td.row-net { padding-top: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.lines td.rownum { padding-top: 12px; color: var(--slate-400); font-variant-numeric: tabular-nums; }
.cell { min-width: 0; }
.rownum { width: 28px; }
/* A narrow leading column, for a checkbox that selects a row. */
.w-40 { width: 40px; }

/* A statement on the document aimed at the recipient rather than at the reader
   of the totals: on a credit note, what they have to do about their own input
   tax credit. */
.doc-note { margin-top: 20px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--muted); font-size: 12px; line-height: 1.55; }
.doc-note p { margin: 0; }

/* A control that is present but not in play. Used by the credit note screen to
   swap the amount box for the quantity box without removing either from the
   form, so whichever is in use is the one that submits. */
.hidden { display: none !important; }
/* The line's remove-button column. It was called `drop`, which is also the name
   of the floating dropdown panel below: `position: absolute; z-index: 30; top:
   calc(100% + 4px)`. Applied to a table cell that rule took the × button out of
   the row and floated it across the totals panel, on top of the Save draft
   button. Same shape of defect as a `display: flex` rule landing on a <table>:
   the class matched real markup, so a missing-class gate could not see it. */
.line-drop { width: 44px; text-align: right; }
.totals-panel { margin-left: auto; width: 100%; max-width: 360px; }
.totals-row { display: flex; justify-content: space-between; gap: 24px; padding: 6px 0; font-size: 14px; }
.totals-row.grand { padding-top: 12px; margin-top: 6px; border-top: 1px solid var(--border); font-size: 18px; font-weight: 700; }
.tax-basis { font-size: 12px; color: var(--slate-500); }
.chosen { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.picker { position: relative; }
/* THE OPEN ATTRIBUTE IS WHAT SHOWS IT, and until now nothing acted on it. Every
   handler removed `open` after a choice was made, as it should, and the list
   stayed on screen anyway, covering the rows under it: the flag was being set and
   cleared by the script while the stylesheet had no rule that cared. Choosing a
   product left its own suggestions sitting over the next line. */
.picker-results { display: none; }
.picker-results[open] { display: block; }
.picker-results {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 16rem; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--popover); box-shadow: var(--shadow-2xl);
}
.picker-results button {
  display: block; width: 100%; padding: 10px 12px; text-align: left;
  border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
}
.picker-results button:hover { background: var(--muted); }
/* The name and the detail line are two elements with nothing between them, so
   without this they run together: "P Holding27AGAPA8167G1ZJ". A margin rather
   than a separator character, because the detail is already a · joined list and
   a second separator would read as an empty field. */
.picker-results button .meta { margin-left: .5ch; color: var(--slate-500); }
.drop {
  position: absolute; z-index: 30; right: 0; top: calc(100% + 4px); min-width: 12rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--popover); box-shadow: var(--shadow-2xl); padding: 4px;
}

/* ------------------------------------------------- searchable code picker
 *
 * The popup is NOT tied to the width of its input. That constraint is exactly
 * what made the native <datalist> unusable here: the classification field is a
 * narrow column in a wide table, and "Hosting and information technology
 * infrastructure provisioning services" rendered as "Hosting and". The code is
 * the identifier, the description is what a person recognises, so the
 * description is what gets the room.
 */
.pick-pop {
  position: absolute; z-index: 70;
  max-height: 22rem; overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--popover); box-shadow: var(--shadow-2xl);
}
.pick-row {
  display: grid; grid-template-columns: 5.5rem 1fr; gap: 10px; align-items: baseline;
  width: 100%; padding: 8px 10px; text-align: left;
  border: 0; border-radius: var(--radius-sm); background: none;
  color: inherit; font: inherit; cursor: pointer;
}
.pick-row b { font-family: var(--font-mono); font-size: 13px; }
.pick-row span {
  font-size: 13px; color: var(--slate-500); line-height: 1.35;
  /* Two lines, then ellipsis. A long statutory description should be readable
     without one row pushing the rest of the list off the screen. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.pick-row:hover, .pick-row.on { background: var(--muted); }
.pick-row.on span { color: var(--foreground); }
.pick-none { padding: 12px 10px; font-size: 13px; color: var(--slate-500); }

/* The source list is data for the picker, never rendered itself. */
.pick-src { display: none; }

/* Which heads a line is taxed under. Stated on the line, never chosen there:
   the slab is the operator's decision, the split into CGST+SGST or IGST is the
   engine's, and a dropdown would invite somebody to overrule it. */
.head-tag {
  display: block; margin-top: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: var(--brand-ink); text-transform: uppercase;
}
.dark .head-tag { color: #ffa48f; }

/* ===================================================================== recurring

   The line chip and the configuration modal.

   The chip sits under the line description rather than in a column of its own,
   so the numeric columns keep their width and the row keeps the height it had.
   Off, it is quiet text; on, it carries the accent and reads as a summary. */

.rec-chip {
  display: flex; align-items: flex-start; gap: 6px;
  margin-top: 6px; padding: 4px 8px 4px 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; cursor: pointer;
  font: inherit; font-size: 12px; line-height: 1.35;
  color: var(--muted-foreground);
  text-align: left; width: 100%;
}
.rec-chip:hover { border-color: var(--border); background: var(--muted); }
.rec-chip.on {
  color: var(--primary); background: var(--accent); border-color: var(--border);
}
.rec-ico { font-size: 13px; line-height: 1.35; flex: 0 0 auto; }
/* The summary WRAPS rather than truncating. It is the only place the schedule is
   visible without opening the modal, so "Monthly · Starts ..." would hide exactly
   the part that matters. The description column is narrow, so two lines is the
   normal case and the row absorbs it. */
.rec-text { white-space: normal; }

/* The modal. Three panes, one visible at a time, so it never scrolls the way a
   single long form does. */
.dialog-rec { max-width: 40rem; }
.rec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.rec-switch {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; white-space: nowrap;
}

.rec-tabs {
  display: flex; gap: 2px; padding: 0 24px;
  border-bottom: 1px solid var(--border);
}
.rec-tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500;
  color: var(--muted-foreground);
  padding: 10px 12px; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}
.rec-tab:hover { color: var(--foreground); }
.rec-tab.is-on { color: var(--primary); border-bottom-color: var(--primary); }

.rec-body { min-height: 17rem; }
.rec-pane { display: none; }
.rec-pane.is-on { display: block; }

/* Switched off, the configuration is still readable but plainly inactive. */
.rec-body.is-off { opacity: .45; pointer-events: none; }

/* The custom-interval pair, revealed only when the frequency is Custom. */
.rec-custom { align-self: end; }
.rec-inline { display: flex; align-items: center; gap: 8px; }
.rec-inline input { flex: 0 1 7rem; }
.rec-suffix { font-size: 13px; color: var(--muted-foreground); }
.rec-note { margin-top: 16px; }

/* The calculated answers sit above the footer, where they are visible from every
   tab: the two questions anybody configuring a schedule actually has. */
.rec-calc {
  display: flex; gap: 32px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--muted);
}
.rec-calc > div { display: flex; flex-direction: column; gap: 2px; }
.rec-calc-k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted-foreground);
}
.rec-calc strong { font-size: 14px; font-weight: 600; }

@media (max-width: 640px) {
  .rec-head { flex-direction: column; gap: 8px; }
  .rec-calc { gap: 20px; }
}

/* A panel heading, and the label/value list used on the schedule detail.
   Two columns where there is room, one where there is not, so a long value never
   collides with the next label. */
.panel-title {
  font-size: 15px; font-weight: 600; margin-bottom: 16px;
}
/* panel-clip has no padding of its own, because a table inside it must reach the
   panel's edges. A heading inside one therefore has to carry its own, or it hangs
   off the left edge of the card. */
.panel-clip > .panel-title { padding: 20px 24px 0; margin-bottom: 12px; }
.kv {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
}
.kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv dt {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted-foreground);
}
.kv dd { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 720px) { .kv { grid-template-columns: minmax(0, 1fr); } }


/* ---------------------------------------------------- correction review

   ORIGINAL / CORRECTED / DIFFERENCE. Three money columns read against each
   other, so they are tabular: proportional digits make two numbers of the same
   magnitude different widths and the eye cannot compare a column it has to
   re-measure on every row.

   Added, removed and changed are marked with a tinted left edge rather than a
   background wash. A wash on a third of the rows makes the table look broken;
   an edge marks the row without fighting the figures for attention. The colour
   tokens are redefined for dark mode at the top of this file, so both themes
   get the same meaning without a second rule here. */
.corr-table { font-variant-numeric: tabular-nums; }
.corr-table tbody tr > td:first-child { border-left: 3px solid transparent; }

.corr-table tr.corr-added   > td:first-child { border-left-color: var(--emerald-700); }
.corr-table tr.corr-removed > td:first-child { border-left-color: var(--rose-700); }
.corr-table tr.corr-changed > td:first-child { border-left-color: var(--amber-800); }

.corr-table tr.corr-added   { background: var(--emerald-50); }
.corr-table tr.corr-removed { background: var(--rose-50); }
.corr-table tr.corr-changed { background: var(--amber-50); }

/* A removed line is struck through, because "Removed" in the last column is
   read after the figure and the figure is the thing being cancelled. */
.corr-table tr.corr-removed > td:first-child { text-decoration: line-through; }

.corr-tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid var(--border); background: var(--card);
  color: var(--muted-foreground);
}
.corr-added   .corr-tag { color: var(--emerald-700); border-color: var(--emerald-700); }
.corr-removed .corr-tag { color: var(--rose-700);    border-color: var(--rose-700); }
.corr-changed .corr-tag { color: var(--amber-800);   border-color: var(--amber-800); }

.corr-table tfoot td { border-top: 1px solid var(--border); }
.corr-table tfoot tr.corr-total td { font-size: 16px; font-weight: 700; }

/* The correction history on the invoice. A chain, read top to bottom, with the
   original at the top and never hidden. */
.corr-chain { list-style: none; margin: 0; padding: 0; }
.corr-chain > li { padding: 12px 0; border-top: 1px solid var(--border); }
.corr-chain > li:first-child { border-top: 0; }
.corr-chain .corr-when { font-size: 12px; color: var(--muted-foreground); }
.corr-chain .corr-docs { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.corr-chain .corr-docs li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

.corr-effective { display: grid; gap: 6px; margin-top: 12px; }
.corr-effective div { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.corr-effective .corr-net { font-weight: 700; font-size: 16px;
  border-top: 1px solid var(--border); padding-top: 6px; }

/* ------------------------------------------------------------- 30. reports */

/* A report card is a whole panel that is also a link. The panel styles already
   carry the border and padding; this adds the affordance and stops the anchor
   inheriting the underline it would get in body text. */
.report-card { display: block; text-decoration: none; color: inherit; transition: border-color .12s ease, transform .12s ease; }
.report-card:hover { border-color: var(--slate-400); transform: translateY(-1px); }
.report-card h2 { margin: 0 0 4px; font-size: 1rem; }
.report-card .sub { margin: 0; }

/* A section row inside a statement or ledger table: the class heading on a
   balance sheet, the opening balance on a ledger. Tinted rather than bold alone
   so the eye finds the blocks without reading them. */
.data tr.sec > td { background: var(--muted); border-top: 1px solid var(--border); }

/* A match row carries an amount box and its button on one line, inside a table
   cell that is already tight. flex rather than inline-block so the two align on
   their baselines whatever the button's padding is. */
.inline-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.input-xs { padding: 4px 8px; font-size: .8125rem; width: 7rem; text-align: right; }

/* A clause's wording, shown as it will read on a document: preserved line
   breaks, comfortable measure. The text is the product here, so it gets the
   room a paragraph of terms needs rather than table styling. */
.clause-body {
  white-space: pre-wrap;
  max-width: 68ch;
  line-height: 1.6;
  margin: 8px 0 0;
}

/* A list of checkboxes that is a list, not a bulleted list. */
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

/* One assembled section of a proposal. An excluded section stays visible but
   dimmed, so the shape of the document is legible even where it has holes. */
.doc-section { padding: 12px 0; border-top: 1px solid var(--border); }
.doc-section:first-child { border-top: 0; }
.doc-section h3 { margin: 0 0 6px; font-size: 1rem; }
.doc-section.is-off { opacity: .5; }

/* One entry in Review Mode. The blocking ones carry a left edge so a person can
   see, without reading, how much is still outstanding. */
.review-item { padding: 10px 0; border-top: 1px solid var(--border); }
.review-item:first-child { border-top: 0; }
.review-item h3 { margin: 0 0 4px; font-size: .95rem; }
/* An outstanding item is marked by its heading, not by a coloured edge: the
   heading already carries the word "Outstanding", and a stripe down the side
   would be decoration doing the same job twice. */
.review-item.is-blocking h3 { color: var(--destructive); }

/* ============================================================================
   THE PROPOSAL DOCUMENT
   ============================================================================

   Everything below is scoped to .proposal and applies only to the rendered
   proposal, never to the application's own screens.

   IT IS A THEME, NOT A DESIGN. Not one colour, size or margin below is a
   literal: every one reads a custom property that the renderer writes onto the
   document from document_themes.tokens, and an issued proposal writes its own
   frozen copy of those tokens. A second theme is a second row in that table.
   The values that arrive with the Soch Commercial Proposal theme were measured
   off the reference PDF; see migration 0051.

   PAGINATION IS EXPLICIT. Each .pp-sheet is one A4 page with its own header,
   footer and page number, and a page break after it. Browsers disagree about
   running headers and about @page margin boxes, and a proposal whose footer
   moves between Chrome and Safari is not a document somebody can send. */

@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 300; font-display: block;
  src: url("fonts/Poppins-Light.ttf") format("truetype");
}
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: block;
  src: url("fonts/Poppins-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: block;
  src: url("fonts/Poppins-Medium.ttf") format("truetype");
}
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: block;
  src: url("fonts/Poppins-Bold.ttf") format("truetype");
}
@font-face {
  font-family: "Pagella"; font-style: normal; font-weight: 400; font-display: block;
  src: url("fonts/texgyrepagella-regular.otf") format("opentype");
}
@font-face {
  font-family: "Pagella"; font-style: italic; font-weight: 400; font-display: block;
  src: url("fonts/texgyrepagella-italic.otf") format("opentype");
}

.proposal {
  background: var(--pp-page);
  color: var(--pp-ink);
  font-family: var(--pp-sans), system-ui, sans-serif;
  font-weight: 300;
  font-size: var(--pp-body);
  line-height: var(--pp-body-lead);
  margin: 0;
  padding: 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.pp-sheet {
  position: relative;
  width: var(--pp-w);
  height: var(--pp-h);
  margin: 0 auto 10mm;
  background: var(--pp-page);
  box-sizing: border-box;
  /* The bottom padding reserves the footer's own height as well as the page
     margin, so a full page of content stops above the rule rather than running
     underneath it. */
  padding: var(--pp-mt) var(--pp-mx) calc(var(--pp-mb) + 24pt);
  overflow: hidden;
  break-after: page;
  page-break-after: always;
}
.pp-sheet:last-child { break-after: auto; page-break-after: auto; margin-bottom: 0; }

/* ------------------------------------------------------------ furniture */

.pp-sheet-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--pp-micro); letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-ink);
}
.pp-sheet-head .right { color: var(--pp-muted); }

.pp-sheet-foot {
  position: absolute; left: var(--pp-mx); right: var(--pp-mx); bottom: var(--pp-mb);
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 7pt; border-top: .5pt solid var(--pp-rule);
  font-size: var(--pp-micro); letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-muted);
}
.pp-sheet-foot .pp-page-no { color: var(--pp-accent); }

/* ---------------------------------------------------------------- cover */

.pp-cover { padding: 0; }
.pp-cover-frame {
  position: absolute; inset: var(--pp-cover-inset);
  border: .75pt solid var(--pp-border);
}
.pp-cover-inner {
  position: absolute; inset: var(--pp-cover-inset);
  padding: var(--pp-cover-pad);
  box-sizing: border-box;
  display: flex; flex-direction: column;
}
.pp-cover-brand { font-weight: 700; font-size: 15pt; letter-spacing: -.01em; }
.pp-cover-brand .pp-dot { color: var(--pp-accent); }
.pp-cover-tagline {
  margin-top: 7pt; font-size: var(--pp-micro); font-weight: 400;
  letter-spacing: var(--pp-track); text-transform: uppercase; color: var(--pp-muted);
}
.pp-cover-mid { margin-top: auto; margin-bottom: auto; }
.pp-cover-eyebrow {
  font-size: 7.4pt; font-weight: 500; letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-accent);
}
.pp-cover-title {
  font-family: var(--pp-serif), Georgia, serif;
  font-size: var(--pp-cover-title); line-height: 1.06; font-weight: 400;
  margin: 9pt 0 0;
}
.pp-cover-title .pp-line-2 { display: block; font-style: italic; color: var(--pp-accent); }
.pp-cover-lead {
  font-family: var(--pp-serif), Georgia, serif;
  font-size: var(--pp-cover-lead); margin-top: 16pt;
}
.pp-cover-rule {
  width: var(--pp-rule-w); height: 1.5pt; background: var(--pp-accent);
  margin-top: 22pt;
}
.pp-cover-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16pt 40pt;
}
.pp-cover-meta .pp-k {
  font-size: var(--pp-micro); font-weight: 400; letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-muted);
}
.pp-cover-meta .pp-v { margin-top: 4pt; font-size: var(--pp-body); }

/* -------------------------------------------------------------- section */

.pp-sec-eyebrow {
  margin-top: 20pt;
  font-size: 6.8pt; font-weight: 500; letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-accent);
}
.pp-sec-title {
  font-family: var(--pp-serif), Georgia, serif;
  font-size: var(--pp-h1); font-weight: 400; margin: 2pt 0 0;
}
.pp-sec-rule { width: var(--pp-rule-w); height: 1.5pt; background: var(--pp-accent); margin: 10pt 0 20pt; }

.pp-sec-body > *:first-child { margin-top: 0; }
.pp-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28pt; align-items: start; }
.pp-col { min-width: 0; }

h3.pp-blk-head {
  font-family: var(--pp-serif), Georgia, serif;
  font-size: var(--pp-h2); font-weight: 400; margin: 16pt 0 8pt;
}
.pp-blk-text { margin: 0 0 9pt; }
.pp-blk-note { margin: 10pt 0 0; color: var(--pp-muted); }

/* Lists. The reference marks an included item with a diamond, an excluded one
   with a cross and a deliverable with a tick, and the glyph carries meaning, so
   it is a character in the markup rather than a list-style. */
.pp-blk-list { list-style: none; margin: 0 0 9pt; padding: 0; }
.pp-blk-list li {
  display: grid; grid-template-columns: 13pt 1fr; gap: 0;
  margin-bottom: 7pt; break-inside: avoid;
}
.pp-blk-list .pp-mk { color: var(--pp-accent); font-size: 8pt; line-height: 1.7; }
.pp-blk-list.pp-is-out li .pp-mk { color: var(--pp-muted); }
.pp-blk-list.pp-is-out li { color: var(--pp-muted); }
.pp-blk-list b { font-weight: 500; }

/* Panels: the tinted blocks with a gold edge. */
.pp-blk-panel {
  background: var(--pp-panel); border-left: 1.5pt solid var(--pp-accent);
  padding: 14pt 16pt; margin: 16pt 0; break-inside: avoid;
}
.pp-blk-panel .pp-panel-title {
  font-family: var(--pp-serif), Georgia, serif;
  font-size: 9.6pt; letter-spacing: .06em; text-transform: uppercase;
  margin: 0 0 8pt;
}
.pp-blk-panel p { margin: 0 0 6pt; }
.pp-blk-panel p:last-child { margin-bottom: 0; }
.pp-blk-panel .pp-blk-list { margin-bottom: 0; }
.pp-blk-panel .pp-blk-list li:last-child { margin-bottom: 0; }
.pp-blk-panel.pp-is-quiet p { color: var(--pp-muted); }

/* Numbered lists: the nine pages, and the approval gates. */
.pp-blk-rows { margin: 0; }
.pp-blk-rows .pp-row {
  /* The label column is wide enough for "Days 12 to 14" on one line: a stage
     label that wraps into its own heading is the first thing a reader notices. */
  display: grid; grid-template-columns: 76pt 1fr; gap: 0 0;
  padding: 8pt 0; border-top: .5pt solid var(--pp-rule); break-inside: avoid;
}
.pp-blk-rows .pp-row:first-child { border-top: 0; }
.pp-blk-rows .pp-idx {
  font-family: var(--pp-serif), Georgia, serif;
  font-size: 11pt; color: var(--pp-accent);
}
.pp-blk-rows .pp-idx.pp-is-label {
  font-family: var(--pp-sans), sans-serif; font-size: var(--pp-micro);
  letter-spacing: var(--pp-track); text-transform: uppercase; color: var(--pp-accent);
  white-space: nowrap; padding-right: 8pt;
}
.pp-blk-rows .pp-rh {
  font-family: var(--pp-serif), Georgia, serif; font-size: 10.2pt; margin: 0 0 3pt;
}
.pp-blk-rows .pp-rt { font-size: var(--pp-small); color: var(--pp-ink); margin: 0; }
.pp-blk-rows.pp-is-plain .pp-rh { font-size: 9.6pt; }

/* The investment table. */
.pp-blk-table { width: 100%; border-collapse: collapse; margin: 0 0 14pt; }
.pp-blk-table th {
  font-size: var(--pp-micro); font-weight: 400; letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-muted);
  text-align: left; padding: 0 0 7pt; border-bottom: .5pt solid var(--pp-rule);
  white-space: nowrap;
}
.pp-blk-table th.pp-num, .pp-blk-table td.pp-num { text-align: right; }
/* The figure columns are sized so the item description takes the rest. Without
   this the headings collide the moment one of them is two words. */
.pp-blk-table th.pp-num { width: 56pt; }
.pp-blk-table th.pp-num:last-child { width: 92pt; }
.pp-blk-table td { padding: 8pt 0; vertical-align: top; border-bottom: .5pt solid var(--pp-rule); }
.pp-blk-table .pp-item-name { font-family: var(--pp-serif), Georgia, serif; font-size: 10pt; }
.pp-blk-table .pp-item-note { display: block; margin-top: 4pt; font-size: 7.6pt; color: var(--pp-muted); }
.pp-blk-table tfoot td {
  border-bottom: 0; padding-top: 12pt;
  font-family: var(--pp-serif), Georgia, serif; font-size: 13pt;
}

/* The acceptance and payment block. */
.pp-blk-accept { border: .75pt solid var(--pp-accent); padding: 14pt 16pt; margin: 18pt 0 0; }
.pp-blk-accept .pp-accept-title {
  font-size: var(--pp-micro); font-weight: 400; letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-accent); margin: 0 0 8pt;
}
.pp-blk-accept .pp-pay-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10pt 28pt;
  margin-top: 12pt; padding-top: 12pt; border-top: .5pt solid var(--pp-border);
}
.pp-blk-accept .pp-k {
  font-size: var(--pp-micro); letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-muted);
}
.pp-blk-accept .pp-v { margin-top: 3pt; }

.pp-sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28pt; margin-top: 34pt; }
.pp-sign-grid .pp-line { border-top: .5pt solid var(--pp-ink); padding-top: 7pt;
  font-size: var(--pp-micro); letter-spacing: var(--pp-track);
  text-transform: uppercase; color: var(--pp-muted); }

/* Terms and conditions: two columns of justified small print, numbered. */
.pp-terms { columns: 2; column-gap: 24pt; font-size: var(--pp-terms); line-height: var(--pp-terms-lead); }
.pp-terms .pp-clause { display: grid; grid-template-columns: 18pt 1fr; margin-bottom: 8pt; break-inside: avoid; }
.pp-terms .pp-clause .pp-n { color: var(--pp-accent); }
.pp-terms .pp-clause .pp-t { text-align: justify; }
.pp-terms .pp-clause .pp-t b { font-weight: 500; }

@media print {
  /* THE PAPER IS THE PAGE. An explicit size with no margin means the browser
     prints the sheet exactly as it is laid out, rather than adding its own
     margin and then shrinking the content to fit inside it. */
  @page { size: 210mm 297mm; margin: 0; }
  html, body.proposal { width: var(--pp-w); min-width: 0; margin: 0; padding: 0; }
  .pp-sheet { margin: 0; box-shadow: none; }
}

/* A definition table: a serif label against its explanation, used for the
   approval gates. The same table furniture as the investment table, so the two
   pages read as one document. */
.pp-blk-defs td.pp-dt { font-family: var(--pp-serif), Georgia, serif; font-size: 9.6pt; width: 150pt; }
.pp-blk-defs td.pp-dd { font-size: var(--pp-small); }

/* The blocks added for the guided template builder. */
.pp-blk-quiet { margin: 0 0 9pt; color: var(--pp-muted); }
.pp-blk-quote {
  font-family: var(--pp-serif), Georgia, serif; font-size: 11pt;
  margin: 14pt 0; padding-left: 14pt; border-left: 1.5pt solid var(--pp-accent);
}
.pp-blk-space { height: 16pt; }
.pp-blk-image { margin: 14pt 0; }
.pp-blk-image img { max-width: 100%; height: auto; display: block; }
.pp-cover-logo { max-width: 150pt; max-height: 46pt; height: auto; display: block; }

/* THE OVERFLOW WARNING. A page whose content is longer than the paper is the one
   failure a preview cannot show you, because the overflow is clipped and simply
   is not there. The script measures each page and marks it; this is what the
   author sees, on screen only, never on the printed document. */
.pp-overflow-note {
  display: none;
  position: absolute; left: var(--pp-mx); right: var(--pp-mx); bottom: 6pt;
  padding: 6pt 8pt; border-radius: 4px;
  background: var(--destructive); color: #fff;
  font-family: var(--pp-sans), sans-serif; font-size: 8pt; letter-spacing: 0;
  text-transform: none;
}
.pp-sheet.pp-is-over .pp-overflow-note { display: block; }
@media print { .pp-overflow-note { display: none !important; } }

/* THE GUIDED BUILDER. A choice a person makes by reading a sentence, not by
   recognising a term, and a block of questions about one page of their document. */
.choice-list { display: grid; gap: 8px; margin: 12px 0 20px; }
.choice {
  display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.choice:hover { background: var(--secondary); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--secondary); }
.choice strong { display: block; }
.setup-block { padding: 16px 0; border-top: 1px solid var(--border); }
.setup-block:first-of-type { border-top: 0; }

/* THE BLOCK EDITOR.
   One row per piece of a page: its position, what it is, and what it says. The
   labels are present for a screen reader and hidden from sight, because the
   select itself already says what the row is for. */
.blk-row {
  display: grid;
  grid-template-columns: 4rem 13rem 1fr;
  gap: 0.5rem;
  align-items: start;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}
.blk-pos input { width: 100%; text-align: right; }
.blk-kind { display: grid; gap: 0.35rem; }
.blk-kind select { width: 100%; }
.blk-text textarea { width: 100%; }
.vis-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 40rem) {
  .blk-row { grid-template-columns: 1fr; }
}

/* THE LIBRARY GRID. Cards of equal width that reflow to one column on a phone,
   because a template's name and what it is for are the whole decision. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1rem;
  align-items: start;
}

/* GET STARTED. One row per step: what it is on the left, the way to do it on the
   right. A finished step keeps its place and loses its emphasis, so the list reads
   as progress rather than rearranging itself under the reader. */
.start-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.start-step {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}
.start-step:first-child { border-top: 0; }
.start-step.is-done { opacity: 0.6; }
.start-step .btn { flex: none; }
@media (max-width: 40rem) {
  .start-step { flex-direction: column; align-items: flex-start; }
}

/* A plain list, for plan features: the bullets are noise next to three short
   facts, and the list still reads as a list to a screen reader. */
.plain-list { list-style: none; margin: 0.5rem 0 1rem; padding: 0; }
.plain-list li { padding: 0.15rem 0; }
.auth-card.wide { max-width: 64rem; }

/* The inline add-a-category panel on the item form. Indented under the field it
   belongs to, so it reads as part of that control rather than as a new section,
   and spaced away from the select so the two are not mistaken for one widget. */
.inline-add { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--slate-200);
  border-radius: 8px; background: var(--slate-50); }
.inline-add label { display: block; font-size: 12px; margin-bottom: 4px; }
.inline-add input { width: 100%; }
.inline-add-actions { display: flex; gap: 8px; margin-top: 8px; }

/* The library preview bar. It sits above the first sheet and never prints: the
   whole point of the preview is that what comes out of the printer is the
   document, with no application furniture on it. */
.pp-preview-bar { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; max-width: 210mm; margin: 16px auto; padding: 12px 16px;
  border: 1px solid var(--slate-200); border-radius: 10px; background: #fff; }
.pp-preview-bar strong { display: block; }
.pp-preview-bar span { font-size: 13px; color: var(--slate-500); }
.pp-preview-actions { display: flex; gap: 8px; align-items: center; }
@media print { .no-print { display: none !important; } }

/* THE TEMPLATE LIBRARY CARD.
   A third action (Preview) broke the row: .inline-actions does not wrap, so the
   buttons ran out past the card edge, and .card-grid aligns to start, so the
   cards were ragged and no two action rows lined up. Both are fixed here rather
   than on the shared classes, because every other screen using them has two
   actions and a different shape.

   The grid stretches so every card is the height of the tallest in its row, the
   card is a column with the actions pushed to the bottom by auto margin, and the
   actions wrap instead of overflowing. The service list is clamped to three
   lines: it is there to say roughly what the template sells, and eleven services
   spelled out made one card twice the height of its neighbour. */
.lib-grid { align-items: stretch; }
.lib-card { display: flex; flex-direction: column; }
.lib-card > h2 { margin-top: 0; }
.lib-card-for {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.lib-card-actions {
  margin-top: auto; padding-top: 12px; flex-wrap: wrap;
  justify-content: flex-start; row-gap: 8px;
}
.lib-card-actions .btn { white-space: nowrap; }

/* ------------------------------------------------------------- date picker
 *
 * The calendar <input type="date"> will not let us style. See datepicker.js for
 * why it is an enhancement rather than a replacement. The native field stays
 * visible and keeps working; this adds the button beside it and the panel below.
 *
 * Everything here is a theme token, so the picker follows light and dark with
 * the rest of the product rather than carrying its own palette. */
.dp-wrap { position: relative; display: block; }
.dp-wrap > .dp-input { width: 100%; padding-right: 2.5rem; }
/* DISPLAY NONE, NOT OPACITY ZERO. An invisible indicator still has a click area,
   so the browser's own calendar kept opening next to ours when somebody clicked
   the right-hand end of the field: two pickers, one of them the thing this
   component exists to replace. Removing the box removes the target.
   The field is still a date input and still opens natively if this stylesheet
   never loads, which is the fallback the whole component depends on. */
.dp-input::-webkit-calendar-picker-indicator { display: none; }
.dp-input::-webkit-inner-spin-button { display: none; }

.dp-open {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--slate-500); cursor: pointer;
}
.dp-open:hover { background: var(--muted); color: var(--fg); }
.dp-open:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.dp-open svg { width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; }

.dp-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  width: 17.5rem; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--popover); box-shadow: var(--shadow-2xl);
}
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.dp-title { font-weight: 600; font-size: .9375rem; }
.dp-nav {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--slate-500); cursor: pointer;
}
.dp-nav:hover { background: var(--muted); color: var(--fg); }
.dp-nav:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.dp-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.dp-dow, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dp-dow { margin: 8px 0 2px; }
.dp-dow span {
  text-align: center; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--slate-500);
}
.dp-grid { gap: 2px; }
.dp-day {
  display: flex; align-items: center; justify-content: center;
  height: 34px; padding: 0; border: 0; border-radius: 8px;
  background: none; color: var(--fg); font: inherit; font-size: .875rem;
  font-variant-numeric: tabular-nums; cursor: pointer;
}
.dp-day:hover:not(:disabled) { background: var(--muted); }
.dp-day:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
/* A day from the neighbouring month is shown so the weeks line up, and dimmed so
   it is not mistaken for this month's. */
.dp-day.is-outside { color: var(--slate-400); }
/* Today is marked, never selected. The two mean different things and a picker
   that conflates them makes people set the wrong date. */
.dp-day.is-today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--border); }
.dp-day.is-selected, .dp-day.is-selected:hover {
  background: var(--brand); color: var(--brand-fg); font-weight: 600;
}
.dp-day.is-blocked { color: var(--slate-300); cursor: not-allowed; }

.dp-foot {
  display: flex; gap: 6px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.dp-today, .dp-clear {
  flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: none; color: var(--fg); font: inherit; font-size: .8125rem; cursor: pointer;
}
.dp-today:hover, .dp-clear:hover { background: var(--muted); }
.dp-today:focus-visible, .dp-clear:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

/* The contract field's suggestion list. The field itself is an ordinary text
   input and stays one; this only gives the dropdown something to anchor to. */
.picker-field { position: relative; }

/* The quick choices. Four, because a document date is nearly always one of them
   or a specific day somebody already has in mind; a longer list is a menu to
   read rather than a shortcut. */
.dp-shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 8px; }
.dp-shortcut {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px;
  background: none; color: var(--fg); font: inherit; font-size: .75rem; cursor: pointer;
}
.dp-shortcut:hover { background: var(--muted); }
.dp-shortcut:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

/* The tick column on the classification worklist. A class rather than a style
   attribute, because style-src is self and the browser drops inline styles. */
.w-tick { width: 32px; }

/* ===========================================================================
   CUSTOMER 360. F-105.

   The approved reference's layout, proportions and spacing, expressed in
   this product's own dark palette rather than a second set of hard-coded
   colours. Everything is prefixed c360- so none of it can reach another
   screen, and no rule here overrides an existing class.

   No inline style attributes anywhere: style-src is 'self' and a build gate
   fails the release if one appears.
   =========================================================================== */

.c360-layout { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 12px; }
.c360-main { min-width: 0; }
.c360-side { display: flex; flex-direction: column; gap: 12px; }

.c360-card { background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.c360-section { padding: 14px; min-height: 180px; }
.c360-section h2, .c360-sidecard h2 { font-size: 14px; margin: 0 0 13px;
  letter-spacing: -.2px; display: flex; justify-content: space-between; align-items: baseline; }
.c360-section h2 a, .c360-sidecard h2 a { font-size: 11px; font-weight: 400; }

.c360-kpis { display: grid; grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 7px; margin: 8px 0 14px; }
.c360-kpi { padding: 13px 12px; min-height: 84px; }
.c360-kpi .label { font-size: 10px; color: var(--slate-500); margin-bottom: 9px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ONE ICON SIZE, ONE STROKE, AND COLOUR BY MEANING. The six tints are the
   approved palette: a figure about money is blue, money that arrived is
   green, money that is late is coral, an opportunity is violet, something to
   do is amber, a conversation is cyan. */
.ic { width: 14px; height: 14px; display: block; }
.c360-ic { display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 8px; flex: none; }
.c360-ic-rev   { color: #3b82f6; background: color-mix(in srgb, #3b82f6 15%, transparent); }
.c360-ic-trend { color: #10b981; background: color-mix(in srgb, #10b981 15%, transparent); }
.c360-ic-due   { color: #f97363; background: color-mix(in srgb, #f97363 16%, transparent); }
.c360-ic-inv   { color: #8b5cf6; background: color-mix(in srgb, #8b5cf6 15%, transparent); }
.c360-ic-talk  { color: #06b6d4; background: color-mix(in srgb, #06b6d4 15%, transparent); }
.c360-ic-task  { color: #f59e0b; background: color-mix(in srgb, #f59e0b 16%, transparent); }
.c360-ic-s { color: var(--slate-500); display: inline-grid; place-items: center;
  vertical-align: -2px; margin-right: 5px; }
.c360-smallkpis .label { display: flex; align-items: center; }
.c360-kpi .value { font-size: 17px; font-weight: 800; white-space: nowrap;
  letter-spacing: -.4px; }
.c360-kpi .sub { font-size: 10px; color: var(--slate-500); margin-top: 7px; }
.c360-kpi .sub.good { color: #27d17a; }
.c360-kpi .sub.bad { color: #ff634f; }

.c360-smallkpis { display: grid; grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 7px; margin-bottom: 11px; }
.c360-smallkpis .c360-card { padding: 11px 10px; min-height: 59px; }
.c360-smallkpis .label { font-size: 10px; color: var(--slate-500); }
.c360-smallkpis .value { font-size: 13px; font-weight: 800; margin-top: 6px; }

.c360-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 10px; }

.c360 .chart { width: 100%; height: 148px; overflow: visible; }
/* The chart's paint lives here, not on the elements: style-src is 'self', so
   an inline style attribute is dropped by the browser and refused by a build
   gate. The gradient's two stops are classes for the same reason. */
.bar-top { stop-color: #60a5fa; }
.bar-bottom { stop-color: #2563eb; }
.chart-bar { fill: url(#c360bar); transition: opacity .15s ease; }
.chart-bar:hover { opacity: .78; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--slate-500); font-size: 8.5px; text-anchor: end;
  font-variant-numeric: tabular-nums; }
.chart-label { fill: var(--slate-500); font-size: 9px; text-anchor: middle; }

/* The annual / monthly selector in the panel's heading. */
.c360-seg { display: inline-flex; border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; font-size: 10px; font-weight: 500; }
.c360-seg a { padding: 4px 10px; color: var(--slate-500); text-decoration: none; }
.c360-seg a:hover { background: color-mix(in srgb, var(--card-foreground) 7%, transparent); }
.c360-seg a.on { background: color-mix(in srgb, #3b82f6 18%, transparent);
  color: var(--card-foreground); }
.c360-seg a:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.c360-donutarea { display: flex; align-items: center; justify-content: space-around;
  gap: 10px; flex-wrap: wrap; }
.c360-donut { height: 164px; width: 164px; flex: none; position: relative; }
.c360-donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.c360-donutcenter { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 12px; }
.c360-donutcenter { font-size: 9.5px; text-align: center; padding: 0 30px; }
.c360-donutcenter b { font-size: 12px; line-height: 1.25; word-break: break-word;
  font-variant-numeric: tabular-nums; }
.c360-donutcenter small { font-size: 9px; color: var(--slate-500); }
.c360-legend { display: flex; flex-direction: column; gap: 12px; font-size: 11px; }
.c360-legendrow { display: flex; align-items: center; gap: 7px; }
.c360-legendrow strong { margin-left: auto; text-align: right;
  font-variant-numeric: tabular-nums; }
.c360-legendrow strong small { display: block; font-weight: 400;
  color: var(--slate-500); font-size: 9.5px; margin-top: 2px; }
.c360-legendname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 120px; }

/* Classification coverage, shown rather than buried in fine print: it is the
   figure that says how much of the picture above can be trusted. */
.c360-coverage { margin-top: 12px; }
.c360-coverage-head { display: flex; justify-content: space-between;
  font-size: 10px; color: var(--slate-500); margin-bottom: 5px; }
.c360-coverage-head strong { color: var(--card-foreground);
  font-variant-numeric: tabular-nums; }
.c360-meter { height: 6px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--card-foreground) 10%, transparent); }
.c360-meter-fill { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa); }

/* Widths as classes in steps of five, because an inline style attribute is
   refused by the content security policy and by a build gate. */
.w-pct-0 { width: 0; } .w-pct-5 { width: 5%; } .w-pct-10 { width: 10%; }
.w-pct-15 { width: 15%; } .w-pct-20 { width: 20%; } .w-pct-25 { width: 25%; }
.w-pct-30 { width: 30%; } .w-pct-35 { width: 35%; } .w-pct-40 { width: 40%; }
.w-pct-45 { width: 45%; } .w-pct-50 { width: 50%; } .w-pct-55 { width: 55%; }
.w-pct-60 { width: 60%; } .w-pct-65 { width: 65%; } .w-pct-70 { width: 70%; }
.w-pct-75 { width: 75%; } .w-pct-80 { width: 80%; } .w-pct-85 { width: 85%; }
.w-pct-90 { width: 90%; } .w-pct-95 { width: 95%; } .w-pct-100 { width: 100%; }
.c360-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none;
  display: inline-block; }
/* The same six colours the donut draws, so the legend agrees with the
   picture, plus grey for unclassified. */
.c360-swatch-0 { background: #55afff; }
.c360-swatch-1 { background: #ad86fa; }
.c360-swatch-2 { background: #27d17a; }
.c360-swatch-3 { background: #ffb84f; }
.c360-swatch-4 { background: #ff634f; }
.c360-swatch-5 { background: #4fd6d2; }
.c360-swatch-x { background: #5b6b7a; }

.c360-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.c360-table th { background: color-mix(in srgb, var(--card-foreground) 8%, transparent);
  text-align: left; font-weight: 500; color: var(--slate-500); padding: 10px 8px; }
.c360-table th:first-child { border-top-left-radius: 8px; }
.c360-table th:last-child { border-top-right-radius: 8px; text-align: right; }
.c360-table td { padding: 11px 8px; border-bottom: 1px solid var(--border); }
.c360-table td:last-child { text-align: right; }
.c360-table td:nth-child(2), .c360-table td:nth-child(3),
.c360-table td:last-child { font-variant-numeric: tabular-nums; }
.c360-table tbody tr { transition: background .12s ease; }
.c360-table tbody tr:hover { background: color-mix(in srgb, var(--card-foreground) 5%, transparent); }
.c360-table tbody tr:last-child td { border-bottom: 0; }

.c360-link { font-size: 11px; margin-top: 13px; display: inline-block; }
.c360-item { display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 11px; }
.c360-item:last-of-type { border-bottom: 0; }
.c360-item .symbol { display: grid; place-items: center; width: 31px; height: 31px;
  flex: none; border-radius: 50%; color: var(--slate-500);
  background: color-mix(in srgb, var(--card-foreground) 9%, transparent); }

/* AN EVENT'S COLOUR SAYS WHAT KIND OF EVENT IT IS, and the same colour means
   the same thing on every panel of this screen: billing blue, cash green,
   a credit amber, a conversation cyan, something owed coral. */
.c360-item .symbol.c360-ev-invoice      { color: #3b82f6; background: color-mix(in srgb, #3b82f6 15%, transparent); }
.c360-item .symbol.c360-ev-receipt      { color: #10b981; background: color-mix(in srgb, #10b981 16%, transparent); }
.c360-item .symbol.c360-ev-credit_note  { color: #f59e0b; background: color-mix(in srgb, #f59e0b 17%, transparent); }
.c360-item .symbol.c360-ev-estimate     { color: #8b5cf6; background: color-mix(in srgb, #8b5cf6 15%, transparent); }
.c360-item .symbol.c360-ev-interaction  { color: #06b6d4; background: color-mix(in srgb, #06b6d4 15%, transparent); }
.c360-item .symbol.c360-ev-follow_up    { color: #f59e0b; background: color-mix(in srgb, #f59e0b 15%, transparent); }
.c360-item .symbol.c360-ev-opportunity { color: #8b5cf6; background: color-mix(in srgb, #8b5cf6 15%, transparent); }
.c360-item .symbol.c360-ev-complaint    { color: #f97363; background: color-mix(in srgb, #f97363 16%, transparent); }
.c360-item .symbol.c360-ev-satisfaction { color: #eab308; background: color-mix(in srgb, #eab308 17%, transparent); }
.c360-item .desc { flex: 1; }
.c360-item .desc b { display: block; font-size: 11px; }
.c360-item .desc small { display: block; color: var(--slate-500); margin-top: 3px; }
.c360-item time { color: var(--slate-500); margin-left: auto; white-space: nowrap; }
.c360-mini { border: 1px solid var(--border); border-radius: 8px; font-size: 10px;
  padding: 7px 9px; white-space: nowrap; }

.c360-sidecard { padding: 14px 12px; }
.c360-person { display: flex; align-items: center; gap: 9px; margin: 12px 0; }
.c360-person .circle { width: 29px; height: 29px; border-radius: 50%;
  background: #318cba; display: grid; place-items: center; font-weight: 700;
  font-size: 11px; color: #fff; }
.c360-person .info { flex: 1; font-size: 11px; }
.c360-person .info small { display: block; color: var(--slate-500); }

.c360-detail { display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; font-size: 11px; border-top: 1px solid var(--border); }
.c360-detail span { color: var(--slate-500); }
.c360-detail strong { font-size: 11px; text-align: right; }

.c360-task { display: flex; gap: 8px; align-items: flex-start; padding: 9px 0;
  font-size: 11px; }
.c360-task span { flex: 1; }
.c360-due { font-size: 10px; border-radius: 12px; padding: 5px 7px;
  background: color-mix(in srgb, #53aeff 20%, transparent); white-space: nowrap; }
.c360-due.red { background: color-mix(in srgb, #ff634f 22%, transparent); }

.c360-insight { display: flex; gap: 11px; padding: 12px 0;
  border-bottom: 1px solid var(--border); }
.c360-insight:last-of-type { border-bottom: 0; }
.c360-insight b { font-size: 11px; }
.c360-insight p { margin: 4px 0 0; color: var(--slate-500); font-size: 10px;
  line-height: 1.4; }

/* ---------------------------------------------------------------------------
   TENURE AND HISTORICAL REVENUE. F-106.
   --------------------------------------------------------------------------- */

/* Tenure sits under the customer's name, which is where a person looks for
   it, and is the only figure on that line with a weight of its own. */
.c360-tenure { display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin: 7px 0 0; font-size: 11px; color: var(--slate-500); }
.c360-tenure-main { display: inline-flex; align-items: center; gap: 6px;
  color: var(--card-foreground); font-weight: 600; }
.c360-tenure-dur { border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 9px; background: color-mix(in srgb, #3b82f6 12%, transparent);
  color: var(--card-foreground); font-weight: 600; }
.c360-milestone { display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 2px 9px; font-weight: 600;
  background: color-mix(in srgb, #eab308 18%, transparent);
  color: var(--card-foreground); }

.c360-hist { display: flex; flex-direction: column; }
.c360-histbig { display: flex; align-items: center; gap: 11px; padding-bottom: 12px; }
.c360-histbig b { display: block; font-size: 17px; letter-spacing: -.4px; }
.c360-histbig small { color: var(--slate-500); font-size: 10px; }
.c360-flag { font-size: 9px; font-weight: 500; border-radius: 999px;
  padding: 2px 7px; margin-left: 6px; color: var(--card-foreground);
  background: color-mix(in srgb, #f59e0b 20%, transparent); }
.c360-detail strong small { display: block; font-weight: 400; font-size: 9.5px;
  color: var(--slate-500); margin-top: 2px; }

/* The annual record as rows rather than a second chart: fourteen labelled
   figures are easier to read down than to compare across. */
.c360-years { display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 11px; max-height: 168px; overflow-y: auto; }
.c360-year { display: grid; grid-template-columns: 34px 1fr auto;
  align-items: center; gap: 9px; font-size: 10.5px; }
.c360-yearlabel { color: var(--slate-500); font-variant-numeric: tabular-nums; }
.c360-yearbar { height: 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--card-foreground) 9%, transparent);
  overflow: hidden; }
.c360-yearfill { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #60a5fa); }
.c360-year.best .c360-yearfill { background: linear-gradient(90deg, #059669, #34d399); }
.c360-year.best .c360-yearval { font-weight: 700; }
.c360-yearval { font-variant-numeric: tabular-nums; white-space: nowrap; }
.c360-up { color: #10b981; font-weight: 600; }
.c360-down { color: #f97363; font-weight: 600; }

/* The at-risk estimate is drawn as an estimate: an amber note with its
   reasoning on the face of it, not a red metric pretending to be a fact. */
.c360-risk { display: flex; gap: 9px; margin-top: 11px; padding: 10px 11px;
  border-radius: 10px; color: var(--card-foreground);
  background: color-mix(in srgb, #f59e0b 13%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 30%, transparent); }
.c360-risk b { font-size: 11px; }
.c360-risk p { margin: 3px 0 0; font-size: 10px; line-height: 1.45;
  color: var(--slate-500); }

/* Panel hierarchy: a heading rule, a softer shadow, and a lift on hover so a
   card reads as one object rather than as a rectangle of text. */
.c360-card { box-shadow: 0 1px 2px color-mix(in srgb, #000 6%, transparent);
  transition: box-shadow .16s ease, border-color .16s ease; }
.c360-card:hover { box-shadow: 0 4px 14px color-mix(in srgb, #000 10%, transparent); }
.c360-section h2, .c360-sidecard h2 { padding-bottom: 9px;
  border-bottom: 1px solid var(--border); font-weight: 650; }
.c360-insight b, .c360-task { letter-spacing: -.1px; }

/* A page that moves is a page some people cannot use. */
@media (prefers-reduced-motion: reduce) {
  .c360-card, .c360-table tbody tr, .chart-bar { transition: none; }
  .c360-card:hover { box-shadow: 0 1px 2px color-mix(in srgb, #000 6%, transparent); }
}

/* The reference's own breakpoints, so the dashboard folds the same way. */
@media (max-width: 1250px) {
  .c360-layout { grid-template-columns: minmax(0,1fr) 245px; }
  .c360-kpis, .c360-smallkpis { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .c360-layout { grid-template-columns: 1fr; }
  .c360-side { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 600px) {
  .c360-grid2, .c360-side { grid-template-columns: 1fr; }
  .c360-kpis, .c360-smallkpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .c360-donutarea { flex-wrap: wrap; }
  .c360-year { grid-template-columns: 32px 1fr; row-gap: 2px; }
  .c360-yearval { grid-column: 2; text-align: right; }
  .c360-tenure { font-size: 10.5px; }
  .c360-legendname { max-width: 100%; }
}

/* The identity block: avatar beside the name, facts on one line. */
.c360-identity .c360-who { display: flex; gap: 20px; align-items: center; }
.c360-avatar { width: 57px; height: 57px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #bed5ff, #85aef5); display: grid;
  place-items: center; font-size: 23px; font-weight: 800; color: #06111a; }
.c360-meta { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
@media (max-width: 600px) {
  .c360-identity .c360-who { gap: 12px; }
  .c360-avatar { width: 44px; height: 44px; font-size: 18px; }
}

/* NINE TABS DO NOT FIT A PHONE, and an inline-flex strip that does not fit
   widens the whole page instead of itself: every panel then sits in a
   horizontally scrolling document. The strip scrolls on its own below the
   tablet breakpoint, which is what the approved reference does. */
@media (max-width: 900px) {
  .tabs { display: flex; max-width: 100%; overflow-x: auto; white-space: nowrap;
    -webkit-overflow-scrolling: touch; }
  .tabs a, .tabs button { flex: none; }
}

/* Customer groups. F-107. The member name in a contribution row, and the
   filter above a multiple select. Both reuse the Customer 360 vocabulary
   rather than introducing a second one. */
.c360-memname { width: auto; max-width: 150px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.c360-year { grid-template-columns: minmax(60px, 150px) 1fr auto; }
/* THE CREATE FORM IS A FORM, NOT A BANNER. On a wide screen a full-width
   field makes a name box two thousand pixels long and the eye has to travel
   the whole width to get from the label to what it typed. The column is
   capped at a readable measure and the fields fill it. */
/* THE HEADING AND ITS BUTTONS WRAP ON A NARROW SCREEN. Without this the three
   buttons push the page 127px wider than the phone and every panel below
   scrolls sideways. A utility class named wrap is used in several templates
   but was never defined; rather than change what that does everywhere, this
   is scoped to the groups screen. F-107. */
.group-head { flex-wrap: wrap; row-gap: 12px; }
.group-actions { flex-wrap: wrap; row-gap: 8px; }
.group-panel { max-width: 680px; }
.group-form { max-width: 620px; }
.group-form label { display: block; margin-bottom: 6px; }
.group-form .input, .group-form .select { width: 100%; }
.group-form .fine { margin-top: 8px; line-height: 1.5; }
.group-field { margin-top: 18px; }

/* A MULTIPLE SELECT IS A LIST, NOT A DROPDOWN. The shared .select rule paints
   a chevron and reserves room for it, which is right for one that opens and
   wrong for one that is already open: it clipped twelve rows down to two and
   drew an arrow that does nothing. */
.multipick {
  appearance: none;
  background-image: none;
  padding: 4px;
  padding-right: 4px;
  height: auto;
  min-height: 280px;
  overflow-y: auto;
  line-height: 1.5;
}
.multipick option { padding: 7px 9px; border-radius: 6px; }
.multipick option:checked {
  background: color-mix(in srgb, #3b82f6 28%, transparent);
  color: var(--card-foreground);
  font-weight: 600;
}
.multipick-search { margin-bottom: 8px; width: 100%; }
.multipick-count { margin-top: 7px; font-weight: 500; }
.is-hidden { display: none; }

/* ---------------------------------------------------------------------------
   FOUR UTILITIES THAT WERE USED BUT NEVER DEFINED.

   Several templates write class="row gap-3 wrap items-end" and class="panel
   p-4". None of those four existed in this stylesheet, so a panel had no
   padding, a row of buttons could not wrap and controls next to each other sat
   on different baselines. The groups screen made it obvious — three buttons
   pushed a phone page 127px wider than the phone — but the same rules were
   missing for the screens that already used them. Defining them is smaller
   and safer than renaming the classes in every template. F-107.
   --------------------------------------------------------------------------- */
.p-4 { padding: 16px; }
.gap-3 { gap: 12px; }
.wrap { flex-wrap: wrap; row-gap: 10px; }
.items-end { align-items: flex-end; }

/* A field that holds a country or state code is four characters wide, not
   half a form. F-111. */
.w-ch-4 { width: 7ch; }

/* F-288. A key in the keyboard shortcuts reference. */
kbd {
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--muted);
}

/* F-298. A payment partner's own official logo, where its file has been
   supplied. Sized to sit on a heading line; nothing else uses it. */
.partner-logo { height: 26px; width: auto; vertical-align: middle; }
/* Light and dark: the partner's own file for each. A logo with no dark file is
   never recoloured; in dark mode it sits on a white plate instead. */
.pl-dark { display: none; }
.dark .pl-dark { display: inline; }
.dark .pl-light { display: none; }
.dark .pl-plate { background: #fff; padding: 4px 8px; border-radius: 6px; box-sizing: content-box; }
/* F-298. The public invoice's action row holds one more button when Pay Now is
   offered, so on a phone it is allowed to wrap. The class is added only then:
   the row on every other invoice is exactly as it was. */
.pay-row { flex-wrap: wrap; }
/* F-302. The Advanced settings fold on a payment partner's screen. */
.adv { margin-top: 20px; padding-top: 16px; }
.adv > summary { cursor: pointer; font-weight: 600; margin-bottom: 12px; }

/* Bills brought in many at a time. F-323. */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 20px; border: 2px dashed var(--border); border-radius: var(--radius-panel); background: var(--slate-50); text-align: center; cursor: pointer; }
.dropzone:hover, .dropzone.is-over, .dropzone:focus-within { border-color: var(--ring); background: var(--sky-50); }
.bb-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bb-progress { display: block; width: 100%; margin-top: 8px; }
table.bb-table tbody tr { cursor: default; }
table.bb-table th, table.bb-table td { padding-left: 8px; padding-right: 8px; }
table.bb-table td { height: auto; padding-top: 8px; padding-bottom: 8px; vertical-align: top; }
table.bb-table .bb-in { display: block; height: 34px; font-size: 13px; }
table.bb-table .bb-in + .bb-in { margin-top: 6px; }
table.bb-table .bb-vendor { width: 200px; }
table.bb-table .bb-no { width: 120px; }
table.bb-table .bb-date { width: 140px; }
table.bb-table .bb-num { width: 100px; text-align: right; margin-left: auto; }
table.bb-table .bb-rate { width: 120px; }
table.bb-table .bb-treat { width: 120px; }
.bb-doc { min-width: 170px; max-width: 260px; overflow-wrap: anywhere; }
.bb-doc .fine, .bb-why { display: block; margin-top: 4px; font-size: 12px; }
.bb-why { color: var(--amber-700); }

/* The reconciliation form: one compact form for one statement line. F-325. */
.recon { padding: 16px 20px; }
.recon-label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; }
.recon > .recon-label:first-of-type { margin-top: 0; }
.recon-line { margin: 10px 0 0; font-size: 13px; }
.recon-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.recon-msg { margin: 8px 0 0; padding: 8px 12px; font-size: 13px; }
.recon-check { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; font-size: 13px; }
.recon-comments { min-height: 72px; }
.recon-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
table.recon-table td { height: 44px; }
table.recon-table td:first-child { padding-left: 4px; width: 28px; }
table.recon-table td:last-child { padding-right: 4px; }
table.recon-table tbody tr { cursor: default; }
.recon-note { white-space: pre-line; }

/* F-360. What else a statement line could be: the choices, and the further
   question each one needs. */
.move-choices { display: grid; gap: 2px; margin-top: 6px; }
.move-choice { margin-top: 6px; line-height: 1.45; }
.move-choice span { display: block; }
.move-fields { margin-top: 12px; }

/* F-363. A bill's own lines on the import review screen, and the currency and
   rate when the vendor billed in their own. */
.bb-line { display: flex; gap: 4px; margin-top: 4px; }
.bb-lined { flex: 1 1 auto; min-width: 0; }

/* Seven statuses do not fit a phone in one row. F-329. */
.tabs-wrap { flex-wrap: wrap; max-width: 100%; }

/* Sortable list headings and the subject column. F-331. */
.th-sort { color: inherit; text-decoration: none; white-space: nowrap; cursor: pointer; }
.th-sort-idle { opacity: .45; font-size: 11px; }
.th-sort:hover .th-sort-idle { opacity: 1; }
.th-sort:hover { text-decoration: underline; }
.th-sort[aria-sort="ascending"], .th-sort[aria-sort="descending"] { color: var(--foreground); font-weight: 600; }
.list-subject { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* LC & BG. F-333. */
.lcbg-ccy { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--slate-500); }
.lcbg-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.lcbg-cards .stat { padding: 14px 16px; }
.lcbg-cards .stat .value { margin-top: 8px; font-size: 18px; }
.lcbg-cards .stat .note { margin-top: 4px; }
.lcbg-dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.lcbg-dl dt { color: var(--slate-500); }
.lcbg-dl dd { margin: 0; overflow-wrap: anywhere; }
.lcbg-tick { display: flex; align-items: flex-end; padding-bottom: 8px; }
table.lcbg-report td, table.lcbg-report th { white-space: nowrap; }
.lcbg-print { padding: 24px; }
.lcbg-print h1 { font-size: 18px; margin: 0 0 4px; }
@media print { .lcbg-print { padding: 0; } .lcbg-print .panel { border: 0; box-shadow: none; } table.lcbg-report { font-size: 10px; } }

/* ---------------------------------------------------- financial intelligence
 * F-340. Reports, Financial Intelligence. Built from the tokens above: the
 * chart colours are named once here, for both themes, and finintel.js reads
 * them from the page so a chart is never a different colour from its legend.
 * Semantic colour (good, warning, bad) is kept apart from the series colours.
 */
:root {
  --fi-c1: #1d4f7a; --fi-c2: #ff6548; --fi-c3: #0f8a63; --fi-c4: #7c5cc4; --fi-c5: #d98a00; --fi-c6: #8a9bb0;
  --fi-good: #0f8a63; --fi-warn: #b56a00; --fi-bad: #d43d51; --fi-info: #1f6fb2;
  --fi-grid: #e6ebf1; --fi-ink: #10263d; --fi-soft: #f1f4f8;
}
.dark {
  --fi-c1: #6fb0e8; --fi-c2: #ff8168; --fi-c3: #45cf9d; --fi-c4: #b39cf0; --fi-c5: #f2b750; --fi-c6: #8fa3b8;
  --fi-good: #45cf9d; --fi-warn: #f2b750; --fi-bad: #ff7d8e; --fi-info: #6fb0e8;
  --fi-grid: #223445; --fi-ink: #edf4f8; --fi-soft: #1b2c3b;
}
#fi-root { animation: fi-in .22s ease both; }
@keyframes fi-in { from { opacity: .55; } to { opacity: 1; } }
#fi-root.htmx-request { opacity: .6; transition: opacity .15s ease; }
.fi-tabs { display: flex; flex-wrap: wrap; max-width: 100%; margin-bottom: 16px; }
.fi-tabs a { white-space: nowrap; }
.fi-filters { margin-bottom: 20px; }
.fi-horizon { margin-bottom: 12px; }
.fi-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; margin-bottom: 20px; }
.fi-kpis-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.fi-kpi { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-panel);
  background: var(--card); color: var(--foreground); text-decoration: none; box-shadow: var(--shadow-panel); transition: border-color .15s ease, transform .15s ease; }
a.fi-kpi:hover { border-color: var(--slate-300); transform: translateY(-1px); }
.fi-kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.fi-kpi-label { font-size: 13px; font-weight: 500; color: var(--slate-500); }
.fi-basis { flex: none; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-500); white-space: nowrap; }
.fi-kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; overflow-wrap: anywhere; }
.fi-kpi-value small { font-size: 12px; font-weight: 500; color: var(--slate-500); letter-spacing: 0; }
.fi-kpi-second { font-size: 16px; font-weight: 600; color: var(--slate-500); }
.fi-kpi-na { font-size: 15px; font-weight: 600; color: var(--slate-500); }
.fi-kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; min-height: 30px; }
.fi-delta { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fi-up { color: var(--fi-good); } .fi-down { color: var(--fi-bad); } .fi-flat { color: var(--slate-500); font-weight: 500; }
.fi-spark-wrap { flex: 0 1 96px; min-width: 48px; height: 30px; color: var(--fi-c1); }
.fi-spark-wrap.fi-good { color: var(--fi-c3); } .fi-spark-wrap.fi-plain { color: var(--fi-c2); }
.fi-spark { display: block; width: 100%; height: 30px; overflow: visible; }
.fi-spark polyline { fill: none; stroke: currentColor; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.fi-spark polygon { fill: currentColor; opacity: .1; stroke: none; }
.fi-how { font-size: 11.5px; line-height: 1.4; color: var(--slate-500); }
.fi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; margin-bottom: 20px; align-items: start; }
.fi-grid > * { min-width: 0; }
.fi-panel { padding: 20px; }
.fi-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.fi-panel-head h2 { font-size: 15px; font-weight: 600; }
.fi-panel-head .fine { margin-top: 3px; max-width: 62ch; }
.fi-chart { position: relative; width: 100%; height: 320px; }
.fi-chart-tall { height: 400px; }
.fi-skeleton { position: absolute; inset: 8px 0 0; border-radius: 10px; background: linear-gradient(90deg, var(--fi-soft) 25%, var(--card) 50%, var(--fi-soft) 75%); background-size: 200% 100%; animation: fi-shimmer 1.2s linear infinite; }
@keyframes fi-shimmer { to { background-position: -200% 0; } }
.fi-empty { padding: 28px 16px; border: 1px dashed var(--border); border-radius: 12px; text-align: center; font-size: 14px; color: var(--slate-500); }
.fi-insights { display: grid; gap: 10px; }
.fi-insights-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.fi-insight { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--slate-300); border-radius: 10px; }
.fi-insight h3 { font-size: 14px; font-weight: 600; }
.fi-insight.fi-act { border-left-color: var(--fi-bad); } .fi-insight.fi-watch { border-left-color: var(--fi-warn); } .fi-insight.fi-info { border-left-color: var(--fi-info); }
.fi-insight.fi-none { color: var(--slate-500); }
.fi-sev { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--slate-500); }
.fi-act .fi-sev { color: var(--fi-bad); } .fi-watch .fi-sev { color: var(--fi-warn); } .fi-info .fi-sev { color: var(--fi-info); }
.fi-figures { font-size: 13px; font-variant-numeric: tabular-nums; }
.fi-next { font-size: 13px; font-weight: 600; color: var(--fi-info); }
.fi-apart { margin-bottom: 20px; padding: 16px; border: 1px dashed var(--slate-300); border-radius: var(--radius-panel); }
.fi-imported .fi-kpi { border-style: dashed; }
.fi-apart-note { margin-bottom: 12px; font-size: 13px; color: var(--slate-500); }
.fi-data { margin-bottom: 12px; overflow: hidden; }
.fi-data > summary { padding: 12px 20px; font-size: 13px; font-weight: 600; cursor: pointer; }
table.fi-table td { height: 44px; } table.fi-table tbody tr { cursor: default; }
.fi-amount { max-width: 7rem; text-align: right; }
.fi-bullet { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.fi-bullet:first-of-type { border-top: 0; }
.fi-bullet-bar, .fi-progress { display: block; width: 100%; height: 14px; }
.fi-progress { height: 8px; }
.fi-track { fill: var(--fi-soft); } .fi-fill { fill: var(--fi-c1); } .fi-mark { fill: var(--fi-ink); }
.fi-over .fi-fill { fill: var(--fi-bad); } .fi-met .fi-fill { fill: var(--fi-good); }
.fi-bullet-val { font-size: 12.5px; white-space: nowrap; }
.fi-goal { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px; }
.fi-goal:first-of-type { border-top: 0; }
.fi-goal-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.fi-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.fi-sub { margin-top: 20px; font-size: 14px; font-weight: 600; }
.fi-foot { margin-top: 8px; }
@media (max-width: 640px) { .fi-chart { height: 270px; } .fi-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .fi-kpi { padding: 12px; } .fi-kpi-value { font-size: 18px; } .fi-kpi-top { flex-wrap: wrap; } .fi-basis { white-space: normal; } .fi-kpi-foot { flex-wrap: wrap; } .fi-panel { padding: 14px; } .fi-panel-head { flex-wrap: wrap; } .fi-bullet { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
@media (max-width: 380px) { .fi-kpis { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { #fi-root, .fi-skeleton { animation: none; } .fi-kpi { transition: none; } }
@media print { .fi-tabs, .fi-filters, .fi-horizon, #fi-root .actions, #fi-root form { display: none; } .fi-data { break-inside: avoid; } .fi-grid { grid-template-columns: 1fr 1fr; } }
