/* Achie Platform interface. Serif type only, never italic. One shared sheet for the staff app, client portal, console and hosted forms. */
:root {
  --ground: #F3F5F1; --surface: #FFFFFF; --ink: #15211A; --soft: #3B4740; --mute: #5A665E; --rule: #DCE3DC; --rule-strong: #C3CEC4;
  --brand: #0B4A2A; --brand-ink: #FFFFFF; --tint: #EAF2EC; --good: #1D6A38; --warn: #8F5400; --warn-tint: #FBF1E2; --bad: #9B2C1F; --bad-tint: #FBEAE7;
  /* ---------- type ----------
     Every text size in this sheet is set in rem, so --fs is the one knob that
     moves all of them together. Workspace > Appearance writes --fs and the two
     family variables onto :root, which is why they are declared here rather
     than baked into the rules below. */
  /* Light, and say so. Without this a browser is free to decide the page is
     unstyled for dark mode and invert it: Chrome's auto dark mode repaints the
     text white while the white backgrounds set here stay white, which is how a
     filter pill ends up white on white. Declaring the scheme also pins the
     system colours (buttontext, canvas, form controls, scrollbars) to their
     light values, so a control that inherits its colour inherits a readable one. */
  color-scheme: light;
  --fs: 17px;
  --display: 'Playfair Display', 'Iowan Old Style', Georgia, serif;
  --serif: 'Source Serif 4', 'Source Serif Pro', Charter, 'Iowan Old Style', Georgia, serif;
  --r: 6px; --focus: 0 0 0 3px rgba(11, 74, 42, .28);
}
*, *::before, *::after { box-sizing: border-box; }
/* The base size lives on <html>, so a rem is one body line everywhere. */
html { -webkit-text-size-adjust: 100%; font-size: var(--fs); }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 1rem/1.6 var(--serif); font-optical-sizing: auto; font-variant-numeric: lining-nums; }
em, i, cite, address, var, dfn { font-style: normal; }
em, i { font-weight: 600; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; text-wrap: balance; }
/* A title is half again the body size (1.5rem). The page title takes one more
   step up so the hierarchy still reads at a glance. */
h1 { font: 500 1.9rem/1.15 var(--display); letter-spacing: -0.005em; }
h2 { font: 500 1.5rem/1.25 var(--display); }
h3 { font: 600 1.2rem/1.3 var(--serif); }
p { margin: 0; text-wrap: pretty; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 3px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.muted { color: var(--mute); }
.soft { color: var(--soft); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.8125rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- buttons and inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--rule-strong); color: var(--ink);
  background: var(--surface); color: var(--ink); font: 600 0.9375rem/1 var(--serif); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #E3B9B2; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--brand); padding: 0 8px; }
.btn.quiet:hover { background: var(--tint); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 0.875rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.875rem; font-weight: 600; color: var(--soft); min-width: 0; }
label.field .help { font-weight: 400; color: var(--mute); font-size: 0.8125rem; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--rule-strong); border-radius: var(--r); background: var(--surface); color: var(--ink);
  font: 400 0.9375rem/1.45 var(--serif); font-style: normal; }
input::placeholder, textarea::placeholder { color: #7C877F; font-style: normal; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); margin: 0; flex: none; }
input[type=color] { padding: 2px; width: 56px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9375rem; font-weight: 400; color: var(--ink); cursor: pointer; }
label.check input { margin-top: 3px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > .btn, .stack > a.btn { align-self: flex-start; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 24px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel > h2 + *, .panel > header + * { margin-top: 16px; }
.panel header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.notice { padding: 12px 16px; border-radius: var(--r); background: var(--tint); color: var(--ink); font-size: 0.9375rem; }
.notice.warn { background: var(--warn-tint); color: #5C3700; }
.notice.bad { background: var(--bad-tint); color: #6E1F15; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 16px 24px; padding: 16px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.facts dt { font-size: 0.8125rem; color: var(--mute); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
dl.pairs { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 24px; margin: 0; }
dl.pairs dt { color: var(--mute); font-size: 0.875rem; }
dl.pairs dd { margin: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
table.list th { text-align: left; font-weight: 600; font-size: 0.8125rem; color: var(--mute); padding: 12px 16px; border-bottom: 1px solid var(--ink); white-space: nowrap; }
table.list td { padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.list th.num { text-align: right; }
table.list tbody th { border-bottom: 1px solid var(--rule); font-size: 0.875rem; color: var(--soft); }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #F7FAF7; }
table.list tr:last-child td { border-bottom: 0; }
table.list tfoot td { font-weight: 600; border-top: 1px solid var(--ink); }
.empty { padding: 40px 24px; text-align: center; color: var(--mute); }
.empty p + .btn { margin-top: 16px; }

/* ---------- status marks ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 0.8125rem; font-weight: 600; background: #EEF1EE; color: var(--soft); white-space: nowrap; }
.tag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .7; }
.tag.good { background: #E4F1E7; color: var(--good); }
.tag.warn { background: var(--warn-tint); color: var(--warn); }
.tag.bad { background: var(--bad-tint); color: var(--bad); }
.tag.brand { background: var(--tint); color: var(--brand); }
.tag.plain::before { display: none; }

/* ---------- tracker (case progress) ---------- */
ol.tracker { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
ol.tracker li { display: grid; grid-template-columns: 24px 1fr auto; gap: 14px; position: relative; padding-bottom: 18px; }
ol.tracker li:last-child { padding-bottom: 0; }
ol.tracker li::after { content: ''; position: absolute; left: 11px; top: 26px; bottom: 2px; width: 2px; background: var(--rule); }
ol.tracker li:last-child::after { display: none; }
ol.tracker li.done::after { background: var(--brand); }
ol.tracker .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px dashed #B6C2B8; background: var(--surface); display: grid; place-items: center; }
ol.tracker li.done .dot { border: 0; background: var(--brand); }
ol.tracker li.done .dot svg { display: block; }
ol.tracker li.current .dot { border: 2px solid var(--brand); }
ol.tracker li.current .dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
ol.tracker .label { padding-top: 1px; }
ol.tracker li.current .label { font-weight: 600; }
ol.tracker li.ahead .label, ol.tracker li.ahead .when { color: var(--mute); }
ol.tracker .when { font-size: 0.8125rem; color: var(--mute); padding-top: 3px; white-space: nowrap; }

/* ---------- modal and toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(16, 26, 20, .42); display: grid; place-items: start center; padding: 6vh 16px 16px; z-index: 50; overflow-y: auto; }
.dialog { width: min(640px, 100%); background: var(--surface); border-radius: 10px; box-shadow: 0 24px 64px rgba(10, 20, 14, .24); }
.dialog.wide { width: min(980px, 100%); }
.dialog > header { padding: 20px 24px 0; }
.dialog > .body { padding: 20px 24px; }
.dialog > footer { padding: 16px 24px 20px; display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--rule); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r); font-size: 0.9375rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast.bad { background: var(--bad); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .18s ease-out; } @keyframes rise { from { transform: translateY(8px); opacity: 0; } } }

/* ---------- tabs ---------- */
nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
nav.tabs button { border: 0; background: none; font: 600 0.9375rem var(--serif); color: var(--mute); padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; min-height: 44px; }
nav.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--brand); }

/* ---------- staff app shell ---------- */
.shell { --side-w: 252px; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.shell > .body { min-width: 0; display: flex; flex-direction: column; }
.shell.rail { --side-w: 72px; }
@media (prefers-reduced-motion: no-preference) { .shell { transition: grid-template-columns .18s ease; } }
.side { background: var(--brand); color: var(--brand-ink); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.side::-webkit-scrollbar { width: 6px; }
.side::-webkit-scrollbar-thumb { background: color-mix(in srgb, currentColor 22%, transparent); border-radius: 99px; }

/* The mark sits straight on the brand colour. A light panel behind it is a
   choice in Settings for anyone whose logo is dark, not the default. */
.side .org { display: flex; flex-direction: column; gap: 10px; padding: 4px 8px 14px; }
.side .org img { max-width: 100%; max-height: 54px; object-fit: contain; object-position: left; align-self: flex-start; }
.side .org img.plate { background: #fff; border-radius: 6px; padding: 6px 8px; }
.side .org .name { font: 500 1.25rem/1.2 var(--display); }
.side .org select { background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 35%, transparent); min-height: 34px; padding: 4px 8px; font-size: 0.875rem; }
.side .org select option { color: var(--ink); }

/* Section heading: the prominent one. Its pages sit under it in regular
   weight, so the hierarchy reads the right way round. */
.side .group { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; width: 100%; cursor: pointer; margin: 14px 0 2px; padding: 6px 10px; border-radius: var(--r); font: 600 0.7812rem/1.2 var(--serif); letter-spacing: .07em; text-transform: uppercase; color: color-mix(in srgb, currentColor 88%, transparent); }
.side .group:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.side .group:focus-visible { box-shadow: 0 0 0 2px currentColor; }
.side .group .chev { margin-left: auto; width: 14px; height: 14px; flex: none; transition: transform .18s ease; opacity: .75; }
.side .group[aria-expanded=false] .chev { transform: rotate(-90deg); }
.side .sect { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .18s ease; }
.side .sect > div { overflow: hidden; display: flex; flex-direction: column; gap: 1px; }
.side .sect[hidden] { display: none; }
.side .group[aria-expanded=false] + .sect { grid-template-rows: 0fr; }

.side a.nav { display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 10px; border-radius: var(--r); color: inherit; text-decoration: none; font: 400 0.9688rem/1.2 var(--serif); position: relative; }
.side a.nav .ico { width: 19px; height: 19px; flex: none; opacity: .92; }
.side a.nav .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side a.nav:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.side a.nav[aria-current=page] { background: color-mix(in srgb, currentColor 20%, transparent); font-weight: 600; }
.side a.nav[aria-current=page]::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: currentColor; }
.side a.nav .count { margin-left: auto; font-size: 0.8125rem; font-variant-numeric: tabular-nums; opacity: .85; }
.side .foot { margin-top: auto; padding: 16px 10px 0; font-size: 0.875rem; display: flex; flex-direction: column; gap: 4px; }
.side .foot button { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 0.875rem; }
.side .foot button:focus-visible { box-shadow: 0 0 0 2px currentColor; }

/* The collapse control, and what the rail hides. */
.side .railbtn { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; min-height: 34px; margin-top: 10px; border-radius: var(--r); font-size: 0.8125rem; opacity: .85; }
.side .railbtn:hover { background: color-mix(in srgb, currentColor 12%, transparent); opacity: 1; }
.side .railbtn:focus-visible { box-shadow: 0 0 0 2px currentColor; }
.side .railbtn svg { width: 16px; height: 16px; transition: transform .18s ease; }
.shell.rail .railbtn svg { transform: rotate(180deg); }
.shell.rail .side { padding: 16px 8px; align-items: stretch; }
.shell.rail .side .org { padding: 4px 0 12px; align-items: center; }
.shell.rail .side .org .name, .shell.rail .side .org select, .shell.rail .side .railbtn .t { display: none; }
.shell.rail .side .org img { max-height: 34px; }
.shell.rail .side .group { justify-content: center; padding: 6px 0; margin: 12px 0 2px; font-size: 0; letter-spacing: 0; }
.shell.rail .side .group .chev { display: none; }
.shell.rail .side .group::after { content: ""; width: 20px; height: 1px; background: currentColor; opacity: .4; }
.shell.rail .side .sect, .shell.rail .side .group[aria-expanded=false] + .sect { grid-template-rows: 1fr; }
.shell.rail .side a.nav { justify-content: center; padding: 0; }
.shell.rail .side a.nav .lbl, .shell.rail .side a.nav .count { display: none; }
.shell.rail .side a.nav[aria-current=page]::before { left: -8px; }
.shell.rail .side .foot { padding: 16px 0 0; align-items: center; text-align: center; font-size: 0.75rem; }
.shell.rail .side .foot span:nth-child(2), .shell.rail .side .foot a { display: none; }
.main { padding: 32px clamp(16px, 4vw, 48px) 64px; min-width: 0; }
.main > .page { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
/* ---------- page header ----------
   A hairline closes the header off from the page, and a short brand segment
   sits under the title itself. The rule is structure, not ornament: it is the
   same line that separates every header from its content, thickened for the
   width of the title so the eye starts there. */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; position: relative; padding-bottom: 14px; margin-bottom: 4px;
  border-bottom: 1px solid var(--rule); }
.pagehead::after { content: ''; position: absolute; left: 0; bottom: -1px; width: 56px; height: 2px;
  background: var(--brand); border-radius: 2px; }
.pagehead h1 { letter-spacing: -0.012em; }
.pagehead .sub { color: var(--mute); margin-top: 6px; }
.crumb { font-size: 0.875rem; color: var(--mute); margin-bottom: 6px; }
.crumb a { color: inherit; }
.topbar { display: none; }
.banner { background: var(--warn-tint); color: #5C3700; padding: 10px clamp(16px, 4vw, 48px); font-size: 0.9375rem; }
.search { position: relative; max-width: 360px; width: 100%; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); overflow: hidden; }
.kpis > div { padding: 18px 20px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0 -1px -1px 0; }
.kpis .v { font: 600 1.625rem/1.15 var(--serif); font-variant-numeric: tabular-nums lining-nums; margin-top: 4px; }
.kpis .l { font-size: 0.875rem; color: var(--mute); }
.kpis a { color: inherit; text-decoration: none; display: block; }
.kpis a:hover .l { text-decoration: underline; }
/* ---------- filter pills ----------
   At rest they sit on the page's own ground rather than on white, so a strip
   of them reads as one control instead of a row of little cards. The count
   rides in its own badge: on an unselected pill it is the brand tint, and on
   the selected one it inverts to sit legibly on the brand green. */
.stages { display: flex; flex-wrap: wrap; gap: 8px; }
.stages button { border: 1px solid var(--rule); background: var(--ground); color: var(--soft);
  border-radius: 999px; padding: 5px 7px 5px 15px; font: 0.9375rem var(--serif); cursor: pointer;
  display: inline-flex; gap: 9px; min-height: 36px; align-items: center;
  transition: background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease; }
.stages button:has(b) { padding-right: 7px; }
.stages button:not(:has(b)) { padding-right: 15px; }
.stages button:hover { background: var(--tint); border-color: var(--brand); color: var(--ink); }
.stages button:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--brand); }
.stages button[aria-pressed=true] { background: var(--brand); border-color: var(--brand);
  color: var(--brand-ink); box-shadow: 0 2px 8px rgba(11, 74, 42, .22); }
.stages button[aria-pressed=true]:hover { background: var(--brand); filter: brightness(1.08); color: var(--brand-ink); }

.stages b { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.8125rem;
  min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tint); color: var(--brand); transition: background .14s ease, color .14s ease; }
/* Zero is not news: it stays quiet so the counts that matter carry the colour. */
.stages b.zero { background: transparent; color: var(--mute); border: 1px solid var(--rule); }
/* A count of overdue invoices is not the same news as a count of paid ones, so
   the badge takes the colour of what it is counting. */
.stages b.bad { background: #F7E4E0; color: var(--bad); }
.stages b.warn { background: #FBEFD8; color: var(--warn); }
.stages b.good { background: #DCEFE3; color: var(--good); }
.stages button:hover b { background: var(--surface); }
.stages button[aria-pressed=true] b,
.stages button[aria-pressed=true]:hover b { background: rgba(255, 255, 255, .22); color: var(--brand-ink); border-color: transparent; }
.lines td { padding: 8px 6px; vertical-align: top; }
.lines input, .lines select { min-height: 36px; padding: 6px 8px; font-size: 0.9062rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--rule); display: grid; gap: 4px; }
.timeline li:last-child { border-bottom: 0; }
.prose { white-space: pre-wrap; }
.feedback-doc h3 { font: 600 1.125rem var(--serif); color: var(--brand); margin: 18px 0 6px; }
.feedback-doc p { margin: 0 0 10px; }
.feedback-doc ul { margin: 0 0 10px; padding-left: 22px; }
.qcard { border: 1px solid var(--rule); border-radius: 8px; padding: 16px; display: grid; gap: 12px; background: #FBFCFA; }
.chartbars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; height: 150px; padding-top: 8px; }
.chartbars .bar { background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; }
.chartbars .col { display: flex; flex-direction: column; gap: 6px; height: 100%; justify-content: flex-end; text-align: center; font-size: 0.8125rem; color: var(--mute); }

/* ---------- sign-in and portal ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 36px 32px; display: flex; flex-direction: column; gap: 18px; }
.card.wide { width: min(560px, 100%); }
.card .mark { font: 500 1.75rem/1.15 var(--display); color: var(--brand); }
.card img.logo { max-height: 56px; max-width: 220px; object-fit: contain; align-self: flex-start; }
.portal { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; }
.portal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--rule); margin-bottom: 24px; }
.portal-top img { max-height: 40px; max-width: 180px; object-fit: contain; }
.portal-top .name { font: 500 1.25rem var(--display); color: var(--brand); }
.portal-nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--rule); display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); z-index: 20; }
.portal-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; font-size: 0.8125rem; color: var(--mute); text-decoration: none; }
.portal-nav a[aria-current=page] { color: var(--brand); font-weight: 600; }
.portal-nav svg { width: 22px; height: 22px; }
.casecard { display: block; text-decoration: none; color: inherit; }
.casecard:hover { border-color: var(--rule-strong); }

/* ---------- hosted form ---------- */
.formpage { max-width: 760px; margin: 0 auto; padding: 40px 16px 80px; }
.formpage fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.formpage legend { font: 500 1.375rem var(--display); margin-bottom: 4px; padding: 0; }
.scale { display: flex; gap: 8px; flex-wrap: wrap; }
.scale label { display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 1px solid var(--rule-strong); border-radius: var(--r); cursor: pointer; font-weight: 600; }
.scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale input:checked + span { color: var(--brand-ink); }
.scale label:has(input:checked) { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.scale label:has(input:focus-visible) { box-shadow: var(--focus); }

@media (max-width: 860px) {
  /* minmax(0, 1fr), not 1fr: a bare 1fr track is min-width:auto, so a wide
     table stretches the whole column and the PAGE scrolls sideways instead of
     the table. This is what kept the layout dragging on a phone. */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .shell.rail { --side-w: 252px; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform .2s; height: 100%; padding: 16px 12px; }
  .shell.open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(16, 26, 20, .4); }
  /* On a phone the rail would be a worse menu than the drawer, so the drawer
     always shows full labels. */
  .shell.rail .side .org .name, .shell.rail .side a.nav .lbl, .shell.rail .side .foot a { display: block; }
  .shell.rail .side .group { justify-content: flex-start; padding: 6px 10px; font-size: 0.7812rem; letter-spacing: .07em; }
  .shell.rail .side .group .chev { display: block; }
  .shell.rail .side .group::after { display: none; }
  .shell.rail .side a.nav { justify-content: flex-start; padding: 0 10px; }
  .shell.rail .side .org img { max-height: 54px; }
  .side .railbtn { display: none; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: inherit; min-width: 44px; min-height: 44px; display: grid; place-items: center; cursor: pointer; }
  .topbar .name { font: 500 1.1875rem var(--display); }
  .main { padding-top: 20px; }
  h1 { font-size: 1.6875rem; }
  .panel { padding: 18px; }
  table.list th, table.list td { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
@media print { .side, .topbar, .pagehead .row, .btn { display: none !important; } .shell { display: block; } body { background: #fff; } }

/* ---------- charts ----------
   The figures on these screens are the point of the product, so they get the
   same care as the type: one palette, aligned baselines, numbers that line up
   in columns, and nothing decorative that does not encode a value. */
.chart { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-title { font: 500 1.35rem/1.25 var(--display); color: var(--ink); }
.chart-note { font-size: 0.8125rem; color: var(--mute); }
.chart-empty { padding: 26px 0; text-align: center; color: var(--mute); font-size: 0.875rem; }
/* stretch, not start: two charts side by side read as a pair, and ragged
   bottoms make the shorter one look unfinished. The chart itself stays at the
   top of its panel and the spare room falls below it. */
.chart-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); align-items: stretch; }
.chart-grid > .chart { display: flex; flex-direction: column; }
.chart-grid.wide { grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); }

.plot-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
svg.plot { width: 100%; height: auto; max-height: 280px; overflow: visible; }
svg.plot .grid { stroke: var(--rule); stroke-width: 1; }
svg.plot .axis { stroke: var(--rule-strong); stroke-width: 1; }
svg.plot .tick { font: 0.75rem var(--serif); fill: var(--mute); font-variant-numeric: tabular-nums; }
svg.plot .bar, svg.plot .dot { transition: opacity .15s ease; }
svg.plot:hover .bar { opacity: .82; }
svg.plot .bar:hover { opacity: 1; }

.donut-wrap { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.donut-figure { position: relative; width: 236px; flex: none; }
svg.donut { display: block; width: 100%; height: auto; }
/* The highlight is driven by a class the chart sets, not by :hover, so
   pointing at a legend row lights the matching slice and the other way round.
   Only the opacity moves: making the active slice thicker pushed it past its
   neighbours and read as a second ring. */
svg.donut .seg { transition: opacity .12s ease; outline: none; }
.donut-wrap.picking svg.donut .seg { opacity: .28; }
.donut-wrap.picking svg.donut .seg.on { opacity: 1; }
svg.donut .seg:focus-visible { opacity: 1; }

/* The readout sits in the hole as HTML, so it can wrap and clamp. inset 23%
   keeps it inside the 63% hole with room to spare at every size. */
.donut-centre { position: absolute; inset: 23%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; text-align: center;
  pointer-events: none; overflow: hidden; }
.donut-centre .dc-v { font: 600 clamp(1.1rem, 2.4cqw + 0.7rem, 1.55rem)/1.05 var(--display);
  color: var(--ink); font-variant-numeric: tabular-nums; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-centre .dc-l { font-size: 0.8rem; line-height: 1.2; color: var(--mute); max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.donut-centre .dc-p { font-size: 0.72rem; line-height: 1.2; color: var(--mute); }
.donut-centre .dc-p:empty { display: none; }

.legend { display: flex; flex-direction: column; gap: 9px; min-width: 0; flex: 1; }
.legend.inline, .legend.wrap { flex-direction: row; flex-wrap: wrap; gap: 8px 18px; }
.legend-item { display: flex; align-items: flex-start; gap: 9px; min-width: 0; padding: 3px 6px; margin: -3px -6px;
  border-radius: var(--r); cursor: default; transition: background .12s ease; outline: none; }
.legend-item.on, .legend-item:focus-visible { background: var(--tint); }
.legend-item.on .legend-label { color: var(--ink); font-weight: 600; }
.donut-wrap.picking .legend-item:not(.on) { opacity: .5; }
.legend .swatch { width: 12px; height: 12px; flex: none; margin-top: 5px; }
.legend-label { font-size: 0.95rem; color: var(--soft); }
.legend-value { font-size: 0.875rem; color: var(--mute); font-variant-numeric: tabular-nums; margin-top: 1px; }

.funnel { display: flex; flex-direction: column; gap: 14px; }
.funnel-step { display: flex; flex-direction: column; gap: 5px; }
.funnel-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.funnel-label { font-size: 0.9062rem; color: var(--soft); }
.funnel-count { font: 600 0.9062rem var(--serif); font-variant-numeric: tabular-nums; color: var(--ink); }
.funnel-track { background: var(--tint); border-radius: 5px; height: 26px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 5px; transition: width .5s cubic-bezier(.22,.8,.3,1); }
.funnel-conv { font-size: 0.7812rem; color: var(--mute); }

.split { display: flex; flex-direction: column; gap: 12px; }
.split-bar { display: flex; height: 26px; border-radius: 5px; overflow: hidden; background: var(--tint); }
.split-seg { transition: width .5s cubic-bezier(.22,.8,.3,1); min-width: 2px; }

.ranked { display: flex; flex-direction: column; gap: 11px; }
.rank-row { display: grid; grid-template-columns: minmax(84px, 1.1fr) minmax(60px, 2fr) auto; gap: 12px; align-items: center; }
.rank-label { font-size: 0.875rem; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { background: var(--tint); border-radius: 4px; height: 16px; overflow: hidden; }
.rank-bar { height: 100%; border-radius: 4px; transition: width .5s cubic-bezier(.22,.8,.3,1); }
.rank-value { font-size: 0.8438rem; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

svg.spark { width: 100%; max-width: 128px; height: 30px; margin-top: 10px; }

/* Summary tiles: the figure, what it means, and which way it moved. */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
.tile { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 18px 18px; display: flex; flex-direction: column; min-width: 0; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.tile:has(.tile-link:hover) { border-color: var(--brand); box-shadow: 0 6px 18px rgba(11, 74, 42, .10); transform: translateY(-1px); }
.tile-link { position: absolute; inset: 0; border-radius: 8px; z-index: 1; }
.tile-link:focus-visible { box-shadow: var(--focus); }
.tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tile-label { font-size: 0.8438rem; color: var(--mute); }
.tile-hint { font-size: 0.75rem; color: var(--mute); opacity: .85; }
.tile-value { font: 600 1.6875rem/1.15 var(--display); font-variant-numeric: tabular-nums lining-nums; margin-top: 6px; color: var(--ink); }
.tile-foot { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.tile-delta { font-size: 0.7812rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-delta.up { color: var(--good); }
.tile-delta.down { color: var(--bad); }
.tile-sub { font-size: 0.7812rem; color: var(--mute); }
.tile.good { border-left: 3px solid var(--good); }
.tile.warn { border-left: 3px solid var(--warn); }
.tile.bad { border-left: 3px solid var(--bad); }
.tile.brand { border-left: 3px solid var(--brand); }

@media (max-width: 640px) {
  .chart { padding: 16px 14px 18px; }
  .donut-wrap { gap: 14px; }
  .donut-figure { width: min(220px, 70vw); margin: 0 auto; }
  .tile-value { font-size: 1.5rem; }
  .rank-row { grid-template-columns: minmax(70px, 1fr) minmax(40px, 1.4fr) auto; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .funnel-bar, .split-seg, .rank-bar, .tile { transition: none; }
}
@media print { .chart, .tile { break-inside: avoid; } }

.jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.jobs li { padding: 10px 0 10px 14px; border-bottom: 1px solid var(--rule); border-left: 3px solid var(--rule-strong); font-size: 0.9062rem; }
.jobs li:last-child { border-bottom: 0; }
.jobs li.warn { border-left-color: var(--warn); }
.jobs li.bad { border-left-color: var(--bad); }
.jobs li a { color: var(--ink); text-decoration: none; }
.jobs li a:hover { text-decoration: underline; }

/* ---------- the summary strip and the bar that replaces it ---------- */
.sumsentinel { height: 1px; margin-bottom: -1px; }

/* Pinned, for anyone who turns it on. The strip keeps its own scrollbar so a
   tall set of charts can never push the rows off the screen entirely. */
.sumstrip.pinned { position: sticky; top: 0; z-index: 18; background: var(--ground);
  max-height: 62vh; overflow: auto; padding-bottom: 12px;
  box-shadow: 0 10px 14px -12px rgba(16, 26, 20, .35); }

/* The default: a slim bar of the same figures, sliding in once the charts have
   scrolled past and sliding out again when they come back. */
/* Fixed rather than sticky: a sticky element only sticks while its own parent
   is on screen, and this bar has to stay up for the whole length of the table
   below it. --side-w comes from the shell, so the bar starts where the menu
   ends and follows it when the menu drops to a rail. */
.sumbar { position: fixed; top: 0; left: var(--side-w, 0px); right: 0; z-index: 18;
  padding: 0 clamp(16px, 4vw, 48px); background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule);
  box-shadow: 0 6px 12px -10px rgba(16, 26, 20, .5);
  transform: translateY(-110%); opacity: 0; pointer-events: none;
  transition: transform .18s ease, opacity .18s ease; }
.sumbar.up { transform: none; opacity: 1; pointer-events: auto; }
.sumbar .bar-in { display: flex; align-items: center; gap: 16px; min-width: 0; }
/* The page title again, at a size that belongs in a 44px strip. It does not
   scroll away with the heading, so you always know which ledger you are in. */
.sumbar .bar-title { font: 500 1.05rem/1.2 var(--display); color: var(--ink); white-space: nowrap;
  flex: none; padding-right: 16px; border-right: 1px solid var(--rule); }
.sumbar .chips { display: flex; gap: 10px; overflow-x: auto; padding: 9px 0; scrollbar-width: none;
  flex: 1; min-width: 0; }
.sumbar .chips::-webkit-scrollbar { display: none; }
.sumbar .chip { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap;
  padding: 4px 12px; border-radius: 999px; background: var(--ground); border: 1px solid var(--rule); }
.sumbar .chip .k { font-size: 0.8rem; color: var(--mute); }
.sumbar .chip .v { font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.sumbar .chip.good { border-color: #BFE0CC; } .sumbar .chip.good .v { color: var(--good); }
.sumbar .chip.bad { border-color: #E9C3BD; } .sumbar .chip.bad .v { color: var(--bad); }
.sumbar .chip.warn { border-color: #E6D2A8; } .sumbar .chip.warn .v { color: var(--warn); }
.sumbar .chip.brand { border-color: #B9D3C2; } .sumbar .chip.brand .v { color: var(--brand); }

@media (max-width: 1100px) {
  /* Not enough width for both; the figures are the reason the bar exists. */
  .sumbar .bar-title { display: none; }
}
@media (max-width: 860px) {
  /* Too little height to give any of it away, so the charts simply scroll,
     and the bar stays out of the way of the small-screen top bar. */
  .sumstrip.pinned { position: static; max-height: none; overflow: visible; box-shadow: none; }
  .sumbar { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sumbar { transition: none; } }
/* Not a box of its own: see the note in books.js beside strip(). */
.sumslot { display: contents; }
/* Native controls in the brand colour rather than the browser's blue. */
input[type="range"], input[type="checkbox"], input[type="radio"], progress { accent-color: var(--brand); }
input[type="range"] { flex: 1 1 220px; min-width: 180px; max-width: 420px; height: 28px; }

/* ---------- shop photographs ---------- */
.shots { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.shot { margin: 0; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden;
  background: var(--ground); position: relative; display: flex; flex-direction: column; }
.shot.lead { border-color: var(--brand); }
/* contain, not cover: a product photograph is of a pouch or a jar, and
   cropping it to a square cuts the label off. The whole picture is shown at
   its own proportions, with the panel colour filling what is left. */
.shot img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; background: #fff; padding: 6px; }
.shot .lead-tag { position: absolute; top: 8px; left: 8px; background: var(--brand); color: var(--brand-ink);
  font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; }
.shot-tools { display: flex; gap: 6px; padding: 8px; flex-wrap: wrap; background: var(--surface); }
.shot-tools .btn { flex: 1; min-width: 0; }

/* ---------- restock reading ---------- */
.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.restock { display: grid; grid-template-columns: minmax(90px, 1.2fr) 2fr auto auto; gap: 9px 12px; align-items: center; }
.restock .rank-label { font-size: 0.95rem; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.restock .rank-track { background: var(--tint); border-radius: 999px; height: 14px; overflow: hidden; }
.restock .rank-bar { display: block; height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.22,.8,.3,1); }
.restock-qty { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 2.5ch; text-align: right; }
.restock-state { font-size: 0.8rem; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.restock-state.out, .restock-state.low { background: #F7E4E0; color: var(--bad); font-weight: 600; }
.restock-state.watch { background: #FBEFD8; color: var(--warn); }
.restock-state.ok { background: #DCEFE3; color: var(--good); }
.restock-key { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.82rem; color: var(--mute);
  padding-top: 10px; border-top: 1px solid var(--rule); }
.restock-key-item { display: flex; align-items: center; gap: 6px; }
.restock-key .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
@media (max-width: 620px) {
  .restock { grid-template-columns: 1fr auto auto; }
  .restock .rank-track { display: none; }
}
