/* Budget App - the design system (step 5.1, briefing section 3).
   The one place values live outside config.py: colour, type, spacing, radius,
   elevation are tokens here, used everywhere below. Branding is deferred: a
   neutral palette, no logo, the app name as text. */

:root {
  /* colour */
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ee;
  --border-strong: #cdd5df;
  --ink: #1b2733;
  --ink-2: #364152;
  --muted: #5b6b7b;
  --faint: #8a97a6;
  --primary: #2457d6;
  --primary-hover: #1b45ad;
  --primary-soft: #eef3ff;
  --focus: #9db4ff;
  --danger: #b42318;   --danger-bg: #fee4e2;   --danger-line: #fecdca;
  --warning: #b54708;  --warning-bg: #fef0c7;  --warning-line: #fedf89;
  --success: #067647;  --success-bg: #d1fadf;  --success-line: #a6f4c5;
  --info: #175cd3;     --info-bg: #e0ecff;     --info-line: #c2d6ff;
  --neutral: #364152;  --neutral-bg: #eef2f6;  --neutral-line: #dde3ea;
  --violet: #5925dc;   --violet-bg: #ebe9fe;
  --log-bg: #101828;   --log-ink: #d0d5dd;
  /* type */
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: Consolas, "Cascadia Mono", ui-monospace, monospace;
  --fs-meta: 13px; --fs-body: 14px; --fs-lead: 16px; --fs-card: 20px; --fs-page: 28px;
  --lh: 1.45;
  /* space */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* shape */
  --r-control: 8px; --r-card: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --shadow-lift: 0 4px 8px -2px rgba(16,24,40,.1), 0 2px 4px -2px rgba(16,24,40,.06);
  --shadow-float: 0 12px 24px -4px rgba(16,24,40,.12), 0 4px 8px -4px rgba(16,24,40,.06);
  --rail: 232px;
  --topbar: 76px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: var(--fs-body)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); border-radius: var(--r-control); }
.mono { font-family: var(--mono); font-size: .95em; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-meta); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.break { word-break: break-all; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; display: inline-block; vertical-align: -0.2em; }

/* ---- the shell: the rail, the top bar, the content column ------------------ */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.tenant {
  display: flex; flex-direction: column; gap: 1px; margin: 0 4px 18px; padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control);
}
.tenant-label { font-size: 11.5px; color: var(--faint); font-weight: 600; letter-spacing: .02em; }
.tenant-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px;
  border-radius: var(--r-control); color: var(--muted); font-weight: 500; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--canvas); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.active .icon { color: var(--primary); }
.nav-label { flex: 1; }
.nav-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger);
  color: #fff; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.rail-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--faint); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; height: var(--topbar); display: flex; align-items: center;
  justify-content: space-between; gap: var(--s4); padding: 0 var(--s6);
  background: rgba(244,246,248,.88); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: var(--fs-page); font-weight: 650; letter-spacing: -.02em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* step 5.14 - Back, in the app's own window only: the title stays beside it, the pill on the right */
.window-back { flex: none; }
.window-back[hidden] { display: none; }
.window-back + .page-title { margin-right: auto; }
.wz-panel .window-back { align-self: flex-start; }
/* M5 (2026-11-11) - Refresh, in the app's own window only: on the right, before the pill */
.window-refresh { flex: none; margin-left: auto; }
.window-refresh[hidden] { display: none; }
.window-refresh + .pill { margin-left: 0; }
.content { width: 100%; max-width: 1264px; padding: var(--s5) var(--s6) 64px; display: flex; flex-direction: column; gap: var(--s5); }

/* loading: a thin bar under the top bar while htmx is talking to the server */
.loading-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; opacity: 0; transition: opacity .15s; }
.loading-bar::after { content: ""; position: absolute; top: 0; left: -40%; width: 40%; height: 100%; background: var(--primary); border-radius: 2px; animation: slide 1s ease-in-out infinite; }
.loading-bar.htmx-request { opacity: 1; }
@keyframes slide { from { left: -40%; } to { left: 100%; } }

/* the readiness pill */
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px 0 12px; flex: none;
  border-radius: 999px; font-weight: 600; font-size: 13.5px; border: 1px solid transparent; white-space: nowrap;
}
.pill:empty { display: none; }
.pill a { color: inherit; }
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-success { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.pill-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.pill-muted { background: var(--neutral-bg); color: var(--muted); border-color: var(--neutral-line); }
.pill-muted .pill-dot { animation: blink 1.2s ease-in-out infinite; }
.pill-neutral { background: var(--surface); color: var(--muted); border-color: var(--border); }
@keyframes blink { 50% { opacity: .25; } }

/* ---- layout helpers ----------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s4); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.section { display: flex; flex-direction: column; gap: var(--s3); }
.section-title { font-size: var(--fs-lead); font-weight: 650; }
.lead { font-size: var(--fs-lead); color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.lead .icon { color: var(--success); }
.lead-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: var(--s2); }
.back-link { font-size: var(--fs-meta); }
.back-link a { color: var(--muted); }
.after-note { margin-top: calc(-1 * var(--s2)); }

/* ---- cards ---------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 20px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.card-title { font-size: var(--fs-card); font-weight: 650; letter-spacing: -.01em; }
.link-arrow { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-meta); font-weight: 600; color: var(--primary); }
.table-card { padding: 0; overflow: clip; }

/* stat cards */
.stat { display: flex; flex-direction: column; gap: 4px; padding: 18px 22px; }
.stat-label { font-size: var(--fs-meta); color: var(--muted); font-weight: 500; }
.stat-value { font-size: var(--fs-page); font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-value-sm { font-size: var(--fs-card); line-height: 1.6; }
.stat-hint { font-size: var(--fs-meta); color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 2px 0 6px; }
.dot:first-child { margin-left: 0; }
.dot-success { background: var(--success); } .dot-danger { background: var(--danger); } .dot-neutral { background: var(--faint); }
.dot-warning { background: var(--warning); }   /* step 9.44: Home's holes */

/* "what needs you" */
.needs-group { display: flex; flex-direction: column; gap: var(--s2); }
.needs-group + .needs-group { margin-top: var(--s4); }
.needs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.needs-list a { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 9px 12px; border-radius: var(--r-control); }
.needs-list a:hover { background: var(--surface-2); text-decoration: none; }
.count { min-width: 28px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.count-danger { background: var(--danger-bg); color: var(--danger); }
.count-warning { background: var(--warning-bg); color: var(--warning); }
.count-neutral { background: var(--neutral-bg); color: var(--neutral); }

/* the three actions */
.actions-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.action-tile-form { display: contents; }
.action-tile {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow);
  font: inherit; color: var(--ink); cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.action-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lift); text-decoration: none; transform: translateY(-1px); }
.action-tile > .icon { color: var(--faint); }
.action-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.action-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.action-title { font-weight: 650; }
.action-hint { font-size: var(--fs-meta); color: var(--muted); }

/* ---- tables ------------------------------------------------------------------------------ */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-body); }
.table th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 11px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th.num, .table td.num { text-align: right; }
.table-sticky thead th { position: sticky; top: var(--topbar); z-index: 2; }
.table-card .table-sticky { border-radius: var(--r-card); }
.table.compact td, .table.compact th { padding: 8px 12px; }
.table-empty { text-align: center; padding: 28px 16px !important; }
.nominal { display: flex; flex-direction: column; line-height: 1.3; }
.nominal-code { font-size: 12.5px; color: var(--ink-2); }
.nominal-name { font-size: var(--fs-meta); color: var(--muted); }
.how-cell { white-space: nowrap; }
.how-cell .small { margin-left: 6px; }
.how-cell .pending { margin: 6px 0 0; display: flex; align-items: center; gap: 6px; color: var(--success); white-space: normal; }
.how-cell .payee-change { margin: 6px 0 0; display: flex; align-items: center; gap: 6px; }     /* step 9.18b */
.more-row td { background: var(--surface) !important; }
.more { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.report-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.report-link .icon { color: var(--faint); }

/* ---- badges --------------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap; line-height: 1; letter-spacing: .01em;
}
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); font-weight: 500; }
.badge-violet { background: var(--violet-bg); color: var(--violet); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blink 1.2s ease-in-out infinite; }

/* ---- buttons and inputs ----------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border-radius: var(--r-control); border: 1px solid transparent; font: 600 var(--fs-body)/1 var(--font);
  cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--surface); color: var(--danger); border-color: var(--danger-line); }
.btn-danger-soft:hover { background: var(--danger-bg); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled, .btn.htmx-request { opacity: .6; cursor: progress; }
.icon-btn { width: 34px; height: 34px; border-radius: var(--r-control); border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: var(--canvas); color: var(--ink); }

.input {
  height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink); font: var(--fs-body)/1.3 var(--font); min-width: 0;
  transition: border-color .12s, box-shadow .12s; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.input.mono { font-family: var(--mono); font-size: 13px; }
select.input { padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6b7b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.textarea { height: auto; min-height: 64px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.input-sm { height: 30px; font-size: 13px; padding: 0 9px; }
select.input-sm { padding-right: 28px; background-position: right 9px center; }
.num-input { width: 90px; }
.note-input { width: 150px; }
.check, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-body); }
.check input, .radio input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; margin: 0; padding: 0; }
.field-label { font-size: var(--fs-meta); font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12.5px; color: var(--muted); }
.field-hint.picked { color: var(--success); font-weight: 600; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: 14px; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filters { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1; min-width: 260px; max-width: 460px; display: flex; align-items: center; }
.search .icon { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.search-input { width: 100%; padding-left: 36px; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

/* ---- banners, empty, error, done ------------------------------------------------------------- */
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid transparent; font-size: var(--fs-body); }
.banner .icon { margin-top: 1px; }
.banner-text { min-width: 0; overflow-wrap: anywhere; }
.banner-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.banner-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }
.banner-success { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.banner-info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.banner-muted { background: var(--neutral-bg); color: var(--ink-2); border-color: var(--neutral-line); }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 56px 24px; }
.empty-glyph { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.empty-text { font-size: var(--fs-lead); font-weight: 600; max-width: 520px; }
.empty-note { font-size: var(--fs-meta); color: var(--muted); max-width: 520px; }
.empty .btn { margin-top: 6px; }
.error-card { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; max-width: 720px; }
.error-glyph { width: 52px; height: 52px; border-radius: 14px; background: var(--danger-bg); color: var(--danger); display: flex; align-items: center; justify-content: center; }
.error-line { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control); padding: 10px 12px; width: 100%; overflow-wrap: anywhere; }
.done-state { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 10px; background: var(--success-bg); color: var(--success); border: 1px solid var(--success-line); }
.done-state p { flex: 1; font-weight: 600; }
.done-glyph { display: inline-flex; }
.hint-line { display: flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--warning); margin: 8px 0 12px; }
.confidential { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-line); font-size: var(--fs-meta); font-weight: 500; }

/* ---- the busy state --------------------------------------------------------------------------- */
.busy { display: flex; flex-direction: column; gap: var(--s4); border-color: var(--neutral-line); background: linear-gradient(180deg, #fbfcfd, var(--surface)); }
.busy-head { display: flex; gap: 14px; align-items: flex-start; }
.busy-title { font-weight: 650; font-size: var(--fs-lead); }
.busy-line { font-size: 13px; color: var(--ink-2); margin: 2px 0; overflow-wrap: anywhere; }
.busy-spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--neutral-bg); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- the job panel ------------------------------------------------------------------------------ */
.job-panel { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.card .job-panel, .busy .job-panel { box-shadow: none; }
#job-area > .job-panel, .content > .job-panel { box-shadow: var(--shadow); }
.job-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.job-title { display: flex; align-items: center; gap: 10px; }
.job-kind { font-weight: 650; font-size: var(--fs-lead); }
.job-id { font-size: 12px; color: var(--faint); }
.job-stage { display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--fs-body); }
.job-stage-name { font-weight: 600; color: var(--ink-2); }
.progress { height: 8px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .5s ease; min-width: 8px; }
.progress-success > span { background: var(--success); }
.progress-danger > span { background: var(--danger); }
.progress-warning > span { background: var(--warning); }
.progress-neutral > span { background: var(--faint); }
.progress-live > span { background-image: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,.35) 50%, rgba(255,255,255,0) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.chip-value { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.chip-label { font-size: var(--fs-meta); color: var(--muted); }
.chip-danger { background: var(--danger-bg); border-color: var(--danger-line); }
.chip-danger .chip-value, .chip-danger .chip-label { color: var(--danger); }
.chip-warning { background: var(--warning-bg); border-color: var(--warning-line); }
.chip-warning .chip-value, .chip-warning .chip-label { color: var(--warning); }
.chip-success { background: var(--success-bg); border-color: var(--success-line); }
.chip-success .chip-value, .chip-success .chip-label { color: var(--success); }
.log-box > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: var(--fs-meta); font-weight: 600; color: var(--primary); padding: 2px 0; }
.log-box > summary::-webkit-details-marker { display: none; }
.log { margin: 8px 0 0; padding: 14px 16px; border-radius: 10px; background: var(--log-bg); color: var(--log-ink); font: 12.5px/1.55 var(--mono); max-height: 340px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; display: flex; flex-direction: column-reverse; }
.log-lines { display: block; }
.log-lines > span { display: block; }
.failure-line { margin-top: 4px; color: var(--danger); opacity: .9; }
.log .log-err { color: #fda29b; }
.log .log-ok { color: #a6f4c5; }
.job-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.job-actions { display: flex; gap: var(--s2); }
.job-actions form { display: inline-flex; }
.job-none { padding: 6px 0; }
.job-link { display: flex; flex-direction: column; gap: 1px; }
.job-kind-sm { font-weight: 600; }
.job-data pre.json-tall { max-height: 520px; }

/* ---- import ------------------------------------------------------------------------------------ */
.upload { display: flex; flex-direction: column; gap: var(--s3); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 220px;
  padding: 32px; border: 2px dashed var(--border-strong); border-radius: var(--r-card); background: var(--surface-2);
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--primary); }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-glyph { width: 60px; height: 60px; border-radius: 18px; background: var(--surface); color: var(--primary); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); margin-bottom: 6px; }
.dropzone-title { font-size: var(--fs-lead); font-weight: 650; }
.dropzone-or { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-meta); }
.dropzone-hint { font-size: var(--fs-meta); color: var(--faint); }
.upload-busy { display: none; font-size: var(--fs-meta); color: var(--primary); font-weight: 600; }
.upload-busy.htmx-request { display: block; }
.upload-result { margin-top: var(--s3); display: flex; flex-direction: column; gap: 8px; }
.upload-summary { font-weight: 600; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-control); background: var(--success-bg); color: var(--success); font-size: 13.5px; }
.file-refused { background: var(--danger-bg); color: var(--danger); }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.file-note { font-size: 12.5px; text-align: right; }
.file-icon { display: inline-flex; }
.dedup { margin-top: var(--s3); }
.run-card { display: flex; flex-direction: column; gap: var(--s3); }
.run-form { display: flex; flex-direction: column; gap: var(--s4); }
.run-option { display: flex; flex-direction: column; gap: 8px; padding-top: var(--s4); border-top: 1px solid var(--border); }

/* ---- review: groups, kinds, the drawer, the item --------------------------------------------- */
.queue { display: flex; flex-direction: column; gap: var(--s6); }
.group { display: flex; flex-direction: column; gap: var(--s3); }
.group-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.group-title { font-size: var(--fs-card); font-weight: 650; letter-spacing: -.01em; }
.group-danger .group-title::before, .group-warning .group-title::before, .group-neutral .group-title::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 10px; vertical-align: 2px; }
.group-danger .group-title::before { background: var(--danger); }
.group-warning .group-title::before { background: var(--warning); }
.group-neutral .group-title::before { background: var(--faint); }
.group-hint { color: var(--muted); font-size: var(--fs-meta); }
.group-empty { display: flex; align-items: center; gap: 8px; color: var(--success); font-weight: 600; padding: 14px 18px; border: 1px dashed var(--success-line); border-radius: var(--r-card); background: #f6fef9; }
.kind { padding: 0; overflow: clip; }
.kind-head { list-style: none; display: flex; align-items: center; gap: 14px; padding: 15px 20px; cursor: pointer; }
.kind-head::-webkit-details-marker { display: none; }
.kind-head:hover { background: var(--surface-2); }
.chevron { width: 8px; height: 8px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(-45deg); transition: transform .15s; flex: none; margin: 0 4px; }
.kind[open] .chevron { transform: rotate(45deg); }
.kind-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.kind-label { font-weight: 650; }
.kind-desc { font-size: var(--fs-meta); color: var(--muted); }
.kind-actions { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.kind[open] .kind-head { border-bottom: 1px solid var(--border); }
.table-items td { padding: 10px 20px; }
.table-items .ident { width: 1%; white-space: nowrap; color: var(--muted); font-size: 12.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.item-link { display: block; color: var(--ink); }
.item-link:hover { color: var(--primary); }
.kind-fix, .kind-more { display: flex; gap: 8px; align-items: flex-start; padding: 12px 20px; font-size: var(--fs-meta); color: var(--muted); border-top: 1px solid var(--border); background: var(--surface-2); }
.kind-fix .icon { color: var(--warning); margin-top: 1px; }

.backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.32); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 94vw); background: var(--surface); z-index: 31;
  box-shadow: -16px 0 32px -8px rgba(16,24,40,.18); transform: translateX(104%); transition: transform .22s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto; overscroll-behavior: contain;
}
.drawer:has(.item) { transform: none; }
body:has(.drawer .item) .backdrop { opacity: 1; pointer-events: auto; }
body:has(.drawer .item) { overflow: hidden; }
.drawer .item { padding: 22px 26px 40px; }
.item { display: flex; flex-direction: column; gap: var(--s5); }
.item-page .item { gap: var(--s5); }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); }
.drawer .item-head { position: sticky; top: -22px; margin: -22px -26px 0; padding: 22px 26px 16px; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); z-index: 2; }
.item-head-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.item-head-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.eyebrow { font-size: 12.5px; font-weight: 650; color: var(--primary); letter-spacing: .01em; }
.item-title { font-size: 18px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.item-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: var(--fs-meta); }
.item-section { display: flex; flex-direction: column; gap: var(--s3); }
.item-section-title { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.fix-hint { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-line); font-size: var(--fs-meta); }
.fix-hint strong { display: block; margin-bottom: 2px; }
.action-form { border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px 18px; background: var(--surface); box-shadow: var(--shadow); }
.action-head { margin-bottom: 14px; }
.action-title { font-size: 15px; font-weight: 650; }
.action-hint { font-size: var(--fs-meta); color: var(--muted); margin-top: 2px; }
.kv { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 0; margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.kv dt, .kv dd { margin: 0; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv dt { color: var(--muted); font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); overflow-wrap: anywhere; }
.kv dd { overflow-wrap: anywhere; }
.kv dt:nth-last-of-type(1), .kv dd:last-of-type { border-bottom: 0; }
pre.json { margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control); font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow: auto; }
.kv pre.json { border: 0; padding: 0; background: transparent; }

/* ---- settings, backups ---------------------------------------------------------------------- */
.settings, .backups { display: flex; flex-direction: column; gap: var(--s4); }
.setting-key { font-weight: 600; color: var(--ink); }
.setting-note { color: var(--ink-2); margin-top: 2px; }
.setting-value { margin-right: 8px; }
.value-cell { white-space: nowrap; }
.change-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.change-cell .inline-form { flex-wrap: nowrap; }
.change-cell input.input-sm[type=text]:not(.note-input) { width: 150px; }
.change-cell .note-input { width: 130px; }
.settings-table td { vertical-align: top; }
.tables-cell { display: flex; flex-wrap: wrap; gap: 4px; max-width: 420px; }
.table-chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.workbook-card { display: flex; flex-direction: column; gap: 8px; align-self: start; }
.workbook-name { font-weight: 600; overflow-wrap: anywhere; }

/* ---- a rendered report ---------------------------------------------------------------------- */
.prose { padding: 32px 40px; line-height: 1.6; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 16px; line-height: 1.25; }
.prose h2 { font-size: 19px; margin: 32px 0 12px; padding-top: 20px; border-top: 1px solid var(--border); }
.prose h3 { font-size: 16px; margin: 24px 0 8px; }
.prose h4 { font-size: 14px; margin: 18px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 3px 0; }
.prose a { color: var(--primary); }
.prose code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.prose pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow: auto; margin: 0 0 14px; }
.prose pre code { border: 0; padding: 0; background: transparent; }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 6px 0 18px; font-size: 13px; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.prose tr:nth-child(even) td { background: #fbfcfd; }
.prose blockquote { margin: 0 0 14px; padding: 8px 14px; border-left: 3px solid var(--info-line); background: var(--info-bg); color: var(--ink-2); border-radius: 0 8px 8px 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* ---- toasts ------------------------------------------------------------------------------------ */
#toasts { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; min-width: 300px; max-width: 440px;
  padding: 13px 14px 13px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--success); box-shadow: var(--shadow-float); font-size: 13.5px; color: var(--ink-2);
  animation: toast-in .22s cubic-bezier(.2,.8,.2,1);
}
.toast-danger { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-body { flex: 1; min-width: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 2px; }
.toast-first { font-weight: 650; color: var(--ink); }
.toast-close { border: 0; background: transparent; color: var(--faint); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast-close:hover { color: var(--ink); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* =================================================================================================
   step 5.2 - the figures, the drill-down, the statement page. Extends the system above; no new
   colours: the primary for links and the highlight, success / danger / muted for the checks.
   ================================================================================================= */
.nowrap { white-space: nowrap; }
.actions-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.banner-link { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 4px; font-weight: 650; color: inherit; white-space: nowrap; }
.banner-pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; }
.btn.disabled { opacity: .45; pointer-events: none; }
.section-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }

/* the toolbar and the tabs */
.figures-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 16px 20px; }
.figures-toolbar input[type=date] { width: 158px; }
.figures-toolbar .field-sub select { width: 230px; }
.toolbar-check { height: 36px; }
.toolbar-buttons { display: flex; gap: var(--s2); margin-left: auto; }
.tabs-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; }
.tab { padding: 10px 14px 11px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.excel-card { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 12px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); min-width: 0; }
.excel-icon { color: var(--success); display: inline-flex; }
.excel-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.excel-label { font-size: 11.5px; font-weight: 650; color: var(--faint); letter-spacing: .02em; }
.excel-name { font-size: 12.5px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }

/* the headline */
.headline { display: flex; flex-direction: column; gap: var(--s3); }
.headline-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.headline .stat-value { font-size: 26px; }
.bridge { max-width: 1000px; }
.filtered-line { font-size: 13.5px; color: var(--ink-2); font-weight: 600; }

/* a statement: indent by level, the kind's weight and border, the first column sticky */
.statement-scroll { overflow-x: auto; }
.statement { font-size: 13.5px; }
.statement th, .statement td { padding: 7px 14px; white-space: nowrap; }
.statement th.st-label, .statement td.st-label { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 300px; max-width: 460px; white-space: normal; box-shadow: 1px 0 0 var(--border); }
.statement th.st-label { background: var(--surface-2); z-index: 2; }
.statement tbody tr:hover td.st-label { background: var(--surface-2); }
.statement td.st-total-col, .statement th.st-total-col { box-shadow: inset 1px 0 0 var(--border); font-weight: 600; }
.lvl-0 { padding-left: 14px !important; } .lvl-1 { padding-left: 30px !important; } .lvl-2 { padding-left: 46px !important; }
.lvl-3 { padding-left: 62px !important; } .lvl-4 { padding-left: 78px !important; } .lvl-5 { padding-left: 94px !important; }
.lvl-6 { padding-left: 110px !important; } .lvl-7 { padding-left: 126px !important; }
.st-heading td { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .03em; padding-top: 14px; }
.st-top td, .st-subtotal td, .bva-section td, .bva-subtotal td { font-weight: 650; }
.st-subtotal td, .bva-subtotal td { border-top: 1px solid var(--border-strong); }
.statement tbody tr.st-total td, .statement tbody tr.bva-total td { border-top: 1px solid var(--ink-2); border-bottom: 3px double var(--ink-2); font-weight: 700; }
.st-check td { color: var(--muted); font-style: italic; }
.st-blank td { padding: 3px; border-bottom: 0; }
.bva-heading td { color: var(--muted); font-style: italic; }
/* not .group-head / .sub-head: the review queue owns .group-head (display: flex) */
.bva th.period-head { text-align: center; border-bottom: 0; padding-bottom: 2px; }
.bva .measure-head { font-size: 11.5px; padding-top: 2px; }
.no-budget { color: var(--faint); font-style: italic; font-size: 12px; }
.mark-cell { text-align: center; }
.fig-link { color: var(--primary); font-weight: 500; }
.fig-link:hover { text-decoration: underline; }
.meta-line { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-meta); color: var(--muted); }
.window-note { max-width: 1000px; }

/* the states: not ready, refused, failed checks */
.notready, .refusal-card { display: flex; flex-direction: column; gap: var(--s4); }
.notready-head { display: flex; gap: var(--s4); align-items: center; }
.notready-head .empty-glyph { margin: 0; flex: none; }
.notready-form { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }

/* checks & notes, the commentary */
.checks-table .check-result { white-space: nowrap; }
.fail-line { color: var(--danger); margin-top: 4px; white-space: normal; }
.notes-list { display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); gap: 10px 22px; margin: 0; }
.notes-list dt { font-weight: 650; }
.notes-list dd { margin: 0; color: var(--ink-2); }
.comment { display: flex; flex-direction: column; gap: 10px; }
.comment .card-head { margin-bottom: 0; }
.comment-title { font-size: 15px; font-weight: 650; }

/* the drill-down */
.drill-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; }
.drill-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.drill-what { font-size: var(--fs-lead); font-weight: 650; overflow-wrap: anywhere; }
.drill-tools { display: flex; gap: 10px; align-items: center; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-control); overflow: hidden; background: var(--surface); }
.seg { padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg + .seg { border-left: 1px solid var(--border-strong); }
.seg:hover { text-decoration: none; color: var(--ink); }
.seg.active { background: var(--primary-soft); color: var(--primary); }
.drill-table td { padding: 9px 14px; }
.d-desc { min-width: 220px; }
.page-link { color: var(--primary); display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.unverified { color: var(--warning); }
.more-actions { display: flex; gap: var(--s2); }
.drill-totals { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--ink-2); }
/* the CLI's own lines, its spacing kept */
.drill-title p, .drill-totals p { white-space: pre-wrap; }
.drill-figure { font-weight: 650; color: var(--ink); }

/* the statement page */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.page-head-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-name { font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
.page-nav { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.page-count { padding: 0 4px; }
.row-card { display: flex; flex-direction: column; gap: 10px; border-left: 4px solid var(--primary); }
.row-data { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 0; }
.row-data dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.row-data dd { margin: 0; font-size: 15px; font-weight: 600; }
.row-desc { min-width: 240px; }
.original-note { display: flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--warning); font-weight: 600; }
.page-viewer { padding: 18px; overflow: auto; background: var(--neutral-bg); }
.page-image { display: block; margin: 0 auto; max-width: none; height: auto; background: var(--surface); box-shadow: var(--shadow-lift); }
.pdf-frame { display: block; width: 100%; height: calc(100vh - var(--topbar) - 140px); min-height: 420px; padding: 0; overflow: hidden; }
.page-foot { display: flex; justify-content: flex-end; }

/* ---- narrow windows ------------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .span-3, .span-4 { grid-column: span 6; }
  .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .actions-row { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .span-3, .span-4 { grid-column: span 12; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =================================================================================================
   step 5.3 - the firm console (the matters) and a matter's way back to it. Extends the system
   above; no new colours, no new tokens.
   ================================================================================================= */
.matters { display: flex; flex-direction: column; gap: var(--s4); }
.matters-new { display: flex; }
.matter-number { font-weight: 700; font-size: 15px; color: var(--ink); }
.matter-ref { flex-wrap: nowrap; }
.matter-ref .input { width: 200px; }
.matter-data { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.matter-actions { white-space: nowrap; text-align: right; }
.matter-actions form { display: inline-flex; margin-left: 6px; }
/* the matter's rail: "Matters", back to the console, above Home - a line under it */
.nav-back { position: relative; margin-bottom: 9px; }
.nav-back::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -6px; border-top: 1px solid var(--border); }

/* =================================================================================================
   step 5.5a - the Accounts page: the coverage grid (one square per account per month,
   review/coverage.py) and one card per account with its decisions. Extends the system above; the
   squares take the status tones - solid for what a statement says (verified, accepted, read not
   proven, failed), outlined for what no statement says (missing, partly covered, outside).
   ================================================================================================= */
.coverage-card { padding: 20px 0 16px; }
.coverage-card .card-head { padding: 0 24px; flex-wrap: wrap; }
.cov-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-meta); color: var(--muted); }
.cov-legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cov-scroll { overflow-x: auto; margin-bottom: var(--s3); }
.cov-grid { border-collapse: separate; border-spacing: 0; font-size: var(--fs-meta); }
.cov-grid th, .cov-grid td { padding: 4px 3px; text-align: center; white-space: nowrap; }
.cov-grid thead th { font-size: 11.5px; font-weight: 600; color: var(--faint); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.cov-grid thead .cov-month-year { color: var(--ink-2); }
.cov-grid .cov-account {
  position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 500;
  padding: 4px 16px 4px 24px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border);
}
.cov-grid tbody .cov-account a { color: var(--ink); }
.cov-grid tbody .cov-account .badge { margin-left: 6px; height: 18px; font-size: 11px; }
.cov-grid tbody tr:hover th, .cov-grid tbody tr:hover td { background: var(--surface-2); }
.cov-grid .cov-note { text-align: left; padding-left: 12px; }
.cov { display: inline-block; width: 16px; height: 16px; border-radius: 3px; vertical-align: middle; flex: none; }
a.cov:hover { text-decoration: none; box-shadow: 0 0 0 2px var(--focus); }
.cov-verified { background: var(--success); }
.cov-accepted { background: var(--muted); }
.cov-unverified { background: var(--warning); }
.cov-failed { background: var(--danger); }
.cov-partial { background: linear-gradient(135deg, var(--warning) 50%, var(--surface) 50%); box-shadow: inset 0 0 0 1.5px var(--warning); }
a.cov-partial:hover { box-shadow: inset 0 0 0 1.5px var(--warning), 0 0 0 2px var(--focus); }
.cov-missing { background: var(--danger-bg); box-shadow: inset 0 0 0 1.5px var(--danger); }
a.cov-missing:hover { box-shadow: inset 0 0 0 1.5px var(--danger), 0 0 0 2px var(--focus); }
.cov-outside { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.cov-foot { padding: 0 24px; }
.cov-foot + .cov-foot { margin-top: 4px; }
/* the cards */
.account-cards { display: flex; flex-direction: column; gap: var(--s4); }
.account-card { display: flex; flex-direction: column; gap: var(--s4); scroll-margin-top: calc(var(--topbar) + 12px); }
.account-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.account-title { font-size: var(--fs-card); font-weight: 650; letter-spacing: -.01em; }
.account-subtitle { font-size: var(--fs-body); font-weight: 500; }
.account-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.account-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s4); align-items: start; }
.decision { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.decision-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.decision-note { color: var(--ink-2); overflow-wrap: anywhere; }
.account-facts a { color: var(--primary); font-weight: 500; }
.account-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--s3); }
.account-form { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.account-form .action-head { margin-bottom: 0; }
.account-form .form-actions { margin-top: auto; }
/* Home: the Accounts card opens the page */
.stat-link { color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.stat-link:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lift); }
@media (max-width: 1100px) { .account-body { grid-template-columns: 1fr; } }

/* =================================================================================================
   step 5.5b - the Outputs page: four cards in a 2x2 grid (one column below 1100px, as every
   .span-6), each with what it is, its newest file and one action; the budget card re-rendered
   whole by htmx. Extends the system above; no new colours, no new tokens.
   ================================================================================================= */
.outputs-grid { align-items: stretch; }
.output-card { display: flex; flex-direction: column; gap: var(--s3); }
.output-head { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.output-head .card-title { color: var(--ink); }
.output-lead { margin-top: -4px; }
.output-block { display: flex; flex-direction: column; gap: 8px; }
.output-label { font-size: 11.5px; font-weight: 650; color: var(--faint); letter-spacing: .02em; text-transform: uppercase; }
.output-file { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.output-file + .output-file { margin-top: 6px; }
.output-file-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.output-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; color: var(--ink); }
.pack-summary { color: var(--ink-2); }
.pack-gaps ul { margin: 2px 0 0; padding-left: 18px; }
.pack-foreign { color: var(--warning); font-weight: 600; }
.output-older summary { cursor: pointer; font-size: var(--fs-meta); color: var(--muted); margin: 4px 0; }
.output-form { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; border-top: 1px solid var(--border); }
.output-form .fields { margin-top: 10px; }
.output-card > .form-actions { margin-top: auto; }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-row .input { flex: 1; min-width: 0; }
.key-note { display: flex; align-items: flex-start; gap: 8px; margin-top: auto; padding: 10px 12px; border-radius: 10px; background: var(--warning-bg); border: 1px solid var(--warning-line); color: var(--ink-2); }
.key-note .icon { color: var(--warning); flex: none; margin-top: 1px; }
.budget-versions { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.budget-versions li { display: flex; flex-direction: column; gap: 1px; }
.budget-version { font-weight: 600; font-size: 13.5px; }
.budget-upload, .proposal-form { display: flex; flex-direction: column; gap: 8px; }
.proposal-form { flex-direction: row; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; }
.proposal-form .field { min-width: 140px; }
@media (max-width: 760px) { .output-file { flex-direction: column; } }

/* step 5.7 - the gallery: the whole tile is the link */
.output-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.output-tile { display: flex; align-items: flex-start; gap: 14px; padding: 18px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, transform .15s; }
.output-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lift); text-decoration: none; transform: translateY(-1px); }
.output-tile-date { margin-top: 4px; font-size: 12.5px; color: var(--faint); }
@media (max-width: 760px) { .output-tiles { grid-template-columns: 1fr; } }
/* step 5.7 - the package's account and sub-entity appear only for the scope that reads them */
.scope-field { display: none; }
.output-form:has(select[name="scope"] option[value="account"]:checked) .scope-account,
.output-form:has(select[name="scope"] option[value="sub_entity"]:checked) .scope-sub_entity { display: flex; }
@supports not selector(:has(a)) { .scope-field { display: flex; } }
/* step 5.7 - a finished import or update: what needs attention on top */
.run-table { display: flex; flex-direction: column; gap: 6px; }
.run-group { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.run-head, .run-group > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; font-weight: 650; }
.run-group > summary { cursor: pointer; }
.run-count { font-variant-numeric: tabular-nums; }
.run-note { font-weight: 400; font-size: var(--fs-meta); color: var(--muted); margin-left: auto; }
.run-danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.run-warning { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning); }
.run-zero { color: var(--muted); }
.run-rows { width: 100%; border-collapse: collapse; color: var(--ink); font-size: 13.5px; }
.run-rows td { padding: 6px 12px; border-top: 1px solid var(--border); }
.run-rows .num { width: 1%; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.run-clear { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 12px; border-radius: 10px; font-weight: 650; background: var(--success-bg); border: 1px solid var(--success-line); color: var(--success); }

/* step 5.6 - the private address (the firm console's rows) and what arrived by mail (Import) */
.address-note { display: flex; flex-direction: column; gap: 2px; margin: 0 0 var(--s3); }
.address-note p { margin: 0; }
.address-line { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.address-text { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; user-select: all; }
.by-mail-files { display: flex; flex-direction: column; gap: 2px; }
.by-mail-files .hint-line { margin: 4px 0 0; }
.matters-table tr:has(+ .matter-address-row) td { border-bottom: 0; padding-bottom: 2px; }
.matter-address-row td { padding-top: 0; }
.matters-table tr:hover + .matter-address-row td, .matters-table tr:has(+ .matter-address-row:hover) td { background: var(--surface-2); }

/* ---- step 4b.8a: the budget folder's workbooks ("Use this workbook"); an unreadable database ---- */
.budget-candidates { margin-top: 12px; }
.budget-candidate-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.budget-candidate { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.budget-candidate-name { font-weight: 600; overflow-wrap: anywhere; }
.budget-candidate form { margin-left: auto; }
.busy-unreadable { border-color: var(--danger-line); }
.busy-unreadable .busy-title { color: var(--danger); }

/* step 5.4a - the firm console's Licence and Mailbox cards, above the clients */
.firm-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s4); align-items: start; }
.firm-cards .card-head { margin-bottom: var(--s3); }
.licence-lines { display: flex; flex-direction: column; gap: 8px; }
.licence-lines p { margin: 0; }
.licence-firm { font-weight: 600; }
.licence-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.licence-unreachable { color: var(--warning); font-weight: 600; }
.licence-downloaded { color: var(--success); }
.licence-install-success { color: var(--success); font-weight: 600; }   /* step 5.4b */
.licence-install-danger { color: var(--danger); font-weight: 600; }    /* step 5.4b */
.licence-key-change, .mailbox-settings { margin-top: var(--s3); }
.licence-key-change summary, .mailbox-settings summary { cursor: pointer; color: var(--muted); }
.licence-key-form { display: flex; align-items: flex-start; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s3); }
.licence-key-field { flex: 1; min-width: 220px; }
.licence-key-form > .btn { margin-top: 26px; }
.mailbox-card p { margin: 0 0 6px; }
.mailbox-form { margin-top: var(--s3); display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; }
.mailbox-form .fields { width: 100%; }
.delivery-state { margin: var(--s2) 0; }                                  /* step 5.4c */
.delivery-on { color: var(--success); font-weight: 600; }
.delivery-off { color: var(--warning); font-weight: 600; }
.mailbox-instead { margin-top: var(--s3); }
.mailbox-instead > summary { cursor: pointer; color: var(--muted); }
.mailbox-pull { margin-top: var(--s2); }
@media (max-width: 1100px) { .firm-cards { grid-template-columns: minmax(0, 1fr); } }

/* step 5.4d - the firm portal on our side (vendor/templates): the console's shell and tokens;
   the logged-out pages are one card in the middle of the page */
.portal-auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s4); padding: var(--s6) var(--s4); }
.portal-auth-brand { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.portal-auth-brand .brand-name { font-size: 20px; }
.portal-auth-card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: var(--s4); padding: 28px 32px; }
.portal-auth-title { font-size: var(--fs-card); font-weight: 650; letter-spacing: -.01em; }
.portal-auth-lead { margin-top: calc(-1 * var(--s2)); }
.portal-auth-links { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; align-items: center; }
.portal-auth-links a { color: var(--primary); }
.portal-auth-foot { max-width: 440px; text-align: center; }
.portal-form { display: flex; flex-direction: column; gap: 14px; }
.portal-form .form-actions { margin-top: 2px; }
.portal-terms { display: flex; align-items: center; gap: 8px; }
.portal-terms a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.portal-message { display: flex; flex-direction: column; gap: 10px; color: var(--ink-2); }
.portal-user { color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-logout { margin: 4px 0; }
.portal-logout .btn { padding-left: 0; }
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.portal-grid > .card .card-head { margin-bottom: var(--s3); }
.portal-grid > .card > p + p, .portal-grid > .card > p + .portal-facts { margin-top: 8px; }
.portal-wide { grid-column: 1 / -1; }
.portal-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; margin: 0; }
.portal-facts dt { color: var(--muted); font-size: var(--fs-meta); }
.portal-facts dd { margin: 0; min-width: 0; }
.portal-sha { overflow-wrap: anywhere; }
/* step 5.14b - the Mac's installer under the Windows one, on the firm's dashboard */
.portal-download-mac { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border); }
.portal-download-mac > .portal-facts { margin-top: 8px; }
.portal-trial { margin-top: var(--s3); font-weight: 600; color: var(--info); }
.portal-trial-ended { color: var(--danger); }
.portal-state-note { margin-top: var(--s2); padding: 10px 12px; border-radius: 10px; background: var(--warning-bg); border: 1px solid var(--warning-line); color: var(--ink-2); }
.portal-steps { margin: var(--s3) 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); }
.portal-steps-title { margin-top: var(--s4); }
.portal-key-card, .portal-confirm { max-width: 720px; display: flex; flex-direction: column; gap: var(--s3); }
.portal-key-card .card-head, .portal-confirm .card-head { margin-bottom: 0; }
.portal-key { font-size: 17px; padding: 12px 14px; border-radius: var(--r-control); background: var(--surface-2); border: 1px dashed var(--border-strong); user-select: all; overflow-wrap: anywhere; }
.portal-key-warn { color: var(--warning); font-weight: 600; }
.portal-search { justify-content: flex-start; }
.portal-search .search { min-width: 320px; }
.portal-search .search-input { padding-left: 12px; }
.portal-firm-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s4); }
.portal-firm-actions form { display: inline-flex; }
@media (max-width: 1100px) { .portal-grid { grid-template-columns: minmax(0, 1fr); } }
/* step 9.9a - the back office's board and task (vendor/templates/backoffice_*.html): the columns sit
   side by side and stack on a narrow screen; nothing new but the layout */
.bo-toolbar { margin-bottom: var(--s4); }
.bo-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--s4); align-items: start; }
.bo-column { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.bo-column-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); font-weight: 650; padding: 0 2px; }
.bo-card { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; }
.bo-card-overdue { border-color: var(--danger-line); }
.bo-card-title { font-weight: 600; }
.bo-card-title a { color: var(--ink); }
.bo-card-action { margin-top: 6px; }
.bo-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: var(--fs-meta); }
.bo-overdue { color: var(--danger); font-weight: 600; }
.bo-empty { padding: 4px 2px; }
.bo-prompt { font-size: var(--fs-lead); font-weight: 600; margin: 0 0 var(--s3); }
.bo-account { margin: 0 0 var(--s3); font-family: var(--mono); }   /* step 9.12 (S15): Account ending 1001 */
.bo-explain { margin: 0 0 var(--s4); max-width: 78ch; }   /* step 9.19: the paragraph under the question */
.bo-context-label { margin-bottom: 6px; }
.bo-context { margin: 0 0 var(--s4); padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control); font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; }
.bo-options { display: flex; flex-direction: column; gap: 8px; }
/* the lead, after step 9.18b: a category question offers every category (72 on the standard chart), so the
   Answer button stays in sight at the bottom of the window while the list scrolls */
.bo-answer .form-actions { position: sticky; bottom: 0; padding: 10px 0; background: var(--surface); border-top: 1px solid var(--border); }
.bo-free { max-width: 480px; }
.bo-given p { margin: 4px 0 0; }
.bo-assign { margin-top: var(--s4); }
/* step 9.9b - the back office in the app: a Review row whose question is with our team, the line above the
   queue, and the role on the People page */
.rv-team { display: block; margin-top: 2px; font-size: 12.5px; color: var(--info); }
.rv-team-line { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; margin: 0 0 var(--s3); padding: 8px 12px; background: var(--info-bg); border-radius: var(--r-control); color: var(--info); font-weight: 600; }
.rv-team-line span { display: inline-flex; align-items: center; gap: 6px; }
.rv-team-refused { color: var(--ink); font-weight: 500; }
.people-table .role-col { width: 150px; }
.people-table .role-col form { margin: 0; }

/* step 9.7a - the secure upload link: its line under a client's address (firm/templates/partials/
   _matters.html), the e-mail text folded below it; the client's page (vendor/templates/upload.html). */
.upload-line { margin-top: 4px; flex-wrap: wrap; }
.upload-url { max-width: 520px; overflow: hidden; text-overflow: ellipsis; }
.upload-days { width: 64px; }
.upload-email { margin-top: 4px; }
.upload-email-body { display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; }
.upload-email-text { margin: 0; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 620px; }
.upload-form input[type="file"] { padding: 6px; height: auto; }
/* step 9.7b - the Import page's folder and bank cards, the Plaid page, "Whose documents are these?" */
.source-card { display: flex; flex-direction: column; gap: var(--s2); }
.source-card form { display: flex; flex-direction: column; gap: var(--s2); }
.source-card .card-title { display: flex; align-items: center; gap: 8px; }
.source-actions { display: flex; justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
.bank-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s2) 0; border-top: 1px solid var(--border); }
.bank-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bank-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bank-actions form { display: inline; }
.plaid-status { font-weight: 600; }
.plaid-status-bad { color: var(--danger); }
.roles-card { margin-bottom: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.roles-table td, .roles-table th { vertical-align: middle; }
.roles-pick { width: 150px; text-align: center; }
.roles-absent td { color: var(--ink-2); font-style: italic; }
.roles-actions { display: flex; justify-content: flex-end; }

/* step 5.10 - the portal's public landing: a page of its own (vendor/templates/landing.html), the
   Keystone logo's blue on a dark navy; no script, no web font, no image (PORTAL_CSP). */
.site, .wz {
  --site-navy: #0e1a2b; --site-navy-2: #16263c; --site-navy-line: #2a3d57;
  --site-sky: #4eabe9; --site-sky-hover: #74bfef; --site-on-dark: #c4d0de;
}
.site { background: var(--surface); font-size: var(--fs-lead); line-height: 1.55; }
.site a { color: inherit; }
.site-wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--s5); }
.site-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 46px; padding: 0 22px; border-radius: var(--r-control); border: 1px solid transparent;
  font-size: 15px; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s;
}
.site-button:hover { text-decoration: none; }
.site-button-sky, .site a.site-button-sky { background: var(--site-sky); color: var(--site-navy); }
.site-button-sky:hover, .site a.site-button-sky:hover { background: var(--site-sky-hover); }
.site-button-line { border-color: var(--site-navy-line); color: #fff; }
.site-button-line:hover { border-color: var(--site-sky); }
.site-button-sm { height: 38px; padding: 0 16px; font-size: 14px; }

/* the header */
.site-head { position: sticky; top: 0; z-index: 10; background: var(--site-navy); border-bottom: 1px solid var(--site-navy-line); color: #fff; }
.site-head-row { display: flex; align-items: center; gap: var(--s5); height: 68px; }
.site-brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.site-brand:hover { text-decoration: none; }
.site-logo { display: block; width: 44px; height: 17px; color: #fff; }
.site-nav { display: flex; gap: var(--s5); margin-left: auto; font-size: 14px; color: var(--site-on-dark); }
.site-nav a:hover { color: #fff; }
.site-head-actions { display: flex; align-items: center; gap: var(--s4); font-size: 14px; font-weight: 600; }

/* the hero */
.site-hero { background: var(--site-navy); color: #fff; padding: 72px 0 80px; }
.site-hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 64px; align-items: center; }
.site-eyebrow { color: var(--site-sky); font-size: 14px; font-weight: 600; letter-spacing: .02em; }
.site-hero h1 { margin-top: var(--s3); font-size: 50px; line-height: 1.1; font-weight: 700; letter-spacing: -.025em; }
.site-hero-lead { margin-top: 20px; font-size: 18px; color: var(--site-on-dark); }
.site-hero-how { margin-top: var(--s3); color: var(--site-on-dark); }
.site-cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); margin-top: var(--s6); }
.site-cta-note { margin-top: var(--s3); font-size: var(--fs-meta); color: var(--site-on-dark); }
.site-have-account { font-size: 14px; color: var(--site-on-dark); }
.site-have-account a { color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* the sample: a figure, its transactions, its page */
.site-proof { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.site-proof-card { background: var(--surface); color: var(--ink); border-radius: var(--r-card); padding: 14px 18px; box-shadow: var(--shadow-float); }
.site-proof-card:nth-child(2) { margin-left: 24px; }
.site-proof-card:nth-child(3) { margin-left: 48px; }
.site-proof-title { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.site-proof-row { display: flex; justify-content: space-between; gap: var(--s4); padding: 2px 8px; margin: 0 -8px; border-radius: 4px; font-size: 14px; font-variant-numeric: tabular-nums; }
.site-proof-row.marked { background: var(--warning-bg); font-weight: 600; }
.site-proof-line { height: 7px; margin: 7px 0; border-radius: 4px; background: var(--neutral-bg); }
.site-proof-line.short { width: 62%; }
.site-proof figcaption, .site-proof-caption { align-self: flex-end; font-size: 12px; color: var(--site-on-dark); }

/* the sections */
.site-section { padding: 80px 0; scroll-margin-top: 68px; }
.site-section-alt { background: var(--canvas); }
.site-section-dark { background: var(--site-navy); color: #fff; }
.site-section h2 { font-size: 34px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.site-section-lead { margin-top: var(--s3); max-width: 640px; color: var(--muted); font-size: 18px; }
.site-section-dark .site-section-lead { color: var(--site-on-dark); }
.site-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5); margin-top: 40px; }
.site-feature { padding: var(--s5); border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.site-feature-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--r-control); background: var(--primary-soft); color: var(--primary); }
.site-feature h3, .site-step h3, .site-promise h3 { font-size: 17px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
.site-feature h3 { margin-top: var(--s4); }
.site-feature p, .site-step p { margin-top: var(--s2); color: var(--muted); font-size: 15px; }

.site-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s5); margin: 40px 0 0; padding: 0; list-style: none; counter-reset: site-step; }
.site-step { counter-increment: site-step; border-top: 2px solid var(--primary); padding-top: var(--s4); }
.site-step::before { content: counter(site-step); display: block; margin-bottom: var(--s3); color: var(--primary); font-size: 26px; font-weight: 700; line-height: 1; }

.site-promises { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5) 56px; margin-top: 40px; }
.site-promise { border-left: 2px solid var(--site-sky); padding-left: 20px; }
.site-promise p { margin-top: var(--s2); color: var(--site-on-dark); font-size: 15px; }

.site-downloads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); margin-top: 40px; }
.site-download { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: 28px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.site-download h3 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.site-download p { color: var(--muted); font-size: 15px; }
.site-download .site-button { margin-top: var(--s3); }
.site-download .site-download-note { margin-top: var(--s2); font-size: var(--fs-meta); }
.site a.site-button-primary { background: var(--primary); color: #fff; }
.site a.site-button-primary:hover { background: var(--primary-hover); }
.site a.site-button-quiet { border-color: var(--border-strong); color: var(--ink); }
.site a.site-button-quiet:hover { background: var(--surface-2); }

.site-contact { display: flex; align-items: center; justify-content: space-between; gap: var(--s5); flex-wrap: wrap; }
.site-contact-mail { margin-top: var(--s2); font-weight: 600; }
.site-contact-mail a { text-decoration: underline; text-underline-offset: 2px; }

/* the footer */
.site-foot { background: var(--site-navy); color: var(--site-on-dark); border-top: 1px solid var(--site-navy-line); padding: 56px 0 28px; font-size: 14px; }
.site-foot-grid { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: var(--s6); }
.site-foot .site-brand { color: #fff; }
.site-foot-about { margin-top: var(--s3); max-width: 300px; }
.site-foot h3 { color: #fff; font-size: 14px; font-weight: 600; margin-bottom: var(--s3); }
.site-foot ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.site-foot a:hover { color: #fff; }
.site-foot-legal { display: flex; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--site-navy-line); font-size: var(--fs-meta); }

/* the login side: the way back to the landing */
.portal-auth-brand a { display: inline-flex; color: var(--ink); }
.portal-auth-company { text-align: center; }

@media (max-width: 960px) {
  .site-nav { display: none; }
  .site-head-actions { margin-left: auto; }
  .site-hero { padding: 48px 0 56px; }
  .site-hero-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .site-hero h1 { font-size: 38px; }
  .site-section { padding: 56px 0; }
  .site-grid, .site-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .site-wrap { padding: 0 var(--s4); }
  .site-head-login { display: none; }
  .site-hero h1 { font-size: 32px; }
  .site-section h2 { font-size: 27px; }
  .site-grid, .site-steps, .site-promises, .site-downloads, .site-foot-grid { grid-template-columns: minmax(0, 1fr); }
  .site-proof-card:nth-child(2), .site-proof-card:nth-child(3) { margin-left: 0; }
}

/* ---- step 5.11: the first run by steps, the masked key ---------------------------------------- */
.input-masked { -webkit-text-security: disc; }

/* step 5.13 - the first run, Create your account (firm/templates/welcome.html): the landing's navy
   side with the headline and three benefits, the form beside it */
.wz-body { background: var(--surface); }
.wz { display: grid; grid-template-columns: minmax(320px, 36%) minmax(0, 1fr); min-height: 100vh; }
.wz-side {
  display: flex; flex-direction: column; padding: 40px 48px; color: #fff;
  background: var(--site-navy); position: sticky; top: 0; height: 100vh;
}
.wz-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.wz-headline { margin-top: 64px; font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.wz-benefits { margin: 40px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 18px; font-size: 15px; line-height: 1.45; color: var(--site-on-dark); }
.wz-benefits li { display: flex; align-items: flex-start; gap: 12px; }
.wz-benefits .icon { flex: none; margin-top: 2px; color: var(--site-sky); }

.wz-main { display: flex; align-items: center; justify-content: center; padding: 48px 32px; }
.wz-panel { width: 100%; max-width: 500px; display: flex; flex-direction: column; gap: var(--s4); }
.wz-title { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; }
.wz-lead { color: var(--muted); font-size: 15px; line-height: 1.5; }
.wz .input { height: 42px; }

/* the form, then the other ways in */
.wz .licence-key-change { margin-top: 0; padding-top: 0; border-top: 0; }
.wz .licence-signup { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
/* step 9.55: one password field (Show beside it) - every field across the whole form */
.wz .licence-signup > .field, .wz .licence-signup > .check, .wz .licence-signup > .btn { grid-column: 1 / -1; }
.wz .password-field > .show-password { height: 42px; }
.wz .licence-signup > .btn { width: 100%; height: 46px; font-size: 15px; margin-top: 2px; }
.wz .field-hint { font-size: 12px; }
.wz-other { display: flex; flex-direction: column; gap: var(--s3); }
.wz-or { display: flex; align-items: center; gap: var(--s3); color: var(--faint); font-size: var(--fs-meta); }
.wz-or::before, .wz-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.wz #licence-have-account { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; color: var(--ink-2); }
.wz #licence-have-key summary { color: var(--muted); cursor: pointer; }
.wz #licence-have-key .licence-key-form { margin-top: var(--s3); }

/* the Clients table: whether a client's address works yet */
.address-state { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; font-size: var(--fs-meta); font-weight: 600; }
.address-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.address-state.on { color: var(--success); }
.address-state.off { color: var(--warning); }
.address-state.off::before { animation: wz-pulse 1.4s ease-in-out infinite; }
@keyframes wz-pulse { 50% { opacity: .3; } }

/* step 9.10a - what the lawyer is told: the files received (Home's banner, the line on every page, the
   console's badge), the question nobody saw (every page), the court production's offer and "build it again" */
.page-notice:empty, .home-received:empty { display: none; }
.banner .banner-action { margin-left: auto; flex: none; align-self: center; }
.received-banner { align-items: center; }
.received-banner .received-form { margin: 0 0 0 auto; flex: none; }
.received-import { margin: calc(-1 * var(--s3)) 0 0; }
.received-line { margin: 0; font-size: var(--fs-meta); font-weight: 600; }
.received-line a { display: inline-flex; align-items: center; gap: 6px; color: var(--info); }
.matter-received:empty { display: none; }
.production-offer { display: flex; flex-direction: column; gap: var(--s2); margin: var(--s3) 0; }
.production-offer .action-form { margin: 0; }
.btn-attention { box-shadow: 0 0 0 3px var(--warning-line); }

/* step 9.8 - the one button: Home's card Court production (Generate, Under review, Ready), the console's badge */
.generate-card { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s4); }
.generate-area { display: flex; flex-direction: column; gap: var(--s3); }
.generate-area .generate-form, .generate-area .generate-cancel { margin: 0; }
.generate-line { margin: 0; font-weight: 650; }
.generate-ready { display: inline-flex; align-items: center; gap: 8px; color: var(--success); }
.generate-team, .generate-lead, .generate-date { margin: 0; }
/* the owner's test of 0.2.19: Under review seen at a glance - a coloured panel, a big count, the promise beside it */
.generate-review { display: flex; align-items: center; gap: var(--s4); padding: 16px 18px; border-radius: var(--r-card); border: 1px solid var(--info-line); border-left: 6px solid var(--info); background: var(--info-bg); }
.generate-review-count { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; min-width: 104px; padding: 10px 12px; border-radius: var(--r-control); background: var(--surface); border: 1px solid var(--info-line); line-height: 1.1; }
.generate-review-n { font-size: 38px; font-weight: 750; color: var(--info); font-variant-numeric: tabular-nums; }
.generate-review-unit { margin-top: 4px; font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--info); text-align: center; }
.generate-review-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.generate-review .generate-promise { font-size: var(--fs-card); line-height: 1.3; }
.generate-review-note { margin: 0; color: var(--ink-2); }
.generate-review-warning { border-color: var(--warning-line); border-left-color: var(--warning); background: var(--warning-bg); }
.generate-review-warning .generate-review-count { border-color: var(--warning-line); }
.generate-review-warning .generate-review-n, .generate-review-warning .generate-review-unit { color: var(--warning); }
.generate-review-danger { border-color: var(--danger-line); border-left-color: var(--danger); background: var(--danger-bg); }
.generate-review-danger .generate-review-count { border-color: var(--danger-line); }
.generate-review-danger .generate-review-n, .generate-review-danger .generate-review-unit { color: var(--danger); }
@media (max-width: 640px) { .generate-review { flex-direction: column; align-items: flex-start; } }
.generate-yours-title { margin: 0 0 6px; font-weight: 600; }
.generate-items li a { gap: var(--s3); }
.generate-answer { display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--info); }
.generate-files { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.generate-files .rv-form { margin: 0; }
.generate-stale { display: flex; flex-direction: column; gap: var(--s2); }
.matter-generate:empty { display: none; }

@media (max-width: 860px) {
  .wz { grid-template-columns: minmax(0, 1fr); }
  .wz-side { position: static; height: auto; padding: 24px; }
  .wz-headline { margin-top: var(--s4); font-size: 22px; }
  .wz-benefits { margin-top: var(--s4); gap: 10px; font-size: 14px; }
  .wz-main { padding: 32px 20px; }
}

/* step 5.13 slice A - the Import page: add statements, one button, one card per file.
   A file with problems is the soft amber card of Mauro's reference; one white card per problem. */
.import-add { display: flex; flex-direction: column; gap: var(--s3); }
.import-run { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.import-run-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.import-run-text .hint-line { margin: 4px 0 0; }
.job-compact { gap: 10px; padding: 14px 18px; }
.job-compact-title { font-weight: 650; }
#job-area:empty { display: none; }
.import-files { display: flex; flex-direction: column; gap: 10px; }
.import-files .hint-line { margin: 2px 0 0; }
.import-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); }
.import-card-problem { background: #fffbeb; border-color: #fde68a; box-shadow: none; }
.import-line { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 28px; }
.import-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 15px; font-weight: 650; }
.import-name-text, .import-card > .import-line:first-child > .import-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-alert { display: inline-flex; flex: none; color: #d97706; }
.import-sub { color: var(--muted); font-size: var(--fs-body); }
.import-card-problem .import-name { color: #92400e; }
.import-card-problem .import-sub { color: #b45309; }
.import-card-problem .btn-secondary { flex: none; }
.import-details { margin-top: 6px; padding-top: 8px; border-top: 1px solid #fde68a; }
.import-details > summary { display: flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; color: #92400e; font-size: var(--fs-body); font-weight: 500; }
.import-details > summary::-webkit-details-marker { display: none; }
.import-details .chevron { border-color: #92400e; }
.import-details[open] .chevron { transform: rotate(45deg); }
.import-problems { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.import-problem { padding: 10px 12px; background: var(--surface); border: 1px solid #fde68a; border-radius: var(--r-control); }
.import-problem-label { color: var(--danger); font-weight: 500; }
.import-problem-text { margin-top: 2px; color: var(--ink); overflow-wrap: anywhere; }
.import-more { margin: 0; color: #b45309; font-size: var(--fs-meta); }

/* Step 5.13 slice D - People */
.people-head { display: flex; flex-direction: column; gap: var(--s3); }
.people-title { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.people-name { font-size: var(--fs-lead); font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.people-file { margin-top: var(--s4); }
.people-file-name { font-size: var(--fs-body, 14px); font-weight: 650; padding: var(--s3) var(--s4); overflow-wrap: anywhere; }

/* step 5.13 slice C - the disclosure package's form reads in order: bold labels, a red asterisk on
   what is required, the dates quiet under Optional. Generated files use the Import page's cards. */
.pack-form .field-label { font-size: var(--fs-body); font-weight: 700; color: var(--ink); }
.req { color: var(--danger); font-weight: 700; }
.req-line { margin: 0; font-size: var(--fs-meta); color: var(--muted); }
.pack-form .field-optional { gap: 4px; padding-top: 10px; border-top: 1px dashed var(--border); }
.field-optional-tag { font-size: 11.5px; font-weight: 600; color: var(--faint); letter-spacing: .02em; text-transform: uppercase; }
.pack-form .field-optional .field-label { font-size: var(--fs-meta); font-weight: 500; color: var(--muted); }
.pack-limit { margin: 0; }
.generated-gap { margin: 2px 0 0; color: #b45309; font-size: var(--fs-meta); overflow-wrap: anywhere; }
/* step 5.14d - the package holds real names unless "Hide names and account numbers" is ticked: the
   hint under the box always, what hiding cannot promise only while it is ticked (as .scope-field;
   without :has it shows). Each card says which kind of package it is, beside Ready. */
.hide-hint { margin: -6px 0 0; }
.hide-only { display: none; }
.output-form:has(input[name="hide"]:checked) .hide-only { display: block; }
@supports not selector(:has(a)) { .hide-only { display: block; } }
.generated-badges { display: inline-flex; align-items: center; gap: 6px; flex: none; }
/* step 5.17 - while the box is ticked: what will be hidden, the names under a details, and the
   names the lawyer adds */
.also-hide { margin: 0; }
.also-hide .will-hide-line { margin: 0 0 4px; }
.will-hide { margin: 0 0 10px; font-size: var(--fs-meta); }
.will-hide summary { cursor: pointer; color: var(--accent, var(--ink)); }
.will-hide-group { margin: 8px 0 2px; font-weight: 600; color: var(--muted); }
.will-hide-names { margin: 0; padding-left: 18px; columns: 2; }
.also-hide textarea { min-height: 64px; resize: vertical; }

/* ---- step 5.13 (slice B): the review queue as tables - a soft amber head on what needs a decision, white rows ---- */
.rv-kind { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: clip; }
.rv-kind-danger { border-color: var(--warning-line); }
.rv-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: 14px 20px; border-bottom: 1px solid var(--border); }
.rv-kind-danger .rv-head { background: #fffbeb; border-bottom-color: var(--warning-line); }
.rv-head-text { min-width: 0; }
.rv-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.rv-kind-danger .rv-title { color: var(--danger); }
.rv-desc { margin-top: 2px; font-size: var(--fs-meta); color: var(--muted); }
.rv-kind-danger .rv-desc { color: var(--warning); }
.rv-table td { padding: 11px 20px; }
.rv-table th { padding-left: 20px; padding-right: 20px; }
.rv-table tbody tr:hover td { background: var(--surface); }
.rv-main { min-width: 220px; }
.rv-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.rv-sub { display: block; font-size: var(--fs-meta); color: var(--muted); overflow-wrap: anywhere; }
.rv-text { color: var(--ink-2); }
.rv-count { white-space: nowrap; color: var(--muted); font-size: var(--fs-meta); }
.rv-also { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 600; color: var(--primary); }
.rv-answer { width: 1%; white-space: nowrap; text-align: right; }
.rv-answer > .btn, .rv-form { vertical-align: middle; }
.rv-form { display: inline-flex; align-items: center; gap: var(--s2); margin-left: var(--s2); }
.rv-form select { width: 260px; max-width: 34vw; }
.rv-quiet .btn { color: var(--muted); font-weight: 500; }
.rv-quiet .btn:hover { color: var(--danger); background: var(--danger-bg); }
.rv-saved { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: 12px 16px; border: 1px solid var(--success-line); border-radius: var(--r-card); background: var(--success-bg); color: var(--success); font-weight: 600; }
.rv-saved-text { display: inline-flex; align-items: center; gap: var(--s2); }
.queue > .kind-more, .rv-kind .kind-more { margin: 0; }
@media (max-width: 860px) {
  .rv-answer { white-space: normal; width: auto; }
  .rv-form { flex-wrap: wrap; margin-left: 0; margin-top: var(--s2); }
}
.rv-answer .item-link { display: inline-flex; color: var(--ink); }
.nav-count[hidden] { display: none; }

/* step 5.13 slice F - Settings in words, Advanced, what folds away */
.setting-name { font-weight: 600; }
.settings-advanced-link { margin-top: var(--s4); text-align: right; }
.settings-advanced-link a { color: var(--muted); }
.account-change { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); }
.account-change > summary, .figures-fold > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-meta); font-weight: 600; }
.account-change[open] > summary { margin-bottom: var(--s3); }
.figures-fold { margin-top: var(--s4); }
.figures-fold[open] > summary { margin-bottom: var(--s3); }
.account-facts dt { font-family: inherit; }

/* step 5.14 - Print is back in the window: the page goes on paper, not the app around it */
@media print {
  .rail, .window-back, .window-refresh, .pill, .loading-bar, .backdrop, .drawer, #toasts, .figures-toolbar { display: none; }
  .shell { display: block; }
  .topbar { position: static; background: none; backdrop-filter: none; padding: 0; }
  .content { max-width: none; padding: var(--s4) 0 0; }
}

/* M6 (Mauro, 2026-11-11): the People page's family mark - a family icon per row, blue on a blue ground when
   marked (the colour of the Family badge); Mateo, 2026-11-12: a heart did not say "family", and hover says it */
.people-table .family-col { width: 44px; padding-right: 0; }
.people-table .family-col form { margin: 0; }
.family-mark { transition: color .12s, background .12s; }
.family-mark.on, .family-mark.on:hover { color: var(--info); background: var(--info-bg); }
.family-mark:not(.on):hover { color: var(--info); }

/* A tooltip at once on hover or keyboard focus (a native title shows late, and not in every window) */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 6px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; padding: 4px 8px; border-radius: 6px; background: var(--ink); color: var(--surface);
  font: 500 12px/1.3 var(--font); opacity: 0; pointer-events: none; transition: opacity .1s; z-index: 5;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; }

/* M1 (Mauro, 2026-11-11) - in the app's own window, as in a native app: the app's own words (navigation,
   buttons, headings, labels, the welcome side) are not selectable; the content is (figures, tables, names,
   addresses, keys, statement text, messages, fields). A browser - the portal, `web` - keeps the usual rule. */
.in-window .rail, .in-window .topbar, .in-window .wz-side, .in-window .wz-title, .in-window .wz-or,
.in-window .btn, .in-window button, .in-window label, .in-window .badge, .in-window .pill,
.in-window .section-title, .in-window th, .in-window .seg, .in-window .dropzone, .in-window .stat-label,
.in-window .tabs, .in-window .nav-count, .in-window .icon { -webkit-user-select: none; user-select: none; }
.in-window input, .in-window textarea, .in-window select, .in-window .address-text, .in-window .portal-key,
.in-window code { -webkit-user-select: text; user-select: text; }
.in-window .address-text, .in-window .portal-key { -webkit-user-select: all; user-select: all; }


/* step 5.19 - Update required: the one page while this version is below our side's minimum */
.update-required { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--s5) var(--s4); }
.update-card { max-width: 560px; width: 100%; display: flex; flex-direction: column; gap: var(--s3); }
.update-card .page-title { margin: 0; }
.update-versions { font-weight: 600; }
.update-note { padding: var(--s3); border: 1px solid var(--warning-line); background: var(--warning-bg); border-radius: 8px; }
.update-form { margin: 0; }
.update-progress:empty { display: none; }
.update-failed { color: var(--danger); }
.update-kept { margin-top: var(--s2); }


/* step 9.4 - the Case page: the case's details by section, the certificate's responses */
.case-form { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s4); }
.case-section { margin-top: var(--s2); }
.case-row { padding-bottom: var(--s3); border-bottom: 1px solid var(--border); }
.field-missing .input { border-color: var(--warning-line); }
.case-response { padding: var(--s3) 0; border-top: 1px solid var(--border); }
.case-letter { font-size: var(--fs-body); font-weight: 650; margin: 0 0 var(--s2); display: flex; align-items: center; gap: 8px; }
.case-generated { color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; line-height: 1.45; }
.case-generated div + div { margin-top: 4px; }


/* step 9.13 - the lawyer's flow: Import as a gallery. Step 9.21 - Home's three steps are two cards (Import, Export);
   the numbered steps live on the court production's page (the case, the production) */
.home-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }
.home-card { display: flex; flex-direction: column; gap: 12px; }
.home-card-head { display: flex; align-items: center; gap: 12px; }
.home-card-head .card-title { margin: 0; }
.home-card-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.home-card-lead { margin: 0; }
.home-card-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.home-card.is-disabled { opacity: 0.6; box-shadow: none; }
.home-card.is-disabled .home-card-icon { background: var(--surface-2); color: var(--muted); }
.home-card .home-received:empty { display: none; }
@media (max-width: 760px) { .home-cards { grid-template-columns: 1fr; } }
.generate-go { margin: 0; }
.export-heading { font-size: var(--fs-lead); font-weight: 650; margin: 0 0 var(--s3); }
.export-first { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: var(--s3); border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface-2); }
.export-first-text { margin: 0; flex: 1; font-weight: 600; }
.output-tiles-main { margin-bottom: var(--s4); }
.output-tile-main { padding: 24px; }
.output-tile-main .action-title { font-size: var(--fs-lead); }
.output-tile.is-disabled { opacity: 0.55; box-shadow: none; cursor: not-allowed; }
.output-tile.is-disabled:hover { transform: none; border-color: var(--border); box-shadow: none; }
.flow-steps { list-style: none; margin: 0 0 var(--s4); padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.flow-step { display: flex; flex-direction: column; gap: 10px; }
.flow-step.step-waiting:not(.step-open) { opacity: 0.72; box-shadow: none; }
.flow-step.step-open { border-color: var(--primary); }
.flow-step .generate-card { box-shadow: none; border: none; padding: 0; margin: 0; }
.step-head { display: flex; align-items: center; gap: 12px; }
.step-number { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.step-open .step-number { background: var(--primary); border-color: var(--primary); color: #fff; }
.step-done .step-number { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.step-title { font-size: var(--fs-lead); font-weight: 650; margin: 0; flex: 1; }
.step-lead { margin: 0; }
.step-line { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.case-fixed { font-weight: 600; padding: 8px 0; }
.case-title-other { margin-top: 6px; }
.generate-blanks { display: flex; flex-direction: column; gap: 10px; }
.drive-line { margin: 0; }
.ways-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s3); }
.way-tile { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; padding: 18px; transition: border-color .15s, box-shadow .15s; }
.way-tile:hover { border-color: var(--primary); }
.way-tile.active { border-color: var(--primary); background: var(--primary-soft); }
.way-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); }
.way-tile.active .way-icon { background: var(--surface); }
.way-title { font-weight: 650; }
.way-hint { font-size: var(--fs-meta); color: var(--muted); }
.way-panel .sources { display: block; }
.way-console { display: flex; flex-direction: column; gap: 12px; }
.way-console .address-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.way-console .upload-email-body { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.way-link-form { display: flex; align-items: center; gap: 10px; }
.field-inline { display: inline-flex; align-items: center; gap: 6px; }
.import-run-card { margin-bottom: var(--s3); }

/* step 9.26 - the lawyer's pages after the audit (auditor b1).
   D10: the Clients table fits 1100 px and up - the row's actions stack (Open, then Close under it) instead of
   running past the table's edge; the files that wait are one polled element (Read / Nothing read yet, the PDFs
   received, N received - not read yet), a column like the rest of the cell. */
.matter-actions { white-space: normal; }
.matter-actions-row { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; }
.matter-actions .matter-actions-row form { display: flex; margin: 0; }
.matter-received { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.matter-ref .input { width: 160px; }
@media (max-width: 1279px) {
  /* the narrower windows: tighter cells, the date may take two lines, a shorter alias box */
  .matters-table th, .matters-table td { padding-left: 10px; padding-right: 10px; }
  .matters-table td.nowrap { white-space: normal; }
  .matter-ref .input { width: 120px; }
}
/* D2: on Home, nothing asked yet - the card is the lawyer's list itself, its heading the list's own */
.generate-asks-head { margin-bottom: 6px; }
/* D12: the Statements card - each dot with its words (the spacing the loose dots had) */
.stat-hint > .nowrap { display: inline-flex; align-items: center; gap: 4px; }
.stat-hint > .nowrap + .nowrap { margin-left: 6px; }

/* step 9.24 - Redacted documents: what to hide. Two choices; the block of the one that is ticked is shown. */
.redacted-hide { border: 0; padding: 0; margin: 0 0 var(--s4); display: grid; gap: var(--s2); }
.redacted-hide legend { padding: 0; margin-bottom: var(--s2); }
.redacted-choice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--r-control); cursor: pointer; }
.redacted-choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.redacted-choice input { margin-top: 3px; flex: none; }
.redacted-choice-words { display: grid; gap: 2px; }
.redacted-form:has(input[name="hide"][value="numbers"]:checked) .redacted-mode-names { display: none; }
.redacted-form:has(input[name="hide"][value="names"]:checked) .redacted-mode-numbers { display: none; }
/* step 9.60 - the third choice (obfuscate): its own block; "Also hide these names" with the first and the third */
.redacted-form:has(input[name="hide"][value="names"]:checked) .redacted-mode-obfuscate,
.redacted-form:has(input[name="hide"][value="numbers"]:checked) .redacted-mode-obfuscate,
.redacted-form:has(input[name="hide"][value="numbers"]:checked) .redacted-mode-also,
.redacted-form:has(input[name="hide"][value="obfuscate"]:checked) .redacted-mode-names,
.redacted-form:has(input[name="hide"][value="obfuscate"]:checked) .redacted-mode-numbers { display: none; }
.generated-extra { margin-top: var(--s2); }
.redacted-hidden { margin: 0 0 var(--s3); padding-left: 1.2em; }

/* step 9.55 - the boss's first run on a Mac. A password and its Show / Hide on one line (the app's pages and our
   server's); the Import page: the upload's answer with THE button that reads, the drop zone folded under Add more
   files, the card that says what comes next after a reading, the calm busy line */
.password-field { display: flex; align-items: center; gap: 8px; min-width: 0; }
.password-field > .input { flex: 1 1 auto; min-width: 0; }
.password-field > .show-password { flex: none; min-width: 64px; }
span.password-field { display: inline-flex; }
#upload-result:first-child .upload-result { margin-top: 0; }
.upload-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload-read { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 400; }
.upload-read:empty { display: none; }
.read-form { margin: 0; }
.upload-more > summary { display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; color: var(--primary); font-weight: 600; padding: 4px 0; }
.upload-more > summary::-webkit-details-marker { display: none; }
.upload-more > summary .chevron { border-color: var(--primary); }
.upload-more[open] > summary { margin-bottom: var(--s3); }
.upload-more[open] .chevron { transform: rotate(45deg); }
#import-next:empty { display: none; }
.import-next { display: flex; flex-direction: column; gap: 10px; margin-bottom: var(--s4); border-color: var(--primary); }
.import-next .card-title { margin: 0; }
.import-next-read { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--success); font-weight: 600; }
.import-next-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.import-next-review { margin: 0; font-size: var(--fs-meta); display: flex; align-items: center; gap: 2px; }
.job-calm { margin: 0 0 var(--s2); color: var(--muted); font-size: var(--fs-meta); }

/* step 9.33 - the reading problems: one quiet line on Home, by account on the court production's page */
.home-reading-line, .generate-reading-line { margin: 0; }
.generate-reading { display: flex; flex-direction: column; gap: 6px; }
.generate-reading .reading-lead { margin: 0 0 4px; }
.reading-groups .reading-kinds { display: block; margin-top: 2px; }
.reading-more > summary { cursor: pointer; color: var(--info); padding: 6px 12px; }
.reading-ask { display: flex; flex-direction: column; gap: 8px; }
