/* Mercevar. The model is the tax form itself: boxed fields with shared rules,
   line numbers in a tinted gutter, Kennzahlen as boxed numerals. */

@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(/static/fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(/static/fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(/static/fonts/barlow-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 500; font-display: swap; src: url(/static/fonts/barlow-semi-condensed-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 600; font-display: swap; src: url(/static/fonts/barlow-semi-condensed-latin-600-normal.woff2) format('woff2'); }

:root {
  --paper: #161616;
  --sheet: #1e1e1e;
  --ink: #e6e6e6;
  --ink-2: #ababab;
  --muted: #8f8f8f;
  --rule: #3a3a3a;
  --rule-soft: #2a2a2a;
  --tint: #252525;
  --hi: #2e2e2e;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23ababab' stroke-width='1.6'/%3E%3C/svg%3E");
  --accent: #e58a80;
  --accent-soft: rgba(229, 138, 128, 0.12);
  --primary-bg: #e6e6e6;
  --primary-fg: #161616;
  --ok: #7fc79c;
  --ok-bg: rgba(127, 199, 156, 0.12);
  --warn: #e3b866;
  --warn-bg: rgba(227, 184, 102, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: 'Barlow', 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif;
  --font-cond: 'Barlow Semi Condensed', 'Barlow', 'Arial Narrow', sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --paper: #f2f4f0;
  --sheet: #ffffff;
  --ink: #1d2621;
  --ink-2: #4b5a52;
  --muted: #627068;
  --rule: #bfcbc2;
  --rule-soft: #dce3dd;
  --tint: #eaf0eb;
  --hi: #e4ebe5;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234b5a52' stroke-width='1.6'/%3E%3C/svg%3E");
  --accent: #a8322a;
  --accent-soft: rgba(168, 50, 42, 0.07);
  --primary-bg: #1d2621;
  --primary-fg: #ffffff;
  --ok: #2e6b48;
  --ok-bg: #e5f1e9;
  --warn: #7a5200;
  --warn-bg: #f7eedc;
  --shadow: 0 10px 30px rgba(29, 38, 33, 0.16);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --paper: #f2f4f0;
    --sheet: #ffffff;
    --ink: #1d2621;
    --ink-2: #4b5a52;
    --muted: #627068;
    --rule: #bfcbc2;
    --rule-soft: #dce3dd;
    --tint: #eaf0eb;
    --hi: #e4ebe5;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234b5a52' stroke-width='1.6'/%3E%3C/svg%3E");
    --accent: #a8322a;
    --accent-soft: rgba(168, 50, 42, 0.07);
    --primary-bg: #1d2621;
    --primary-fg: #ffffff;
    --ok: #2e6b48;
    --ok-bg: #e5f1e9;
    --warn: #7a5200;
    --warn-bg: #f7eedc;
    --shadow: 0 10px 30px rgba(29, 38, 33, 0.16);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }
a:hover { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-cond); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.small { font-size: 13.5px; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- shell */

.topbar { background: var(--sheet); border-bottom: 1px solid var(--rule); }
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 24px; min-height: 56px;
  display: flex; align-items: stretch; gap: 32px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-cond); font-weight: 600; font-size: 20px; }
.brand-mark { width: 22px; height: 22px; border: 2px solid currentColor; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a { display: flex; align-items: center; padding: 0 14px; text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -3px 0 var(--ink); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.theme-switch { display: inline-flex; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.theme-switch button { width: 34px; height: 30px; display: inline-flex; align-items: center; justify-content: center; background: none; border: none; color: var(--ink-2); cursor: pointer; }
.theme-switch button + button { border-left: 1px solid var(--rule); }
.theme-switch button[aria-pressed="true"] { background: var(--tint); color: var(--ink); }
.logout { background: none; border: none; color: var(--ink-2); cursor: pointer; padding: 6px; display: inline-flex; }
.logout:hover { color: var(--ink); }

.page { max-width: 1240px; margin: 0 auto; padding: 30px 24px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head p { margin-top: 6px; color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- controls */

.btn {
  min-height: 40px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); border-radius: 3px;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-primary { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); font-weight: 600; }
.btn-primary:hover { color: var(--primary-fg); opacity: 0.9; }
.btn-danger { color: var(--accent); border-color: var(--accent); }
.btn-danger:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn-plain { background: none; border-color: transparent; }
.btn-dashed { border-style: dashed; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn-lg { min-height: 44px; padding: 0 22px; }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; background: none; border: none; color: var(--ink-2); cursor: pointer; border-radius: 3px; }
.icon-btn:hover { color: var(--ink); background: var(--tint); }

.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.seg button, .seg a { min-height: 34px; padding: 0 13px; display: inline-flex; align-items: center; background: var(--sheet); border: none; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.seg > * + * { border-left: 1px solid var(--rule) !important; }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--primary-bg); color: var(--primary-fg); }

input[type="text"], input[type="search"], input[type="password"], input[type="date"], input:not([type]), select, .select, textarea {
  min-height: 40px; padding: 0 10px; background-color: var(--sheet); border: 1px solid var(--rule); border-radius: 3px; width: 100%;
}
textarea { padding: 8px 10px; min-height: 80px; resize: vertical; }
select, .select {
  appearance: none; padding-right: 30px; cursor: pointer; text-align: left;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right 10px center; background-size: 12px 8px;
}
.select { display: flex; align-items: center; }
/* Every label is stacked in one cell, so the button is as wide as its longest option, like a native select. */
.select-value { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.select-value > span { grid-area: 1 / 1; visibility: hidden; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-value > .is-on { visibility: visible; }
select[data-enhanced], input[data-enhanced] { display: none !important; }

input[type="radio"] { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }
input[type="checkbox"] {
  appearance: none; width: 18px; height: 18px; margin: 0; flex: none; cursor: pointer;
  display: inline-grid; place-content: center;
  background: var(--sheet); border: 1.5px solid var(--ink-2); border-radius: 3px;
}
input[type="checkbox"]::before {
  content: ''; width: 11px; height: 9px; background: var(--primary-fg); transform: scale(0);
  clip-path: polygon(0 52%, 14% 38%, 38% 62%, 86% 0, 100% 14%, 38% 92%);
}
input[type="checkbox"]:hover { border-color: var(--ink); }
input[type="checkbox"]:checked { background: var(--primary-bg); border-color: var(--primary-bg); }
input[type="checkbox"]:checked::before { transform: scale(1); }

.datefield { position: relative; display: flex; align-items: center; }
/* Not the label caption that `.field > span` styles. */
.field > .datefield, .field > .filepick { font: inherit; color: inherit; }
.datefield input { padding-right: 38px; }
.datefield .icon-btn { position: absolute; right: 2px; width: 32px; height: 32px; }
.filepick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; position: relative; }
.filepick input { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; }
.filepick-names { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }

/* Popups of the custom controls (public/js/controls.js), placed by script. */
.popup {
  inset: auto; margin: 0; padding: 4px 0; overflow: auto;
  background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); border-radius: 3px; box-shadow: var(--shadow);
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.popup-list { max-height: 320px; max-width: calc(100vw - 16px); }
.popup-list [role="option"] { padding: 7px 14px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none; }
.popup-list [role="option"]:focus, .popup-list .is-active { background: var(--hi); }
.popup-list [aria-selected="true"] { font-weight: 600; box-shadow: inset 3px 0 0 var(--ink); }
.popup-list [aria-disabled="true"] { color: var(--muted); cursor: default; }
.popup-group { padding: 9px 14px 3px; font-family: var(--font-cond); font-weight: 500; font-size: 12.5px; color: var(--muted); }
.popup-cal { padding: 10px; width: 272px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-title { font-family: var(--font-cond); font-weight: 600; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { font-family: var(--font-cond); font-weight: 500; font-size: 12.5px; color: var(--muted); text-align: center; padding: 3px 0; }
.cal-grid button { height: 32px; padding: 0; background: none; border: 1px solid transparent; border-radius: 3px; color: var(--ink); cursor: pointer; }
.cal-grid button:hover { background: var(--hi); }
.cal-grid button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.cal-grid .is-today { border-color: var(--ink-2); }
.cal-grid .is-selected, .cal-grid .is-selected:hover { background: var(--primary-bg); color: var(--primary-fg); font-weight: 600; }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span, .field-label { font-family: var(--font-cond); font-weight: 500; font-size: 13.5px; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--muted); }

/* The form box grid: fields share their rules like boxes on a Vordruck. */
.boxgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.boxgrid > .box { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.box { background: var(--sheet); padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.box-label { display: flex; justify-content: space-between; gap: 8px; font-family: var(--font-cond); font-weight: 500; font-size: 13px; color: var(--ink-2); }
.box input:not([type="checkbox"]), .box select, .box .select { border: none; padding: 2px 0; min-height: 32px; font-size: 16.5px; background-color: transparent; }
.box select, .box .select { padding-right: 24px; background-position: right 2px center; }
.box .datefield input { padding-right: 38px; }
.box input:focus-visible, .box select:focus-visible, .box .select:focus-visible { outline: none; }
.box:focus-within { box-shadow: inset 0 0 0 2px var(--ink); }
.from-source { color: var(--accent); font-weight: 500; }
.box.wide { grid-column: 1 / -1; }
.box .seg { align-self: flex-start; }

.kz { display: inline-block; border: 1px solid var(--accent); color: var(--accent); font-family: var(--font-cond); font-weight: 600; font-size: 12.5px; padding: 0 6px; line-height: 19px; white-space: nowrap; }
.tag { display: inline-block; font-family: var(--font-cond); font-weight: 500; font-size: 12.5px; padding: 0 7px; line-height: 20px; border: 1px solid var(--rule); color: var(--ink-2); white-space: nowrap; }
.tag-warn { border-color: var(--warn); color: var(--warn); }
.tag-ok { border-color: var(--ok); color: var(--ok); }
.tag-accent { border-color: var(--accent); color: var(--accent); }

.flash { padding: 10px 14px; border: 1px solid var(--rule); background: var(--sheet); margin-bottom: 18px; }
.flash.err { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.flash.ok { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.flash.warn { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }

/* ---------------------------------------------------------------- tables */

.sheet { background: var(--sheet); border: 1px solid var(--rule); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--sheet); }
.table th { font-family: var(--font-cond); font-weight: 500; font-size: 13.5px; color: var(--ink-2); text-align: left; padding: 9px 12px; background: var(--tint); white-space: nowrap; }
.table td { padding: 10px 12px; border-top: 1px solid var(--rule-soft); vertical-align: top; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--tint); }
.table tr.is-reversed td { color: var(--muted); }
.table tr.is-reversed td .strike { text-decoration: line-through; }
.table .num { text-align: right; }
.table a.rowlink { text-decoration: none; font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters select, .filters .select, .filters input:not([type="checkbox"]) { width: auto; }
.filters input[type="search"] { min-width: 220px; flex: 1 1 220px; max-width: 360px; }

.empty { padding: 48px 24px; text-align: center; color: var(--ink-2); }
.empty .btn { margin-top: 14px; }

/* ---------------------------------------------------------------- receipt form */

.entry { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.entry-file { flex: 1 1 340px; max-width: 440px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 16px; }
.entry-data { flex: 2 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 26px; }

.dropzone {
  border: 1px dashed var(--ink-2); background: var(--sheet); aspect-ratio: 1 / 1.25;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; cursor: pointer;
}
.dropzone.is-over { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { font-family: var(--font-cond); font-size: 19px; font-weight: 600; }
.preview { border: 1px solid var(--rule); background: var(--sheet); aspect-ratio: 1 / 1.35; width: 100%; }
.preview iframe, .preview img { width: 100%; height: 100%; border: 0; display: block; object-fit: contain; background: #fff; }
.filebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--sheet); border: 1px solid var(--rule); }
.filebar-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.filebar-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-note { font-size: 13.5px; color: var(--ink-2); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.kind-seg { margin-top: 12px; }

.positions { display: flex; flex-direction: column; gap: 10px; }
.pos-block { display: grid; grid-template-columns: 44px minmax(0, 1fr); border: 1px solid var(--rule); background: var(--sheet); overflow: hidden; }
.pos-num { background: var(--tint); border-right: 1px solid var(--rule); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0; font-family: var(--font-cond); font-weight: 600; color: var(--ink-2); }
.pos-fields { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); margin: 0 -1px -1px 0; }
.pos-fields > .box { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.pos-fields .box input.amount { text-align: right; }
.pos-fields .box input.computed { color: var(--muted); }
.pos-fields .box input:disabled { color: var(--muted); }
.pos-fields .asset-box { background: var(--tint); }
.s2 { grid-column: span 2; }
.s3 { grid-column: span 3; }
.s4 { grid-column: span 4; }
.s5 { grid-column: span 5; }
.s6 { grid-column: span 6; }
.s7 { grid-column: span 7; }
.s8 { grid-column: span 8; }
.s12 { grid-column: span 12; }

.summary { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: flex-start; }
.landing { flex: 1 1 300px; max-width: 520px; }
.landing-list { display: grid; grid-template-columns: auto auto 1fr auto; gap: 6px 10px; align-items: center; font-size: 14px; margin-top: 8px; }
.landing-list .amount { text-align: right; }
/* Totals the way they are written on paper: a rule above the sum, a double rule under it. */
.totals { flex: 0 1 280px; display: flex; flex-direction: column; gap: 4px; }
.totals div { display: flex; justify-content: space-between; gap: 28px; }
.totals .grand { border-top: 1px solid var(--ink); margin-top: 4px; padding-top: 8px; font-weight: 600; font-size: 17px; }
.totals .grand span:last-child { border-bottom: 3px double var(--ink); padding-bottom: 1px; }
.totals .grand + div { margin-top: 8px; }

.form-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; padding-top: 18px; border-top: 1px solid var(--rule); }

/* ---------------------------------------------------------------- reports */

.report-tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--rule); margin-top: 6px; }
.report-tabs a { padding: 10px 16px; text-decoration: none; color: var(--ink-2); border: 1px solid transparent; margin-bottom: -1px; }
.report-tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; background: var(--sheet); border-color: var(--rule); border-bottom-color: var(--sheet); }
.report { background: var(--sheet); border: 1px solid var(--rule); border-top: none; }
.report-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; padding: 20px 24px 16px; }
.report-head .controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.report-head select, .report-head .select { width: auto; }
.report-note { margin: 0 24px 16px; }
.form-table { width: 100%; border-collapse: collapse; }
.form-table th { font-family: var(--font-cond); font-weight: 500; font-size: 13px; color: var(--ink-2); text-align: left; padding: 8px 12px; }
.form-table td { padding: 11px 12px; border-top: 1px solid var(--rule-soft); vertical-align: top; }
.form-table .zeile { width: 64px; text-align: center; background: var(--tint); border-right: 1px solid var(--rule); font-family: var(--font-cond); color: var(--ink); }
.form-table .kzcol { width: 74px; }
.form-table .amount { width: 150px; text-align: right; font-weight: 600; font-size: 16px; white-space: nowrap; }
.form-table .copycol { width: 52px; text-align: right; padding: 4px 8px 0 0; }
.form-table tr.group th { padding: 22px 12px 6px; font-family: var(--font-cond); font-weight: 600; font-size: 18px; color: var(--ink); border-top: 1px solid var(--rule); }
.form-table tr.group th.zeile-cell { background: var(--tint); border-right: 1px solid var(--rule); }
.form-table tr.sum td { border-top: 1px solid var(--ink); color: var(--ink-2); }
.form-table tr.sum td.amount { color: var(--ink); }
.form-table tr.result td { border-top: 2px solid var(--ink); font-family: var(--font-cond); font-weight: 600; font-size: 18px; background: var(--tint); }
.form-table tr.result td.amount { font-size: 20px; }
.form-table tr.muted-row td { color: var(--muted); }
.elster-label { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; }
.copy { position: relative; }
.copy.is-done { color: var(--ok); }

/* ---------------------------------------------------------------- detail */

.detail { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.detail-main { flex: 2 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.detail-side { flex: 1 1 320px; max-width: 440px; display: flex; flex-direction: column; gap: 10px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); margin: 0; }
.facts > div { background: var(--sheet); padding: 8px 12px 10px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.facts dt { font-family: var(--font-cond); font-weight: 500; font-size: 13px; color: var(--ink-2); }
.facts dd { margin: 3px 0 0; font-size: 16px; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.history li { padding: 6px 0; border-top: 1px solid var(--rule-soft); display: flex; gap: 12px; }
.history li:first-child { border-top: none; }
.banner { padding: 12px 16px; border: 1px solid var(--rule); background: var(--sheet); display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; }
.banner.reversed { border-color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- start page */

.home-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 30px; }
.home-year { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 24px; }
.home-year h1 { font-size: 44px; line-height: 1; }
.home-year p { margin-top: 4px; color: var(--ink-2); }
.home-section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 30px; }
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.figs.periods { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.fig { background: var(--sheet); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
a.fig:hover { color: inherit; background: var(--tint); }
.fig-label { min-height: 22px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--font-cond); font-weight: 500; font-size: 13px; color: var(--ink-2); }
.fig-value { font-size: 26px; font-weight: 600; }
.periods .fig-value { font-size: 22px; }
.fig-value.total { align-self: flex-start; border-bottom: 3px double var(--ink); }
.fig-value.none { color: var(--muted); }
.home-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 22px; align-items: start; }
.cat-list { padding: 6px 0; }
.cat { padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.cat-row { display: flex; justify-content: space-between; gap: 12px; }
.cat-bar { display: block; width: 100%; height: 4px; background: var(--rule-soft); }
.cat-bar rect { fill: var(--ink-2); }
.recent > p { padding: 10px 14px; }
.recent a { display: grid; grid-template-columns: 82px 92px minmax(0, 1fr) auto; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--rule-soft); text-decoration: none; }
.recent a:first-child { border-top: none; }
.recent a:hover { color: inherit; background: var(--tint); }
.recent a.is-reversed { color: var(--muted); }
.recent-nr { font-weight: 600; }
.recent-partner { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- dialogs, auth, misc */

dialog { border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog-body { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--rule); background: var(--tint); }

.auth { max-width: 380px; margin: 9vh auto 0; padding: 0 16px; }
.auth .brand { margin-bottom: 26px; }
.auth form { display: flex; flex-direction: column; gap: 14px; background: var(--sheet); border: 1px solid var(--rule); padding: 24px; }
.auth h1 { margin-bottom: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 22px; }
.panel { background: var(--sheet); border: 1px solid var(--rule); padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.panel form { display: flex; flex-direction: column; gap: 12px; }
.panel form.actions { flex-direction: row; gap: 8px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 12px; }

.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input:not([type="checkbox"]) { width: auto; min-height: 34px; }

@media (max-width: 760px) {
  .topbar-inner { padding: 0 12px; gap: 16px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin: 0 -12px; padding: 0 4px; }
  .nav a { min-height: 44px; }
  .topbar-end { min-height: 52px; }
  .page { padding: 22px 16px 48px; }
  h1 { font-size: 26px; }
  .entry-file { position: static; max-width: none; }
  .report-head { padding: 16px; }
  .s2, .s3, .s4, .s5 { grid-column: span 6; }
  .s6, .s7, .s8 { grid-column: span 12; }
  .recent a { grid-template-columns: 76px minmax(0, 1fr) auto; }
  .recent-date { display: none; }
}

/* ---------------------------------------------------------------- utilities (inline styles are blocked by the CSP) */
.m-0 { margin: 0; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }
.mt-28 { margin-top: 28px; }
.mb-22 { margin-bottom: 22px; }
.w-auto { width: auto; }
.fw-400 { font-weight: 400; }
.prewrap { white-space: pre-wrap; }
.narrow { max-width: 760px; }
.spacer-8 { height: 8px; }
.framed { border: 1px solid var(--rule); }
.alert-text { color: var(--accent); }
