/* Layout der Buchhaltung. Grundstil und Komponenten kommen aus /design/base.css. */

.skip-link { position: absolute; left: var(--space-4); top: -100px; z-index: 10; padding: var(--space-2) var(--space-4); background: var(--action); color: var(--on-action); border-radius: var(--radius-md); }
.skip-link:focus { top: var(--space-2); }

/* Kopfzeile: Logo, Navigation, Aktionen */
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
/* Im Dunkelmodus bleibt die Kopfzeile im dunkleren Ton (surface-sunken = anthrazit-950) */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: var(--surface-sunken); } }
:root[data-theme="dark"] .topbar { background: var(--surface-sunken); }
/* Gleiche Breite und Kanten wie der Inhalt (.content) */
.topbar__inner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-6);
  min-height: var(--header-height); max-width: var(--container); margin: 0 auto; padding: 0 var(--space-6);
}
.brand { display: inline-flex; align-items: center; gap: var(--space-3); margin: 0; color: var(--ink); text-decoration: none; }
.brand__logo { display: block; height: 36px; width: auto; }
/* Name der App in der Schrift der Wortmarke: Grotesk, mittel, Logo-Blau; Größe wie die Wortmarke neben dem 36px-Icon */
.brand__name { font-family: var(--font-sans); font-size: 17px; line-height: 36px; font-weight: 500; letter-spacing: 0; color: var(--brand); }
.bare .brand { justify-content: center; width: 100%; margin-bottom: var(--space-5); }

/* Benutzermenü */
/* Der Kreis schließt rechts bündig mit dem Inhalt ab: Innenabstand und Rahmen des Buttons nach außen ziehen */
.usermenu { position: relative; margin-right: calc(-1 * (var(--space-1) + 1px)); }
.usermenu__trigger {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: var(--space-1);
  font: inherit; font-weight: 600; color: var(--ink); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer;
}
.usermenu__trigger:hover, .usermenu__trigger[aria-expanded="true"] { border-color: var(--line); background: var(--surface-sunken); }
.usermenu__avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--surface-tint); color: var(--accent); font-family: var(--font-mono); font-size: 13px; font-weight: 500;
}
.usermenu__panel {
  position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: 20; min-width: 220px; padding: var(--space-2) 0;
  background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.usermenu__panel[hidden] { display: none; }
.usermenu__panel form { margin: 0; }
.usermenu__panel [role^="menuitem"] {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 40px; padding: var(--space-2) var(--space-4);
  font: inherit; text-align: left; color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer;
}
.usermenu__panel [role^="menuitem"]:hover, .usermenu__panel [role^="menuitem"]:focus-visible { background: var(--surface-sunken); color: var(--ink); }
.usermenu__panel [role^="menuitem"]:focus-visible { outline-offset: -2px; }
.usermenu__sep { height: 1px; margin: var(--space-2) 0; background: var(--line); }

/* Hauptnavigation in der Kopfzeile */
.mainnav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-1); }
.mainnav a {
  display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  color: var(--ink); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.mainnav a:hover { background: var(--surface-sunken); color: var(--ink); }
.mainnav a[aria-current="page"] { background: var(--surface-tint); color: var(--accent); }

.content { padding: var(--space-6) var(--space-6) var(--space-8); max-width: var(--container); margin: 0 auto; outline: none; }
.page-head { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-5); }

/* Seiten ohne Navigation */
.bare__main { max-width: 420px; margin: 0 auto; padding: var(--space-8) var(--space-4); }
.login { display: flex; flex-direction: column; gap: var(--space-4); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }

@media (max-width: 1023px) {
  .topbar__inner { grid-template-columns: auto minmax(0, 1fr); gap: 0 var(--space-4); }
  .topbar__actions { justify-self: end; }
  .mainnav { grid-column: 1 / -1; grid-row: 2; margin: 0 calc(-1 * var(--space-6)); padding: var(--space-2) var(--space-6); border-top: 1px solid var(--line); overflow-x: auto; }
}

@media (max-width: 767px) {
  .topbar__inner { min-height: 64px; padding: 0 var(--space-4); }
  .mainnav { margin: 0 calc(-1 * var(--space-4)); padding: var(--space-2) var(--space-4); }
  .brand__logo { height: 30px; }
  .brand__name { font-size: 15px; line-height: 30px; }
  .mainnav ul { justify-content: space-between; gap: 0; }
  .mainnav a { padding: var(--space-2); font-size: 14px; }
  .content { padding: var(--space-5) var(--space-4) var(--space-7); }
}

/* Kopfzeile: Aktionen rechts */
.topbar__actions { display: flex; align-items: center; gap: var(--space-2); }

.iconbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: var(--radius-md);
  cursor: pointer; text-decoration: none;
}
.iconbtn:hover { background: var(--surface-sunken); border-color: var(--line); color: var(--ink); }
.iconbtn--active { color: var(--accent); }
.iconbtn--static { color: var(--ink-muted); cursor: default; }
.iconbtn--static:hover { background: none; border-color: transparent; }
.icon { display: block; }

/* Umschalter zeigt das Symbol des Ziel-Themes: Mond im hellen, Sonne im dunklen Modus */
.themetoggle__sun { display: none; }
:root[data-theme="dark"] .themetoggle__sun { display: block; }
:root[data-theme="dark"] .themetoggle__moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .themetoggle__sun { display: block; }
  :root:not([data-theme="light"]) .themetoggle__moon { display: none; }
}

.themetoggle { margin: 0; }
.flash { margin-bottom: var(--space-4); }
.page-head--row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.count { font-family: var(--font-mono); font-size: 15px; font-weight: 500; color: var(--ink-muted); letter-spacing: 0; vertical-align: middle; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--line); font-weight: 400; }
.table thead th { font-weight: 600; color: var(--ink-muted); font-size: 13px; }
.reportstats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.stat { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-raised); }
.stat__label { font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.stat__value { font-size: 22px; line-height: 30px; font-weight: 500; }
.hm-btn--small { min-height: 36px; padding: var(--space-1) var(--space-4); }
code { font-family: var(--font-mono); font-size: 0.93em; }

/* Tabellen mit Belegen */
.table-scroll { overflow-x: auto; }
.table th, .table td { padding: var(--space-2) var(--space-3); vertical-align: top; }
.table .num { text-align: right; font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 650; border-bottom: 2px solid var(--ink); }
.table__empty { padding: var(--space-5) 0; }
.section { margin-top: var(--space-7); }
.section h2 { margin-bottom: var(--space-3); }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin-bottom: var(--space-4); }
.filters a[aria-current="page"] { font-weight: 650; color: var(--ink); text-decoration: none; }
.syncactions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-4) 0; }
.syncactions form { margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-5); margin: 0; }
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; }

@media (max-width: 767px) {
  .reportstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.table thead .num { font-family: inherit; font-size: inherit; }

/* Timeline der offenen Zahlungen (SVG, Positionen als Attribute) */
.timeline { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-raised); padding: var(--space-3) var(--space-4); }
.tl { display: block; max-width: 100%; height: auto; }
.tl--wide { min-width: 760px; }
.tl--narrow { display: none; width: 100%; }
@media (max-width: 767px) {
  .tl--wide { display: none; }
  .tl--narrow { display: block; }
  .timeline { padding: var(--space-2) var(--space-3); }
}
.tl text { font-family: var(--font-sans); font-size: 13px; fill: var(--ink); }
.tl .tl__group { font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; fill: var(--ink-muted); }
.tl .tl__number, .tl .tl__amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tl .tl__amount { font-weight: 500; }
.tl .tl__status, .tl .tl__tick { fill: var(--ink-muted); font-size: 12px; }
.tl .is-overdue .tl__status { fill: var(--danger); font-weight: 600; }
.tl__rule { stroke: var(--line); stroke-width: 1; }
.tl__week { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.tl__month { stroke: var(--line-strong); stroke-width: 1; }
.tl__bar { fill: var(--brand); }
.tl__row--out .tl__bar { fill: var(--line-strong); }
.tl__late { fill: var(--danger); }
.tl__due { fill: var(--surface-raised); stroke: var(--ink); stroke-width: 1.5; }
.tl__today { stroke: var(--ink); stroke-width: 1.5; }
.tl .tl__todaylabel { font-weight: 650; font-size: 12px; }
.timeline__legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-2); font-size: 13px; }
.tl-key { display: inline-block; width: 20px; height: 10px; border-radius: 3px; margin-left: var(--space-3); }
.tl-key:first-child { margin-left: 0; }
.tl-key--bar { background: var(--brand); }
.tl-key--late { background: var(--danger); }
.tl-key--due { width: 10px; border-radius: var(--radius-full); border: 1.5px solid var(--ink); background: var(--surface-raised); }

/* Umsätze je Monat und Woche */
.filters__sep { width: 1px; align-self: stretch; background: var(--line); }
.revenue tbody th { font-weight: 600; white-space: nowrap; }
.revenue__range { font-weight: 400; font-family: var(--font-mono); font-size: 13px; margin-left: var(--space-2); }
.revenue .is-empty th, .revenue .is-empty td { color: var(--ink-muted); }
.revenue__bar, .revenue__barhead { width: 28%; min-width: 120px; }
.table .revenue__bar { vertical-align: middle; }
.revenue__bar progress { appearance: none; display: block; width: 100%; height: 10px; border: 0; background: transparent; }
.revenue__bar progress::-webkit-progress-bar { background: transparent; }
.revenue__bar progress::-webkit-progress-value { background: var(--brand); border-radius: 3px; }
.revenue__bar progress::-moz-progress-bar { background: var(--brand); border-radius: 3px; }

/* Geplante Zahlungen in der Timeline */
.tl__band { fill: var(--surface-tint); stroke: var(--brand); stroke-width: 1; }
.tl__row--out .tl__band { fill: var(--surface-sunken); stroke: var(--line-strong); }
.tl .tl__bandtext { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.tl__due.is-past { fill: var(--line-strong); stroke: var(--line-strong); }
.tl-key--band { background: var(--surface-tint); border: 1px solid var(--brand); }
.section--first { margin-top: 0; }

/* Cashflow-Matrix */
.cf { font-size: 14px; }
.cf th, .cf td { padding: var(--space-1) var(--space-2); white-space: nowrap; }
.cf tbody th { text-align: left; font-weight: 400; position: sticky; left: 0; background: var(--surface); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.cf .num { font-size: 13px; }
.cf .is-current { background: var(--surface-tint); }
.cf .is-neg { color: var(--ink); }
.cf__part th { padding-top: var(--space-5); font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); border-bottom-color: var(--line-strong); }
.cf__group th a { font-weight: 600; color: var(--ink); text-decoration: none; }
.cf__group th a::before { content: "▸ "; color: var(--accent); }
.cf__group th a[aria-expanded="true"]::before { content: "▾ "; }
.cf__group th a:hover { color: var(--accent); text-decoration: underline; }
.cf__item th { padding-left: var(--space-5); color: var(--ink-muted); }
.cf__item td { color: var(--ink-muted); }
.cf__sum th, .cf__sum td { font-weight: 650; border-bottom-color: var(--line-strong); }
.cf__balance th, .cf__balance td { font-weight: 650; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.cf__year { border-left: 1px solid var(--line); font-weight: 600; }
.cf__import h3 { margin: var(--space-5) 0 var(--space-2); }
.cf__hints { margin: 0; padding-left: var(--space-5); max-width: var(--measure); }
.cf__hints li { margin-bottom: var(--space-1); }

/* Konten: Formular unter den Tabellen */
.kontenform { margin-top: var(--space-7); }
.kontenform__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); align-items: start; }
.kontenform__buttons { display: flex; gap: var(--space-2); margin-top: var(--space-4); }
.kontenform__archive { margin-top: var(--space-4); }
.hm-btn--quiet { background: transparent; color: var(--ink-muted); border-color: transparent; }
.hm-btn--quiet:hover { background: var(--surface-sunken); color: var(--ink); }
