/* EPU-Finanzen — Kassabuch-Optik: Linienpapier, Königsblau für Normales, Rot für Fehlbeträge. */

:root {
  color-scheme: light dark;
  --paper: #EDF1EA;
  --sheet: #FAFBF8;
  --rule: #D6DECF;
  --rule-2: #AAB8A3;
  --ink: #17202A;
  --ink-2: #4A5562;
  --ink-3: #5F6A76;
  --blue: #2D4BC0;
  --blue-ink: #22399A;
  --blue-wash: #E3E8F7;
  --on-blue: #FFFFFF;
  --red: #B42318;
  --red-wash: #F8E2DE;
  --amber: #8A5A00;
  --amber-fill: #D69A00;
  --track: #DCE3D6;
  --ghost: #B9C2CB;
  --c-a: #B4532A;   /* Ausgaben */
  --c-r: #2D4BC0;   /* Rücklage */
  --c-e: #1F8A5B;   /* Entnahme */
  --col: #4A5562;   /* Säulen */
  --col-hi: #17202A;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Noto Sans", Inter, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101419;
    --sheet: #171C22;
    --rule: #29313A;
    --rule-2: #3E4955;
    --ink: #E7EAEE;
    --ink-2: #B4BCC6;
    --ink-3: #8C96A1;
    --blue: #8DA2FF;
    --blue-ink: #ABBAFF;
    --blue-wash: #1D2645;
    --on-blue: #101419;
    --red: #FF8A80;
    --red-wash: #3B1F1C;
    --amber: #F0B847;
    --amber-fill: #C98E00;
    --track: #262E37;
    --ghost: #46505B;
    --c-a: #D06A40;
    --c-r: #6F86EE;
    --c-e: #2C9F6C;
    --col: #9AA4AF;
    --col-hi: #E7EAEE;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--blue-ink); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0 0 12px; }
small { font-size: 14px; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 460px; }
.settings { max-width: 820px; }
.muted { color: var(--ink-3); margin: 0; }
.hint { color: var(--ink-3); font-size: 14px; margin: 6px 0 0; }
.note { font-size: 14px; color: var(--ink-2); margin: 12px 0 0; padding-left: 12px; border-left: 3px solid var(--red); }
.skip { position: absolute; left: -9999px; top: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip:focus { left: 8px; top: 8px; z-index: 10; background: var(--sheet); padding: 8px 12px; }

/* Kopfzeile ------------------------------------------------------------ */
.top { border-bottom: 1px solid var(--rule-2); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 8px 24px; min-height: 56px; flex-wrap: wrap; }
.brand { color: var(--ink); text-decoration: none; font-weight: 650; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { color: var(--ink); text-decoration: none; }
.top-nav { display: flex; align-items: center; gap: 4px 22px; flex-wrap: wrap; font-size: 15px; }
.top-nav a { color: var(--ink-2); text-decoration: none; padding: 6px 0; }
.top-nav a:hover { color: var(--ink); }
.top-nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.inline-form { display: inline; margin: 0; }
.linkbtn { background: none; border: 0; padding: 6px 0; font: inherit; color: var(--ink-2); cursor: pointer; }
.linkbtn:hover { color: var(--ink); }

/* Urteil oben ------------------------------------------------------------ */
.hero { padding: 56px 0 40px; max-width: 920px; }
.verdict {
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -0.022em;
  margin: 0 0 14px;
  text-wrap: balance;
}
.hero--short .verdict { color: var(--red); }
.hero--ok .verdict { color: var(--blue); }
.verdict-sub { font-size: 18px; line-height: 1.45; color: var(--ink-2); max-width: 64ch; margin: 0 0 24px; }
.hero-actions { margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }

/* Jahreszeile ------------------------------------------------------------ */
.yearbar { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; border-top: 2px solid var(--ink); padding: 12px 0 0; margin: 0 0 24px; }
.year-title { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.years { display: flex; gap: 6px; }
.years a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border: 1px solid var(--rule-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.years a:hover { color: var(--ink); border-color: var(--ink); }

/* Raster ------------------------------------------------------------ */
.grid-main { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 40px; align-items: start; margin-bottom: 48px; }
.side-block { padding: 0 0 22px; margin: 0 0 22px; border-bottom: 1px solid var(--rule-2); }
.side-block:last-child { border-bottom: 0; margin-bottom: 0; }
.side-block h3, .sheet-head h3, .sec-head h3, .chart-sec h3 { font-size: 17px; font-weight: 650; }
.side-block h3 { margin-bottom: 8px; }

.sheet { background: var(--sheet); border: 1px solid var(--rule); padding: 24px 28px 26px; }
.sheet-head, .sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; margin-bottom: 12px; }

/* Kontoauszug-Zeilen ------------------------------------------------------------ */
.ledger { margin: 0; }
.ledger .row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.ledger dt { color: var(--ink-2); min-width: 0; }
.ledger dd { margin: 0; font-weight: 500; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.ledger .row--head dt, .ledger .row--head dd { color: var(--ink); font-weight: 650; font-size: 19px; }
.ledger .row--head { border-bottom: 0; padding-bottom: 4px; }
.ledger .row--sub { border-top: 1px solid var(--ink); margin-top: -1px; }
.ledger .row--sub dt, .ledger .row--sub dd { color: var(--ink); font-weight: 650; }
.ledger .row--total { border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); margin-top: -1px; padding: 11px 0 10px; }
.ledger .row--total dt, .ledger .row--total dd { color: var(--ink); font-weight: 700; font-size: 18px; }
.ledger .row--alarm dt { color: var(--red); }
.ledger .row--group { border-bottom: 1px solid var(--rule-2); padding-top: 18px; }
.ledger .row--group dt { color: var(--ink); font-weight: 650; }
.ledger .row--minor dt, .ledger .row--minor dd { color: var(--ink-3); font-size: 14px; font-weight: 400; }
.ledger--compact .row { padding: 7px 0; font-size: 15px; }
.ledger--calc { margin-top: 18px; }
.ledger--parts dt { display: flex; align-items: baseline; }
.neg { color: var(--red); }
.share { display: inline-block; min-width: 3.4em; text-align: right; color: var(--ink-3); font-weight: 400; margin-left: 10px; }

/* Aufteilungsbalken ------------------------------------------------------------ */
.split { display: flex; gap: 2px; height: 8px; margin: 6px 0 6px; }
.split .seg { display: block; min-width: 2px; }
.seg-a { background: var(--c-a); }
.seg-r { background: var(--c-r); }
.seg-e { background: var(--c-e); }
.seg-rest { background: var(--track); box-shadow: inset 0 0 0 1px var(--rule-2); }
.sw { flex: none; display: inline-block; width: 10px; height: 10px; margin-right: 10px; transform: translateY(1px); }

/* Kleinunternehmer-Anzeige ------------------------------------------------------------ */
.ku-line { margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.meter { position: relative; height: 10px; background: var(--track); margin: 12px 0 52px; }
.meter-proj { position: absolute; inset: 0 auto 0 0; background: var(--ghost); }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: var(--ink-2); }
.meter--warn .meter-fill { background: var(--amber-fill); }
.meter--over .meter-fill { background: var(--red); }
.meter-tick { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); }
.meter-tick > span { position: absolute; right: 6px; font-size: 12px; line-height: 1.2; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Beide Beschriftungen enden an ihrer Markierung; die Toleranz steht eine Zeile tiefer */
.tick-limit > span { top: 16px; }
.tick-tol { bottom: -32px; }
.tick-tol > span { top: 30px; }
.status { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 0; font-size: 15px; }
.status-icon { flex: none; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; margin-top: 1px; }
.status--ok .status-icon { color: var(--blue); font-size: 17px; }
.status--warn .status-icon { background: var(--amber-fill); color: #17202A; }
.status--over .status-icon { background: var(--red); color: #FFFFFF; }

/* Termine ------------------------------------------------------------ */
.dates { list-style: none; margin: 0; padding: 0; }
.dates li { display: grid; grid-template-columns: 6.6em 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.dates li:last-child { border-bottom: 0; }
.dates time { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }
.dates span { color: var(--ink-2); }

/* Säulendiagramm ------------------------------------------------------------ */
.chart-sec { margin: 0 0 48px; }
.chart { padding: 28px 0 0; }
.chart-plot { position: relative; height: 220px; margin: 0 0 30px 56px; border-bottom: 1px solid var(--rule-2); }
.gl { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--rule); }
.gl > span { position: absolute; right: calc(100% + 10px); top: -0.72em; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols { position: absolute; inset: 0; display: flex; margin: 0; padding: 0; list-style: none; }
.col { position: relative; flex: 1 1 0; display: flex; align-items: flex-end; justify-content: center; outline: none; cursor: default; }
.col[data-href] { cursor: pointer; }
.col .bar { display: block; width: min(24px, 58%); height: var(--h); background: var(--col); }
.col:hover .bar, .col:focus-visible .bar { background: var(--col-hi); }
.col:focus-visible { box-shadow: inset 0 0 0 2px var(--blue); }
.col .v { position: absolute; bottom: calc(var(--h) + 6px); font-size: 12px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.col .x { position: absolute; top: calc(100% + 8px); font-size: 12px; color: var(--ink-3); }
.col--empty .x { opacity: 0.55; }
/* Tooltip neben der Säule, oben im Diagramm – verdeckt weder Säule noch Überschrift */
.col .tip {
  display: none; position: absolute; z-index: 3; top: 0; left: calc(50% + 20px);
  background: var(--ink); color: var(--paper); padding: 10px 12px; font-size: 13px; line-height: 1.35; white-space: nowrap; pointer-events: none;
}
.col--r .tip { left: auto; right: calc(50% + 20px); }
.col:hover .tip, .col:focus .tip { display: block; }
.tip-h { display: block; font-weight: 650; margin-bottom: 4px; }
.tip-row { display: flex; gap: 10px; justify-content: space-between; }
.tip-row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tip-row span { opacity: 0.75; }

/* Monatstabelle ------------------------------------------------------------ */
.table-sec { margin: 0 0 48px; }
.tablewrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--rule); }
.tablewrap:focus-visible { outline-offset: -2px; }
table.months { width: 100%; min-width: 820px; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.months th, .months td { padding: 10px 14px; text-align: right; white-space: nowrap; }
.months thead th { font-size: 13px; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--ink); vertical-align: bottom; }
.months th:first-child { text-align: left; position: sticky; left: 0; background: var(--sheet); }
.months tbody th { font-weight: 500; }
.months tbody th a { color: var(--ink); text-decoration: none; }
.months tbody th a:hover { color: var(--blue); text-decoration: underline; }
.months tbody tr > * { border-bottom: 1px solid var(--rule); }
.months tbody tr.filled:hover > * { background: var(--blue-wash); }
.months tr.empty th a { color: var(--ink-3); }
.months .empty-cell { text-align: left; color: var(--ink-3); font-size: 14px; }
.months tr.is-current th { box-shadow: inset 3px 0 0 var(--blue); }
.months tfoot > tr > * { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); }
.flag { display: inline-block; width: 7px; height: 7px; background: var(--red); margin-right: 8px; vertical-align: 2px; }

/* Steuerrechnung ------------------------------------------------------------ */
.tax { margin: 0 0 56px; }
.tax-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; align-items: start; }
.ledger--lead { max-width: calc(50% - 24px); }
@media (max-width: 900px) { .ledger--lead { max-width: none; } }
.rate-line { margin: 18px 0 0; font-size: 18px; font-weight: 600; color: var(--blue); }

/* Formulare ------------------------------------------------------------ */
.page-title { font-size: 32px; font-weight: 650; letter-spacing: -0.02em; }
.page-title--top { margin: 40px 0 8px; }
.welcome { padding: 56px 0 64px; }
.welcome .page-title { margin-bottom: 12px; }
.lead { font-size: 17px; color: var(--ink-2); margin-bottom: 24px; }
.stack > * + * { margin-top: 14px; }
.field label { display: block; font-weight: 550; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="search"], input[type="month"], input[type="date"], input[type="file"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--rule-2); border-radius: 0; padding: 10px 12px; min-height: 46px;
}
input[type="file"] { padding: 9px 10px; }
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
input.amount { text-align: right; font-size: 18px; font-variant-numeric: tabular-nums; }
.field.has-error input, .field.has-error textarea { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.err { color: var(--red); font-size: 14px; margin: 6px 0 0; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }
.check small { display: block; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 24px; }
.field { margin-bottom: 18px; }
fieldset { border: 0; border-top: 2px solid var(--ink); margin: 0 0 26px; padding: 14px 0 0; min-width: 0; }
legend { font-size: 18px; font-weight: 650; padding: 0 12px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 22px;
  background: var(--blue); color: var(--on-blue); border: 1px solid var(--blue); border-radius: 0;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--blue-ink); border-color: var(--blue-ink); color: var(--on-blue); text-decoration: none; }
.btn--quiet { background: transparent; color: var(--ink); border-color: var(--rule-2); }
.btn--quiet:hover { background: var(--sheet); color: var(--ink); border-color: var(--ink); }
.btn--danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn--danger:hover { background: var(--red-wash); color: var(--red); border-color: var(--red); }
.btn--small { min-height: 34px; padding: 0 12px; font-size: 14px; font-weight: 550; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.rec { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 0; font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.flash { margin: 24px 0 0; padding: 12px 16px; background: var(--sheet); border: 1px solid var(--rule); border-left: 4px solid var(--blue); }
.flash--err { border-left-color: var(--red); }

/* Monatsformular ------------------------------------------------------------ */
.monthhead { display: flex; align-items: baseline; gap: 16px 28px; flex-wrap: wrap; padding: 40px 0 24px; }
.mh-nav { color: var(--ink-2); text-decoration: none; font-size: 15px; }
.mh-nav:hover { color: var(--ink); }
.monthhead .page-title { order: -1; flex: 1 1 auto; }
.mf-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
.mf-live { position: sticky; top: 24px; }
.live-title { font-size: 17px; font-weight: 650; margin-bottom: 6px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 0 24px; }
.delete-form { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 24px 0 56px; border-top: 1px solid var(--rule-2); }

/* Einstellungen ------------------------------------------------------------ */
.set-sec { border-top: 2px solid var(--ink); padding: 16px 0 32px; }
.set-sec:first-of-type { margin-top: 24px; }
.set-sec h2 { font-size: 20px; font-weight: 650; margin-bottom: 10px; }
.set-sec .sec-head h2 { margin-bottom: 0; }
.plain-list { list-style: none; margin: 0 0 20px; padding: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--rule); }

/* Fußzeile ------------------------------------------------------------ */
.foot { border-top: 1px solid var(--rule-2); margin-top: 24px; }
.foot-in { display: flex; justify-content: space-between; gap: 16px; padding-top: 16px; padding-bottom: 32px; font-size: 13px; color: var(--ink-3); }
.foot p { margin: 0; max-width: 72ch; }

/* Kleine Bildschirme ------------------------------------------------------------ */
@media (max-width: 900px) {
  .grid-main { grid-template-columns: 1fr; gap: 32px; }
  .mf-grid { grid-template-columns: 1fr; gap: 8px; }
  .mf-live { position: static; }
  .tax-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 36px 0 28px; }
  .verdict-sub { font-size: 16px; }
  .sheet { padding: 18px 16px 20px; }
  .ledger .row--head dt, .ledger .row--head dd { font-size: 17px; }
  .share { min-width: 3em; margin-left: 6px; }
  .chart-plot { margin-left: 44px; height: 180px; }
  .col .v { display: none; }
  .col .x { font-size: 11px; }
  .col .tip { font-size: 12px; padding: 8px 10px; }
  .year-title { font-size: 28px; }
  .foot-in { flex-direction: column; }
}

@media print {
  .top-nav, .hero-actions, .years, .actions, .delete-form, .skip, .entry-form, .e-actions, .mh-nav, .inv-actions, .inv-filters, .inv-next .btn, .inv-block-links, .save-status { display: none !important; }
  body { background: #fff; color: #000; }
  .sheet, .tablewrap { border-color: #999; }
}

/* Speicheranzeige, Fußzeile ------------------------------------------------------------ */
.save-status { font-size: 13px; color: var(--ink-3); min-width: 9em; text-align: right; font-variant-numeric: tabular-nums; }
.save-status.is-error { color: var(--red); min-width: 0; }
.foot-ver { white-space: nowrap; }

/* Einnahmen und Ausgaben im Monat ------------------------------------------------------------ */
.entries { margin: 0 0 34px; }
.entries-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.entries-head h2 { font-size: 20px; font-weight: 650; }
.entries-head .muted { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.entries-empty { padding: 12px 0 2px; }
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: 4.2em minmax(0, 1fr) 46px minmax(8.5em, auto) auto; gap: 0 14px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--rule); min-height: 62px;
}
.entry.is-editing { box-shadow: inset 3px 0 0 var(--blue); background: var(--blue-wash); padding-left: 10px; }
.e-date { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 15px; }
.e-text { min-width: 0; overflow-wrap: anywhere; }
.e-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.e-amount b { display: block; font-weight: 600; font-size: 17px; }
.e-tax { display: block; font-size: 13px; color: var(--ink-3); }
.e-actions { display: flex; gap: 6px; opacity: 0.6; }
.entry:hover .e-actions, .entry:focus-within .e-actions, .entry.is-editing .e-actions { opacity: 1; }
.btn--del:hover { color: var(--red); border-color: var(--red); background: transparent; }
.e-file { display: flex; justify-content: center; }
.thumb {
  position: relative; width: 44px; height: 44px; padding: 0; border: 1px solid var(--rule-2); background: var(--sheet);
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; color: var(--ink-2);
}
.thumb:hover { border-color: var(--ink); }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink-2); }
.thumb-badge--big { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 80px; border: 1px solid var(--rule-2); background: var(--paper); font-size: 13px; }

/* Formular für eine Buchung */
.entry-form { background: var(--sheet); border: 1px solid var(--rule); padding: 16px 20px 6px; margin: 16px 0 0; }
.entry-form.is-editing { border-left: 4px solid var(--blue); }
.entry-form-title { font-size: 16px; font-weight: 650; margin: 0 0 12px; }
.ef-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 0 22px; align-items: start; }
.field-row--entry { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 16px; }
.field-row--entry.field-row--tax { grid-template-columns: minmax(0, 4fr) minmax(0, 3fr) minmax(0, 3fr); }
.field-row--entry .field { margin-bottom: 14px; }
.entry-form .btn-row { margin: 0 0 12px; }
input.day { font-variant-numeric: tabular-nums; }

/* Ablagefläche für Foto oder PDF */
.drop {
  border: 1.5px dashed var(--rule-2); background: var(--paper); padding: 14px 12px; text-align: center; margin-bottom: 14px;
  min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.drop.is-over { border-color: var(--blue); border-style: solid; background: var(--blue-wash); }
.drop.has-file { border-style: solid; border-color: var(--rule-2); }
.drop.has-error { border-color: var(--red); }
.drop-hint { margin: 0; color: var(--ink-2); font-size: 14px; }
.drop-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 0; }
.drop-label { margin: 0; font-size: 13px; }
.drop-file { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 100%; }
.drop-preview { max-width: 100%; max-height: 120px; object-fit: contain; border: 1px solid var(--rule); background: var(--sheet); }
.drop-name { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.drop .err { margin: 0; }

/* Belege in der Monatstabelle */
.files-cell { color: var(--ink-2); }
.clip { display: inline-block; width: 9px; height: 11px; border: 1.5px solid var(--ink-3); margin-right: 6px; vertical-align: -1px; }

/* Datenordner und Sicherung */
.path code { display: inline-block; max-width: 100%; font: 13px/1.4 ui-monospace, "SF Mono", Menlo, monospace; background: var(--sheet); border: 1px solid var(--rule); padding: 6px 8px; overflow-wrap: anywhere; }
.data-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px 24px; margin-top: 20px; }
.data-actions .hint { margin-top: 8px; }

@media (max-width: 980px) {
  .ef-grid { grid-template-columns: 1fr; }
  .drop { min-height: 0; }
}
@media (max-width: 640px) {
  .field-row--entry, .field-row--entry.field-row--tax { grid-template-columns: 1fr; }
  .entry { grid-template-columns: 3.6em minmax(0, 1fr) auto; grid-template-areas: "d t a" "d f x"; row-gap: 6px; }
  .e-date { grid-area: d; } .e-text { grid-area: t; } .e-amount { grid-area: a; } .e-file { grid-area: f; justify-content: flex-start; } .e-actions { grid-area: x; justify-content: flex-end; }
}

/* ===================================================================== */
/* Web-Version: Rechnungsnummern, Zugang, Handy                          */
/* ===================================================================== */

input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
select { -webkit-appearance: none; appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

/* Anmeldeseiten */
.auth-sec { font-size: 18px; font-weight: 650; margin: 30px 0 10px; padding-top: 14px; border-top: 2px solid var(--ink); }
.forgot { margin-top: 30px; }
.forgot summary { cursor: pointer; color: var(--ink-2); }
.forgot summary:hover { color: var(--ink); }

/* Rechnungen in der Übersicht */
.inv-block dd b { font-size: 18px; font-variant-numeric: tabular-nums; }
.inv-block-links { margin: 12px 0 0; font-size: 15px; }

/* Rechnungsseite: nächste Nummer, Zahlen, Lücken */
.inv-top {
  display: grid; grid-template-columns: minmax(0, auto) minmax(0, 420px); justify-content: space-between; gap: 16px 48px;
  align-items: end; padding: 12px 0 22px; border-bottom: 2px solid var(--ink);
}
.inv-next { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
.inv-next-label { width: 100%; color: var(--ink-2); font-size: 15px; }
.inv-next-no { font-size: clamp(44px, 7vw, 68px); line-height: 1; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--blue); }
.inv-top .note { grid-column: 1 / -1; margin: 0; }
.inv-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.inv-quick .hint { flex: 1 1 260px; max-width: 46ch; margin: 0; }
.inv-empty { padding: 20px 0; max-width: 60ch; }

/* Filter */
.inv-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 22px 0 6px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--rule-2); background: transparent; color: var(--ink-2); font: inherit; font-size: 15px; cursor: pointer;
}
.chip-btn:hover { border-color: var(--ink); color: var(--ink); }
.chip-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip-n { font-size: 13px; opacity: 0.75; font-variant-numeric: tabular-nums; }
.inv-filters select, .inv-filters input[type="search"] { width: auto; min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
.inv-filters select { max-width: 240px; }
.inv-filters input[type="search"] { flex: 1 1 200px; max-width: 320px; margin-left: auto; }

/* Liste der Rechnungen */
.inv-list { list-style: none; margin: 0; padding: 0; --no-w: 4ch; }
.inv {
  display: grid; grid-template-columns: calc(var(--no-w) + 14px) minmax(0, 1fr) 46px 9em 10.5em 13em;
  grid-template-areas: "no main file amount status actions";
  gap: 0 16px; align-items: center; padding: 10px 10px; border-bottom: 1px solid var(--rule); min-height: 68px;
}
.inv-no { grid-area: no; font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; overflow-wrap: anywhere; line-height: 1.2; }
.inv-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; }
.inv-client { font-weight: 550; overflow-wrap: anywhere; }
.inv-sub { font-size: 14px; color: var(--ink-3); overflow-wrap: anywhere; }
.inv-file { grid-area: file; display: flex; justify-content: center; }
.inv-amount { grid-area: amount; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-amount .muted { font-weight: 400; font-size: 14px; }
.inv-status { grid-area: status; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.inv-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.inv--paid .inv-no { color: var(--ink-2); }
.inv--cancelled .inv-no, .inv--cancelled .inv-client, .inv--cancelled .inv-amount { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.inv--gap { grid-template-columns: calc(var(--no-w) + 14px) minmax(0, 1fr) auto; grid-template-areas: "no main actions"; min-height: 0; background: var(--red-wash); box-shadow: inset 3px 0 0 var(--red); }
.inv--gap .inv-no { color: var(--red); }
.inv--gap .inv-client { font-weight: 500; }

.chip { display: inline-block; padding: 2px 8px; font-size: 13px; font-weight: 600; line-height: 1.4; border: 1px solid; white-space: nowrap; }
.chip--open { color: var(--amber); border-color: var(--amber-fill); }
.chip--paid { color: var(--blue-ink); border-color: var(--blue); background: var(--blue-wash); }
.chip--cancelled { color: var(--ink-3); border-color: var(--rule-2); }
.chip-link { font-size: 13px; color: var(--ink-2); white-space: nowrap; }

/* Zahlung zu einer Rechnung erfassen */
.inv-pay { padding: 16px 20px 4px; margin: 0 0 14px; background: var(--sheet); border: 1px solid var(--rule); border-left: 4px solid var(--blue); }
.pay-form h3 { font-size: 16px; font-weight: 650; margin: 0 0 12px; }
.pay-form .field-row--entry { max-width: 560px; }
.pay-form .btn-row { margin: 0 0 12px; }

/* Formular einer Rechnung */
.inv-form { margin: 22px 0 8px; }
.inv-form-head { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin: 0 0 14px; }
.inv-form-head .entry-form-title { font-size: 20px; margin: 0; }
.inv-form-head .inv-status { display: inline-flex; }
input.inv-number-input { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.inv-more { border-top: 1px solid var(--rule); padding: 14px 0 12px; }
.inv-more .btn-row { margin: 0; }
.inv-more .btn-row:empty { display: none; }
.inv-more .hint { margin-top: 8px; max-width: 70ch; }
.thumb--big { width: 96px; height: 120px; }

/* Zahlungen mit Rechnung und Tätigkeit */
.e-meta { display: block; font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.e-inv { color: var(--blue); font-weight: 550; text-decoration: none; }
.e-inv:hover { text-decoration: underline; }

/* Umsatz nach Tätigkeit */
table.months.act { min-width: 0; }

/* Zugang */
.acc-form { border-top: 1px solid var(--rule-2); padding-top: 16px; margin-top: 22px; }
.acc-form h3 { font-size: 17px; font-weight: 650; }
.acc-form > .err { margin: 0; }

@media (max-width: 1060px) {
  .inv { grid-template-columns: calc(var(--no-w) + 14px) minmax(0, 1fr) 46px 9em; grid-template-areas: "no main file amount" "no status status actions"; row-gap: 8px; }
}
@media (max-width: 640px) {
  .top-in { padding-top: 6px; padding-bottom: 6px; gap: 2px 16px; }
  .top-nav { gap: 2px 16px; }
  .save-status { position: fixed; z-index: 30; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); min-width: 0; max-width: calc(100% - 24px); padding: 7px 12px; background: var(--ink); color: var(--paper); text-align: left; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
  .save-status.is-error { background: var(--red); color: #fff; }
  .save-status:empty { display: none; }
  .page-title { font-size: 27px; }
  .page-title--top { margin-top: 28px; }
  .inv-top { grid-template-columns: 1fr; align-items: start; }
  .inv-filters input[type="search"] { margin-left: 0; max-width: none; flex-basis: 100%; }
  .inv { grid-template-columns: calc(var(--no-w) + 10px) minmax(0, 1fr) auto; grid-template-areas: "no main amount" "file status status" "file actions actions"; gap: 6px 12px; padding: 12px 6px; }
  .inv-file { justify-content: flex-start; align-self: start; }
  .inv-actions { justify-content: flex-start; }
  .inv--gap { grid-template-columns: calc(var(--no-w) + 10px) minmax(0, 1fr); grid-template-areas: "no main" ". actions"; }
  .inv-pay { padding: 14px 14px 2px; }
  .entry-form { padding: 14px 14px 4px; }
  .monthhead { padding-top: 28px; gap: 6px 22px; }
  .monthhead .page-title { flex-basis: 100%; }
  .inv-quick { width: 100%; }
}
