:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e2dc;
  --accent: #1d1d1b;
  --accent-fg: #ffffff;
  --nav-active: #ecece7;
  --ok: #1a7f4b;
  --bad: #b42318;
  --radius: 8px;
  --header-h: 56px;
  --row-hover: rgba(0, 0, 0, 0.05);
  --warn-row: #fff8e1;
  --surface-2: #f3f3f3;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #1e1e1c;
    --fg: #ededea;
    --muted: #9a9a94;
    --line: #32322e;
    --accent: #ededea;
    --accent-fg: #151514;
    --nav-active: #2a2a27;
    --ok: #4cc38a;
    --bad: #f97066;
    --row-hover: rgba(255, 255, 255, 0.07);
    --warn-row: #3a2c0a;
    --surface-2: #2a2a27;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }
.brand { font-weight: 650; letter-spacing: -0.01em; }

button, .button-link { font: inherit; cursor: pointer; border-radius: 6px; }
.primary { background: var(--accent); color: var(--accent-fg); border: 0; padding: 9px 16px; text-decoration: none; display: inline-block; }
.primary:disabled { opacity: 0.6; cursor: default; }
.ghost { background: none; border: 1px solid var(--line); color: var(--fg); padding: 5px 12px; }
.text-button { background: none; border: 0; padding: 0; color: var(--fg); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.status { min-height: 1.5em; margin: 12px 0 0; color: var(--muted); }
.status.error { color: var(--bad); }

/* Sign-in pages */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.auth-card .brand { margin: 0 0 24px; }
.auth-card form { display: grid; gap: 8px; }
.auth-card label { font-weight: 550; }
.auth-card input { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.auth-card form .primary { margin-top: 8px; }

/* Dashboard shell: header on top, actions left, panel right */
.app[data-state="loading"] .layout, .app[data-state="loading"] .account { visibility: hidden; }
.topbar { position: sticky; top: 0; z-index: 1; height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.account { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account #user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); }
.sidebar { border-right: 1px solid var(--line); padding: 16px 12px; background: var(--surface); }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--fg); text-decoration: none; }
.sidebar a:hover { background: var(--nav-active); }
.sidebar a[aria-current="page"] { background: var(--nav-active); font-weight: 600; }
.nav-group { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 0; border-radius: 6px; background: none; color: var(--fg); text-align: left; }
.nav-group:hover { background: var(--nav-active); }
.nav-group::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; }
.nav-group[aria-expanded="true"]::after { transform: rotate(45deg); }
.sidebar .subnav { margin: 2px 0 4px; padding-left: 12px; }
.sidebar .subnav[hidden] { display: none; }
.breadcrumb { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.panel { padding: 28px 32px; outline: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; max-width: 720px; }
.card > h2, .card-head { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tag { font-weight: 600; color: var(--muted); }
.tag.ok { color: var(--ok); }
.tag.bad { color: var(--bad); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 16px; overflow-x: auto; scrollbar-width: none; }
  .sidebar ul { display: flex; gap: 4px; }
  .sidebar a, .nav-group { white-space: nowrap; }
  .sidebar li:has(> .nav-group) { display: flex; gap: 4px; }
  .nav-group { width: auto; gap: 8px; }
  .sidebar .subnav { margin: 0; padding-left: 0; }
  .panel { padding: 20px 16px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
}

/* Reports */
.panel.wide .card { max-width: none; }
.report-status { margin: -8px 0 12px; font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); font-weight: 600; }
.report-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.report-controls select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.report { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.report th, table.report td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.report thead th { position: sticky; top: 0; background: var(--surface); font-weight: 600; color: var(--muted); }
table.report tbody th, table.report tfoot th { font-weight: 400; }
table.report .num { text-align: right; }
/* Grid: bounded scroll area; header row and first column stay in view. Height is set in grid.js. */
.grid-wrap { overflow: auto; isolation: isolate; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.grid { border-collapse: separate; border-spacing: 0; }
table.grid thead th { z-index: 2; border-bottom: 1px solid var(--muted); }
table.grid th:first-child { position: sticky; left: 0; z-index: 1; min-width: 220px; background: var(--surface); border-right: 1px solid var(--line); }
table.grid thead th.grid-corner { z-index: 3; }
table.grid tr.section th, table.grid tr.section td { background: var(--bg); }
table.grid tbody tr:last-child > * { border-bottom: 0; }
@media (max-width: 720px) { table.grid th:first-child { min-width: 130px; max-width: 42vw; white-space: normal; } }
/* Sortable grid: heading buttons, sort arrows, totals pinned to the bottom of the scroll area. */
table.grid.sortable th button.sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
table.grid.sortable th button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table.grid.sortable th button.sort:hover { color: var(--fg); }
table.grid.sortable th button.sort::after { content: "\2195"; font-size: 10px; opacity: 0.35; }
table.grid.sortable th[aria-sort="ascending"] button.sort::after { content: "\25B2"; opacity: 1; }
table.grid.sortable th[aria-sort="descending"] button.sort::after { content: "\25BC"; opacity: 1; }
table.grid.sortable th[aria-sort="ascending"], table.grid.sortable th[aria-sort="descending"] { color: var(--fg); }
table.grid.sortable thead th.num button.sort { flex-direction: row-reverse; }
table.grid.sortable thead th.num { text-align: right; }
table.grid tfoot th, table.grid tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--surface); }
table.grid tfoot th:first-child { z-index: 3; }
table.grid.sortable td.desc { white-space: normal; min-width: 260px; max-width: 420px; }
table.grid tbody tr.muted > * { color: var(--muted); }
table.grid tbody tr:not(.section):hover > * { background-image: linear-gradient(var(--row-hover), var(--row-hover)); }
table.report .subtotal { background: var(--nav-active); }
table.report .provisional { font-style: italic; color: var(--muted); }
table.report tr.section th { background: var(--bg); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 12px; }
table.report tr.detail th { padding-left: 24px; color: var(--muted); }
table.report tr.detail td { color: var(--muted); }
table.report tr.reference th, table.report tr.reference td { color: var(--muted); font-style: italic; }
table.report tr.strong th, table.report tr.strong td, table.report tr.subtotal-row th, table.report tr.subtotal-row td { font-weight: 600; }
table.report tr.total th, table.report tr.total td { font-weight: 700; border-top: 2px solid var(--fg); }
table.report tr.unmapped th, table.report tr.unmapped td { color: var(--muted); }
table.report td.neg { color: var(--bad); }
table.report details summary { cursor: pointer; }
.project-list { margin: 6px 0 0; padding-left: 16px; color: var(--muted); font-size: 12px; white-space: normal; }
.footnote { font-size: 12px; margin-top: 10px; max-width: 900px; }
.card p { margin: 0 0 8px; }

/* Drill-down: clickable grid cells and the side panel they open */
table.grid td.drill { padding: 0; }
table.grid td.drill button { width: 100%; padding: 6px 10px; border: 0; border-radius: 0; background: none; color: inherit; font: inherit; font-style: inherit; text-align: right; }
table.grid td.drill button:hover { text-decoration: underline; }
table.grid td.drill button:focus-visible { outline-offset: -2px; }
table.grid td.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 10; width: min(760px, 100vw); overflow-y: auto; padding: 20px 24px 32px; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.drawer-head h2 { font-size: 18px; }
.drawer-head p { margin: 2px 0 0; font-size: 13px; }
.drawer-headline { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.drawer h3 { margin: 24px 0 8px; font-size: 13px; }
.drawer .footnote { margin-top: 6px; }
@media (max-width: 720px) { .drawer { padding: 16px; } }
.row-toggle { display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; }
.row-toggle::before { content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; }
.row-toggle[aria-expanded="true"]::before { transform: rotate(45deg); }
.row-toggle:hover { text-decoration: underline; }
table.entries tr.entry th, table.entries tr.entry td { background: var(--bg); vertical-align: top; }
table.entries tr.entry th { padding-left: 23px; }
table.entries a { color: inherit; }
table.entries tbody th, table.entries tbody td { vertical-align: top; }
table.entries .memo { color: var(--muted); font-size: 12px; }
table.entries tr.after-goal td { background: var(--nav-active); }
table.entries { table-layout: fixed; }
table.entries th:first-child { white-space: normal; }
table.entries th:nth-child(2) { width: 150px; }
table.entries th:nth-child(3) { width: 96px; }
table.entries th:nth-child(4) { width: 64px; }
table.entries td { overflow: hidden; text-overflow: ellipsis; }
.drawer-body a { color: inherit; }
table.fit { table-layout: fixed; }
table.fit th:first-child { white-space: normal; overflow-wrap: anywhere; }
table.fit thead th:not(:first-child) { width: 104px; white-space: normal; vertical-align: bottom; }

/* Forms (Admin > Users drawer) */
.field { display: block; margin: 0 0 12px; font-size: 0.9rem; }
.field input { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; border: 1px solid var(--border, #c8c8c8); border-radius: 6px; background: var(--bg, #fff); color: inherit; }
.check { display: block; margin: 4px 0; font-size: 0.9rem; }
fieldset { border: 1px solid var(--border, #c8c8c8); border-radius: 6px; padding: 8px 12px; margin: 0 0 12px; }
legend { font-weight: 600; padding: 0 4px; }
.actions { display: flex; gap: 12px; align-items: center; margin: 12px 0; }
tr.muted td { opacity: 0.6; }
.report td input[type=text] { width: 100%; min-width: 120px; font: inherit; padding: 4px 6px; }
.report td input[type=number] { width: 70px; font: inherit; padding: 4px 6px; }
.report td select, .card-head select { font: inherit; padding: 4px 6px; }
.card-head input[type=text] { font: inherit; font-weight: 600; padding: 4px 6px; min-width: 240px; }
.actions .field { margin: 0; }
.actions .field input { width: 90px; }

/* Buttons: one style everywhere. */
.actions button, .card button, .drawer button { padding: 8px 14px; font: inherit; border-radius: 6px; cursor: pointer; border: 1px solid #1f1f1f; background: #1f1f1f; color: #fff; }
.actions button:disabled { opacity: 0.5; cursor: default; }

.status.banner:empty { display: none; }
.status.banner.warn { background: #fff8e1; border: 1px solid #b7791f; color: #5f370e; padding: 10px 14px; border-radius: 6px; margin: 0 0 12px; max-width: 900px; }
.status.banner.warn p { margin: 0 0 4px; }
.status.banner.warn p:last-child { margin: 0; }
.status.banner.warn ul { margin: 2px 0 0; padding-left: 20px; }
table.report td.muted { color: var(--muted); }
@media (prefers-color-scheme: dark) { .status.banner.warn { background: #3a2c0a; border-color: #b7791f; color: #f6e2b3; } .status.banner.error { background: #3b1414; border-color: #f97066; color: #fecaca; } }
table.report.kv { width: auto; min-width: 360px; margin-bottom: 8px; }
table.report td.desc { white-space: normal; min-width: 260px; max-width: 420px; }
.report-body h3 { margin: 20px 0 8px; font-size: 14px; }
.report-controls input[type=date] { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
.status.banner.error { background: #fdecea; border: 1px solid #c62828; color: #7f1d1d; padding: 10px 14px; border-radius: 6px; margin: 0 0 12px; }

.field select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; border: 1px solid var(--border, #c8c8c8); border-radius: 6px; background: var(--bg, #fff); }

/* Contracts > Templates editor */
.card.full { max-width: none; }
.editor-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.editor-wrap .slots { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; margin: 0; font-size: 13px; }
.editor-wrap .slots .facts { grid-template-columns: 1fr; gap: 2px 0; }
.editor-wrap .slots dd { margin: 0 0 8px; }
.editor-wrap code { font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; }
.toolbar select { font: inherit; padding: 6px 8px; }
.doc-editor { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px; padding: 0.8in 0.9in; min-height: 60vh; font: 11pt/1.45 Georgia, serif; outline: none; }
.doc-editor:focus { border-color: #1f1f1f; }
.doc-editor[contenteditable=false] { background: #fafafa; }
.doc-editor h1 { font-size: 14pt; text-align: center; text-transform: uppercase; margin: 0 0 1em; }
.doc-editor h2 { font-size: 11pt; margin: 1.2em 0 0.4em; }
.doc-editor p { margin: 0 0 0.8em; }
.doc-editor ul, .doc-editor ol { margin: 0 0 0.8em 1.4em; }
.doc-editor table.sign { width: 100%; margin-top: 2em; }
.doc-editor table.sign td { width: 50%; vertical-align: top; }
.doc-source { width: 100%; min-height: 60vh; font: 12px/1.5 ui-monospace, Consolas, monospace; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.doc-source[hidden], .doc-editor[hidden] { display: none; }

/* Template editor toolbar: icon buttons, pressed state shows the formatting at the cursor. */
.toolbar { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; gap: 2px; }
.toolbar .tb { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #1f1f1f; font: 15px/1 Georgia, serif; cursor: pointer; }
.toolbar .tb svg { width: 20px; height: 20px; fill: currentColor; }
.toolbar .tb:hover { background: #ececec; }
.toolbar .tb[aria-pressed=true] { background: #1f1f1f; color: #fff; }
.toolbar .tb:disabled { opacity: 0.35; cursor: default; background: transparent; }
.toolbar .tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.toolbar .tb-select { font: 13px/1 system-ui, sans-serif; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; max-width: 260px; margin-left: 2px; }

.toolbar[hidden] { display: none; }
.doc-editor[contenteditable=false] { background: #fff; cursor: default; }

.signing { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.signing h3 { margin: 0 0 8px; font-size: 14px; }
ul.small { font-size: 12px; padding-left: 18px; }

.field.rows table { width: 100%; margin-top: 6px; }
.field.rows th { font-weight: 500; font-size: 12px; color: var(--muted); }
.field.rows td input { width: 100%; min-width: 60px; font: inherit; padding: 4px 6px; }
.field.rows .actions { margin: 6px 0 0; }

/* Collapsed group rows on the summary grid (former staff, fixed-fee contractors) */
.grid tr.child th { padding-left: 1.75em; font-weight: normal; }
.grid .group-toggle { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.grid .group-toggle::before { content: '▸ '; }
.grid .group-toggle[aria-expanded="true"]::before { content: '▾ '; }

/* Invoicing > Hours attribution */
.report td.num, .report th.num { text-align: right; white-space: nowrap; }
.report tr.flag td:first-child { border-left: 3px solid var(--bad); }
.report tr.selected td { background: var(--surface-2); }
.report td.small { font-size: 12px; max-width: 420px; }
button.link { background: none; border: none; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

.report td.num.bad { color: var(--bad); font-weight: 600; }
button.link.selected { font-weight: 700; }

.small.bad, span.bad { color: var(--bad); }
.drawer details { margin: 8px 0; }
.drawer details summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

/* Fit-to-pane grid (grid.js fitGrid): no horizontal scroll, wrapping cells, locked header. */
.fit-wrap { overflow-y: auto; overflow-x: hidden; isolation: isolate; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.report.fit { table-layout: fixed; width: 100%; }
table.report.fit th, table.report.fit td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; padding: 8px 10px; line-height: 1.4; }
table.report.fit thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: 0 1px 0 var(--line); vertical-align: bottom; }
table.report.fit td.num, table.report.fit th.num { text-align: right; white-space: nowrap; overflow-wrap: normal; }
table.report.fit td.act { text-align: right; white-space: nowrap; }
table.report.fit .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
table.report.fit .why { font-weight: 600; }
table.report.fit .src { font-size: 12px; color: var(--muted); margin-top: 4px; }
table.report.fit .src b { font-weight: 600; color: var(--fg); }
table.report.fit td button { padding: 4px 10px; font-size: 12px; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); white-space: nowrap; }
.pill.open { border-color: var(--bad); color: var(--bad); }
.pill.done { border-color: var(--ok); color: var(--ok); }
ol.basis { margin: 0 0 12px; padding-left: 20px; font-size: 13px; line-height: 1.5; }
ol.basis li { margin-bottom: 4px; }
.clamp2 { -webkit-line-clamp: 2; line-clamp: 2; } .clamp3 { -webkit-line-clamp: 3; line-clamp: 3; } .clamp4 { -webkit-line-clamp: 4; line-clamp: 4; }

/* Revenue recognition > Accommodations */
.field textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; border: 1px solid var(--border, #c8c8c8); border-radius: 6px; background: var(--bg, #fff); color: inherit; resize: vertical; }
.field.check { display: flex; align-items: center; gap: 6px; }
.field.check input { width: auto; margin: 0; }
.toolbar.seg button { padding: 6px 12px; border: 1px solid transparent; border-radius: 6px; background: transparent; font: inherit; cursor: pointer; color: inherit; }
.toolbar.seg button[aria-pressed=true] { background: #1f1f1f; color: #fff; }
.acc-value { font-weight: 600; margin: 0 0 12px; }
ol.history { padding-left: 18px; }
ol.history li { margin-bottom: 6px; }
details.how summary { cursor: pointer; font-weight: 600; }
details.how ol { margin: 8px 0 0; padding-left: 20px; }
details.how li { margin-bottom: 4px; }

/* Contracts > Upload: review page. PDF on the left stays in view; proposed terms scroll on the right. */
.intake-split { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr); gap: 16px; align-items: start; }
.intake-left { position: sticky; top: calc(var(--header-h) + 12px); }
.intake-pdf { width: 100%; height: calc(100vh - var(--header-h) - 40px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.intake-side .card + .card { margin-top: 12px; }
.intake-row { display: flex; gap: 12px; flex-wrap: wrap; }
.intake-row .field { flex: 1 1 180px; }
.intake-doc.skipped { opacity: 0.7; }
.intake-warnings { margin: 4px 0 8px; padding-left: 18px; color: var(--bad); font-size: 13px; }
.evidenced { padding: 4px 8px 2px; margin: 0 -8px 4px; border-left: 3px solid transparent; border-radius: 4px; }
.evidenced.conf-low { border-left-color: var(--bad); background: rgba(180, 35, 24, 0.06); }
.evidenced.conf-medium { border-left-color: #c48a00; }
.evidence { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); }
.evidence q { font-style: italic; }
.pill.conf-high { background: rgba(26, 127, 75, 0.12); color: var(--ok); }
.pill.conf-medium { background: rgba(196, 138, 0, 0.15); color: #8a6100; }
.pill.conf-low { background: rgba(180, 35, 24, 0.12); color: var(--bad); }
.no-evidence input, .no-evidence select { border-style: dashed; }
@media (max-width: 960px) { .intake-split { grid-template-columns: 1fr; } .intake-left { position: static; } .intake-pdf { height: 60vh; } }

/* Delivery > Time bot: the conversation in the drawer. */
.tb-msg { border-left: 3px solid var(--line); padding: 4px 0 4px 10px; margin: 0 0 10px; }
.tb-msg.in { border-left-color: var(--ok); }
.tb-text { white-space: pre-wrap; }

/* Reports > Acquisition */
.acq table.report .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: normal; }
.kpis { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 14px; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 150px; background: var(--surface); }
.kpi .v { display: block; font-size: 20px; font-weight: 600; }
.kpi .l { display: block; font-size: 12px; color: var(--muted); }
.kpi .s { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.report th.plan-col, .report td.plan-col { background: var(--surface-2, #f7f7f7); }
.report td.plan-col { color: var(--muted); }
.grid tr.channel th, .grid tr.channel td { font-weight: 600; border-top: 2px solid var(--line); }
.grid tr.total th, .grid tr.total td { font-weight: 600; border-top: 2px solid var(--line); }
.plan-grid input[type=number] { width: 64px; font: inherit; padding: 3px 4px; }
.plan-grid .actions.stack { flex-direction: column; align-items: stretch; gap: 4px; margin: 0; }
.plan-grid .actions.stack input { width: 110px; font: inherit; padding: 3px 4px; }
.plan-grid td.calc { color: var(--muted); font-size: 12px; white-space: nowrap; }
.plan-grid th.sticky, .plan-grid td.sticky { position: sticky; left: 0; background: var(--surface); }
.rules-table select, .rules-table input[type=text] { font: inherit; padding: 3px 4px; max-width: 220px; }
.rules-table input[type=number] { width: 60px; font: inherit; padding: 3px 4px; }

/* Forecast report: stacked inputs in the assumptions grid. */
.fc .stack { display: flex; flex-direction: column; gap: 4px; }
.fc .plan-grid input { width: 9em; }
.fc .plan-grid input[type="text"] { width: 16em; }
/* Time bot messages: a conversation that needs a person. */
table.grid tr.warn > * { background: var(--warn-row); }

/* First invoice preview on a posted upload (QuickBooks PDF). */
.intake-invoice-pdf { width: 100%; height: 560px; border: 1px solid var(--border, #ddd); border-radius: 6px; margin: 8px 0; }
.drawer-body table.report { width: 100%; table-layout: fixed; }
.drawer-body table.report td, .drawer-body table.report th { white-space: normal; overflow-wrap: anywhere; }
.drawer-body table.report tr > :first-child { width: 46%; }
.drawer-body textarea { width: 100%; box-sizing: border-box; }

/* Delivery > Client health: status pills, pace labels, utilization, severity. */
.ch { --amber: #b7791f; }
.ch .rag, .ch .pace, .ch .util, .ch .sev { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid currentColor; }
.ch .rag.green, .ch .util.ok { color: var(--ok); }
.ch .rag.amber, .ch .util.warn, .ch .pace.under, .ch .sev.medium { color: var(--amber); }
.ch .rag.red, .ch .util.bad, .ch .pace.over, .ch .sev.high { color: var(--bad); }
.ch .pace.ok, .ch .sev.low { color: var(--ok); border-color: transparent; }
.ch .pace.na, .ch .pace.early { color: var(--muted); border-color: transparent; font-weight: normal; }
.ch .kpi.k-red .v { color: var(--bad); }
.ch .kpi.k-amber .v { color: var(--amber); }
.ch .kpi.k-green .v { color: var(--ok); }
.ch .sub { display: block; font-size: 12px; color: var(--muted); font-weight: normal; }
.ch tr.muted td { color: var(--muted); }
.drawer .stack, .ch .stack { display: flex; flex-direction: column; gap: 8px; }
.drawer textarea { font: inherit; width: 100%; box-sizing: border-box; }

/* Reports > Acquisition v2: one fixed colour per channel (identity follows the channel key, never its rank). Palette:
   dataviz reference categorical order, validated on --surface in both modes; swatches always sit beside the channel's
   name, so no colour stands alone. Existing clients are neutral grey: not an acquisition channel. */
.acq { --ch-existing: #9a9a94; --ch-shopify: #2a78d6; --ch-partner: #eb6834; --ch-referral: #1baf7a; --ch-event: #eda100;
  --ch-outbound: #e87ba4; --ch-ppc: #008300; --ch-organic: #6250d6; --ch-inbound: #e34948; --ch-other: #bdbdb6; }
@media (prefers-color-scheme: dark) {
  .acq { --ch-existing: #6b6b66; --ch-shopify: #3987e5; --ch-partner: #d95926; --ch-referral: #199e70; --ch-event: #c98500;
    --ch-outbound: #d55181; --ch-ppc: #008300; --ch-organic: #9085e9; --ch-inbound: #e66767; --ch-other: #55554f; }
}
.acq .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: baseline; background: var(--ch-other); }
.acq .swatch.ch-existing { background: var(--ch-existing); } .acq .swatch.ch-shopify { background: var(--ch-shopify); }
.acq .swatch.ch-partner { background: var(--ch-partner); } .acq .swatch.ch-referral { background: var(--ch-referral); }
.acq .swatch.ch-event { background: var(--ch-event); } .acq .swatch.ch-outbound { background: var(--ch-outbound); }
.acq .swatch.ch-ppc { background: var(--ch-ppc); } .acq .swatch.ch-organic { background: var(--ch-organic); }
.acq .swatch.ch-inbound { background: var(--ch-inbound); }
.acq .acq-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 0 0 16px; }
.acq .acq-filters label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 2px; }
.acq .overdue { color: var(--bad); }

/* Invoice approval, per-invoice months: one block per invoice in the row. */
.inv-block { padding: 4px 0; border-top: 1px solid var(--line); }
.inv-block:first-child { border-top: 0; padding-top: 0; }

/* Acquisition: projection rows (actual to date, then plan) show their planned months in the projection colour. */
:root { --projection: #1d5fd1; }
@media (prefers-color-scheme: dark) { :root { --projection: #8ab4f8; } }
.report tr.projection td.plan-col, .report tr.projection td.plan-col button { color: var(--projection); font-style: italic; font-weight: 600; }
.legend-projection { color: var(--projection); font-style: italic; font-weight: 600; }

.intake-reject { margin-top: 8px; }
.intake-reject-note { width: 100%; box-sizing: border-box; margin-bottom: 6px; font: inherit; padding: 6px 8px; }
