/* wunderBerater — design tokens + components. No build step. */
:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --sunken: #efede7;
  --ink: #18212d;
  --muted: #5b6676;
  --faint: #8b94a2;
  --line: #e5e2da;
  --line-strong: #d3cfc4;
  --primary: #1d4a76;
  --primary-hover: #163a5e;
  --primary-soft: #e7eef6;
  --primary-ink: #ffffff;
  --ok: #17775a;
  --ok-soft: #e3f3ec;
  --warn: #a35a06;
  --warn-soft: #fdf1df;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --focus: 0 0 0 3px rgba(29, 74, 118, 0.25);
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(24, 33, 45, 0.06), 0 1px 1px rgba(24, 33, 45, 0.04);
  --shadow-lg: 0 8px 24px rgba(24, 33, 45, 0.12);
  /* data sources */
  --src-manual: #6b7280;
  --src-master_data: #475569;
  --src-client: #7c3aed;
  --src-extraction: #c2410c;
  --src-push: #2563eb;
  --src-pull: #0891b2;
  --src-elster: #15803d;
  --src-mcp: #db2777;
  --src-bookkeeping: #0f766e;
  --src-linked: #4f46e5;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #191e26;
    --surface-2: #1d232c;
    --sunken: #151a21;
    --ink: #e6e9ee;
    --muted: #a2abb8;
    --faint: #75808f;
    --line: #2a313c;
    --line-strong: #39424f;
    --primary: #6ea8e0;
    --primary-hover: #8dbbe8;
    --primary-soft: #1d2b3b;
    --primary-ink: #0d1520;
    --ok: #4cc493;
    --ok-soft: #15302a;
    --warn: #f0b252;
    --warn-soft: #33270f;
    --danger: #ff7a6e;
    --danger-soft: #3a1b19;
    --focus: 0 0 0 3px rgba(110, 168, 224, 0.35);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
    --src-manual: #9ca3af;
    --src-master_data: #94a3b8;
    --src-client: #a78bfa;
    --src-extraction: #fb923c;
    --src-push: #60a5fa;
    --src-pull: #22d3ee;
    --src-elster: #4ade80;
    --src-mcp: #f472b6;
    --src-bookkeeping: #2dd4bf;
    --src-linked: #a5b4fc;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* inline icons default to the text size; components size them explicitly below */
svg[aria-hidden="true"] { width: 1em; height: 1em; vertical-align: -0.125em; flex: none; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--ink); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
.num, td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 750; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-firm { font-size: 12px; color: var(--muted); line-height: 1.2; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); padding: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--sunken); color: var(--muted);
  display: grid; place-items: center; font-weight: 650; font-size: 12px; flex: none;
}
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { min-width: 0; }
.page { padding: 24px 28px 48px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.env-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--warn); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 6px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

.tile { padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile a { color: inherit; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- tables ---------- */
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: var(--surface-2); }
.list .primary-cell a { font-weight: 600; color: var(--ink); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--sunken); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--sunken); color: var(--ink); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.08); background: var(--ok); }
.btn svg { width: 16px; height: 16px; }
form.inline { display: inline; }

input:not([type]), input[type=text], input[type=url], input[type=tel], input[type=email], input[type=search], input[type=date], input[type=number], input[type=password],
select, textarea {
  width: 100%; height: 34px; padding: 6px 10px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
textarea { height: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
label { font-weight: 550; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-field label { display: block; margin-bottom: 4px; font-size: 13px; }
.form-field .help, .errorlist { font-size: 12px; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 4px 0 0; }
.form-field.has-error input, .form-field.has-error select { border-color: var(--danger); }
.search { position: relative; }
.search input { padding-left: 32px; }
.search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--faint); }

/* ---------- pills, badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--sunken); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-draft { color: var(--muted); }
.st-in_progress { color: var(--primary); background: var(--primary-soft); }
.st-waiting_client { color: var(--warn); background: var(--warn-soft); }
.st-review { color: #7c3aed; background: color-mix(in srgb, #7c3aed 12%, transparent); }
.st-approved, .st-submitted, .st-assessed { color: var(--ok); background: var(--ok-soft); }
.st-closed { color: var(--faint); }
.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--sunken); color: var(--muted); font-variant-numeric: tabular-nums; }
.count.warn { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--sunken); color: var(--muted); }

.src { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--src, var(--muted)); white-space: nowrap; }
.src::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.src-manual { --src: var(--src-manual); }
.src-master_data { --src: var(--src-master_data); }
.src-client { --src: var(--src-client); }
.src-extraction { --src: var(--src-extraction); }
.src-push { --src: var(--src-push); }
.src-pull { --src: var(--src-pull); }
.src-elster { --src: var(--src-elster); }
.src-mcp { --src: var(--src-mcp); }
.src-bookkeeping { --src: var(--src-bookkeeping); }
.src-linked { --src: var(--src-linked); }
.src-computed { --src: var(--primary); }
.count.err { background: var(--danger-soft); color: var(--danger); }
.field.computed .computed-value { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; padding-right: 10px; }
.emsg { grid-column: 2 / 5; font-size: 12.5px; padding: 6px 10px; border-radius: var(--radius-sm); margin-top: 2px; }
.emsg strong { margin-right: 6px; }
.emsg-error { background: var(--danger-soft); color: var(--danger); }
.emsg-hint { background: var(--warn-soft); color: var(--warn); }
.verdict { display: flex; align-items: center; gap: 14px; padding: 16px; }
.verdict .big { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.verdict .big svg { width: 24px; height: 24px; }
.verdict.ok .big { background: var(--ok-soft); color: var(--ok); }
.verdict.bad .big { background: var(--danger-soft); color: var(--danger); }
.verdict.run .big { background: var(--primary-soft); color: var(--primary); }
.verdict h2 { font-size: 17px; }
.spinner { width: 20px; height: 20px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-list li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.msg-list .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; }
.msg-list .dot.error { background: var(--danger); }
.msg-list .dot.hint { background: var(--warn); }
.msg-list .where { font-size: 12px; color: var(--muted); }

/* ---------- messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 550; }
.messages li.error { background: var(--danger-soft); color: var(--danger); }
.messages li + li { margin-top: 6px; }

/* ---------- case workspace ---------- */
.case-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 18px 28px 0; }
.case-head .crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.case-head .title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.case-head .meta { display: flex; gap: 20px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 6px; }
.case-head .meta strong { color: var(--ink); font-weight: 550; }
.tabs { display: flex; gap: 4px; margin-top: 14px; overflow-x: auto; max-width: 100%; }
.tabs a { white-space: nowrap; }
.grid-main { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.grid-main.grid-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.table-wrap { overflow-x: auto; }
.grid-split { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; }
.thread { list-style: none; margin: 0; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow-y: auto; }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 12px; background: var(--sunken); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--primary-soft); }
.bubble .meta { display: block; font-size: 12px; color: var(--faint); margin-top: 4px; white-space: normal; }
.req { padding: 14px 16px; border-top: 1px solid var(--line); }
.req:first-child { border-top: 0; }
.portal-head { background: var(--surface); border-bottom: 1px solid var(--line); }
.portal-head .inner, .portal-main { max-width: 860px; margin: 0 auto; padding: 14px 16px; }
.portal-main { padding-top: 24px; padding-bottom: 64px; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 14px; background: var(--surface-2); }
.tabs a { padding: 9px 12px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.workspace { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 20px; padding: 20px 28px 64px; align-items: start; }
.form-nav { position: sticky; top: 16px; }
.form-nav ul { list-style: none; margin: 0; padding: 6px; }
.form-nav li a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--ink); }
.form-nav li a:hover { background: var(--sunken); text-decoration: none; }
.form-nav li a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.form-nav li a .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-nav .add { padding: 10px; border-top: 1px solid var(--line); }
.form-nav .add select { height: 32px; font-size: 13px; }

.form-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.form-toolbar .search { flex: 1; min-width: 220px; max-width: 360px; }
.form-toolbar label { font-weight: 500; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }

details.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
details.section + details.section { margin-top: 10px; }
details.section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: 650;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint);
  transform: rotate(-45deg); transition: transform 0.15s; margin-right: 2px; flex: none;
}
details.section[open] > summary::before { transform: rotate(45deg); }
details.section[open] > summary { border-bottom: 1px solid var(--line); }
details.section > summary .stitle { flex: 1; min-width: 0; }
.section-body { padding: 4px 0 8px; }

.group { padding: 0; }
.group-title { padding: 12px 16px 4px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: none; display: flex; align-items: center; gap: 8px; }
.group-title .tag { font-weight: 600; }
.group.depth-2 .group-title, .group.depth-3 .group-title { padding-left: 28px; }
.rows { }
.grow { position: relative; }
.grow.repeat { margin: 6px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 4px 0; }
.grow.repeat .field { padding-left: 12px; padding-right: 12px; }
.row-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px 0; font-size: 11px; color: var(--faint); font-weight: 600; }
.add-row { margin: 6px 16px 10px; }

.field {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(200px, 300px) 148px; gap: 12px; align-items: center;
  padding: 7px 16px; border-top: 1px solid transparent;
}
.field + .field { border-top-color: var(--line); }
.field:target, .field.flash { background: var(--warn-soft); }
.field .line { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--faint); text-align: right; }
.field .flabel { min-width: 0; }
.field .flabel .kz { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-left: 6px; }
.field .flabel .req { color: var(--danger); margin-left: 2px; }
.field .finput input, .field .finput select { height: 32px; }
.field .finput input.money, .field .finput input.number { text-align: right; font-variant-numeric: tabular-nums; }
.field .fmeta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.field .fmeta details { font-size: 11px; }
.field .fmeta summary { cursor: pointer; color: var(--faint); list-style: none; }
.field .fmeta summary::-webkit-details-marker { display: none; }
.field .ferror { grid-column: 3 / 5; color: var(--danger); font-size: 12px; margin-top: -4px; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field.saved .finput input, .field.saved .finput select { border-color: var(--ok); transition: border-color 0.6s; }
.field .readonly { padding: 6px 0; font-variant-numeric: tabular-nums; }
.proposal {
  grid-column: 2 / 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 2px;
  padding: 7px 10px; border-radius: var(--radius-sm); background: var(--warn-soft); border-left: 3px solid var(--warn);
}
.proposal .pval { font-weight: 650; font-variant-numeric: tabular-nums; }
.proposal .pmeta { color: var(--muted); font-size: 12px; flex: 1; min-width: 160px; }
.history-pop { position: absolute; z-index: 20; right: 16px; margin-top: 4px; width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px 12px; }
.history-pop ol { list-style: none; margin: 0; padding: 0; }
.history-pop li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 12px; }
.history-pop li:first-child { border-top: 0; }
.history-pop .hv { font-weight: 650; font-size: 13px; }
.htmx-request.field { opacity: 0.7; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline .who { font-weight: 600; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card-body { padding: 28px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card form p, .auth-card form .form-field { margin-bottom: 12px; }
.auth-card form label { display: block; font-size: 13px; margin-bottom: 4px; }
.auth-card button[type=submit], .auth-card .btn-block { width: 100%; justify-content: center; height: 38px; }
.auth-card button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink);
  font: inherit; font-weight: 600; cursor: pointer; }
.auth-card button:hover { background: var(--primary-hover); }
.auth-card input:not([type=checkbox]) { margin-bottom: 4px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 20px; }
.auth-card img { max-width: 100%; height: auto; background: #fff; padding: 8px; border-radius: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .field { grid-template-columns: 32px minmax(0, 1fr) minmax(160px, 240px); }
  .field .fmeta { grid-column: 2 / 4; flex-direction: row; gap: 12px; }
  .proposal, .field .ferror, .emsg { grid-column: 2 / 4; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grid-main, .grid-main.grid-even, .grid-split { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 8px 12px; }
  .sidebar .nav { flex-direction: row; margin: 0; overflow-x: auto; max-width: 100%; }
  .sidebar .nav a { white-space: nowrap; }
  .brand { padding-bottom: 4px; }
  .nav-label, .sidebar-foot .who, .brand-firm { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .page, .workspace { padding: 16px; }
  .case-head { padding: 14px 16px 0; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .form-toolbar .search { min-width: 0; max-width: none; flex-basis: 100%; }
  .case-head .title-row h1 { font-size: 19px; }
  table.list { display: block; overflow-x: auto; }
  .form-nav { position: static; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .field { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .field .line { text-align: left; }
  .field .fmeta, .proposal, .field .ferror, .emsg { grid-column: 1; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}

/* bookkeeping */
.stmt td { padding-top: 6px; padding-bottom: 6px; }
.stmt tr.sum td { font-weight: 600; }
.stmt tr.root td { font-weight: 700; background: var(--surface-2); }
.stmt .pos { padding-left: calc(12px + var(--d, 0) * 16px); }
.stmt .acc td { font-size: 12px; color: var(--muted); padding-top: 2px; padding-bottom: 2px; border-bottom: 0; }
.stmt .acc .pos { padding-left: calc(28px + var(--d, 0) * 16px); }
.stmt details summary { cursor: pointer; list-style: none; }
.stmt details summary::-webkit-details-marker { display: none; }
.chk { list-style: none; margin: 0; padding: 0; }
.chk li { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.chk li:last-child { border-bottom: 0; }
.chk .ico { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.chk .ok .ico { background: var(--ok-soft); color: var(--ok); }
.chk .info .ico { background: var(--primary-soft); color: var(--primary); }
.chk .warning .ico { background: var(--warn-soft); color: var(--warn); }
.chk .error .ico { background: var(--danger-soft); color: var(--danger); }
.chk .t { font-weight: 600; font-size: 13px; }
.chk .d { font-size: 12px; color: var(--muted); }
.years { display: flex; gap: 6px; flex-wrap: wrap; }
.years a { padding: 3px 10px; border-radius: 999px; background: var(--sunken); color: var(--muted); font-size: 12px; font-weight: 600; }
.years a.active { background: var(--primary); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.acc-row.unmapped td { background: var(--danger-soft); }
.map-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.map-form input[name=concept] { min-width: 260px; flex: 1; }
.state-ok { color: var(--ok); } .state-differs { color: var(--warn); } .state-pending { color: var(--primary); } .state-new { color: var(--muted); }
.kpis .tile .value { font-size: 22px; white-space: nowrap; }

/* Public documentation pages (/developers/, /privacy/) */
.pub-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px;
  padding: 12px max(16px, calc((100vw - 1180px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.pub-header .brand { padding: 0; }
.pub-nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pub-nav a { padding: 6px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 550; }
.pub-nav a:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.pub-nav a.active { background: var(--primary-soft); color: var(--primary); }
.pub-nav .pub-signin { margin-left: 8px; border: 1px solid var(--line-strong); color: var(--ink); }
.pub-wrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; max-width: 1180px;
  margin: 0 auto; padding: 32px 16px 64px; }
.pub-wrap:not(:has(.pub-toc)) { grid-template-columns: minmax(0, 860px); }
.pub-toc { position: sticky; top: 24px; align-self: start; font-size: 13px; }
.pub-toc ul { list-style: none; margin: 0; padding: 0; }
.pub-toc > .toc > ul > li > a { display: none; }  /* the page title */
.pub-toc li a { display: block; padding: 4px 8px; border-radius: var(--radius-sm); color: var(--muted); }
.pub-toc li a:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.prose { font-size: 15px; line-height: 1.65; max-width: 860px; min-width: 0; }
.prose h1 { font-size: 30px; margin: 0 0 16px; }
.prose h2 { font-size: 21px; margin: 40px 0 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.prose h3 { font-size: 16px; margin: 28px 0 8px; }
.prose p, .prose ul, .prose ol, .prose blockquote { margin: 0 0 14px; }
.prose code { font-family: var(--mono); font-size: 0.86em; background: var(--sunken); padding: 1px 5px; border-radius: 4px; }
.prose pre { background: #18212d; color: #e8ecf1; padding: 14px 16px; border-radius: var(--radius); overflow-x: auto;
  font-size: 13px; line-height: 1.5; margin: 0 0 16px; }
.prose pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 650; background: var(--surface-2); }
.prose blockquote { border-left: 3px solid var(--primary); background: var(--primary-soft); padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose blockquote p:last-child { margin: 0; }
.placeholder { background: var(--warn-soft); color: var(--warn); padding: 0 4px; border-radius: 4px; font-weight: 600; }
@media (max-width: 860px) {
  .pub-wrap { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 20px; }
  .pub-toc { display: none; }
  .prose h1 { font-size: 24px; }
}

/* Language switch */
.lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.lang-switch button { all: unset; cursor: pointer; padding: 2px 8px; font-size: 11.5px; font-weight: 650; color: var(--muted); }
.lang-switch button:hover { background: var(--sunken); color: var(--ink); }
.lang-switch button.active { background: var(--primary-soft); color: var(--primary); }
.lang-switch button:focus-visible { box-shadow: var(--focus); }

/* assistant */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.chat-q { align-self: flex-end; max-width: 82%; padding: 9px 12px; border-radius: 12px; background: var(--primary-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-q .meta { display: block; font-size: 12px; color: var(--faint); margin-top: 4px; white-space: normal; }
.chat-a { max-width: 92%; line-height: 1.55; overflow-wrap: anywhere; }
.chat-a p, .chat-a ul, .chat-a ol { margin: 0 0 8px; }
.chat-a ul, .chat-a ol { padding-left: 20px; }
.chat-a code { font-family: var(--mono); font-size: 0.88em; background: var(--sunken); padding: 1px 4px; border-radius: 4px; }
.chat-steps { list-style: none; margin: 0; padding: 0; color: var(--muted); }
.chat-steps li { display: flex; gap: 6px; align-items: baseline; }
.chat-steps .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; transform: translateY(-1px); }
.chat-steps .error .dot { background: var(--danger); }
.chat-draft { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px 12px; max-width: 92%; }
.chat-draft .pre { white-space: pre-wrap; margin-top: 4px; }
.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-list li { padding: 9px 16px; border-top: 1px solid var(--line); }
.conv-list li:first-child { border-top: 0; }
.conv-list li.active { background: var(--primary-soft); }
