/* KSeF workspace. Canonical Serhard fonts, palettes, icons and status tokens come from packages/brand.
   Reference lock: docs/design/refero-workspace.md. App layout stays here; shared primitives stay in packages/ui-react. */
.wrap { max-width: 1040px; }
main { padding-bottom: var(--space-14); }
h1 { font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.05; letter-spacing: -0.03em; margin: var(--space-4) 0 var(--space-2); }
h2 { font-size: 1.15rem; margin: 0 0 var(--space-3); letter-spacing: -0.03em; }
h3 { font-size: 1.05rem; margin: 0; letter-spacing: -0.03em; }
.lede { color: var(--ink-soft); max-width: 60ch; margin: 0 0 var(--space-8); }

.tools { display: flex; align-items: center; gap: var(--space-4); }
button { font: inherit; cursor: pointer; }
button.link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 0.18em; font-size: 0.95rem; }
.btn { border: 0; padding: 10px 18px; font-size: 0.95rem; }
.btn-line { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; background: var(--sheet); color: var(--ink); border: 1px solid var(--control-border); border-radius: var(--radius-md); padding: 9px 16px; font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer; }
.btn-line:hover { border-color: var(--ink-soft); }
.btn.danger { background: var(--flag); color: var(--sheet); }

label { display: grid; gap: 4px; font-size: 0.88rem; font-weight: 600; color: var(--ink-soft); min-width: 0; }
input, select {
  font: inherit; font-size: 1rem; font-weight: 400; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--control-border); border-radius: var(--radius-md); padding: 8px 10px; min-height: 42px; max-width: 100%;
}
input:hover, select:hover { border-color: var(--ink-soft); }
label.check { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; color: var(--ink); }
label.check input { min-height: 0; width: 18px; height: 18px; }
form { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; }

.bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: var(--space-6); margin-bottom: var(--space-6); }
.amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.panel, .ob { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: var(--space-4); }
.panel { margin-bottom: var(--space-10); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid .wide { grid-column: 1 / -1; }
.grid .btn { justify-self: start; }
.grid select { width: 100%; min-width: 0; }
/* A file input's built-in button and file name would otherwise set the column's minimum width. */
.grid input[type=file] { min-width: 0; }

.ob-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); }
.ob-head .amount { font-size: 1.15rem; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin: 6px 0 var(--space-3); color: var(--muted); font-size: 0.92rem; }
.st { font-weight: 600; font-size: 0.82rem; border: 1px solid currentColor; border-radius: 999px; padding: 2px 9px; }
.st-paid { color: var(--match); background: color-mix(in srgb, var(--match) 8%, var(--sheet)); }
.st-overdue { color: var(--flag); background: var(--flag-bg); }
.st-due { color: var(--ink); }
.st-partial { color: var(--warn); background: var(--warn-bg); }
.note { margin: 0 0 var(--space-3); color: var(--ink-soft); }
details { margin-top: var(--space-3); border-top: 1px solid var(--row-rule); padding-top: var(--space-3); }
summary { cursor: pointer; font-weight: 600; font-size: 0.92rem; color: var(--ink-soft); }
details[open] summary { margin-bottom: var(--space-3); }
details form .btn { align-self: end; }

.error { border: 1px solid var(--flag); background: var(--flag-bg); color: var(--ink); border-radius: var(--radius-md); padding: 12px 14px; }
.empty { color: var(--muted); }
.empty-panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: var(--space-6); }
.export { margin-top: var(--space-8); font-size: 0.95rem; }
.signin { padding-block: var(--space-10) var(--space-18); }

@media (max-width: 640px) {
  .wrap { padding-left: max(var(--space-4), env(safe-area-inset-left, 0px)); padding-right: max(var(--space-4), env(safe-area-inset-right, 0px)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .panel, .ob { padding: 16px; }
  form > label { flex: 1 1 100%; }
  form > label.check { flex: 1 1 100%; }
}
.providers { max-width: 360px; }

/* Revenue register (B2) */
.st-late { color: var(--flag); }
.changed { border-left: 3px solid var(--flag); padding-left: var(--space-3); }
.st-verify { color: var(--warn); background: var(--warn-bg); }
.lp { color: var(--muted); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-6); margin: 0 0 var(--space-2); font-size: 0.92rem; }
.facts dt { color: var(--muted); font-size: 0.82rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts .ksef { font-family: var(--font-mono); font-size: 0.82rem; }
.table-scroll { overflow-x: auto; }
.sums { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.sums th, .sums td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--row-rule); }
.sums thead th { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.sums tfoot th, .sums tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--rule); }
.sums .num { text-align: right; }
.sums .unpriced td { color: var(--muted); }
.sums td:first-child { white-space: nowrap; }
.panel .error { margin: 0 0 var(--space-3); }
.rules ul { margin: 0; padding-left: 1.2em; display: grid; gap: var(--space-3); }
.meta-line { color: var(--muted); font-size: 0.85rem; }
@media (max-width: 640px) {
  .facts { grid-template-columns: 1fr; }
  .sums th, .sums td { padding: 6px 6px; }
}
.payments { list-style: none; padding: 0; margin: 0; }
/* Checks (B6) */
.check-row { display: grid; gap: 4px; padding: var(--space-2) 0; border-bottom: 1px solid var(--row-rule); }
form.inline { display: inline; }
/* Invoices (milestone 5) */
.plain { list-style: none; padding: 0; margin: 0 0 var(--space-3); display: grid; gap: var(--space-2); }
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 22px; margin-bottom: var(--space-6); }
.sheet h2 { font-size: 1.4rem; margin: 2px 0 0; }
.sheet h3 { font-size: 0.85rem; color: var(--muted); margin: 0 0 4px; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); margin-bottom: var(--space-4); overflow-wrap: anywhere; }
.parties p { margin: 0; }
.lines tr.before td { color: var(--muted); }
.due { font-size: 1.1rem; margin: var(--space-4) 0 var(--space-2); }
.muted { color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
fieldset { border: 1px solid var(--row-rule); border-radius: var(--radius-md); padding: var(--space-3); margin: 0; min-width: 0; }
legend { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); padding: 0 4px; }
fieldset.line { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
fieldset.line .wide { grid-column: 1 / -1; }
.invoice-form input:not([type=checkbox]):not([type=radio]), .invoice-form select { width: 100%; min-width: 0; }
fieldset.choice { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); }
.history li { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .parties { grid-template-columns: 1fr; }
  fieldset.line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet { padding: 16px; }
}
/* KSeF verification code: the SVG keeps its own white background and black modules in both themes, so it scans. */
.ksef-qr { margin: 16px 0 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.ksef-qr svg { width: 40mm; height: auto; max-width: 100%; }
.ksef-qr figcaption { display: flex; flex-direction: column; gap: 2px; }
.ksef-qr .code { overflow-wrap: anywhere; }
.error .code { overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media print {
  .site-head, .noprint, .sections { display: none; }
  .table-scroll { overflow: visible; }
  .sheet { border: 0; padding: 0; }
}
.code { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }
.decl th { font-weight: 400; }
.decl tr.key th, .decl tr.key td { font-weight: 600; }
.acct { font-family: var(--font-mono); font-size: 0.88rem; overflow-wrap: anywhere; }
.ob.past h3, .ob.past .meta { color: var(--muted); }

/* App shell: a full-height sidebar (brand, sections, inbox) beside a slim top bar and the page.
   Without JavaScript the sidebar works as is; on narrow screens a checkbox toggle opens it as a sheet. */
.workspace {
  max-width: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  align-items: start;
  background: var(--sheet);
  font-size: .9375rem;
  --workspace-accent: var(--focus);
  --workspace-selection: color-mix(in srgb, var(--workspace-accent) 9%, var(--sheet));
}
.menu-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.workspace > .app-head {
  grid-column: 2; grid-row: 1;
  justify-content: flex-end;
  min-height: 60px;
  background: var(--sheet);
  padding-inline: clamp(16px, 2.5vw, 32px);
  border-bottom: 1px solid var(--rule);
}
.workspace > .app-head::before { inset: 0; }
.app-head .brand { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.app-name { color: var(--ink); font-size: 1rem; font-weight: 800; line-height: 1; padding-inline-start: var(--space-3); border-inline-start: 1px solid var(--rule); }
.tools { display: flex; align-items: center; gap: var(--space-2); }
/* Top-bar controls use the shared .head-control size and look (brand, decision 0042). The bar is a sheet, so hover fills with paper. */
.tools { gap: 2px; }
.app-head :is(.head-control, .appearance summary, .lang-picker):hover, .app-head .appearance[open] summary, .app-head details[open] > summary.head-control { background: var(--paper); }
.tools .appearance { margin-inline-start: 2px; }
.workspace > .app-head > .brand, .workspace .menu-button { display: none; }
.account-menu { position: relative; margin: 0; padding: 0; border: 0; }
.account-menu > summary { margin: 0; list-style: none; }
.account-menu[open] > summary { margin-bottom: 0; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-actions {
  position: absolute; z-index: 25; inset-inline-end: 0; top: calc(100% + 6px);
  min-width: max-content; padding: 6px;
  border: 1px solid var(--control-border); border-radius: var(--radius-md); background: var(--sheet);
  box-shadow: var(--shadow-panel);
}
.account-actions form { display: block; }
.account-actions .link { width: 100%; min-height: 44px; padding: 6px 10px; text-decoration: none; text-align: start; }
.account-actions .link:hover { background: var(--paper); border-radius: var(--radius-md); }
.skip-content { position: fixed; z-index: 30; inset: 10px auto auto 10px; padding: 10px 14px; background: var(--sheet); color: var(--ink); }
.skip-content:not(:focus) { clip-path: inset(50%); }

.workspace > .sections {
  grid-column: 1; grid-row: 1 / span 2;
  position: sticky; top: 0;
  height: 100vh; height: 100dvh; box-sizing: border-box;
  display: flex; flex-direction: column; gap: var(--space-5, 20px);
  overflow-y: auto;
  padding: 18px 12px 20px;
  background: var(--paper);
  border-inline-end: 1px solid var(--rule);
  z-index: 1;
}
/* The sidebar's sheet runs the full height of the window, however long the page is. */
.workspace::before { content: ""; position: fixed; inset: 0 auto 0 0; width: 232px; z-index: 0; pointer-events: none; background: var(--paper); border-inline-end: 1px solid var(--rule); }
.nav-brand { display: inline-flex; align-items: center; gap: var(--space-3); min-height: 32px; padding: 0 10px; margin: 0 0 var(--space-2); text-decoration: none; }
.nav-brand img { height: 26px; width: auto; }
.nav-group p { margin: 0 0 4px; padding-inline: 10px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.nav-group ul, .workspace-utilities { display: grid; gap: 1px; margin: 0; padding: 0; list-style: none; }
.workspace-utilities { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--rule); }
.sections li a {
  display: flex; align-items: center; gap: 10px;
  min-height: 36px; padding: 7px 10px;
  border-radius: var(--radius-md);
  text-decoration: none; color: var(--ink-soft);
  font-size: .85rem; font-weight: 400; line-height: 1.35;
}
.sections li a .icon { order: -1; flex: none; width: 17px; height: 17px; color: var(--muted); }
.sections li a:hover { background: var(--sheet); color: var(--ink); }
.sections li a[aria-current] { background: var(--workspace-selection); color: var(--ink); font-weight: 600; }
.sections li a[aria-current] .icon { color: var(--workspace-accent); }

.workspace > main {
  grid-column: 2; grid-row: 2;
  min-width: 0; width: 100%; max-width: 1360px; box-sizing: border-box;
  padding: var(--space-8) clamp(16px, 2.5vw, 32px) var(--space-14);
}
.workspace > main[aria-busy="true"] { cursor: progress; }
.workspace > main > h1:first-child, .dashboard-head h1 { margin-top: 0; }
.workspace > main h1 { font-size: clamp(1.5rem, 2vw, 1.8rem); line-height: 1.15; letter-spacing: -0.035em; margin: 0 0 var(--space-2); }
.workspace > main > h1 + .lede, .workspace > main > h1 + details + .lede { margin-bottom: var(--space-6); }
.workspace .lede { font-size: .9375rem; line-height: 1.6; }

.signin { display: grid; justify-items: center; }
.signin-card { width: min(100%, 35rem); padding: clamp(20px, 5vw, 44px); background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); }
.signin h1 { margin-top: 0; }
.signin-card > :last-child { margin-bottom: 0; }

/* Shared surfaces for every workspace page: one quiet sheet per topic, lists inside sheets as rows. */
.workspace .panel { padding: 20px 22px; margin-bottom: var(--space-6); }
.workspace .panel > h2:first-child, .workspace .sheet > h2:first-child { padding-bottom: var(--space-3); margin-bottom: var(--space-4); border-bottom: 1px solid var(--row-rule); }
.workspace .panel > h2 + p:not(.error) { margin-top: 0; color: var(--ink-soft); }
.workspace .panel > :last-child { margin-bottom: 0; }
.workspace main > form:not(.invoice-form) { margin-bottom: var(--space-6); }
.workspace .btn { min-height: 44px; padding: 10px 18px; font-size: .95rem; }
.workspace .btn .icon, .workspace .btn-line .icon { width: 17px; height: 17px; }
.workspace summary { min-height: 32px; display: flex; align-items: center; gap: 6px; width: fit-content; }

/* A run of cards (calendar, VAT, checks, register entries) reads as one grouped list. */
.workspace .ob { padding: 16px 20px; }
.workspace .ob:has(+ .ob) { margin-bottom: 0; border-end-start-radius: 0; border-end-end-radius: 0; }
.workspace .ob + .ob { border-top-color: var(--row-rule); border-start-start-radius: 0; border-start-end-radius: 0; margin-top: -1px; }
.workspace .ob .ob-head h3 { font-size: 1rem; }

/* Tables (server-rendered and React) share one compact density. */
.sums thead { background: var(--paper); }
.sums th, .sums td { padding: 10px 12px; }
.sums tbody tr:last-child td { border-bottom: 0; }
.workspace .sh-table th, .workspace .sh-table td { padding: 11px 12px; }
.workspace .sh-table th { font-weight: 600; }
.workspace .sh-table tbody tr:hover td { background: var(--paper); }
/* Stat groups read as one ruled strip, like the dashboard totals: one border, hairlines between figures, no card in a card.
   Each figure draws its right and bottom hairline; the strip's own border and overflow clip the outer ones. */
.workspace :is(.invoice-stats, .register-stats, .calendar-stats, .ryczalt-stats, .unpaid-stats) { gap: 0; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--sheet); overflow: hidden; }
.workspace :is(.invoice-stats, .register-stats, .calendar-stats, .ryczalt-stats, .unpaid-stats) > .sh-stat { border: 0; border-radius: 0; background: transparent; box-shadow: 1px 0 0 var(--rule), 0 1px 0 var(--rule); }
.workspace .sh-stat { background: var(--sheet); padding: 18px 20px; }
/* Stat figures are amounts: mono, never split mid-number; the row wraps to fewer columns instead. */
.workspace .sh-stat strong { font-family: var(--font-mono); overflow-wrap: normal; white-space: nowrap; font-size: clamp(1.1rem, .7rem + 1vw, 1.6rem); }
@media (min-width: 651px) { .workspace :is(.invoice-stats, .register-stats, .calendar-stats, .ryczalt-stats) { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); } }
.workspace .sh-table td .sh-button-ghost { justify-content: flex-start; text-align: start; padding-inline: 0; min-height: 36px; }
.table-scroll { max-width: 100%; }
.inv-list th { white-space: nowrap; }
.invoice-list-panel { padding: 0; overflow: hidden; }
.invoice-list-panel h2 { margin: 0; padding: var(--space-4); }
.workspace .invoice-list-panel > h2:first-child { padding: var(--space-4) 18px; margin: 0; }
.invoice-list-panel .empty { margin: 0; padding: var(--space-4); border-top: 1px solid var(--rule); }
.invoice-setup-links { margin: 0 0 var(--space-4); }
.invoice-setup-links a { min-height: 44px; display: inline-flex; align-items: center; }

/* Taxes and contributions: month stepper, totals, and the month's obligations as a ledger. */
.dashboard-head { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-6); }
.dashboard-head > div:first-child { flex: 1 1 24rem; }
.dashboard-head .lede { margin: 0; max-width: 52ch; }
.head-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.period-overview { margin-bottom: var(--space-8); }
.period-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-3); }
.month-bar { display: flex; align-items: center; gap: var(--space-2); }
/* One segmented control: previous, the month, next. */
.month-nav { display: inline-flex; align-items: center; height: 44px; border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--sheet); }
.month-nav h2 { margin: 0; padding: 0 var(--space-3); min-width: 9.5rem; text-align: center; font-size: .95rem; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.month-step { display: inline-grid; place-items: center; width: 44px; height: 44px; margin: -1px; border-radius: var(--radius-md); color: var(--ink-soft); }
.month-step:hover { background: var(--paper); color: var(--ink); }
.month-step .icon { width: 16px; height: 16px; }
.month-step.back .icon { transform: scaleX(-1); }
.period-head form.month { gap: var(--space-2); align-items: center; }
.period-head form.month input, .period-head form.month .btn-line { min-height: 40px; }
/* A single summary strip: comparable figures share a baseline and neutral dividers. */
.metrics { display: grid; grid-template-columns: 1.35fr repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--sheet); overflow: hidden; }
.metrics > div { min-width: 0; padding: 20px; background: var(--sheet); border: 0; border-inline-end: 1px solid var(--rule); border-radius: 0; }
.metrics > div:last-child { border-inline-end: 0; }
.metrics > .metric-lead { background: var(--paper); }
.metrics dt { display: flex; align-items: center; gap: 7px; font-size: .85rem; color: var(--ink-soft); font-weight: 600; line-height: 1.3; }
.metrics dt .icon { flex: none; }
.metrics dd { margin: 10px 0 0; color: var(--ink); font-family: var(--font-mono); font-size: clamp(1.1rem, 1.6vw, 1.4rem); font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metrics .metric-lead dd { font-size: clamp(1.25rem, 2vw, 1.7rem); }
.metric-note { margin: 8px 0 0; color: var(--ink-soft); font-size: .85rem; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--paper); border: 1px solid var(--row-rule); font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
.metrics .metric-alert dt, .metrics .metric-alert dd, .metrics .metric-alert .metric-note { color: var(--flag); }
.metrics .metric-note.amount { font-weight: 600; }

/* The status card reports what the tiles mean; static here (no entrance animation in a workspace that swaps pages). */
.period-head .toast { margin: 0 0 0 auto; padding: 8px 0; animation: none; box-shadow: none; border: 0; background: transparent; max-width: 22rem; font-size: .85rem; }
/* The status line's mark is a tinted dot in its tone, not a box (a box reads as a checkbox). */
.period-head .toast-icon { width: 28px; height: 28px; border: 0; border-radius: 999px; background: color-mix(in srgb, currentColor 13%, transparent); }
.period-head .toast-icon .icon { width: 15px; height: 15px; }
.toast-flag .toast-icon { color: var(--flag); }
.toast-due .toast-icon { color: var(--ink); }
.month-jump { margin: 0; padding: 0; border: 0; position: relative; }
.month-jump > summary { padding: 0; width: 44px; border-color: var(--rule); background: var(--sheet); }
.month-jump > summary::-webkit-details-marker { display: none; }
.month-jump[open] > summary { margin: 0; }
.month-jump form { position: absolute; z-index: 5; inset-inline-end: 0; max-width: calc(100vw - 2 * var(--space-4)); flex-wrap: wrap; top: calc(100% + 6px); display: flex; flex-wrap: nowrap; align-items: center; gap: var(--space-2); width: max-content; padding: var(--space-3); background: var(--sheet); border: 1px solid var(--control-border); border-radius: var(--radius-md); box-shadow: var(--shadow-panel); }
.month-jump form label { display: block; }
.month-jump form .btn-line { white-space: nowrap; min-height: 40px; }
.month-jump form input { min-height: 40px; }

/* Status tabs filter the ledger in place, without scripts (radio inputs + :has). Underlined, with counts. */
.ledger-tabs { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.tab-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tab { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 2px; border-bottom: 2px solid transparent; color: var(--ink-soft); font-size: .92rem; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab-count { min-width: 1.5em; padding: 0 6px; border-radius: 999px; background: var(--paper); border: 1px solid var(--row-rule); font: 600 .75rem/1.6 var(--font-mono); text-align: center; color: var(--muted); }
.tab-input:checked + .tab { color: var(--ink); border-bottom-color: var(--ink); }
.tab-input:checked + .tab .tab-count { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tab-input:focus-visible + .tab { outline: 3px solid var(--focus); outline-offset: 2px; }
.obligations:has(#ledger-due:checked) .ob-ledger > li:not(:has(.st-row-due)),
.obligations:has(#ledger-overdue:checked) .ob-ledger > li:not(:has(.st-row-overdue)),
.obligations:has(#ledger-paid:checked) .ob-ledger > li:not(:has(.st-row-paid)) { display: none; }

.obligations { margin-bottom: var(--space-8); }
.obligations > h2 { margin: 0 0 var(--space-2); }
/* Brand v3 section markers (decision 0041): a mono address and a rule above the section heading. */
.workspace .marker { margin-bottom: var(--space-3); }
.obligations-head { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-3); border-bottom: 1px solid var(--rule); }
.obligations-head .add-shortcut { margin-bottom: 8px; margin-inline-start: auto; }
.add-shortcut { min-height: 40px; }
.dashboard-head.backdrop { padding-block: var(--space-2); }
/* The brand backdrop spans the window on centred pages; in the workspace it stays inside the page column. */
.workspace > main { overflow-wrap: anywhere; }
.workspace .backdrop::before { inset: calc(-1 * var(--space-8)) calc(-1 * clamp(16px, 3vw, 40px)) -40px; }
.workspace .backdrop::after { top: -320px; width: 100%; height: 620px; }
.ob-ledger, .ob-ledger-head { --ob-ledger-cols: minmax(0, 2.2fr) minmax(5.5rem, .8fr) minmax(7.5rem, 1fr) minmax(6rem, .7fr) minmax(9.5rem, auto); }
.ob-ledger-head { display: grid; grid-template-columns: var(--ob-ledger-cols); gap: var(--space-3); padding: 0 18px 6px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.ob-ledger-head span:nth-child(3) { text-align: end; }
.ob-ledger { list-style: none; margin: 0; padding: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.ob-ledger > li + li { border-top: 1px solid var(--row-rule); }
.ob-ledger .obligation { margin: 0; padding: 0; border: 0; border-radius: 0; background: none; }
.ob-ledger .obligation > summary {
  display: grid; grid-template-columns: var(--ob-ledger-cols); align-items: center; gap: var(--space-3);
  width: auto; min-height: 60px; padding: 10px 18px; margin: 0;
  list-style: none; cursor: pointer; color: var(--ink); font-weight: 400; font-size: .95rem;
}
.ob-ledger .obligation > summary::-webkit-details-marker { display: none; }
.ob-ledger .obligation > summary:hover { background: color-mix(in srgb, var(--brand) 3%, var(--sheet)); }
.ob-ledger .obligation[open] > summary { background: var(--paper); margin: 0; }
.ob-what { display: grid; min-width: 0; }
.ob-kind { font-weight: 700; }
.ob-note { color: var(--ink-soft); font-size: .88rem; overflow-wrap: anywhere; }
.ob-due { display: grid; color: var(--ink-soft); font-size: .9rem; white-space: nowrap; }
.ob-paid, .ob-rel { color: var(--muted); font-size: .8rem; }
.st-row-overdue .ob-rel { color: var(--flag); }
.ob-ledger .amount { text-align: end; font-weight: 600; font-size: 1rem; }
.ob-status .st { display: inline-block; }
.ob-open { justify-self: end; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; color: var(--ink); font-weight: 600; font-size: .9rem; white-space: nowrap; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: .25em; }
.st-row-paid .ob-open { color: var(--ink-soft); }
.ob-ledger .obligation > summary:hover .ob-open { text-decoration-color: currentColor; }
.ob-open .icon { width: 15px; height: 15px; transition: transform .15s; }
.obligation[open] .ob-open .icon { transform: rotate(90deg); }
.st-row-overdue .ob-due time { color: var(--flag); font-weight: 600; }
.ob-ledger .ob-actions { margin: 0; padding: var(--space-4) 18px; border-top: 1px solid var(--row-rule); background: var(--paper); display: grid; gap: var(--space-2); }
.ob-primary { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-3); }
.ob-primary form { align-items: end; }
.ob-ledger .ob-actions details { margin: 0; padding-top: var(--space-2); border-top: 1px solid var(--rule); }
.ob-ledger .ob-actions details[open] form { margin-top: var(--space-2); }
.add-obligation .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.add-obligation input, .add-obligation select { width: 100%; }
.add-obligation h2 { scroll-margin-top: var(--space-3); }
/* With scripts, the add form lives in the shared dialog and the shortcut beside the list opens it. */
.workspace .add-obligation:has(> .btn-line[aria-haspopup]):not(:has(form)) { display: none; }

/* Rules used: folded by default, so the figures lead each page. */
.workspace details.rules { padding: 0; }
.workspace details.rules > summary { width: auto; min-height: 56px; padding: 0 22px; list-style: none; justify-content: space-between; }
.workspace details.rules > summary::-webkit-details-marker { display: none; }
.workspace details.rules > summary h2 { margin: 0; font-size: 1rem; }
.workspace details.rules > summary::after { content: "+"; font: 600 1.2rem/1 var(--font-sans); color: var(--ink-soft); }
.workspace details.rules[open] > summary { border-bottom: 1px solid var(--row-rule); margin: 0; }
.workspace details.rules[open] > summary::after { content: "−"; }
.workspace details.rules > ul { padding: 16px 22px 20px 2.6em; margin: 0; font-size: .95rem; }
details.rules { margin-top: 0; border-top: 1px solid var(--rule); }

/* A filter form right under the page title (year, period, month) reads as one compact toolbar. */
.workspace main :is(form.month, form.bar[method="get"]):not(.period-head form):not(.panel form) { display: inline-flex; flex-wrap: nowrap; align-items: end; gap: var(--space-2); padding: 0; background: none; border: 0; }
.workspace main :is(form.month, form.bar[method="get"]):not(.period-head form):not(.panel form) input[type=number] { width: 7.5rem; }
.workspace main :is(form.month, form.bar[method="get"]):not(.period-head form):not(.panel form) input[type=month] { width: 11rem; }
.workspace main :is(form.month, form.bar[method="get"]):not(.period-head form) label { font-size: .8rem; }
.workspace main :is(form.month, form.bar[method="get"]):not(.period-head form) :is(input, select, .btn-line) { min-height: 40px; }
.workspace main :is(form.month, form.bar[method="get"]) .btn-line { flex: none; white-space: nowrap; }

/* Server-paged document lists (VAT): search, sort and pages on one line. */
.document-toolbar { justify-content: start; gap: var(--space-3); margin: 0 0 var(--space-3); }
.document-toolbar input[type=search] { min-width: min(100%, 18rem); }
.document-toolbar :is(input, select) { min-height: 40px; }
.document-footer { justify-content: start; align-items: center; gap: var(--space-2); margin: var(--space-3) 0 var(--space-8); font-size: .9rem; color: var(--ink-soft); }
.document-footer > span { margin-inline-end: auto; }
.document-footer .btn-line { min-height: 40px; }

/* Monthly close checklist and notification filters. */
.close-state { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); }
.close-list { list-style: none; margin: 0; padding: 0; }
.close-list li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); min-height: 48px; border-top: 1px solid var(--row-rule); }
.close-list a { font-weight: 600; }
.activity-filter { justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.tabs { display: inline-flex; gap: var(--space-4); border-bottom: 1px solid var(--rule); }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--ink-soft); font-weight: 600; font-size: .92rem; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { color: var(--ink); border-bottom-color: var(--ink); }

/* Saved views (client/saved-views.ts) and the table page size sit as small controls, not full-width fields. */
.saved-views { margin: 0 0 var(--space-4); padding: 0; border: 0; }
.saved-views > summary { display: inline-flex; min-height: 36px; padding: 6px 12px; border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--sheet); font-size: .88rem; }
.saved-views[open] > summary { margin-bottom: var(--space-2); }
.saved-views .bar { justify-content: start; gap: var(--space-2); margin: 0; padding: var(--space-3); background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.saved-views .bar :is(select, input) { min-height: 40px; }
.saved-views .bar .btn-line { min-height: 40px; }
.page-size.sh-field { display: inline-flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4); font-size: .85rem; }
.page-size.sh-field select { width: auto; min-height: 36px; padding: 4px 8px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-6); }
.page-actions .note { margin: 0; }
.workspace main > .lede { margin-bottom: var(--space-6); }

/* Language switcher, dialogs and small pieces kept from the earlier workspace. */
.workspace-language { display: grid; }
.workspace-language [hidden], .lang-link[hidden], .lang-picker[hidden] { display: none; }
/* The partial-translation note stays for screen readers and as the picker's tooltip; shown, it would break the top bar onto two rows. */
.workspace-language { position: relative; }
.workspace-language small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sh-dialog .add-obligation { border: 0; margin: 0; padding: 0; }
.sh-dialog .grid { min-width: 0; }
.sh-dialog .grid > button { justify-self: end; grid-column: 1 / -1; }
.sh-dialog .grid > label { min-width: 0; }
.sh-dialog .grid > label > :is(input:not([type=checkbox]):not([type=radio]), select, textarea) { width: 100%; min-width: 0; }
.sh-dialog.invoice-editor-dialog { width: min(56rem, calc(100vw - 2rem)); }
.sh-dialog-header { background: var(--sheet); position: sticky; top: 0; z-index: 2; }
.sh-progress-indicator { background: var(--brand); }
[data-action-error] { white-space: pre-line; }
[data-document-list] > [hidden] { display: none; }
.check-row > .st { justify-self: start; display: inline-flex; align-items: center; gap: .35rem; border: 0; border-radius: 6px; }
.check-row > .st .icon { width: 14px; height: 14px; }
.check-row > .st.st-due { background: var(--paper); color: var(--ink-soft); }
.check-row > .st.st-warn { background: var(--warn-bg); color: var(--warn); }
.check-row > .st.st-late { background: var(--flag-bg); }

@media screen and (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics > div:nth-child(2) { border-inline-end: 0; }
  .metrics > div:nth-child(n+3) { border-top: 1px solid var(--rule); }
}
@media screen and (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; }
  .workspace > .app-head { grid-column: 1; justify-content: space-between; gap: var(--space-2); }
  .workspace > .app-head > .brand { display: inline-flex; margin-right: auto; }
  .workspace::before { display: none; }
  .workspace .menu-button { display: inline-flex; }
  .menu-button .when-open, .menu-toggle:checked ~ .app-head .menu-button .when-closed { display: none; }
  .menu-toggle:checked ~ .app-head .menu-button .when-open { display: inline; }
  .menu-toggle:focus-visible ~ .app-head .menu-button { outline: 3px solid var(--focus); outline-offset: 2px; }
  .workspace > .sections {
    display: none;
    grid-column: 1; grid-row: 2;
    position: static; height: auto;
    border-bottom: 1px solid var(--rule); background: var(--sheet);
    padding: var(--space-3) var(--space-4) var(--space-4);
  }
  .menu-toggle:checked ~ .sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
  .nav-brand { display: none; }
  .workspace-utilities { margin-top: 0; padding-top: 0; border-top: 0; }
  .workspace > main { grid-column: 1; grid-row: 3; padding-top: var(--space-6); }
}
@media screen and (max-width: 740px) {
  /* With the first figure spanning the row, an even count leaves one alone at the end: let it span too. */
  .workspace :is(.register-stats, .calendar-stats, .ryczalt-stats) > .sh-stat:last-child:nth-child(even) { grid-column: 1 / -1; }
  .ob-ledger-head { display: none; }
  .ob-ledger .obligation > summary { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "what amount" "due status" "open open"; row-gap: 6px; padding: 14px 16px; }
  .ob-what { grid-area: what; } .ob-due { grid-area: due; } .ob-ledger .amount { grid-area: amount; }
  .ob-status { grid-area: status; justify-self: end; }
  .ob-open { grid-area: open; justify-self: start; min-height: 40px; }
  .ob-due { display: flex; flex-wrap: wrap; gap: 0 var(--space-2); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
  .metrics > .metric-lead { grid-column: 1 / -1; border-inline-end: 0; }
  .metrics > div:nth-child(2) { border-top: 1px solid var(--rule); border-inline-end: 1px solid var(--rule); }
  .metrics > div:nth-child(3) { border-inline-end: 0; }
  .metrics > div:last-child { grid-column: 1 / -1; }
  .period-head .toast { margin: 0; order: 3; max-width: none; width: 100%; }
  .add-obligation .grid { grid-template-columns: minmax(0, 1fr); }
}
@media screen and (max-width: 520px) {
  .workspace > .app-head { padding-inline: 12px; gap: 4px; }
  .app-head .brand { gap: 7px; }
  .app-head .brand img { height: 22px; }
  .app-name { padding-inline-start: 7px; font-size: .88rem; }
  .tools { gap: 0; }
  .menu-button { padding-inline: 8px; }
  .menu-button > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .account-menu > summary { padding: 0; width: 44px; }
  .account-menu > summary span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .metrics > div { padding: 13px 14px; }
  .workspace .panel, .workspace .ob { padding: 16px; }
  .workspace .ob-ledger .obligation { padding: 0; }
  /* One row: the export becomes an icon button (its name stays for screen readers), the close fills the rest. */
  .head-actions { width: 100%; flex-wrap: nowrap; }
  .head-actions > .btn { flex: 1 1 auto; justify-content: center; }
  .export-all { flex: none; width: 44px; padding: 0; }
  .export-all .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .month-nav { flex: 1; justify-content: space-between; }
  /* The month picker opens under the whole month row, so it never runs off either edge. */
  .month-bar { position: relative; width: 100%; }
  .month-jump form label { flex: 1; } .month-jump form input { width: 100%; }
  .month-jump { position: static; }
  .month-jump form { inset-inline: 0; width: auto; max-width: none; }
  .month-nav h2 { min-width: 0; }
}
@media print {
  .workspace { display: block; }
  .skip-content, .menu-button, .menu-toggle { display: none; }
}


/* App chrome and compact controls use the same type, radii, focus and status roles as serhard-site. */
.workspace-location { display: flex; align-items: center; gap: 12px; min-width: 0; margin: 0 auto 0 0; font-size: .85rem; color: var(--muted); }
.workspace-location [data-workspace-title] { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-close { margin: -12px 0 0; padding: 0; list-style: none; }
.workspace .btn, .workspace .btn-line, .workspace .sh-button { font-size: .85rem; border-radius: var(--radius-md); }
.workspace .btn:not(.danger), .workspace .sh-button-primary { background: var(--brand); color: var(--on-brand); }
.workspace .btn:not(.danger):hover, .workspace .sh-button-primary:hover { background: var(--brand-hover); }
.workspace :is(.sh-button, .sh-table-scroll):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.workspace .sh-table th { background: var(--paper); font-size: .78rem; }
.workspace .sh-table td { border-color: var(--row-rule); padding-block: 16px; }
.workspace .sh-table td .amount { font-size: .85rem; }
.workspace .sh-table a { text-decoration: none; }
.workspace .sh-table a:hover { text-decoration: underline; }
.workspace .sh-badge { border-radius: var(--radius-md); }
.workspace .invoice-list-panel { padding: 0; }
.workspace .invoice-list-panel > h2:first-child { padding: 18px 20px; font-size: 1rem; }
.workspace .page-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.workspace .page-heading > div:first-child { flex: 1 1 18rem; }
.workspace .page-heading .lede { margin: 0; }
.workspace .page-heading .page-actions { margin: 0; }
.workspace .st { display: inline-flex; align-items: center; border: 0; border-radius: var(--radius-md); padding: 4px 8px; font-size: .75rem; }
.workspace .st-due { background: var(--paper); color: var(--ink-soft); }
.workspace .st-late { background: var(--flag-bg); color: var(--flag); }
.workspace .ob-kind { font-weight: 600; }
.workspace .sh-empty { padding-block: 56px; }
.sh-dialog-body .panel { margin-bottom: 0; }
.sh-dialog-header .sh-dialog-close { flex: none; }
@media (min-width: 961px) {
  .workspace > .app-head::before { display: none; }
  .workspace .app-head { flex-wrap: nowrap; }
}
@media (max-width: 960px) { .workspace-location { display: none; } }
@media (max-width: 650px) {
  .workspace .page-heading .page-actions { width: 100%; }
  .workspace .page-heading .page-actions > a:first-child { flex: 1 1 100%; }
  .workspace .sections li a { min-height: 44px; }
  .workspace .invoice-list-panel > h2:first-child { padding: 16px; }
}
@media print {
  .workspace { background: var(--sheet); }
  .workspace > main { max-width: none; padding: 0; }
}

/* Sign-in (Night Ledger): the form on the left, a sample panel on the right; one column below 900px. */
.signin-split { display: grid; grid-template-columns: minmax(0, 26rem) minmax(0, 1fr); gap: var(--space-14); align-items: center; justify-items: stretch; min-height: calc(100vh - 160px); padding-block: var(--space-14) var(--space-18); }
.signin-auth h1 { margin: 0 0 var(--space-3); font-size: 2.5rem; line-height: 1.1; font-weight: 600; letter-spacing: -0.035em; text-wrap: balance; }
.signin-auth .lede { margin: 0 0 var(--space-8); }
.signin-auth .notice { margin: 0 0 var(--space-4); }
.signin-auth .providers { max-width: none; gap: var(--space-3); margin-bottom: var(--space-6); }
.signin-auth .providers > a { min-height: 48px; }
.signin-other { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 14px 16px; background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius-lg); text-decoration: none; }
.signin-other:hover { border-color: var(--control-border); }
.signin-other > span:nth-child(2) { flex: 1; display: grid; gap: 2px; }
.signin-other strong { font-weight: 600; }
.signin-other > span:nth-child(2) > span { font-size: .84rem; color: var(--muted); }
.signin-other-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--row-rule); }
.signin-other .icon { width: 18px; height: 18px; }
.signin-other > .icon { color: var(--ink-soft); }

.signin-preview { position: relative; margin: 0; padding-bottom: 52px; }
.signin-preview.backdrop::before { inset: -96px -64px; }
.signin-preview.backdrop::after { top: -160px; width: 120%; height: 520px; }
.sample-panel { overflow: hidden; }
.sample-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--rule); }
.sample-head p { margin: 0; display: grid; }
.sample-head strong { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.sample-mono { font: 400 .8125rem/1.5 var(--font-mono); color: var(--muted); }
.sample-panel table { width: 100%; border-collapse: collapse; }
.sample-panel th, .sample-panel td { padding: 12px var(--space-6); text-align: left; border-bottom: 1px solid var(--row-rule); vertical-align: middle; }
.sample-panel td + td, .sample-panel th + th { padding-left: 0; }
.sample-panel thead th { font-size: .84rem; font-weight: 400; color: var(--muted); padding-block: 10px; }
.sample-panel tbody th { font-weight: 600; }
.sample-panel tbody th span { display: block; font: 400 .8125rem/1.5 var(--font-mono); color: var(--muted); }
.sample-panel tbody tr:last-child > * { border-bottom: 0; }
.sample-panel .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sample-state { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--radius-md); font: 600 .84rem/1.5 var(--font-mono); white-space: nowrap; }
.sample-state .icon { width: 14px; height: 14px; }
.sample-paid { color: var(--match); padding-inline: 0; }
.sample-inDays { color: var(--warn); background: var(--warn-bg); }
.sample-notPaid { color: var(--ink-soft); background: var(--sheet); }
.sample-overdue { color: var(--flag); background: var(--flag-bg); }
.sample-total { display: flex; justify-content: space-between; gap: var(--space-3); margin: 0; padding: var(--space-4) var(--space-6); background: var(--sheet); border-top: 1px solid var(--rule); }
.sample-total span { color: var(--ink-soft); }
.sample-total strong { font: 600 1rem/1.5 var(--font-mono); font-variant-numeric: tabular-nums; }
.signin-preview .toast { position: absolute; left: calc(-1 * var(--space-8)); bottom: 0; margin: 0; }

@media (max-width: 900px) {
  .signin-split { grid-template-columns: minmax(0, 1fr); gap: var(--space-10); min-height: 0; padding-block: var(--space-8) var(--space-14); }
  .signin-auth h1 { font-size: 2rem; }
  .signin-preview .toast { position: static; margin-top: var(--space-3); }
  .signin-preview { padding-bottom: 0; }
  .signin-preview.backdrop::before { inset: -48px -16px; }
  .signin-preview.backdrop::after { width: 100%; }
}
@media (max-width: 480px) {
  .sample-head, .sample-panel th, .sample-panel td, .sample-total { padding-inline: var(--space-4); }
  .sample-panel td + td, .sample-panel th + th { padding-left: 0; }
  .sample-panel th, .sample-panel td { padding-right: var(--space-2); }
}
