/* Capradix app shell. Plain CSS, no build step. One token set, a small
   component layer, and a page at /styleguide that shows each component once —
   new pages reuse these classes rather than inventing their own. */

/* --- tokens ---------------------------------------------------------------- */
:root {
  --ink: #1d232a; --soft: #5c6670; --faint: #8a939c; --line: #dde2e7; --line-soft: #eceff2;
  --bg: #f6f7f8; --panel: #ffffff; --panel-soft: #fafbfb;
  --accent: #1f5c47; --accent-dark: #16442f; --accent-soft: #e7f0ec;
  --danger: #b0483f; --danger-soft: #fbeaea; --warn: #9a6a12; --warn-soft: #fbf3e2;
  --radius: 6px; --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(29, 35, 42, .05); --shadow-pop: 0 6px 20px rgba(29, 35, 42, .10);
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --focus: 0 0 0 3px rgba(31, 92, 71, .22);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
main { max-width: 1180px; margin: 0 auto; padding: var(--sp-5) 28px 80px; }

/* --- site header ----------------------------------------------------------- */
header.site {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 28px; display: flex; gap: 22px; align-items: center;
  /* ten links on a phone used to push the header — and with it the whole
     page — wider than the viewport; tables scroll inside their own wrappers,
     so the header was the only thing doing it */
  flex-wrap: wrap; row-gap: 10px;
}
header.site .brand { font-weight: 700; font-size: 17px; color: var(--accent); margin-right: 14px; }
header.site a { color: var(--ink); text-decoration: none; }
header.site a:hover { color: var(--accent); }
/* header menus: plain <details>, no JavaScript. The open panel floats below
   the row instead of pushing the page down. */
header.site details.menu { position: relative; }
header.site details.menu > summary { list-style: none; cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; gap: 5px; }
header.site details.menu > summary::-webkit-details-marker { display: none; }
header.site details.menu > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); }
header.site details.menu > summary:hover, header.site details.menu[open] > summary { color: var(--accent); }
header.site details.menu > summary:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 3px; }
header.site details.menu > .menu-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 20; min-width: 180px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); padding: 6px; display: flex; flex-direction: column;
}
header.site details.menu > .menu-panel > a, header.site details.menu > .menu-panel form button { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 4px; }
header.site details.menu > .menu-panel > a:hover { background: var(--panel-soft); }
header.site details.menu > .menu-panel form { margin: 0; }
header.site details.menu > .menu-panel form button { background: none; border: 0; color: var(--ink); font: inherit; cursor: pointer; }
header.site details.menu > .menu-panel form button:hover { background: var(--panel-soft); color: var(--accent); }
/* the account menu sits at the far right; its panel opens leftward so it stays on screen */
header.site details.account-menu { margin-left: auto; }
header.site details.account-menu > .menu-panel { left: auto; right: 0; min-width: 220px; }
/* decision 78: switch organization, inside the account menu */
header.site form.org-switch { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; margin: 4px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
header.site form.org-switch label { font-size: 12px; color: var(--soft); }
header.site form.org-switch select { min-width: 0; }
header.site form.org-switch input[type=submit] { align-self: flex-start; }

/* below that width the account menu flows with the links instead of
   stranding itself on a line, and an open menu takes a full row of its own
   with the panel in flow — a floating panel spills off a narrow screen */
@media (max-width: 900px) {
  header.site details.account-menu { margin-left: 0; }
  header.site details.menu[open] { width: 100%; }
  header.site details.menu > .menu-panel { position: static; margin-top: 8px; min-width: 0; box-shadow: none; }
}
/* on a phone the brand takes its own line, so the links have a full width to
   wrap into */
@media (max-width: 700px) {
  header.site { padding: 10px 14px; gap: 16px; font-size: 15px; }
  header.site .brand { width: 100%; margin-right: 0; }
}

/* --- type ------------------------------------------------------------------ */
h1 { font-size: 24px; margin: 18px 0 10px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 26px 0 8px; }
h3 { font-size: 15px; margin: 20px 0 6px; color: var(--soft); }
h1 small, h2 small { font-size: 14px; font-weight: 400; margin-left: 10px; }
a { color: var(--accent); }
.muted { color: var(--soft); font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

/* Page header: title on the left, actions on the right, an optional one-line
   subtitle underneath. The `.actions` slot is where "+ New …" buttons live. */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4);
  flex-wrap: wrap; margin: 14px 0 12px; }
.page-head h1, .page-head h2 { margin: 0; }
.page-head .sub { color: var(--soft); font-size: 13.5px; margin-top: 3px; }
.page-head .actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-left: auto; }
.page-head .actions form { margin: 0; }
.crumb { font-size: 13px; color: var(--soft); margin: 4px 0 0; }
.crumb a { color: var(--soft); text-decoration: none; }
.crumb a:hover { color: var(--accent); text-decoration: underline; }

/* Section header: the same shape for an h2 that owns a table or a list */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  flex-wrap: wrap; margin: 26px 0 8px; }
.section-head h2 { margin: 0; }
.section-head .actions { display: flex; gap: var(--sp-2); align-items: center; margin-left: auto; }

/* --- buttons --------------------------------------------------------------- */
/* .btn on a link or a button. Default is the quiet secondary; add .primary
   for the one action a page is for, .danger for destructive, .sm for inline
   table/heading use. Bare <button> and submits stay primary-looking so the
   many existing forms need no class. */
.btn, input[type=submit], button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  font: 500 14px/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; white-space: nowrap; vertical-align: middle;
  transition: background-color .12s, border-color .12s, color .12s;
}
input[type=submit], button, .btn.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
input[type=submit]:hover, button:hover, .btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.btn:hover { border-color: var(--soft); color: var(--ink); background: var(--panel-soft); }
.btn.danger, button.danger, input[type=submit].danger { background: var(--panel); color: var(--danger); border-color: #e3b7b3; }
.btn.danger:hover, button.danger:hover, input[type=submit].danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
/* .quiet on a submit/button_to: the white secondary look, for row actions that are not the page's purpose */
button.quiet, input[type=submit].quiet { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
button.quiet:hover, input[type=submit].quiet:hover { background: var(--panel-soft); border-color: var(--soft); color: var(--ink); }
.btn.sm, button.sm, input[type=submit].sm { min-height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn.plain, button.plain { background: none; border-color: transparent; box-shadow: none; color: var(--accent); padding: 0 4px; }
.btn.plain:hover, button.plain:hover { background: var(--accent-soft); color: var(--accent-dark); }
.btn[aria-disabled=true], button:disabled, input[type=submit]:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, button:focus-visible, input[type=submit]:focus-visible { outline: none; box-shadow: var(--focus); }
/* button_to renders a form; keep it inline with its neighbours */
form.inline, form.button_to { display: inline; margin: 0; }
form.inline p { display: inline; margin: 0; }
form.inline input, form.inline select { min-width: 0; margin-right: 6px; }
.btn-group { display: inline-flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

/* --- panels & cards -------------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--sp-4) var(--sp-5); margin: var(--sp-3) 0 var(--sp-5); }
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }
.panel h2, .panel h3 { margin-top: 0; }
.panel table { margin-bottom: 0; }

/* --- accordion (details) --------------------------------------------------- */
/* Every collapsible section — History, Documents, Contacts, custom fields,
   "+ New …" inline forms — is a <details class="acc">. The summary reads as a
   panel header with a chevron; the body is indented inside the panel. */
details.acc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin: var(--sp-3) 0 var(--sp-4); }
details.acc > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 10px var(--sp-4); font-weight: 600; font-size: 14.5px; color: var(--ink); user-select: none;
  border-radius: var(--radius); }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before { content: ""; width: 7px; height: 7px; flex: none;
  border-right: 1.8px solid var(--soft); border-bottom: 1.8px solid var(--soft);
  transform: rotate(-45deg); transition: transform .15s; margin-left: 2px; }
details.acc[open] > summary::before { transform: rotate(45deg); }
details.acc > summary:hover { background: var(--panel-soft); }
details.acc[open] > summary { border-bottom: 1px solid var(--line-soft); border-radius: var(--radius) var(--radius) 0 0; }
details.acc > summary .count { font-weight: 400; color: var(--soft); font-size: 13px; }
details.acc > summary .hint { font-weight: 400; color: var(--soft); font-size: 13px; margin-left: auto; }
details.acc > summary:focus-visible { outline: none; box-shadow: var(--focus); }
details.acc > .acc-body, details.acc > :not(summary) { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
details.acc > table, details.acc > .scroll { padding: 0; margin: 0; }
details.acc > table tr:last-child td { border-bottom: 0; }
details.acc > .scroll table { margin: 0; }
details.acc > .scroll table tr:last-child td { border-bottom: 0; }
details.acc > .acc-body > :first-child { margin-top: 0; }
details.acc > .acc-body > :last-child { margin-bottom: 0; }
details.acc.quiet { background: none; border: 0; box-shadow: none; }
details.acc.quiet > summary { padding: 4px 0; font-weight: 500; color: var(--accent); }
details.acc.quiet > summary:hover { background: none; text-decoration: underline; }
details.acc.quiet[open] > summary { border-bottom: 0; }
details.acc.quiet > .acc-body, details.acc.quiet > :not(summary) { padding: var(--sp-2) 0 var(--sp-2) 19px; }
details.acc.quiet[open] { border-left: 2px solid var(--accent-soft); padding-left: 10px; margin-left: -12px; border-radius: 0; }
details.acc.quiet[open] > summary { color: var(--accent-dark); }
details.acc.quiet > :not(summary) > p:first-child { margin-top: 0; }
/* row-level edit/correct form inside a table cell or list item: a small quiet
   button that opens a bordered form underneath */
details.cell { display: inline-block; vertical-align: middle; }
details.cell > summary { list-style: none; display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px;
  font-size: 12.5px; font-weight: 500; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); cursor: pointer; user-select: none; }
details.cell > summary::-webkit-details-marker { display: none; }
details.cell > summary:hover { border-color: var(--soft); background: var(--panel-soft); }
details.cell[open] > summary { background: var(--accent-soft); border-color: #b9d3c7; color: var(--accent-dark); }
details.cell[open] { display: block; }
details.cell > :not(summary) { display: block; margin-top: 8px; padding: 10px 12px; background: var(--panel-soft);
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }
details.cell form.inline { display: block; }
details.cell label { font-size: 12.5px; color: var(--soft); margin: 0 4px 0 8px; }
details.cell label:first-child { margin-left: 0; }
details.cell input[type=text], details.cell input[type=date], details.cell select { min-width: 0; min-height: 28px; padding: 3px 7px; font-size: 13px; margin: 2px 0; }
details.cell input[type=submit] { min-height: 28px; padding: 0 10px; font-size: 12.5px; margin-left: 6px; }
p.crumb { margin: 0 0 2px; }
/* action cells: every control in a table row is the same compact height and
   sits on one line — small date/text inputs, quiet submits, .cell disclosures */
td.row-actions, td:has(> details.cell) { white-space: nowrap; vertical-align: middle; }
td.row-actions > *, td:has(> details.cell) > * { vertical-align: middle; }
td.row-actions > form.inline, td:has(> details.cell) > form.inline { display: inline-flex; gap: 6px; align-items: center; margin-right: 6px; }
td.row-actions > form.button_to, td:has(> details.cell) > form.button_to, td:has(> details.cell) > details.cell { margin-right: 6px; }
td > form.inline input[type=date], td > form.inline input[type=text], td > form.inline select {
  min-width: 0; min-height: 28px; padding: 3px 7px; font-size: 13px; }
td > form.inline input[type=submit] { min-height: 28px; padding: 0 10px; font-size: 12.5px; }
details.cell[open] { white-space: normal; }
td:has(> details.cell[open]) { white-space: normal; }
/* legacy: a details element with no class still gets a sane summary */
details:not(.acc):not(.colpick):not(.inline):not(.cell) > summary { cursor: pointer; font-weight: 500; color: var(--accent); padding: 4px 0; }
details.inline { display: inline; }
details.inline summary { display: inline; cursor: pointer; font-size: 12px; margin-left: 6px; color: var(--accent); }

/* --- tables ---------------------------------------------------------------- */
table { border-collapse: separate; border-spacing: 0; background: var(--panel); width: 100%; margin: 8px 0 18px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
/* row rules only — vertical lines between cells read as a spreadsheet.
   table.grid opts back in for the few dense matrices that need them. */
th, td { border: 0; border-bottom: 1px solid var(--line-soft); padding: 7px 12px; text-align: left; font-size: 14px; vertical-align: top; }
table.grid th, table.grid td { border-right: 1px solid var(--line-soft); }
table.grid th:last-child, table.grid td:last-child { border-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
th { background: var(--accent-soft); font-weight: 600; white-space: nowrap; font-size: 13px; color: var(--accent-dark); }
td { font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--panel-soft); }
td > .cell-num { display: block; text-align: right; font-variant-numeric: tabular-nums; }
.kpi .cell-num { text-align: left; }
tfoot td, .totals-row td { font-weight: 600; border-top: 2px solid var(--line); padding: 6px 10px; background: var(--panel-soft); }
table.compact th, table.compact td { padding: 3px 8px; font-size: 13px; }
.scroll { overflow-x: auto; }
.scroll > table { margin-top: 0; }
/* a table that scrolls sideways keeps each cell on one line; prose columns opt
   out with .wrap (table_tools marks them automatically) */
.scroll table th, .scroll table td { white-space: nowrap; }
.scroll table th.wrap, .scroll table td.wrap { white-space: normal; min-width: 28ch; max-width: 60ch; }
td > .cell-num { white-space: nowrap; }
.empty { color: var(--soft); font-size: 14px; padding: var(--sp-5); text-align: center;
  background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); margin: var(--sp-3) 0 var(--sp-5); }
.empty a { font-weight: 500; }

/* --- table tools: toolbar above a table, filter row inside its header ------ */
.table-tools { display: flex; gap: var(--sp-2); align-items: center; margin: 10px 0 0;
  padding: 8px 10px; background: var(--panel); border: 1px solid var(--line);
  border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.table-tools + .scroll > table, .table-tools + table { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.table-tools .tt-spacer { flex: 1; }
.table-tools .tt-rows { font-size: 13px; color: var(--soft); margin-left: 4px; font-variant-numeric: tabular-nums; }
.table-tools input[type=search] { min-width: 240px; }
.table-tools button, .table-tools .btn, .colpick summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px; font-size: 13px; font-weight: 500;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); cursor: pointer; }
.table-tools button:hover, .table-tools .btn:hover, .colpick summary:hover { border-color: var(--soft); background: var(--panel-soft); color: var(--ink); }
.table-tools .tt-filters[aria-pressed=true] { background: var(--accent-soft); border-color: #b9d3c7; color: var(--accent-dark); }
.table-tools .tt-filters svg { color: var(--accent); }
.table-tools .tt-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; margin-left: 2px; }
.table-tools .tt-count[hidden], .table-tools .tt-clear[hidden] { display: none; }
.table-tools .tt-clear { border-color: transparent; box-shadow: none; color: var(--accent); padding: 0 6px; }
.table-tools .tt-clear:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); }
.colpick { position: relative; }
.colpick summary { list-style: none; user-select: none; }
.colpick summary::-webkit-details-marker { display: none; }
.colpick summary::after { content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--soft);
  border-bottom: 1.5px solid var(--soft); transform: rotate(45deg) translateY(-2px); }
.colpick-menu { position: absolute; right: 0; z-index: 10; margin-top: 6px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 5px; min-width: 220px; max-height: 60vh; overflow: auto;
  box-shadow: var(--shadow-pop); font-size: 13px; white-space: nowrap; }
.colpick-menu label { display: flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 400; }

/* sortable headers: arrow drawn from aria-sort, header text stays clean */
th.sortable { cursor: pointer; user-select: none; padding-right: 20px; position: relative; }
th.sortable:hover { background: #dbe8e1; }
th.sortable::after { content: ""; position: absolute; right: 7px; top: 50%; width: 6px; height: 6px; margin-top: -4px;
  border-right: 1.6px solid var(--accent-dark); border-bottom: 1.6px solid var(--accent-dark); opacity: 0; transform: rotate(45deg); }
th.sortable:hover::after { opacity: .35; }
th.sortable[aria-sort=ascending]::after { opacity: 1; transform: rotate(-135deg); margin-top: -1px; }
th.sortable[aria-sort=descending]::after { opacity: 1; transform: rotate(45deg); }

/* the filter row: one control under each heading, styled as a search field */
.filter-row th { background: var(--panel); padding: 5px 5px 7px; border-bottom: 1px solid var(--line); cursor: default !important; }
.filter-row th::after { display: none; }
.filter-row .colfilter { min-width: 0; width: 100%; min-height: 28px; padding: 3px 8px 3px 24px; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel-soft) no-repeat 8px center; color: var(--ink);
  box-shadow: none; appearance: none; -webkit-appearance: none; }
.filter-row .colfilter.text { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%238a939c' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E"); }
.filter-row .colfilter.number { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%238a939c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h10M5 8h6M7 11h2'/%3E%3C/svg%3E"); }
.filter-row select.colfilter { padding-left: 10px; padding-right: 22px; background-position: right 8px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 16 16' fill='none' stroke='%238a939c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6l5 5 5-5'/%3E%3C/svg%3E"); }
.filter-row .colfilter::placeholder { color: var(--faint); }
.filter-row .colfilter::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; height: 12px; width: 12px; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%235c6670' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 4l8 8M12 4l-8 8'/%3E%3C/svg%3E") center/contain no-repeat; }
.filter-row .colfilter:hover { border-color: var(--soft); background-color: var(--panel); }
.filter-row .colfilter:focus, .filter-row .colfilter:focus-visible { outline: none; border-color: var(--accent); background-color: var(--panel); box-shadow: var(--focus); }
.filter-row .colfilter.active { border-color: var(--accent); background-color: var(--accent-soft); color: var(--accent-dark); font-weight: 500; }
.filter-row .colfilter.active.text { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%231f5c47' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E"); }
.filter-row .colfilter.active.number { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%231f5c47' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h10M5 8h6M7 11h2'/%3E%3C/svg%3E"); }

/* --- KPI tiles ------------------------------------------------------------- */
.kpis { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0 6px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
       padding: 10px 16px; min-width: 150px; }
.kpi .label { font-size: 12px; color: var(--soft); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; color: var(--soft); }

/* --- flash & callouts ------------------------------------------------------ */
.notice { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent-dark);
          padding: 8px 12px; border-radius: var(--radius-sm); margin: 10px 0; }
.alert { background: var(--danger-soft); border: 1px solid var(--danger); color: #7a2f28; padding: 8px 12px;
         border-radius: var(--radius-sm); margin: 10px 0; }
.warning { background: var(--warn-soft); border: 1px solid #d9b56a; color: #6e4a08; padding: 8px 12px;
           border-radius: var(--radius-sm); margin: 10px 0; }
.errors { background: var(--danger-soft); border: 1px solid var(--danger); color: #7a2f28; padding: 8px 12px;
          border-radius: var(--radius-sm); margin: 10px 0; font-size: 14px; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }

/* --- status pills ---------------------------------------------------------- */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  line-height: 18px; white-space: nowrap; background: var(--line-soft); color: var(--soft); vertical-align: middle; }
.pill.ok { background: var(--accent-soft); color: var(--accent-dark); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.draft { background: #eef0f3; color: var(--soft); border: 1px dashed var(--faint); }

/* --- forms ----------------------------------------------------------------- */
/* Existing forms are <p><label>…<br><input></p>; that shape keeps working.
   New forms may use .field / .field-row for a tidier grid. */
form p { margin: 10px 0; }
label { font-size: 13.5px; color: var(--ink); font-weight: 500; }
form p label + br + input, form p label + br + select, form p label + br + textarea { margin-top: 3px; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=search],
input[type=password], input[type=url], input[type=tel], select, textarea {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 9px; font-size: 14px;
  min-width: 280px; background: white; color: var(--ink); font-family: inherit; min-height: 34px;
}
textarea { min-height: 0; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; vertical-align: -2px; }
.field { margin: 12px 0; }
.field label { display: block; margin-bottom: 3px; }
.field .help { display: block; font-size: 12.5px; color: var(--soft); margin-top: 3px; }
.field-row { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.field-row .field { flex: 1 1 220px; margin: 12px 0 0; }
.field-row .field input, .field-row .field select { min-width: 0; width: 100%; }
.field.full input, .field.full select, .field.full textarea { width: 100%; min-width: 0; }
.form-actions { display: flex; gap: var(--sp-2); align-items: center; margin-top: var(--sp-4); flex-wrap: wrap; }
.form-actions .muted { margin-left: 6px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px 14px; margin: 14px 0; background: var(--panel); }
legend { font-weight: 600; font-size: 13.5px; color: var(--soft); padding: 0 6px; }
.form-narrow { max-width: 560px; }
/* as-of recompute and similar one-line GET forms */
.toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin: 8px 0 12px; font-size: 13.5px; color: var(--soft); }
.toolbar input, .toolbar select { min-width: 0; min-height: 30px; padding: 4px 8px; font-size: 13.5px; }
.toolbar input[type=submit], .toolbar button { min-height: 30px; padding: 0 11px; font-size: 13px; }
.toolbar form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }

/* --- definition list: label/value pairs on a show page --------------------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 10px 0 18px; font-size: 14px; }
.facts dt { color: var(--soft); font-size: 13px; padding-top: 1px; }
.facts dd { margin: 0; }
.facts dd.num { font-variant-numeric: tabular-nums; }

/* --- KPI charts (§5.7): server-rendered SVG, actuals solid, projections dashed */
.kpi-charts { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0; }
.kpi-figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 4px; }
.kpi-figure figcaption { font-size: 12px; color: var(--soft); text-transform: uppercase; letter-spacing: .04em; }
.kpi-chart { display: block; max-width: 100%; }
.kpi-chart .axis { stroke: var(--line); stroke-width: 1; }
.kpi-chart polyline { fill: none; stroke-width: 2; stroke-linejoin: round; }
.kpi-chart polyline.actual, .kpi-chart circle.actual { stroke: var(--accent); fill: var(--accent); }
.kpi-chart polyline.actual { fill: none; }
.kpi-chart polyline.projection { stroke: var(--soft); stroke-dasharray: 5 4; }
.kpi-chart circle.projection { fill: var(--panel); stroke: var(--soft); stroke-width: 1.5; }
.kpi-chart .label { font-size: 10px; fill: var(--soft); }

footer.site { margin: 32px 0 12px; text-align: center; font-size: 12px; color: var(--soft); }

/* --- styleguide page ------------------------------------------------------- */
.sg-block { margin: 0 0 var(--sp-6); }
.sg-block > h2 { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.sg-row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; margin: 10px 0; }
.sg-note { font-size: 13px; color: var(--soft); margin: 4px 0 10px; }
.sg-note code { background: var(--line-soft); padding: 1px 5px; border-radius: 3px; font-size: 12.5px; }

/* --- printable statement (decision 64): a paper layout, no chrome ---------- */
body.statement { background: #fff; }
body.statement main { max-width: 1100px; margin: 0 auto; padding: 18px 24px; }
.statement-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
  border-bottom: 2px solid var(--accent); padding-bottom: 12px; margin-bottom: 18px; }
.statement-head h1 { margin: 2px 0 4px; font-size: 22px; }
.statement-org { font-weight: 700; color: var(--accent); font-size: 17px; }
.statement-who { font-size: 18px; font-weight: 600; }
.statement-meta { text-align: right; font-size: 14px; line-height: 1.6; }
.statement-meta .label { color: var(--soft); text-transform: uppercase; font-size: 11px; letter-spacing: .04em; margin-right: 6px; }
.statement-summary td { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.statement-foot { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 12px; }
.no-print { max-width: 1100px; margin: 12px auto 0; padding: 0 24px; }
@media print {
  .no-print { display: none !important; }
  body.statement main { max-width: none; padding: 0; }
  body, table, th, td { font-size: 11px; }
  th, td { padding: 3px 6px; }
  table { border: 0; border-radius: 0; box-shadow: none; }
  th { background: #f1f1f1 !important; color: #000; }
  h2 { page-break-after: avoid; margin-top: 14px; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  @page { margin: 14mm; }
}

/* clickwrap line on the sign-in and set-password forms (decision 77) */
.consent { font-size: 13.5px; color: #555; margin: 14px 0 6px; max-width: 420px; }

/* deal discussion (decision 83): one entry per comment, author line then body */
.comment { border-top: 1px solid var(--line); padding: 8px 0 2px; }
.comment p { margin: 4px 0; }

/* ---- help center: an index of sections and a readable article column ---- */
.help-search { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.help-search input[type=search] { min-width: 220px; min-height: 30px; padding: 4px 8px; font-size: 13.5px; }
.help-search input[type=submit] { min-height: 30px; padding: 0 11px; font-size: 13px; }
.help-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-4); }
.help-section h2 { margin-bottom: 4px; }
.help-section > .muted { margin: 0 0 8px; }
.help-list { list-style: none; margin: 0; padding: 0; }
.help-list li { padding: 7px 0; border-top: 1px solid var(--line-soft); }
.help-list li:first-child { border-top: 0; }
.help-list a { font-weight: 500; text-decoration: none; }
.help-list a:hover { text-decoration: underline; }
.help-list .help-summary { font-size: 13px; color: var(--soft); margin-top: 2px; }
.help-list.compact li { padding: 4px 0; border: 0; font-size: 13.5px; }
.help-layout { display: flex; gap: var(--sp-5); align-items: flex-start; margin-top: var(--sp-4); }
.help-article { flex: 1 1 auto; max-width: 76ch; font-size: 15px; line-height: 1.55; }
.help-article h2 { margin-top: 28px; }
.help-article h2:first-child { margin-top: 0; }
.help-article h3 { color: var(--ink); }
.help-article p, .help-article ul, .help-article ol { margin: 10px 0; }
.help-article li { margin: 4px 0; }
.help-article li > p { margin: 4px 0; }
.help-article code { background: var(--line-soft); padding: 1px 5px; border-radius: 3px; font-size: 13.5px; }
.help-article pre { background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; font-size: 13px; }
.help-article pre code { background: none; padding: 0; }
.help-article table { margin: 12px 0; width: auto; min-width: 60%; }
.help-article blockquote { margin: 14px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--accent-dark); border-radius: 0 var(--radius) var(--radius) 0; }
.help-article blockquote p { margin: 4px 0; }
.help-article dl { margin: 10px 0; }
.help-article dt { font-weight: 600; margin-top: 8px; }
.help-article dd { margin: 2px 0 0 0; color: var(--ink); }
.help-aside { flex: 0 0 240px; position: sticky; top: 16px; }
.help-aside h3 { margin-top: 0; }
@media (max-width: 900px) { .help-layout { flex-direction: column; } .help-aside { position: static; flex-basis: auto; } }
