/* Tax OS · firm workspace. System fonts only: the content security policy blocks remote fonts. */
:root {
  --ink: #0f1b2d;
  --body: #2b3a4d;
  --muted: #5d6c7e;
  --faint: #8794a5;
  --line: #e2e7ee;
  --line-soft: #eef1f5;
  --background: #f4f6f9;
  --surface: #fff;
  --navy: #0e2238;
  --navy-soft: #17304b;
  --green: #0b7a63;
  --green-dark: #086350;
  --green-tint: #e6f4f0;
  --gold: #b3862b;
  --amber: #a8650c;
  --amber-tint: #fdf3e1;
  --red: #b3372a;
  --red-tint: #fcebe8;
  --blue: #1f5fae;
  --blue-tint: #e8f0fb;
  --radius: 10px;
  --shadow: 0 1px 2px #0f1b2d0a, 0 4px 16px #0f1b2d0a;
  --sidebar: 256px;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--background); color: var(--body); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--green-dark); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, h4 { font-family: var(--display); color: var(--ink); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 650; line-height: 1.25; margin: 6px 0 6px; letter-spacing: -.02em; }
h2 { font-size: 21px; font-weight: 650; line-height: 1.3; }
h3 { font-size: 16px; font-weight: 650; line-height: 1.4; }
h4 { font-size: 14px; font-weight: 650; margin-top: 18px; }
p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; line-height: 1.5; margin-top: 3px; }
strong { color: var(--ink); font-weight: 600; }
code, pre { font-family: var(--mono); }
.eyebrow, .nav-label { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--gold); }

/* ---------- Sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 30; display: flex; flex-direction: column; padding: 22px 14px 16px; background: var(--navy); color: #c3cedb; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2d4763 transparent; }
.brand { display: block; padding: 0 10px; text-decoration: none; color: #fff; font: 700 22px var(--display); letter-spacing: -.02em; }
.brand-mark { color: #4fc3a5; }
.brand-caption { display: block; margin-top: 4px; font: 600 10.5px var(--sans); letter-spacing: .12em; color: #7f93aa; }
.firm { display: flex; gap: 10px; align-items: center; margin: 22px 0 18px; padding: 10px; border: 1px solid #ffffff14; border-radius: var(--radius); background: #ffffff0a; color: #fff; font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.firm small, .profile small { color: #8ea0b5; font-size: 12px; margin-top: 1px; }
.firm > div, .profile > div { min-width: 0; overflow-wrap: anywhere; }
.avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--green-tint); color: var(--green-dark); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.avatar.dark { background: #4fc3a5; color: var(--navy); }
.sidebar > .nav-label { display: none; }
nav { display: flex; flex-direction: column; gap: 14px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group:not(:has(button:not([hidden]):not(.nav-tab))) { display: none; }
nav button.nav-tab { display: none; }  /* a page's tabs: reached from the page's own item and its tab bar (ui.js) */
.nav-group .nav-label { padding: 0 10px 6px; color: #6f849c; font-size: 10.5px; }
nav button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: #b9c5d3; font-size: 14px; font-weight: 500; text-align: left; position: relative; transition: background .15s, color .15s; }
nav button svg { flex: none; width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
nav button:hover { background: #ffffff0f; color: #fff; }
nav button.active { background: #ffffff17; color: #fff; font-weight: 600; }
nav button.active::before { content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: #4fc3a5; }
nav button .nav-count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: #e0a83a; color: var(--navy); font-size: 11px; font-weight: 700; text-align: center; }
.sidebar-bottom { margin-top: auto; padding: 18px 10px 0; font-size: 12.5px; color: #8ea0b5; }
.sidebar-bottom small { color: #6f849c; }
.local-dot, .pulse, .amber-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: #4fc3a5; }
.pulse { box-shadow: 0 0 0 0 #0b7a6366; animation: pulse 2.4s infinite; background: var(--green); }
.amber-dot { width: 7px; height: 7px; margin: 0 0 1px 6px; background: #e0a83a; }
.profile { display: flex; gap: 10px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid #ffffff14; color: #fff; font-size: 13.5px; font-weight: 600; }
.profile small { text-transform: capitalize; }

/* ---------- Shell ---------- */
.main { margin-left: var(--sidebar); min-height: 100vh; }
header { position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 32px; background: #ffffffeb; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
header > div:first-of-type { display: flex; align-items: center; min-width: 0; white-space: nowrap; }
.slash { margin: 0 10px; color: #c2cad5; }
#breadcrumb { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 8px; white-space: nowrap; flex: none; }
.environment { padding: 4px 9px; border-radius: 20px; background: var(--green-tint); color: var(--green-dark); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.menu-button { display: none; width: 38px; height: 38px; margin-right: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); align-items: center; justify-content: center; }
.menu-button svg, .jump-button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.jump-button { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--background); color: var(--muted); font-size: 13.5px; transition: border-color .15s, background .15s; }
.jump-button:hover { border-color: #c5ced9; background: #fff; }
kbd { padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: #fff; font: 600 11px var(--sans); color: var(--muted); }
.text-button { padding: 7px 10px; border: 0; border-radius: 7px; background: none; color: var(--green); font-size: 13.5px; font-weight: 600; }
.text-button:hover { background: var(--green-tint); }
main { max-width: 1480px; margin: auto; padding: 28px 32px 16px; }
main > section:not([hidden]) { animation: rise .22s ease-out; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.page-heading p { font-size: 15px; max-width: 70ch; }
footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 28px; padding: 16px 0; border-top: 1px solid var(--line); color: var(--faint); font-size: 12.5px; }

/* ---------- Buttons ---------- */
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; font-size: 14px; font-weight: 600; line-height: 1.2; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s; }
.primary { background: var(--green); color: #fff; box-shadow: 0 1px 2px #0b7a6340; }
.primary:hover:not(:disabled) { background: var(--green-dark); box-shadow: 0 3px 10px #0b7a6338; }
.secondary { background: var(--surface); border-color: #cfd7e1; color: var(--ink); }
.secondary:hover:not(:disabled) { background: var(--background); border-color: #b5c0cd; }
.primary:active:not(:disabled), .secondary:active:not(:disabled) { transform: translateY(1px); }
.full { width: 100%; margin-top: 14px; }
.primary[aria-busy=true], .secondary[aria-busy=true] { color: transparent; position: relative; }
.close { width: 34px; height: 34px; flex: none; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 22px; line-height: 1; }
.close:hover { background: var(--background); color: var(--ink); }

/* ---------- Forms ---------- */
label { display: block; margin-top: 14px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
input, select, textarea { display: block; width: 100%; margin-top: 6px; padding: 9px 11px; border: 1px solid #cfd7e1; border-radius: 8px; background: #fff; color: var(--ink); font-size: 14px; font-weight: 400; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: #b5c0cd; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px #0b7a6326; }
input[readonly], textarea[readonly] { background: var(--background); color: var(--muted); }
input::placeholder, textarea::placeholder { color: #9aa6b4; }
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
select[multiple] { min-height: 90px; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; margin: 0; padding: 0; flex: none; accent-color: var(--green); box-shadow: none; }
input[type=range] { padding: 0; border: 0; box-shadow: none; accent-color: var(--green); }
input[type=file] { padding: 14px; border-style: dashed; background: var(--background); color: var(--muted); font-size: 13.5px; cursor: pointer; }
input[type=file]:hover, input[type=file].dragging { border-color: var(--green); background: var(--green-tint); }
input[type=file]::file-selector-button { margin-right: 12px; padding: 7px 12px; border: 1px solid #cfd7e1; border-radius: 7px; background: #fff; color: var(--ink); font: 600 13px var(--sans); cursor: pointer; }
.checkbox { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; color: var(--body); line-height: 1.5; }
.checkbox input { margin-top: 3px; }
fieldset { min-width: 0; margin: 0; }
output { font-weight: 700; color: var(--green-dark); }
.format-hint { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: var(--background); color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.format-hint code { display: block; margin: 4px 0; color: var(--ink); overflow-wrap: anywhere; }
.error { color: var(--red); font-size: 13.5px; }
div.error:not(:empty), p.error:not(:empty) { margin-top: 10px; padding: 10px 12px; border: 1px solid #f1c9c3; border-radius: 8px; background: var(--red-tint); }
.reason { margin-top: 8px; padding: 10px 12px; border-left: 3px solid #e0a83a; border-radius: 0 8px 8px 0; background: var(--amber-tint); color: #5c4310; font-size: 13.5px; }
.reason p, .reason small { color: #6d5320; }
.review-evidence { margin-top: 14px; }
.review-evidence form { display: grid; gap: 8px; margin-top: 8px; }
#source-checks details summary { cursor: pointer; font-weight: 600; }
.reason strong { color: #4a350b; }

/* Dense two-column forms inside working cards. */
.manage-card form, .manage-card form > fieldset { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 16px; align-items: start; }
.manage-card form label, .manage-card form .full { margin-top: 0; }
.manage-card form > :not(label), .manage-card form > fieldset > :not(label), .manage-card form label.checkbox, .manage-card form label:has(textarea, input[type=file], input[type=range], select[multiple]), .manage-card form label:empty { grid-column: 1 / -1; }
.manage-card form > small { margin-top: -8px; }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; }
.manage-card { padding: 22px; }
.manage-card > * + *, .manage-card section > * + *, details > * + *, dialog > * + *, #ingest-detail > * + *, #advisory-detail > * + *, #review-content > * + *, #invite-result > * + *, #policy-result > * + * { margin-top: 12px; }
.manage-card > h3 + p, .manage-card section > h3 + p { margin-top: 4px; }
.manage-card > .eyebrow + h3, .manage-card > .eyebrow + h2 { margin-top: 4px; }
.manage-card > .eyebrow { display: block; }
.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.integration-grid > section, .integration-grid > article { min-width: 0; }
.integration-grid article { padding: 22px; }
.integration-grid article h3 { margin-top: 14px; }
.integration-grid article .badge { margin-top: 14px; }
main > section > .panel + .panel, main > section > .panel + .integration-grid, #income-body > * + *, #credit-body > * + *, #compliance-body > * + *, #operations > * + * { margin-top: 20px; }
.overview-strip { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 20px; padding: 11px 16px; border: 1px solid #cfe6df; border-radius: var(--radius); background: var(--green-tint); color: var(--green-dark); font-size: 13.5px; font-weight: 600; }
.overview-strip strong { margin-left: 10px; font-weight: 400; color: var(--body); }
.overview-strip > span { font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }

details { border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; padding: 0 14px; }
details[open] { padding-bottom: 14px; }
summary { padding: 11px 0; cursor: pointer; color: var(--ink); font-size: 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.8px 1.8px 0; transform: rotate(-45deg); transition: transform .15s; flex: none; }
details[open] > summary::before { transform: rotate(45deg); }
summary:hover { color: var(--green-dark); }
.extracted-text { max-height: 280px; overflow: auto; margin-bottom: 0; padding: 14px; border-radius: 8px; background: #101d2e; color: #d5deea; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; text-transform: capitalize; background: #eef1f5; color: #54637a; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.matched, .badge.approved, .badge[data-tone=ok] { background: var(--green-tint); color: var(--green-dark); }
.badge.mismatch, .badge.duplicate, .badge[data-tone=warn] { background: var(--amber-tint); color: var(--amber); }
.badge.missing_2b, .badge.missing_books, .badge[data-tone=bad] { background: var(--red-tint); color: var(--red); }
.badge[data-tone=info] { background: var(--blue-tint); color: var(--blue); }

/* ---------- Metrics ---------- */
.metrics, .kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metrics article, .kpi { padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metrics article > span, .metrics article > small:first-child, .kpi > span { display: block; margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.metrics h2, .kpi strong { display: block; margin: 8px 0 4px; font: 650 27px/1.2 var(--display); color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metrics em { font-style: normal; font-size: 16px; font-weight: 500; color: var(--faint); }
.metrics p { font-size: 13px; }
.kpi { position: relative; text-align: left; transition: transform .15s, box-shadow .15s, border-color .15s; }
button.kpi:hover { transform: translateY(-2px); border-color: #c5ced9; box-shadow: 0 8px 24px #0f1b2d14; }
.kpi small { margin-top: 0; }
.kpi[data-tone=warn] strong { color: var(--amber); }
.kpi[data-tone=ok] strong { color: var(--green-dark); }
.advisory-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 14px 0; }
.advisory-metrics h2, .income-metrics h2 { font-size: 22px; }
.advisory-metrics article, .income-metrics article { box-shadow: none; background: #fbfcfd; }
.income-metrics { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 0; }

/* ---------- Overview ---------- */
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.right-column { display: flex; flex-direction: column; gap: 20px; }
.queue-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 20px; background: #fff; color: var(--muted); font-size: 13px; font-weight: 600; transition: all .15s; }
.chip:hover { border-color: #b5c0cd; color: var(--ink); }
.chip.selected { background: var(--navy); border-color: var(--navy); color: #fff; }
.queue-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 20px; border: 0; border-top: 1px solid var(--line-soft); background: none; text-align: left; transition: background .12s; }
.queue-item:hover { background: #f7f9fb; }
.queue-item > span:first-child { flex: none; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--background); color: var(--navy-soft); }
.queue-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.queue-item > div { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item small { overflow: hidden; text-overflow: ellipsis; }
.queue-item::after { content: "›"; color: var(--faint); font-size: 20px; }
.module-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13.5px; }
.module-row > span:first-child { width: 118px; flex: none; color: var(--ink); font-weight: 600; }
.module-row > span:last-child { width: 44px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; background: var(--green); transition: width .5s ease; }
.bar i + i { background: #e0a83a; }
.quick-actions { display: grid; gap: 8px; margin-top: 14px; }
.quick-actions .secondary { justify-content: flex-start; width: 100%; }

/* ---------- Reconciliation ---------- */
.next-step, .source-panel { padding: 20px; }
.next-step h3 { margin: 8px 0 6px; font-size: 18px; }
.next-step .secondary { width: 100%; margin-top: 16px; }
.progress-track { height: 8px; margin: 18px 0 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.progress-track div { height: 100%; border-radius: 4px; background: var(--green); transition: width .5s ease; }
#progress-label { color: var(--muted); font-size: 13px; }
.source-row { display: flex; align-items: center; gap: 11px; margin-top: 14px; font-size: 14px; font-weight: 600; color: var(--ink); }
.source-row > span:last-child { margin-left: auto; color: var(--green-dark); font-size: 13px; }
.source-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px; background: var(--green-tint); color: var(--green-dark); font-size: 16px; }
.source-panel > p { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 20px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 22px; }
.tabs button { padding: 13px 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs .selected { color: var(--green-dark); border-bottom-color: var(--green); font-weight: 600; }
.tabs span { margin-left: 5px; padding: 1px 7px; border-radius: 10px; background: var(--amber-tint); color: var(--amber); font-size: 12px; font-weight: 700; }
#search { width: 260px; margin: 8px 0; padding: 8px 11px; font-size: 13.5px; background: var(--background); }
.history-panel { margin-top: 20px; }
.quiet { color: var(--faint); font-size: 12.5px; }
.run-list { padding: 0 20px 6px; }
.mini-list .run-item, .run-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.run-item button { flex: 1; min-width: 0; padding: 0; border: 0; background: none; text-align: left; color: var(--ink); font-size: 14px; font-weight: 600; }
.run-item button:hover { color: var(--green-dark); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.audit-item { padding: 16px 20px 16px 44px; border-top: 1px solid var(--line-soft); position: relative; }
.audit-item::before { content: ""; position: absolute; left: 22px; top: 22px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-tint); }
.audit-item strong { font-size: 14px; text-transform: capitalize; }
.audit-item p { margin-top: 6px; overflow-wrap: anywhere; }
.audit-item code, .mini-list code { display: block; margin-top: 6px; color: var(--faint); font-size: 11.5px; overflow-wrap: anywhere; }

/* ---------- Tables ---------- */
.table-wrap, .ingest-table, .income-table, .review-values { overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; z-index: 1; padding: 10px 16px; background: #f7f9fb; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; text-align: left; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th[data-sort]::after { content: "↕"; margin-left: 6px; opacity: .35; }
th[aria-sort=ascending]::after { content: "↑"; opacity: 1; color: var(--green); }
th[aria-sort=descending]::after { content: "↓"; opacity: 1; color: var(--green); }
td { padding: 12px 16px; border-top: 1px solid var(--line-soft); font-size: 14px; color: var(--body); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f7f9fb; }
td:first-child { font-weight: 600; color: var(--ink); }
td small { font-size: 12.5px; }
td button { padding: 5px 10px; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--green); font-size: 13.5px; font-weight: 600; }
td button:hover { background: var(--green-tint); border-color: #cfe6df; }
td input, td select { margin-top: 0; min-width: 120px; padding: 7px 9px; font-size: 13.5px; }
td input[type=checkbox] { min-width: 0; }
.table-footer { display: flex; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.review-values { margin: 14px 0; border: 1px solid var(--line); border-radius: 8px; }
.ingest-table { max-height: 46vh; border: 1px solid var(--line); border-radius: 8px; }
.ingest-table input.missing { border-color: #e0a83a; background: var(--amber-tint); }
.ingest-pagination { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; font-size: 13.5px; color: var(--muted); }
.income-table { max-height: 480px; border: 1px solid var(--line); border-radius: 8px; }
.income-table td { min-width: 110px; white-space: normal; }

/* ---------- Module specifics ---------- */
.mini-list > div { padding: 12px 0; border-top: 1px solid var(--line-soft); font-size: 14px; font-weight: 600; color: var(--ink); }
.mini-list > div > .secondary { min-height: 32px; margin-top: 8px; padding: 5px 11px; font-size: 13px; }
#operations-health > div > strong { float: right; font-weight: 600; color: var(--green-dark); }
.mini-list a { font-weight: 600; }
.mini-list label { margin-top: 6px; }
.income-top { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.5fr); gap: 20px; margin-bottom: 20px; align-items: start; }
#income-body > .income-top, #credit-body > .income-top { margin-bottom: 0; }
.income-heading, .income-source > div:first-child { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.income-heading > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.income-source, .income-format { padding: 14px 0; border-top: 1px solid var(--line-soft); }
.income-source > * + * { margin-top: 10px; }
.income-source small { overflow-wrap: anywhere; }
.income-format .text-button { padding-left: 0; }
#compliance-documents { display: grid; gap: 6px; }
#advisory-preview-result { margin-bottom: 20px; }

/* ---------- Dialogs ---------- */
dialog { width: 580px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); padding: 26px; border: 0; border-radius: 14px; background: var(--surface); color: var(--body); box-shadow: 0 24px 80px #0e223859; }
dialog[open] { animation: pop .18s ease-out; }
dialog::backdrop { background: #0e223880; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.dialog-heading h2 { margin-top: 2px; }
.ingest-dialog { width: min(1200px, 94vw); max-width: 1200px; }

/* ---------- Toast ---------- */
#notice { position: fixed; right: 24px; bottom: 24px; z-index: 60; max-width: min(420px, calc(100vw - 48px)); padding: 13px 16px 13px 18px; border-left: 4px solid #4fc3a5; border-radius: 10px; background: var(--navy); color: #fff; font-size: 14px; box-shadow: 0 12px 40px #0e22384d; animation: rise .22s ease-out; cursor: pointer; }
#notice.error { border-left-color: #f08a7c; color: #fff; }

/* ---------- Command palette ---------- */
#palette { width: 560px; padding: 0; top: 14vh; margin-top: 0; }
#palette input { margin: 0; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; font-size: 16px; box-shadow: none; }
#palette-list { max-height: 50vh; overflow: auto; margin: 0; padding: 8px; }
#palette-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); font-size: 14.5px; text-align: left; }
#palette-list button svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#palette-list button small { margin: 0 0 0 auto; }
#palette-list button.current, #palette-list button:hover { background: var(--green-tint); }

/* ---------- Sign-in ---------- */
.auth-pending > .sidebar, .auth-pending > .main { display: none; }
#auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 28px; background: radial-gradient(900px 500px at 15% 0%, #1c4a66 0%, transparent 60%), radial-gradient(700px 500px at 100% 100%, #0b7a6340 0%, transparent 60%), var(--navy); }
.auth-card { width: 440px; max-width: 100%; padding: 34px; border-radius: 16px; background: var(--surface); box-shadow: 0 30px 90px #00000059; }
.auth-card .brand { padding: 0; color: var(--ink); }
.auth-card .brand-mark { color: var(--green); }
.auth-card > .eyebrow { display: block; margin-top: 26px; }
.auth-card > p { margin-top: 14px; }
.auth-card > h1 + p { margin-top: 0; }
.auth-card > small { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.auth-footnote { font-size: 12.5px; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px #0b7a6300; } 100% { box-shadow: 0 0 0 0 #0b7a6300; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 1180px) {
  .content-grid, .income-top { grid-template-columns: 1fr; }
  .right-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics, .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 60px #00000040; }
  .nav-open .sidebar { transform: none; }
  .nav-open::after { content: ""; position: fixed; inset: 0; z-index: 25; background: #0e223866; }
  .main { margin-left: 0; }
  .menu-button { display: inline-flex; }
  header { padding: 0 16px; }
  main { padding: 20px 16px 12px; }
  .integration-grid, #compliance-body .integration-grid { grid-template-columns: 1fr; }
  .jump-button span, .jump-button kbd { display: none; }
  .jump-button { padding: 0 10px; }
  nav button { min-height: 44px; }
}
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .page-heading { flex-direction: column; align-items: flex-start; }
  .metrics, .kpi-grid, .right-column, .advisory-metrics { grid-template-columns: 1fr; }
  .overview-strip { flex-direction: column; align-items: flex-start; }
  .overview-strip strong { display: block; margin: 4px 0 0; }
  .toolbar { flex-wrap: wrap; padding: 0 14px; }
  #search { width: 100%; }
  .environment, .quiet { display: none; }
  .manage-card, dialog { padding: 18px; }
  th, td { padding: 10px 12px; }
  #notice { right: 12px; bottom: 12px; }
}
body:not([data-screen=reconciliation]) #import-button { display: none; }

/* ---------- Client register ---------- */
.client-tools { display: flex; gap: 10px; align-items: center; }
.client-tools input { width: 260px; margin: 0; background: var(--background); }
tr[data-client] { cursor: pointer; }
#clients-back { margin: -8px 0 10px -10px; }
#clients-detail > .panel { margin-bottom: 20px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 24px; margin: 18px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.profile-grid dt { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.profile-grid dd { margin: 3px 0 0; color: var(--ink); font-size: 15px; font-weight: 600; overflow-wrap: anywhere; text-transform: capitalize; }
.profile-grid div:nth-child(-n+2) dd, .profile-grid div:nth-child(4) dd { text-transform: none; font-variant-numeric: tabular-nums; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
div.kpi { cursor: default; }
@media (max-width: 640px) { .field-pair { grid-template-columns: 1fr; } .client-tools { flex-wrap: wrap; } .client-tools input { width: 100%; } }

.integration-tiles { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.integration-tiles article { display: flex; flex-direction: column; height: 100%; }
.integration-tiles article .badge { align-self: flex-start; margin-top: auto; text-transform: none; }
.integration-tiles article p { margin-bottom: 14px; }
.table-footer .text-button { padding: 2px 6px; }

/* ---------- Requests and calendar ---------- */
#client-extra { margin-top: 20px; }
.request-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.request-row > div:first-child { flex: 1; min-width: 0; }
.request-row strong { display: block; font-size: 14px; }
.request-row small { overflow-wrap: anywhere; }
.request-actions { display: flex; align-items: center; gap: 2px; white-space: nowrap; font-size: 13.5px; }
.request-actions .text-button { padding: 5px 8px; }
.template-list { display: grid; gap: 4px; max-height: 44vh; overflow: auto; margin-top: 6px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 8px; }
.template-list .checkbox { margin: 0; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.template-list .checkbox:first-child { border-top: 0; }
.template-list strong { display: block; font-size: 14px; }
#calendar .client-tools select { width: auto; min-width: 150px; margin: 0; }
#calendar td button + button { margin-left: 2px; }
#calendar-tabs span { background: var(--red-tint); color: var(--red); }
@media (max-width: 900px) { #calendar .panel-heading { flex-direction: column; align-items: stretch; } #calendar .client-tools { flex-wrap: wrap; } }

/* ---------- Sign-in security ---------- */
.security { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.security:empty { display: none; }
.security > * + *, .security form > * + * { margin-top: 12px; }
.security form label { margin-top: 0; }
.security form + form { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.auth-card .security { border-top: 0; padding-top: 0; }
.sec-state { display: inline-block; margin-right: 6px; padding: 2px 9px; border-radius: 20px; background: #eef1f5; color: #54637a; font-size: 12px; font-weight: 700; }
.sec-state.on { background: var(--green-tint); color: var(--green-dark); }
.secret { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.secret code { padding: 9px 12px; border: 1px dashed #b5c0cd; border-radius: 8px; background: var(--background); color: var(--ink); font-size: 14.5px; letter-spacing: .06em; }
.member-actions { display: block; margin: 4px 0 0 -8px; }
.member-actions .text-button { padding: 4px 8px; font-size: 13px; }
.mini-list .badge { margin-left: 4px; vertical-align: middle; }
.reset-code { padding: 12px !important; border: 1px solid #cfe6df !important; border-radius: 8px; background: var(--green-tint); font-weight: 400 !important; }
#auth-forgot-line { margin-top: 8px; text-align: center; }
.error.ok { border-color: #cfe6df; background: var(--green-tint); color: var(--green-dark); }
.badge[data-fixed] { text-transform: none; }

/* ---------- Client setup by type ----------
   The type choice in the client dialog (clients.js), the Setup column, and the setup panel on a client's page (setup-firm.js).
   The setup-* classes on inputs and answers are emitted by setup-form.js, which the client portal styles separately. */
.client-type { padding: 14px 16px; border: 1px solid #cfe6df; border-radius: var(--radius); background: var(--green-tint); font-size: 14.5px; }
.client-type small { color: var(--body); }
.profile-grid .plain dd { text-transform: none; }
/* Long type names and setup notes wrap before the register has to scroll sideways. */
#clients-rows td.wraps { min-width: 130px; white-space: normal; }
#client-setup { margin-bottom: 20px; scroll-margin-top: 76px; }
#client-setup:empty { display: none; }

.setup-panel > .income-heading { flex-wrap: wrap; }
.setup-panel h3 .badge { margin-left: 6px; vertical-align: 2px; }
.setup-panel h4 { margin-top: 0; }
.setup-help, .setup-panel p.setup-help { color: var(--muted); font-size: 12.5px; font-weight: 400; line-height: 1.5; }
.setup-help .text-button { padding: 2px 6px; font-size: 12.5px; }
.setup-progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.setup-progress > div { min-width: 0; }
.setup-progress > div > span { display: block; color: var(--ink); font-size: 12.5px; font-weight: 600; }
.setup-progress .bar { height: 6px; margin: 6px 0 4px; }
.setup-progress small { margin: 0; }
.setup-progress [data-needed] small { color: var(--amber); }

/* Answers, read-only and as a form: one heading per section either way. */
.setup-section { padding-top: 16px; border-top: 1px solid var(--line); }
.setup-sections > .setup-section + .setup-section { margin-top: 18px; }
.setup-progress + .setup-sections > .setup-section:first-child, .setup-progress + form > p + .setup-section { padding-top: 4px; border-top: 0; }
.setup-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setup-answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 24px; margin-bottom: 0; }
.setup-answers > div { min-width: 0; }
.setup-answers > div:has(ul) { grid-column: 1 / -1; }
.setup-answers dt { color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 1.4; }
.setup-answers dd { margin: 3px 0 0; color: var(--ink); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.setup-answers ul { margin: 0; padding: 0; list-style: none; }
.setup-answers li + li { margin-top: 3px; }
.setup-none { color: var(--faint); font-weight: 400; }
.setup-unanswered { padding-left: 10px; border-left: 3px solid #e0a83a; }
.setup-unanswered .setup-none, .setup-gap { color: var(--amber); font-weight: 600; }
.setup-gap { font-size: 13px; }

.setup-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 16px; align-items: start; }
.setup-fields > .setup-field { min-width: 0; }
.setup-fields > div.setup-field { grid-column: 1 / -1; }
.setup-fields > div.setup-field:has(> [data-type=yesno]) { grid-column: auto; }
.setup-label { display: block; color: var(--ink); font-size: 13.5px; font-weight: 600; }
.setup-field abbr { color: var(--red); text-decoration: none; cursor: help; }
.setup-choices { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; padding: 3px 0; border-radius: 6px; }
.setup-choices label { display: inline-flex; align-items: center; gap: 7px; margin: 0; color: var(--body); font-size: 14px; font-weight: 400; }
.setup-list > [data-rows]:not(:empty) { margin-top: 8px; }
.setup-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.setup-row + .setup-row { margin-top: 8px; }
.setup-row > .setup-field { flex: 1 1 150px; min-width: 0; font-size: 12.5px; }
.setup-add, .setup-remove { padding: 7px 10px; border: 0; border-radius: 7px; background: none; font-size: 13px; font-weight: 600; }
.setup-add { margin: 6px 0 0 -10px; color: var(--green); }
.setup-add:hover { background: var(--green-tint); }
.setup-remove { flex: none; color: var(--muted); }
.setup-remove:hover { background: var(--red-tint); color: var(--red); }
.setup-panel :is(input, select, textarea).invalid { border-color: var(--red); background: var(--red-tint); }
.setup-choices.invalid { padding: 3px 8px; background: var(--red-tint); box-shadow: 0 0 0 1px var(--red); }
.setup-list.invalid { padding-left: 10px; border-left: 3px solid var(--red); }
.setup-error { color: var(--red); font-weight: 600; }
.setup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Checks, checklist, coverage and calendar: two columns of short lists under the answers. */
.setup-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin-top: 18px; border-top: 1px solid var(--line); }
.setup-more > div { min-width: 0; }
.setup-more section { padding-top: 16px; }
.setup-more section + section { margin-top: 18px; border-top: 1px solid var(--line); }
.setup-more h4 + p { margin-top: 4px; }
.setup-check .request-row { align-items: flex-start; }
.setup-check details { margin: -2px 0 10px; }
.setup-check textarea { min-height: 60px; }
.setup-check details:not([open]) { padding: 0; border-color: transparent; background: none; }
.setup-check details:not([open]) > summary { display: inline-flex; padding: 2px 0; color: var(--green); font-size: 13px; }
.setup-apply { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
#setup-apply { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; }
#setup-apply > label { margin: 0; }
#setup-apply > label:first-child { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
#setup-apply select { width: auto; margin: 0; }
#setup-apply .error { flex-basis: 100%; }
#setup-apply .error:not(:empty) { margin-top: 0; }
.setup-result { padding: 10px 12px; border: 1px solid #cfe6df; border-radius: 8px; background: var(--green-tint); color: var(--green-dark); font-weight: 600; }
@media (max-width: 900px) { .setup-more { grid-template-columns: 1fr; } }

/* Intake (intake-firm.js)
   The queue of uploads nobody typed, one run's evidence and draft figures, and the compact panel on a client's page. */
.intake-heading { align-items: flex-start; flex-wrap: wrap; }
.intake-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 10px; }
.intake-filters select { width: auto; min-width: 160px; max-width: 100%; margin: 0; padding: 6px 10px; font-size: 13px; }
.intake-note { padding: 0 20px 12px; font-size: 13px; }
.text-button.intake-inline { padding: 2px 6px; font-size: inherit; text-align: left; }
p > .text-button.intake-inline { margin: 0 -4px; }
.intake-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 6px 16px; align-items: center; width: 100%; padding: 13px 20px; border: 0; border-top: 1px solid var(--line-soft); background: none; text-align: left; transition: background .12s; }
.intake-row:hover { background: #f7f9fb; }
.intake-row:focus-visible { outline-offset: -2px; }
.intake-row > span { min-width: 0; }
.intake-who strong, .intake-what > span { display: block; color: var(--ink); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.intake-what > span { color: var(--body); font-weight: 500; }
.intake-state { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.intake-why { grid-column: 1 / -1; padding: 6px 10px; border-left: 3px solid #e0a83a; border-radius: 0 6px 6px 0; background: var(--amber-tint); color: #5c4310; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.intake-why[data-flag], .reason.intake-flag { border-left-color: var(--red); background: var(--red-tint); color: #7a2a20; }
.reason.intake-flag p, .reason.intake-flag small, .reason.intake-flag strong { color: #7a2a20; }
#intake-reasons .mini-list > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; font-weight: 400; }
#intake-reasons .mini-list > div:first-child, #client-intake .mini-list > div:first-child { border-top: 0; }
#intake-tracked:empty { display: none; }
#intake-detail > * + * { margin-top: 20px; }
#intake-detail > .text-button + * { margin-top: 8px; }
.intake-run > .income-heading { flex-wrap: wrap; }
.intake-run h2 { overflow-wrap: anywhere; }
.intake-run a.secondary { text-decoration: none; }
.intake-run h2:focus, .intake-ack strong:focus { outline: 0; }
.intake-run h2 .badge { margin-left: 6px; vertical-align: 3px; }
.intake-run .reason > strong { display: block; }
.intake-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 32px; margin-top: 18px; border-top: 1px solid var(--line); }
.intake-grid > div { min-width: 0; }
.intake-grid section { padding-top: 16px; }
.intake-grid section + section, .intake-grid [data-intake-slot]:not([hidden]) { margin-top: 18px; border-top: 1px solid var(--line); }
.intake-grid h4 { margin-top: 0; }
.intake-grid h5 { margin: 16px 0 2px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.intake-grid h5 + .request-row, .intake-grid h5 + .intake-figure { border-top: 0; }
.intake-figure { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(0, 2fr); gap: 4px 16px; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.intake-figure > div { min-width: 0; }
.intake-figure > div > span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.intake-figure strong { display: block; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.intake-figure small { margin-top: 0; color: var(--amber); font-weight: 600; }
.intake-figure blockquote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--line); border-radius: 0 6px 6px 0; background: #fbfcfd; color: var(--body); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.intake-figure cite { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-style: normal; font-weight: 600; }
.intake-dropped { margin: 6px 0 0; padding-left: 18px; color: var(--body); font-size: 13.5px; line-height: 1.6; }
.intake-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px 20px; margin: 12px 0 0; }
.intake-facts > div { min-width: 0; }
.intake-facts dt { color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 1.4; }
.intake-facts dd { margin: 3px 0 0; color: var(--ink); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.intake-facts dd small { overflow-wrap: anywhere; }
.intake-actions > form { padding-top: 16px; border-top: 1px solid var(--line); }
.intake-actions > .request-row:first-of-type { border-top: 0; padding-top: 0; }
.intake-actions form h4 { margin-top: 0; }
.intake-actions form h4 + p { margin-top: -8px; }
.intake-actions textarea { min-height: 60px; }
.intake-ack { padding: 14px 16px; border: 1px solid #f1c9c3; border-left: 4px solid var(--red); border-radius: 8px; background: var(--red-tint); }
.intake-ack > * + * { margin-top: 10px; }
.intake-ack > strong { display: block; color: var(--red); font-size: 14.5px; }
.intake-ack p { color: #5e231b; }
.intake-ack .checkbox { color: var(--ink); font-weight: 600; }
.intake-counts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.intake-counts strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.intake-counts [data-tone=warn] strong { color: var(--amber); }
#client-intake .mini-list { margin-top: 8px; }
#client-intake .mini-list > div { padding: 8px 0; font-weight: 400; }
#client-intake > .secondary { width: 100%; margin-top: 14px; }
#client-intake-checks { margin: 20px 0 0; }
.intake-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 0 32px; }
.intake-run > .intake-board { margin-top: 18px; border-top: 1px solid var(--line); }
.intake-board > [data-intake-slot] { min-width: 0; padding-top: 16px; }
.intake-board > [data-intake-slot] > * + * { margin-top: 12px; }
.intake-board h4 { margin-top: 0; }
.intake-finding { padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid #e0a83a; border-radius: 8px; background: #fbfcfd; }
.intake-finding > * + * { margin-top: 8px; }
.intake-finding[data-severity=blocker] { border-left-color: var(--red); }
.intake-finding[data-severity=info] { border-left-color: var(--blue); }
.intake-finding[data-explained] { border-left-color: var(--green); }
.intake-finding > .setup-head { justify-content: space-between; flex-wrap: nowrap; align-items: flex-start; }
.intake-finding > .setup-head strong { color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.intake-finding details { background: #fff; }
.intake-finding textarea { min-height: 60px; }
.intake-values, .intake-values ul { margin: 0; padding: 0; list-style: none; }
.intake-values li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 6px 0; border-top: 1px solid var(--line-soft); color: var(--body); font-size: 13.5px; }
.intake-values li > small, .intake-values li > ul { grid-column: 1 / -1; }
.intake-values li > ul { margin-top: 4px; padding-left: 14px; }
.intake-values strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.intake-values small { overflow-wrap: anywhere; }
.intake-difference { font-size: 13.5px; }
.intake-dismiss:not([open]) { padding: 0; border-color: transparent; background: none; }
.intake-dismiss:not([open]) > summary { padding: 7px 4px; color: var(--muted); font-size: 13.5px; }
.intake-dismiss[open] { flex-basis: 100%; }
@media (max-width: 900px) {
  .intake-grid { grid-template-columns: 1fr; }
  .intake-filters { justify-content: flex-start; }
  .intake-row { grid-template-columns: minmax(0, 1fr) auto; }
  .intake-what { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  .intake-figure, .intake-row { grid-template-columns: 1fr; }
  .intake-state { justify-content: flex-start; }
}

/* Reference library (reference-firm.js)
   Official sources and how the last fetch of each went, what changed, and each fact with its quote, period, source and state. */
#reference > .panel { margin-bottom: 20px; }
#reference .kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.reference-notice { margin: 0 0 16px; padding: 10px 14px; border-left: 3px solid var(--blue); border-radius: 0 8px 8px 0; background: var(--blue-tint); color: var(--body); font-size: 13.5px; line-height: 1.5; }
.reference-notice:empty { display: none; }
.reference-note { margin: 0; padding: 10px 20px 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.reference-heading { align-items: flex-start; flex-wrap: wrap; }
.reference-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 10px; }
.reference-filters select, .reference-filters input { width: auto; min-width: 170px; max-width: 100%; margin: 0; padding: 6px 10px; font-size: 13px; }
.reference-source { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; padding: 13px 20px; border-top: 1px solid var(--line-soft); }
.reference-source > div { min-width: 0; }
.reference-source strong { display: block; color: var(--ink); font-size: 14px; }
.reference-source small { display: block; margin-top: 3px; overflow-wrap: anywhere; line-height: 1.5; }
.reference-source-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.reference-source-side .secondary { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.reference-change { display: grid; grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1fr); gap: 6px 16px; align-items: center; width: 100%; padding: 12px 20px; border: 0; border-top: 1px solid var(--line-soft); background: none; text-align: left; }
.reference-change:hover { background: #f7f9fb; }
.reference-change:focus-visible { outline-offset: -2px; }
.reference-change > span { min-width: 0; overflow-wrap: anywhere; }
.reference-change strong { color: var(--ink); font-size: 14px; }
.reference-change small { display: block; margin-top: 2px; }
.reference-change s { color: var(--muted); }
.reference-topic { padding: 14px 20px 4px; border-top: 1px solid var(--line); }
.reference-topic h4 { margin: 0; }
.reference-topic h4 small { display: inline; margin-left: 6px; color: var(--muted); font-weight: 600; }
.reference-fact { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(0, 2fr) auto; gap: 6px 20px; padding: 13px 0; border-top: 1px solid var(--line-soft); }
.reference-fact > div { min-width: 0; }
.reference-fact[data-state=rejected] .reference-what strong { color: var(--muted); text-decoration: line-through; }
.reference-what > span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.reference-what strong, .reference-value { display: block; margin-top: 2px; color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.reference-value { display: inline; font-size: 20px; }
.reference-what small { margin-top: 2px; font-weight: 600; }
.reference-what em { color: var(--amber); font-style: normal; }
.reference-fact blockquote, .reference-context { margin: 0; padding: 8px 12px; border-left: 3px solid var(--line); border-radius: 0 6px 6px 0; background: #fbfcfd; color: var(--body); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.reference-fact cite { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-style: normal; font-weight: 600; }
.reference-fact .reason, .reference-fact .setup-help { margin-top: 6px; }
.reference-context mark { padding: 1px 2px; border-radius: 3px; background: #fff2c2; color: var(--ink); font-weight: 600; }
.reference-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 220px; }
.reference-side .text-button { padding: 2px 4px; font-size: 12.5px; text-align: right; }
.reference-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.reference-actions .secondary { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.reference-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.reference-dialog::backdrop { background: rgba(16, 28, 44, .45); }
.reference-detail { padding: 20px 24px 24px; }
.reference-detail > * + * { margin-top: 12px; }
.reference-detail h3 { margin: 0; overflow-wrap: anywhere; }
.reference-detail h4 { margin-bottom: 0; }
.reference-detail .setup-head { justify-content: space-between; flex-wrap: nowrap; align-items: flex-start; }
@media (max-width: 1100px) { #reference .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .reference-fact { grid-template-columns: 1fr; }
  .reference-side { flex-direction: row; flex-wrap: wrap; align-items: center; max-width: none; }
  .reference-change { grid-template-columns: 1fr; }
  .reference-filters { justify-content: flex-start; }
}

/* Refund check (refund-firm.js) */
#refund .panel + .panel, #refund-detail > .panel { margin-top: 16px; }
.rf-pad { padding: 12px 20px 16px; }
.rf-item { padding: 16px 0 6px; border-top: 1px solid var(--line-soft); overflow-wrap: anywhere; }
.rf-item > * + * { margin-top: 10px; }
.rf-item-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; }
.rf-item-head h4 { margin: 0; font-size: 15px; color: var(--ink); }
.rf-item-head .badge + .badge { margin-left: 6px; }
.rf-item.risk { border-left: 3px solid #d9a59d; padding-left: 14px; }
.rf-cond { padding: 9px 12px; border-left: 3px solid var(--green); border-radius: 0 8px 8px 0; background: var(--green-tint); color: var(--ink); font-size: 13.5px; }
.rf-figures table { white-space: normal; }
.rf-figures td, .rf-figures th { padding: 8px 12px; }
.rf-sources > div, .rf-totals > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; font-weight: 500; }
.rf-sources > div > span, .rf-totals > div > span { flex: 1 1 220px; }
.rf-sources small, .rf-totals small { width: 100%; font-weight: 400; }
.rf-sources strong, .rf-totals strong { font-variant-numeric: tabular-nums; }
.rf-part { padding-left: 14px; }
.rf-warn { color: var(--amber); }
.rf-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.rf-actions .primary, .rf-actions .secondary { min-height: 34px; padding: 6px 14px; font-size: 13.5px; }
.rf-form { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; }
.rf-form > * + * { margin-top: 10px; }
.manage-card form.rf-form, .manage-card form.rf-draftbar { display: block; }
.rf-draftbar { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.rf-draftbar > * + * { margin-top: 10px; }
.rf-draftbar input { max-width: 420px; }

/* Trading and investments (investments-firm.js). The mapping confirmation (investments-map.js) uses the .iv-map rules below. */
#investing-body > .panel { margin-bottom: 20px; }
.invest-start { display: flex; align-items: center; gap: 8px; }
.invest-start select { width: auto; min-width: 200px; margin: 0; }
.invest-broker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.invest-broker small, .invest-account small, .invest-rule small, .invest-finding small, #investing td small { display: block; margin-top: 3px; overflow-wrap: anywhere; line-height: 1.5; }
.invest-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 20px; margin: 10px 0; }
.invest-facts dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.invest-facts dd { margin: 2px 0 0; color: var(--body); font-size: 13px; line-height: 1.5; }
.invest-keys { padding: 14px 20px; }
.invest-keys summary { color: var(--ink); font-weight: 600; cursor: pointer; }
.invest-key { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.invest-key code, .invest-rule code { font-size: 12px; overflow-wrap: anywhere; }
.invest-status .setup-actions, .invest-status > p, .invest-status > form { margin: 0 20px 14px; }
.invest-year { display: flex; align-items: center; gap: 8px; margin: 0; }
.invest-year select { width: auto; margin: 0; }
.invest-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 0 20px 16px; }
.invest-kpis > div { padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 10px; }
.invest-kpis span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.invest-kpis strong { color: var(--ink); font-size: 20px; }
.invest-account { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 12px 20px; border-top: 1px solid var(--line-soft); }
.invest-account small { flex: 1; min-width: 160px; margin: 0; }
.invest-account .secondary { min-height: 32px; padding: 5px 11px; font-size: 13px; }
#investing .request-row { padding: 11px 20px; }
.invest-pad { padding: 8px 20px; }
.invest-sub { margin: 0; padding: 14px 20px 6px; border-top: 1px solid var(--line); }
.invest-inline { margin-top: 10px; padding: 12px 14px; border-radius: 10px; background: var(--background); }
.invest-inline > label:first-child, .invest-inline > p:first-child { margin-top: 0; }
.invest-inline .setup-actions { margin-top: 10px; }
.invest-class { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr) minmax(200px, 2fr) auto; align-items: end; gap: 6px 14px; margin: 8px 20px; }
.invest-class label { margin: 0; }
.invest-finding { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 16px; padding: 13px 20px; border-top: 1px solid var(--line-soft); }
.invest-finding > div:first-child { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.invest-finding p { margin: 4px 0 0; color: var(--body); font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.invest-rule { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto; gap: 6px 20px; padding: 11px 20px; border-top: 1px solid var(--line-soft); }
.invest-rule > form { grid-column: 1 / -1; }
.invest-rule > div:last-of-type { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.invest-rule strong { color: var(--ink); font-size: 13.5px; overflow-wrap: anywhere; }
.invest-tbd { color: var(--amber); font-weight: 600; }
.invest-tbd-line { margin: 10px 20px; padding: 10px 12px; border-left: 3px solid #e0a83a; border-radius: 0 8px 8px 0; background: var(--amber-tint); color: #5c4310; font-size: 13.5px; line-height: 1.5; }
#investing .panel > .setup-help, #investing .panel > .reason { margin: 8px 20px; }
#investing .panel > .invest-facts { margin: 6px 20px 14px; }
.invest-total td { border-top: 2px solid var(--line); color: var(--ink); font-weight: 700; }
.invest-lines { max-height: 560px; }
#investing .table-wrap td { vertical-align: top; }
.invest-flag { color: var(--amber); font-weight: 600; }
.invest-map { padding: 20px 24px 24px; }
@media (max-width: 1100px) { .invest-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .invest-class, .invest-rule { grid-template-columns: 1fr; } .invest-rule > div:last-of-type { align-items: flex-start; } }
@media (max-width: 760px) { .invest-finding, .invest-broker { grid-template-columns: 1fr; } }
.iv-map h3 { margin: 0 0 6px; }
.iv-note { margin-top: 6px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.iv-set { min-width: 0; margin: 18px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.iv-set legend { padding: 0 6px; color: var(--ink); font-weight: 650; }
.iv-scroll { max-width: 100%; overflow: auto; }
.iv-scroll table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.iv-scroll th, .iv-scroll td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.iv-columns td span { display: inline-block; max-width: 180px; margin: 0 6px 4px 0; padding: 1px 6px; border-radius: 6px; background: var(--background); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
.iv-columns select { min-width: 170px; margin: 0; }
.iv-columns small { display: block; margin-top: 4px; color: var(--amber); }
.iv-none { color: var(--muted); font-style: italic; }
.iv-needs, .iv-issues, .iv-sample { margin-top: 16px; padding: 12px 14px; border-left: 4px solid #e0a83a; border-radius: 10px; background: var(--amber-tint); color: var(--ink); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.iv-issues.bad { border-color: var(--red); background: var(--red-tint); }
.iv-sample { border-color: #c3ccd8; background: var(--background); }
.iv-needs ul, .iv-issues ul, .iv-sample ul { margin: 6px 0 0; padding-left: 20px; }
.iv-needs li, .iv-issues li, .iv-sample li { margin-top: 4px; }
.iv-check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; line-height: 1.5; }
.iv-check input { flex: none; width: 19px; height: 19px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--green); }
.iv-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.iv-commit { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.iv-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.iv-lines summary { margin-top: 12px; color: var(--green); font-weight: 600; cursor: pointer; }
@media (max-width: 640px) {
  .iv-columns thead { display: none; }
  .iv-columns tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .iv-columns th, .iv-columns td { display: block; padding: 2px 0; border: 0; }
  .iv-columns select { width: 100%; }
  .iv-pair { grid-template-columns: 1fr; }
}

/* Reference library: the tax calendar, tiers and findings (reference-firm.js); also the official-calendar panel on a client's page and under the compliance calendar. */
.reference-calendar-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 20px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.reference-calendar-head small { display: block; margin-top: 4px; line-height: 1.5; overflow-wrap: anywhere; }
.reference-calrow { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 6px 18px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.reference-calrow > div { min-width: 0; }
.reference-calrow strong { display: block; color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.reference-calrow small { display: block; margin-top: 2px; line-height: 1.45; }
.reference-calrow p { margin: 4px 0 0; color: var(--body); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.reference-calrow[data-state=rejected] strong, .reference-calrow[data-state=needs_review] strong { color: var(--muted); }
.reference-act { color: var(--blue); font-weight: 700; }
.reference-upload { display: inline-flex; align-items: center; cursor: pointer; }
.official-calendar .reference-calrow { padding: 12px 0; }
.official-calendar details { margin-top: 10px; }
.official-calendar summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
#calendar > .official-calendar { margin-top: 18px; padding: 16px 20px; }
@media (max-width: 760px) {
  .reference-calendar-head, .reference-calrow { grid-template-columns: 1fr; }
  .reference-calrow .reference-side { align-items: flex-start; max-width: none; }
}

/* Mutual fund consolidated statement (CAS): the upload form and the scheme-by-scheme check (investments-firm.js). */
.invest-account .iv-cas-warn, .iv-cas-warn { margin-top: 10px; padding: 10px 12px; border-left: 4px solid #e0a83a; border-radius: 10px; background: var(--amber-tint); color: var(--ink); font-size: 13.5px; line-height: 1.5; }
.iv-cas-schemes small { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.iv-cas-schemes .n { text-align: right; white-space: nowrap; }
.iv-cas-schemes small.iv-cas-bad, .iv-cas-lost .iv-cas-bad, .iv-cas-bad { color: var(--red); font-weight: 600; }
.iv-cas-schemes small.iv-cas-ok { color: var(--green); }
.iv-cas-detail td { padding-top: 0; }
.iv-cas-off td { color: var(--muted); }
.iv-cas-lost { margin: 8px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.iv-cas-lost li { margin-top: 4px; }
.iv-cas-lost small { display: block; color: var(--muted); font-weight: 400; }
.invest-account .invest-inline { flex-basis: 100%; }
.iv-cas-schemes { min-width: 640px; }
.iv-cas-detail table { min-width: 560px; }
.iv-cas-schemes tbody th { text-transform: none; letter-spacing: normal; font-size: inherit; font-weight: 400; color: var(--ink); background: none; }
.iv-cas-schemes tbody th { min-width: 200px; }
.iv-cas-schemes td:nth-child(2) { white-space: nowrap; }

/* Return file for the e-filing portal (itr-firm.js, itr-client.js): a panel inside each annual working-paper card. */
.itr-panel { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.itr-panel h4 { margin: 0 0 8px; font-size: 15px; color: var(--ink); }
.itr-panel details { margin-top: 10px; }
.itr-notice { margin: 0 0 12px; padding: 10px 12px; border-left: 4px solid var(--navy); border-radius: 8px; background: var(--background); color: var(--ink); font-size: 13.5px; line-height: 1.5; }
.itr-warn { margin-top: 10px; padding: 10px 12px; border-left: 4px solid #e0a83a; border-radius: 8px; background: var(--amber-tint); color: var(--ink); font-size: 13.5px; line-height: 1.5; }
.itr-pass { margin-top: 10px; padding: 10px 12px; border: 1px solid #cfe6df; border-radius: 8px; background: var(--green-tint); color: var(--green-dark); font-size: 13.5px; }
.itr-kept-note { margin: 12px 0 0; font-size: 13.5px; color: var(--body); }
.itr-kept { display: block; margin-top: 4px; }
.itr-form fieldset { margin-top: 14px; padding: 4px 14px 14px; border: 1px solid var(--line); border-radius: 8px; }
.itr-form legend { padding: 0 6px; font-weight: 700; font-size: 13.5px; color: var(--ink); }
.itr-form button { margin-top: 16px; }
.itr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.itr-grid label .error { display: block; margin-top: 4px; }
.itr-reasons, .itr-errors { margin: 8px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.itr-reasons li, .itr-errors li { margin-top: 5px; }
.itr-rules { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.itr-act { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.itr-act p { margin: 0; font-size: 13.5px; }
.itr-act button { margin-top: 12px; }
.itr-check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.itr-build { margin-top: 16px; }
.itr-build table td { overflow-wrap: anywhere; font-size: 12.5px; }

/* Case board and one client's case (grid-firm.js). No motion: a stage's colour says its state and nothing else. */
.grid-honest { margin: 0 0 16px; }
.grid-tiles { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.grid-tile { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.grid-tile span { display: block; min-height: 34px; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.grid-tile strong { display: block; margin-top: 4px; color: var(--ink); font-size: 24px; font-variant-numeric: tabular-nums; }
.grid-tile small { color: var(--faint); font-size: 12px; }
.grid-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.grid-list { display: flex; flex-direction: column; }
.grid-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 13px 20px; border-top: 1px solid var(--line-soft); }
.manage-card .grid-item { padding: 12px 0; }
.grid-item p { margin: 4px 0 2px; color: var(--body); font-size: 14px; line-height: 1.45; }
.grid-item small { color: var(--muted); font-size: 12.5px; }
.grid-item em { color: var(--muted); font-style: normal; font-size: 13px; }
.grid-item-actions { display: flex; flex: none; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 46%; }
.grid-confirm { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.grid-confirm p { margin: 0 0 8px; }
.grid-confirm button + button { margin-left: 8px; }
.grid-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.grid-dots i { width: 14px; height: 8px; border-radius: 2px; background: var(--line); }
.grid-dots i[data-state=done], .grid-mini li[data-state=done]::before { background: var(--green); }
.grid-dots i[data-state=working], .grid-dots i[data-state=ready], .grid-mini li[data-state=working]::before, .grid-mini li[data-state=ready]::before { background: var(--blue); }
.grid-dots i[data-state=waiting], .grid-mini li[data-state=waiting]::before { background: #e0a83a; }
.grid-dots i[data-state=blocked], .grid-mini li[data-state=blocked]::before { background: var(--red); }
.grid-dots i[data-state=not_applicable] { background: none; border: 1px dashed var(--line); }
.grid-pipe { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0 0; padding: 0; list-style: none; counter-reset: stage; }
.grid-stage { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-top: 3px solid var(--line); border-radius: 8px; background: #fbfcfd; counter-increment: stage; }
.grid-stage[data-state=done] { border-top-color: var(--green); }
.grid-stage[data-state=working], .grid-stage[data-state=ready] { border-top-color: var(--blue); }
.grid-stage[data-state=waiting] { border-top-color: #e0a83a; }
.grid-stage[data-state=blocked] { border-top-color: var(--red); }
.grid-stage.current { background: var(--surface); box-shadow: var(--shadow); }
.grid-stage-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.grid-stage-head strong { color: var(--ink); font-size: 14px; }
.grid-stage-head strong::before { content: counter(stage) ". "; color: var(--faint); font-weight: 400; }
.grid-blocks { margin: 0; padding-left: 18px; color: var(--body); font-size: 13.5px; line-height: 1.45; }
.grid-blocks li + li { margin-top: 4px; }
.grid-next { margin: 0; color: var(--body); font-size: 13.5px; line-height: 1.45; }
.grid-who { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.grid-who[data-who=maker], .grid-who[data-who=checker] { color: var(--amber); }
.grid-who[data-who=client] { color: var(--blue); }
.grid-stage-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.grid-stage-foot small { color: var(--faint); font-size: 12px; }
.grid-timeline { margin: 0; padding: 0 20px 18px; list-style: none; }
.grid-timeline > li { padding: 12px 0 12px 14px; border-left: 2px solid var(--line); }
.grid-timeline > li + li { border-top: 1px solid var(--line-soft); }
.grid-timeline > li.derived { border-left-style: dashed; }
.grid-timeline strong { display: block; color: var(--ink); font-size: 14px; font-weight: 600; }
.grid-timeline small { color: var(--muted); font-size: 12.5px; }
.grid-timeline ul { margin: 6px 0 0; padding: 0; list-style: none; }
.grid-run { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.grid-run::before { content: "→ "; color: var(--faint); }
.grid-run[data-state=needs_attention] { color: var(--red); font-weight: 600; }
.grid-agents td { vertical-align: top; white-space: normal; }
.grid-agents td:first-child { min-width: 300px; }
.grid-mini { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 12.5px; }
.grid-mini li::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; background: var(--line); }
.grid-mini li.current { color: var(--ink); font-weight: 600; }
#grid-search { max-width: 240px; }
#grid-rows td.wraps { min-width: 280px; white-space: normal; line-height: 1.4; }
@media (max-width: 1100px) { .grid-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-item { flex-direction: column; } .grid-item-actions { max-width: none; justify-content: flex-start; } }
/* Reference library: an official page saved by a person, and the firm's settings for the assistant's web search. */
.reference-supplied-form { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin-bottom: 14px; }
.reference-supplied-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.reference-supplied-form input[type="url"] { min-width: min(420px, 80vw); }
.reference-supplied-form p { flex-basis: 100%; margin: 0; }
.reference-web-on { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.reference-web-tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 12px; }
.reference-web-tiers label { display: grid; gap: 4px; font-weight: 600; }
.reference-web-tiers small { font-weight: 400; color: var(--muted); }
.reference-web-tiers textarea { width: 100%; font: 13px/1.5 ui-monospace, Consolas, monospace; }
.reference-web-found { border-left: 3px solid var(--amber, #b7791f); padding-left: 12px; }

/* Collapsible firm sidebar (frontend/app/sidebar-collapse.js): icons only, names as tooltips; desktop widths only, the phone drawer is unchanged. */
.sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; align-self: flex-end; width: 30px; height: 30px; margin: -26px 0 0; padding: 0; border: 1px solid #ffffff1f; border-radius: 8px; background: #ffffff0a; color: #b9c5d3; cursor: pointer; }
.sidebar-toggle:hover { background: #ffffff17; color: #fff; }
.sidebar-toggle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
@media (min-width: 901px) {
  .sidebar-collapsed { --sidebar: 72px; }
  .sidebar-collapsed .sidebar { padding-left: 10px; padding-right: 10px; overflow-x: hidden; }
  .sidebar-collapsed .sidebar-toggle { align-self: center; margin: 14px 0 0; }
  .sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
  .sidebar-collapsed .brand { padding: 0; text-align: center; font-size: 0; }
  .sidebar-collapsed .brand-mark { font-size: 22px; }
  .sidebar-collapsed .brand-caption, .sidebar-collapsed .firm > div, .sidebar-collapsed .nav-group .nav-label, .sidebar-collapsed nav button > span, .sidebar-collapsed .sidebar-bottom { display: none; }
  .sidebar-collapsed .firm { justify-content: center; padding: 8px 0; }
  .sidebar-collapsed nav button { justify-content: center; padding: 9px 0; }
  .sidebar-collapsed nav button .nav-count { position: absolute; top: 2px; right: 4px; min-width: 16px; padding: 0 4px; font-size: 10px; }
  .sidebar-collapsed nav button.active::before { left: -10px; }
}
