/* ==========================================================================
   Buchhaltung – Design-System
   Ein Token-Satz, zwei Themes, ein Layout das von 320px bis 4K funktioniert.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Flächen */
  --bg:            #f4f6fb;
  --bg-muted:      #eaeef7;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #eef2f9;
  --overlay:       rgba(15, 23, 42, .45);

  /* Text */
  --text:          #131722;
  --text-soft:     #4a5568;
  --text-mute:     #7b8698;
  --text-invert:   #ffffff;

  /* Linien */
  --line:          #dfe5f0;
  --line-soft:     #eaeff7;
  --line-strong:   #c6cfdf;

  /* Akzent (wird aus den Einstellungen überschrieben) */
  --accent:        #4f7cff;
  --accent-hover:  #3c68ea;
  --accent-soft:   rgba(79, 124, 255, .12);
  --accent-text:   #ffffff;

  /* Semantik */
  --ok:            #12a150;
  --ok-soft:       rgba(18, 161, 80, .12);
  --warn:          #d98a00;
  --warn-soft:     rgba(217, 138, 0, .14);
  --bad:           #e0334b;
  --bad-soft:      rgba(224, 51, 75, .12);
  --info:          #0d92c9;
  --info-soft:     rgba(13, 146, 201, .12);

  /* Form */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 24px -8px rgba(16, 24, 40, .16), 0 4px 10px -4px rgba(16, 24, 40, .08);
  --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, .24);

  --sp: 4px;
  --header-h: 62px;
  --sidebar-w: 254px;
  --tabbar-h: 84px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.34, .8, .3, 1);
}

[data-theme="dunkel"] {
  color-scheme: dark;

  --bg:            #0d1017;
  --bg-muted:      #141824;
  --surface:       #171b26;
  --surface-2:     #1d222f;
  --surface-3:     #252b3a;
  --overlay:       rgba(4, 6, 12, .68);

  --text:          #eef1f7;
  --text-soft:     #b3bdd0;
  --text-mute:     #7e89a3;
  --text-invert:   #0d1017;

  --line:          #262c3b;
  --line-soft:     #1e2330;
  --line-strong:   #384054;

  --accent-soft:   rgba(79, 124, 255, .18);

  --ok-soft:       rgba(18, 161, 80, .18);
  --warn-soft:     rgba(217, 138, 0, .2);
  --bad-soft:      rgba(224, 51, 75, .18);
  --info-soft:     rgba(13, 146, 201, .18);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, .55);
  --shadow-xl: 0 28px 56px rgba(0, 0, 0, .6);
}

/* --------------------------------------------------------------- Basis */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: .92rem; }
p  { margin: 0 0 .7em; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

/* Grundgrösse für Inline-Icons – jede Komponente überschreibt sie bei Bedarf. */
svg { width: 1.05em; height: 1.05em; vertical-align: -.15em; flex-shrink: 0; }
.brand__mark svg { width: 20px; height: 20px; }
.liste__avatar svg { width: 18px; height: 18px; }
table.data td svg, table.data th svg { width: 14px; height: 14px; opacity: .55; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Scrollbars dezent halten */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------- Layout */

.app {
  display: grid;
  /* minmax(0,…) verhindert, dass ein breiter Inhalt die Spalte aufzieht
     und dadurch die ganze Seite waagrecht scrollen lässt. */
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: "sidebar header" "sidebar main";
  min-height: 100dvh;
}

.app[hidden] { display: none; }

/* Kopfzeile */
.topbar {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar__title { display: flex; flex-direction: column; min-width: 0; }
.topbar__title h1 { font-size: 1.16rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title span { font-size: .78rem; color: var(--text-mute); }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

/* Seitenleiste */
.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px 18px;
}

.brand__mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #a855f7));
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  overflow: hidden;
}
.brand__mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand__text { min-width: 0; }
.brand__text strong { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__text span { font-size: .75rem; color: var(--text-mute); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-mute); padding: 16px 12px 6px; font-weight: 600;
}

.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-soft);
  font-size: .91rem; font-weight: 520;
  cursor: pointer;
  border: 0; background: none; width: 100%; text-align: left;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.nav__item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav__item svg { width: 19px; height: 19px; flex-shrink: 0; }

/* Bereichsfarben. --nav-farbe setzt die Navigation je Eintrag; ohne den Wert
   bleibt es beim Akzent, damit Einträge ohne eigene Farbe nicht auffallen. */
.nav__item { --nav-farbe: var(--accent); }
.nav__item svg { color: var(--nav-farbe); opacity: .9; }
.nav__item.is-active {
  background: color-mix(in srgb, var(--nav-farbe) 14%, transparent);
  color: var(--nav-farbe);
  font-weight: 600;
}
.nav__item.is-active svg { opacity: 1; }
/* Farbiger Balken links – zeigt die Auswahl auch bei schwacher Färbung */
.nav__item.is-active { position: relative; }
.nav__item.is-active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 0 3px 3px 0; background: var(--nav-farbe);
}
.nav__item .badge { margin-left: auto; }

.sidebar__foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-soft); }

/* Hauptbereich */
.main {
  grid-area: main;
  padding: 22px;
  max-width: 1560px;
  width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.view { animation: fade .22s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-head p { color: var(--text-mute); font-size: .88rem; margin: 4px 0 0; }

/* ---------------------------------------------------------- Bausteine */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
}
.card__head h3 { font-size: .96rem; }
.card__head .hint { font-size: .78rem; color: var(--text-mute); font-weight: 400; }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }
.card__foot { padding: 13px 18px; border-top: 1px solid var(--line-soft); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }

.grid { display: grid; gap: 16px; }
.grid--kpi   { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--2     { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid--3     { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--wide  { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid--wide { grid-template-columns: 1fr; } }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row   { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--tight { gap: 6px; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }

/* Kennzahl */
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 17px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 7px;
  position: relative; overflow: hidden;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease);
}
.kpi--klick { cursor: pointer; }
.kpi--klick:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--kpi-color, var(--accent)); opacity: .85;
}
.kpi__top { display: flex; align-items: center; gap: 8px; }
.kpi__icon {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--kpi-color, var(--accent)) 14%, transparent);
  color: var(--kpi-color, var(--accent));
}
.kpi__icon svg { width: 17px; height: 17px; }
.kpi__label { font-size: .78rem; color: var(--text-mute); font-weight: 550; letter-spacing: .01em; }
.kpi__value { font-size: 1.6rem; font-weight: 680; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.kpi__value small { font-size: .62em; font-weight: 550; color: var(--text-mute); margin-right: 3px; }
.kpi__meta {
  font-size: .78rem; color: var(--text-mute);
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; row-gap: 2px;
}

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: .76rem; white-space: nowrap; }
.trend svg { width: 13px; height: 13px; flex-shrink: 0; }
.trend--auf { color: var(--ok); }
.trend--ab  { color: var(--bad); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: .88rem; font-weight: 570;
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s var(--ease), border-color .13s var(--ease), transform .08s var(--ease), box-shadow .13s var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
/* Fuer Verweise, die kein disabled kennen. */
.btn.is-aus { opacity: .5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 38%, transparent); background: var(--bad-soft); }
.btn--danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn--ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 38%, transparent); background: var(--ok-soft); }
.btn--ok:hover { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn--sm { padding: 6px 11px; font-size: .81rem; border-radius: var(--r-xs); }
.btn--sm svg { width: 15px; height: 15px; }
.btn--lg { padding: 13px 22px; font-size: .96rem; border-radius: var(--r-md); }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; }
.btn--icon svg { width: 18px; height: 18px; }

.btn-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.btn-group button {
  border: 0; background: none; padding: 7px 13px; font-size: .84rem; font-weight: 550;
  color: var(--text-soft); cursor: pointer; border-right: 1px solid var(--line-soft);
  transition: background .13s var(--ease);
}
.btn-group button:last-child { border-right: 0; }
.btn-group button:hover { background: var(--surface-3); }
.btn-group button.is-active { background: var(--accent); color: var(--accent-text); }

/* Zeitraumwahl der Übersicht: Umfang oben, darunter die konkrete Periode.
   Rechtsbündig, damit sie unter der Knopfgruppe hängt. */
.zeitraum-wahl {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.periode-nav { display: flex; align-items: center; gap: 6px; }
.periode-nav__liste {
  padding: 6px 30px 6px 10px; font-size: .84rem; font-weight: 550;
  background-size: 15px; min-width: 10.5rem;
}

/* Chips und Etiketten */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: .74rem; font-weight: 620; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-soft);
  white-space: nowrap;
}
.badge--ok   { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad  { background: var(--bad-soft); color: var(--bad); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-full);
  border: 1px solid var(--line); background: var(--surface);
  font-size: .82rem; cursor: pointer; color: var(--text-soft);
  transition: all .13s var(--ease);
}
.chip:hover { border-color: var(--line-strong); background: var(--surface-3); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label {
  font-size: .8rem; font-weight: 580; color: var(--text-soft);
  display: flex; align-items: center; gap: 6px;
}
.field .hilfe { font-size: .75rem; color: var(--text-mute); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  transition: border-color .13s var(--ease), box-shadow .13s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-mute); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 82px; line-height: 1.5; }
.input--num { font-family: var(--font-num); text-align: right; font-variant-numeric: tabular-nums; }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b8698' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: 34px;
}

/* Wiederherstellungscode gross und abschreibbar */
.code-anzeige {
  font-family: var(--font-num);
  font-size: 1.32rem;
  letter-spacing: 1.5px;
  text-align: center;
  padding: 18px 12px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  user-select: all;
  word-break: break-all;
}
@media (max-width: 620px) { .code-anzeige { font-size: 1.1rem; letter-spacing: 1px; } }

/* Passwortfeld mit Auge zum Sichtbarmachen */
.passwortfeld { position: relative; display: block; }
.passwortfeld .input { padding-right: 46px; }
.passwortfeld__auge {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; background: none; cursor: pointer;
  color: var(--text-mute); border-radius: var(--r-sm);
  transition: color .13s var(--ease), background .13s var(--ease);
}
.passwortfeld__auge:hover { color: var(--text); background: var(--surface-3); }
.passwortfeld__auge svg { width: 19px; height: 19px; }

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .input:not(:first-child) { border-radius: 0; border-left: 0; }
.input-group__addon {
  display: flex; align-items: center; padding: 0 11px;
  border: 1px solid var(--line-strong); border-left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface-3); color: var(--text-mute);
  font-size: .84rem; white-space: nowrap;
}
.input-group__addon:first-child { border-left: 1px solid var(--line-strong); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
@media (max-width: 620px) {
  .form-grid, .form-grid--2 { grid-template-columns: 1fr; }
  .span-2, .span-all { grid-column: auto; }
}

/* Schalter */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 42px; height: 24px; border-radius: var(--r-full);
  background: var(--line-strong); position: relative; flex-shrink: 0;
  transition: background .18s var(--ease);
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm); transition: transform .18s var(--ease);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch__text { font-size: .87rem; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .87rem; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

/* Kategorienwahl unter der Übersicht. Die Einträge fliessen in Spalten,
   damit auch zwei Dutzend Kategorien nicht zu einer endlosen Liste werden. */
.kat-wahl {
  display: grid; gap: 2px 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  margin-top: 10px;
}
.kat-wahl__eintrag {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 4px; border-radius: var(--r-xs);
  cursor: pointer; font-size: .87rem; min-width: 0;
}
.kat-wahl__eintrag:hover { background: var(--surface-3); }
.kat-wahl__eintrag input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; flex: none; }
.kat-wahl__punkt { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.kat-wahl__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Abgewählte blasser, damit die Auswahl auf einen Blick lesbar ist */
.kat-wahl__eintrag:has(input:not(:checked)) .kat-wahl__name { color: var(--text-mute); }
.kat-wahl__eintrag:has(input:not(:checked)) .kat-wahl__punkt { opacity: .35; }

/* Tabellen */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  min-width: 560px;
}
table.data th {
  text-align: left;
  padding: 11px 14px;
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mute); font-weight: 640;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr { transition: background .1s var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.is-klick { cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .aktionen { text-align: right; white-space: nowrap; width: 1%; }
table.data .stark { font-weight: 620; }
table.data .leise { color: var(--text-mute); font-size: .82rem; }

/* Rückgabeliste: schmalere Zeilen, das Kästchen mittig und gross genug
   zum Treffen. Erledigte Zeilen treten zurück, verschwinden aber nicht. */
table.data--eng td { padding: 8px 12px; }
table.data--eng { min-width: 440px; }
table.data .mitte { text-align: center; width: 74px; }
table.data .mitte input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer;
}
table.data tbody tr.ist-erledigt td { color: var(--text-mute); }
table.data tbody tr.ist-erledigt .stark { font-weight: 500; }

/* Listen für schmale Bildschirme */
.liste { display: flex; flex-direction: column; }
.liste__item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .1s var(--ease);
}
.liste__item:hover { background: var(--surface-2); }
.liste__item:last-child { border-bottom: 0; }
.liste__main { flex: 1; min-width: 0; }
.liste__titel { font-weight: 580; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste__sub { font-size: .79rem; color: var(--text-mute); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.liste__wert { text-align: right; font-variant-numeric: tabular-nums; font-weight: 620; white-space: nowrap; }
.liste__avatar {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 650; font-size: .85rem;
}

/* Leerzustand */
.leer {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 52px 24px; text-align: center; color: var(--text-mute);
}
.leer svg { width: 44px; height: 44px; opacity: .38; }
.leer strong { color: var(--text-soft); font-size: .96rem; font-weight: 600; }
.leer p { font-size: .85rem; max-width: 380px; margin: 0; }

/* Fortschritt */
.bar { height: 7px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar__fill { height: 100%; border-radius: var(--r-full); background: var(--accent); transition: width .5s var(--ease); }

/* Hinweis-Kasten */
.notiz {
  display: flex; gap: 11px; padding: 13px 15px;
  border-radius: var(--r-sm); font-size: .85rem;
  background: var(--info-soft); color: var(--text-soft);
  border: 1px solid color-mix(in srgb, var(--info) 24%, transparent);
}
.notiz svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--info); margin-top: 1px; }
.notiz--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.notiz--warn svg { color: var(--warn); }
.notiz--bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.notiz--bad svg { color: var(--bad); }
.notiz--ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.notiz--ok svg { color: var(--ok); }

/* --------------------------------------------------------------- Modal */

.modal-bg {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .16s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  width: min(100%, 620px);
  max-height: min(92dvh, 900px);
  display: flex; flex-direction: column;
  animation: pop .22s var(--ease);
  overflow: hidden;
  border: 1px solid var(--line);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.modal--breit { width: min(100%, 1080px); }
.modal--schmal { width: min(100%, 440px); }
.modal--voll { width: min(100%, 1320px); height: min(94dvh, 1000px); }

.modal__head {
  display: flex; align-items: center; gap: 12px;
  padding: 17px 20px; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal__head h2 { font-size: 1.06rem; flex: 1; min-width: 0; }
.modal__head p { margin: 2px 0 0; font-size: .8rem; color: var(--text-mute); font-weight: 400; }
.modal__body { padding: 20px; overflow-y: auto; flex: 1; }
.modal__body--flush { padding: 0; }
.modal__foot {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 15px 20px; border-top: 1px solid var(--line);
  background: var(--surface-2); flex-shrink: 0; flex-wrap: wrap;
}
.modal__foot .spacer { flex: 1; }

/* Meldungen */
.toasts {
  position: fixed; z-index: 200;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); right: 18px;
  display: flex; flex-direction: column; gap: 9px;
  pointer-events: none;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  font-size: .87rem;
  pointer-events: auto;
  animation: slideIn .24s var(--ease);
}
@keyframes slideIn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
.toast.is-weg { animation: slideOut .2s var(--ease) forwards; }
@keyframes slideOut { to { opacity: 0; transform: translateX(28px); } }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast--ok svg { color: var(--ok); }
.toast--bad svg { color: var(--bad); }
.toast--warn svg { color: var(--warn); }
.toast--info svg { color: var(--info); }
.toast__text { flex: 1; min-width: 0; }
.toast__text strong { display: block; font-weight: 620; }
.toast__text span { color: var(--text-mute); font-size: .82rem; }

/* Ladeanzeige */
.spinner {
  width: 17px; height: 17px; flex-shrink: 0;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner--gross { width: 34px; height: 34px; border-width: 3px; }

.laden { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 60px 20px; color: var(--text-mute); font-size: .88rem; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-xs);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------- Dauer-Aktionen */

.schnellzugriff { display: flex; gap: 8px; align-items: center; }

/* Die vier Dauer-Aktionen in der Kopfzeile: gross, farbig, überall gleich */
.aktion {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 17px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: .92rem; font-weight: 640;
  cursor: pointer; white-space: nowrap;
  transition: transform .09s var(--ease), filter .14s var(--ease), box-shadow .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
}
.aktion:hover { filter: brightness(1.07); box-shadow: var(--shadow-md); text-decoration: none; }
.aktion:active { transform: scale(.96); }
.aktion svg { width: 20px; height: 20px; flex-shrink: 0; }

.aktion--uebersicht    { background: #6366f1; color: #fff; }
.aktion--rechnung      { background: var(--accent); color: var(--accent-text); }
.aktion--ausgabe       { background: #0f9d75; color: #fff; }
.aktion--postfach      { background: #d97706; color: #fff; }
.aktion--einstellungen { background: var(--surface-3); color: var(--text-soft); border-color: var(--line-strong); }
.aktion--einstellungen:hover { background: var(--line); color: var(--text); }

[data-theme="dunkel"] .aktion--uebersicht { background: #7c7ff5; color: #0d1017; }
[data-theme="dunkel"] .aktion--ausgabe    { background: #14b98a; color: #0d1017; }
[data-theme="dunkel"] .aktion--postfach   { background: #f0a12e; color: #0d1017; }

.fab-leiste {
  display: none;
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 60;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  gap: 8px;
}
.fab-leiste .btn { flex: 1; padding: 11px 8px; font-size: .82rem; }
.fab-leiste .btn svg { width: 19px; height: 19px; }

/* Untere Navigation (Mobil)
   Der zusätzliche Abstand unten hält die Schaltflächen frei von der
   Browserleiste und der Gestensteuerung des Betriebssystems. */
.tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px -12px rgba(16, 24, 40, .3);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 18px);
}
.tabbar__inner { display: flex; padding: 8px 6px 2px; gap: 2px; }
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 9px 3px;
  min-height: 56px;
  border-radius: var(--r-md);
  color: var(--text-mute); font-size: .74rem; font-weight: 600;
  text-decoration: none; position: relative;
  transition: background .14s var(--ease), color .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.tabbar a { --nav-farbe: var(--accent); }
.tabbar a svg { width: 25px; height: 25px; color: var(--nav-farbe); opacity: .75; }
.tabbar a:active { background: var(--surface-3); }
.tabbar a.is-active {
  color: var(--nav-farbe);
  background: color-mix(in srgb, var(--nav-farbe) 14%, transparent);
}
.tabbar a.is-active svg { opacity: 1; }
.tabbar a.is-active svg { transform: scale(1.06); }

/* --------------------------------------------------------- Anmeldung */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 620px at 12% -8%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 62%),
    radial-gradient(900px 560px at 92% 108%, color-mix(in srgb, #a855f7 12%, transparent), transparent 60%),
    var(--bg);
}
.auth__box {
  width: min(100%, 428px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  padding: 34px 30px;
}
.auth__logo {
  width: 54px; height: 54px; border-radius: 15px; margin: 0 auto 18px;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #a855f7));
  display: grid; place-items: center; color: #fff;
  box-shadow: var(--shadow-md);
}
.auth__logo svg { width: 27px; height: 27px; }
.auth h1 { text-align: center; font-size: 1.42rem; margin-bottom: 6px; }
.auth__sub { text-align: center; color: var(--text-mute); font-size: .87rem; margin-bottom: 26px; }
.auth form { display: flex; flex-direction: column; gap: 15px; }
.auth__fehler {
  padding: 11px 14px; border-radius: var(--r-sm);
  background: var(--bad-soft); color: var(--bad);
  font-size: .85rem; border: 1px solid color-mix(in srgb, var(--bad) 26%, transparent);
}
.auth__fuss { text-align: center; margin-top: 20px; font-size: .8rem; color: var(--text-mute); }

/* ---------------------------------------------------------- Diagramme */

.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart__legende { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 14px; font-size: .8rem; }
.chart__legende span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.chart__punkt { width: 9px; height: 9px; border-radius: 2.5px; flex-shrink: 0; }

.chart-tip {
  position: fixed; z-index: 210; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow-lg);
  padding: 9px 12px; font-size: .8rem; white-space: nowrap;
  transform: translate(-50%, -118%);
}
.chart-tip strong { display: block; font-size: .84rem; margin-bottom: 3px; }
.chart-tip div { display: flex; align-items: center; gap: 7px; color: var(--text-soft); }
.chart-tip b { font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 12px; color: var(--text); }

/* Ranking-Balken */
.rang { display: flex; flex-direction: column; gap: 13px; }
.rang__zeile { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.rang__name { font-size: .86rem; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 7px; }
.rang__wert { font-size: .86rem; font-weight: 620; font-variant-numeric: tabular-nums; }
.rang__bar { grid-column: 1 / -1; height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.rang__fill { height: 100%; border-radius: var(--r-full); transition: width .6s var(--ease); }

/* -------------------------------------------------------- Rechnungen */

.pos-tabelle { width: 100%; border-collapse: collapse; font-size: .87rem; }
.pos-tabelle th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute);
  font-weight: 640; text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line);
}
.pos-tabelle td { padding: 5px 6px; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.pos-tabelle .input, .pos-tabelle .select { padding: 7px 9px; font-size: .85rem; }
.pos-tabelle .griff { cursor: grab; color: var(--text-mute); text-align: center; width: 26px; padding-top: 13px; }
.pos-tabelle tr.zieht { opacity: .4; }
.pos-tabelle .num { text-align: right; }

.summen { display: flex; flex-direction: column; gap: 7px; margin-left: auto; width: min(100%, 330px); }
.summen__zeile { display: flex; justify-content: space-between; gap: 20px; font-size: .88rem; color: var(--text-soft); }
.summen__zeile b { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.summen__gesamt {
  display: flex; justify-content: space-between; gap: 20px;
  padding-top: 11px; margin-top: 5px; border-top: 2px solid var(--line-strong);
  font-size: 1.08rem; font-weight: 700;
}
.summen__gesamt b { font-variant-numeric: tabular-nums; }

/* PDF-Vorschau */
.pdf-rahmen {
  width: 100%; height: 100%; min-height: 460px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-3);
}

/* Lichtkasten: Beleg bildschirmfüllend ansehen.
   Liegt über den Dialogen (z-index 100), aber unter den Meldungen (200). */
.lichtkasten {
  position: fixed; inset: 0; z-index: 150;
  display: flex; flex-direction: column;
  background: #0c0f16;
  animation: fadeIn .16s var(--ease);
}
.lichtkasten__leiste {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: rgba(255, 255, 255, .06);
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  color: #fff;
}
.lichtkasten__titel { flex: 1; min-width: 0; }
.lichtkasten__titel strong {
  display: block; font-size: .95rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lichtkasten__titel span {
  display: block; font-size: .78rem; opacity: .68;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lichtkasten .btn {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .18);
  color: #fff;
}
.lichtkasten .btn:hover { background: rgba(255, 255, 255, .2); }

.lichtkasten__buehne {
  flex: 1; min-height: 0;
  display: flex; overflow: auto;
}
.lichtkasten__pdf {
  flex: 1; width: 100%; height: 100%;
  border: 0; background: #fff;
}
/* flex:none ist nötig: Als Flex-Kind würde das Bild sonst auf die Bühne
   zusammengestaucht, auch wenn max-width aufgehoben ist. Das zentrierende
   margin:auto bleibt auch beim Zoomen stehen, damit die obere linke Ecke
   erreichbar bleibt. */
.lichtkasten__buehne img {
  margin: auto; flex: none;
  max-width: 100%; max-height: 100%;
  object-fit: contain; cursor: zoom-in;
}
/* Auf Originalgrösse: Die Bühne scrollt, das Bild wird nicht mehr eingepasst. */
.lichtkasten__buehne img.is-zoom {
  max-width: none; max-height: none;
  cursor: zoom-out;
}

@media (max-width: 640px) {
  .lichtkasten__leiste { padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .lichtkasten__leiste .btn span { display: none; }
}

/* Beleg-Vorschau beim Erfassen: der eingebaute Betrachter des Browsers,
   gross genug zum Mitlesen. Die Seitenleiste blendet der Aufruf aus
   (#navpanes=0), die Zoomleiste bleibt. */
.beleg-vorschau {
  width: 100%;
  height: clamp(380px, 58vh, 760px);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
}
@media (max-width: 1024px) {
  .beleg-vorschau { height: clamp(300px, 46vh, 520px); }
}

/* Beleg-Aufnahme */
.scan-buehne {
  position: relative;
  background: #0b0d12;
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  max-height: 62dvh;
  display: grid;
  place-items: center;
}
.scan-buehne video, .scan-buehne canvas, .scan-buehne img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.scan-rahmen {
  position: absolute; inset: 7%;
  border: 2px dashed rgba(255, 255, 255, .5);
  border-radius: var(--r-sm);
  pointer-events: none;
}
.scan-rahmen::before {
  content: attr(data-text);
  position: absolute; left: 50%; bottom: -34px; transform: translateX(-50%);
  color: rgba(255, 255, 255, .8); font-size: .78rem; white-space: nowrap;
}
.scan-aktionen { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.ausloeser {
  width: 66px; height: 66px; border-radius: 50%;
  border: 4px solid var(--accent); background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
  transition: transform .1s var(--ease);
}
.ausloeser:active { transform: scale(.93); }
.ausloeser::after { content: ""; width: 46px; height: 46px; border-radius: 50%; background: var(--accent); }

.ocr-status {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent);
  font-size: .85rem; font-weight: 550;
}

.treffer {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .74rem; color: var(--ok); font-weight: 580;
}

/* Rechnungsdesigner */
.designer { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 980px) { .designer { grid-template-columns: 1fr; } }
.designer__vorschau {
  background: var(--surface-3); border-radius: var(--r-md); padding: 16px;
  display: grid; place-items: center; position: sticky; top: 86px;
}

.farbwahl { display: flex; gap: 8px; flex-wrap: wrap; }
.farbwahl button {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  transition: transform .12s var(--ease);
}
.farbwahl button:hover { transform: scale(1.12); }
.farbwahl button.is-active { border-color: var(--text); transform: scale(1.12); }

input[type="color"] {
  width: 42px; height: 34px; padding: 2px; border-radius: var(--r-xs);
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
}

/* Einstellungs-Reiter – umbrechend, damit auch der zwölfte Reiter sichtbar ist */
.reiter {
  display: flex; flex-wrap: wrap; gap: 1px 3px; padding-bottom: 2px;
  border-bottom: 1px solid var(--line); margin-bottom: 20px;
}
.reiter button {
  padding: 10px 14px; border: 0; background: none; cursor: pointer;
  font-size: .88rem; font-weight: 550; color: var(--text-mute);
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color .13s var(--ease), border-color .13s var(--ease);
}
.reiter button:hover { color: var(--text); }
.reiter button.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.einst-block { padding: 20px 0; border-bottom: 1px solid var(--line-soft); }
.einst-block:last-child { border-bottom: 0; }
.einst-block > h3 { margin-bottom: 4px; }
.einst-block > .beschreibung { color: var(--text-mute); font-size: .84rem; margin-bottom: 16px; }

.sortier-liste { display: flex; flex-direction: column; gap: 7px; }
.sortier-liste__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2);
}
/* Der Name ist das Wichtigste in der Zeile und darf nie wegschrumpfen */
.sortier-liste__name  { flex: 1 1 200px; min-width: 150px; }
.sortier-liste__konto { flex: 0 0 110px; width: 110px; }

/* Suchleiste */
.suche { position: relative; flex: 1; min-width: 170px; max-width: 380px; }
.suche svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-mute); pointer-events: none;
}
.suche .input { padding-left: 34px; }

.filterleiste {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}

/* Zwischenueberschrift in einer Liste, etwa "Zuletzt erfasst". */
.liste__gruppe {
  padding: 9px 16px 5px;
  font-size: .72rem; font-weight: 620; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-mute);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}

/* Zweite, leisere Leiste unter der Suche - fuer die Sortierung. */
.filterleiste--zart { background: transparent; padding: 9px 16px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip__pfeil { width: 13px; height: 13px; margin-left: 1px; }

/* Bestellungen und Umsatz am rechten Rand einer Kundenzeile. */
.kennzahlen {
  display: flex; gap: 20px; flex-shrink: 0;
  text-align: right;
}
.kennzahlen > div { display: flex; flex-direction: column; min-width: 68px; }
.kennzahlen strong { font-size: .92rem; font-weight: 620; font-variant-numeric: tabular-nums; }
.kennzahlen span { font-size: .72rem; color: var(--text-mute); }

/* Haken fuer die Auswahlliste. Ohne Markierung bleibt er zurueckhaltend,
   damit er die Zeile nicht beherrscht. */
.merk { color: var(--text-mute); flex-shrink: 0; }
.merk:hover { color: var(--text-soft); }
.merk.is-aktiv { color: var(--accent); border-color: var(--accent); }
.merk.is-aktiv svg { fill: color-mix(in srgb, var(--accent) 18%, transparent); }

@media (max-width: 760px) {
  /* Nebeneinander waere hier zu eng - vom Namen bliebe "Alpha ..." uebrig.
     Die Zahlen ruecken deshalb unter den Namen, auf dessen Hoehe, und beide
     bleiben erhalten. order sorgt dafuer, dass Haken und Pfeil oben bleiben. */
  .liste--kunden .liste__item { flex-wrap: wrap; }
  .liste--kunden .kennzahlen {
    order: 3; width: 100%;
    margin: 2px 0 0 52px;
    gap: 16px; text-align: left;
  }
  .liste--kunden .kennzahlen > div {
    flex-direction: row; align-items: baseline; gap: 5px; min-width: 0;
  }
}

/* Alte und neue Anschrift nebeneinander, damit der Unterschied auffaellt. */
.adressvergleich {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px; margin-top: 9px;
  font-size: .82rem; line-height: 1.45;
}
.adressvergleich .label { display: block; margin-bottom: 3px; font-size: .72rem; }
@media (max-width: 560px) {
  .adressvergleich { grid-template-columns: minmax(0, 1fr); gap: 10px; }
}

/* Hilfsklassen */
.txt-mute  { color: var(--text-mute); }
.txt-soft  { color: var(--text-soft); }
.txt-ok    { color: var(--ok); }
.txt-bad   { color: var(--bad); }
.txt-warn  { color: var(--warn); }
.txt-sm    { font-size: .82rem; }
.txt-xs    { font-size: .75rem; }
.txt-num   { font-variant-numeric: tabular-nums; }
.stark     { font-weight: 620; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.klick { cursor: pointer; }

/* ------------------------------------------------------------ Responsiv */

@media (max-width: 1024px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "header" "main";
    padding-bottom: calc(var(--tabbar-h) + max(env(safe-area-inset-bottom, 0px), 14px));
  }
  .sidebar { display: none; }
  .tabbar { display: block; }
  /* Sobald die Leiste unten steht, muessen die Meldungen darueber bleiben -
     sonst verdecken sie die Navigation. Frueher galt das erst ab 620px, und
     dazwischen lagen sie auf der Leiste. */
  .toasts { bottom: calc(var(--tabbar-h) + max(env(safe-area-inset-bottom, 0px), 14px)); }
  .main { padding: 16px; }
  .topbar { padding: 0 12px; }
  .schnellzugriff { display: none; }

  /* Beschriftungen weichen, die Flächen bleiben gross genug zum Treffen */
  .topbar__actions { gap: 6px; }
  .topbar__actions .aktion span { display: none; }
  .topbar__actions .aktion { padding: 0; width: 44px; height: 44px; border-radius: 13px; }
  .topbar__actions .aktion svg { width: 22px; height: 22px; }
  .topbar__title h1 { font-size: 1.02rem; }
  .topbar__title span { display: none; }
}

@media (max-width: 620px) {
  body { font-size: 15.5px; }
  h1 { font-size: 1.32rem; }
  .main { padding: 13px 12px; }

  /* Eingabefelder: 16px verhindert, dass iOS beim Antippen hineinzoomt */
  .input, .select, .textarea {
    font-size: 16px;
    padding: 12px 13px;
    border-radius: var(--r-sm);
  }
  .select { padding-right: 38px; background-size: 17px; }
  .textarea { min-height: 92px; }
  .field > label, .label { font-size: .88rem; font-weight: 620; }
  .field .hilfe { font-size: .81rem; }
  .check, .switch__text { font-size: .92rem; }
  .check input { width: 20px; height: 20px; }
  .switch__track { width: 48px; height: 27px; }
  .switch__track::after { width: 21px; height: 21px; }
  .switch input:checked + .switch__track::after { transform: translateX(21px); }

  /* Zeitraumwahl der Übersicht: auf dem Handy volle Breite statt gedrängt
     an den rechten Rand. Die Liste nimmt sich den Platz, der übrig bleibt. */
  .zeitraum-wahl { align-items: stretch; width: 100%; }
  .zeitraum-wahl .btn-group { display: flex; }
  .zeitraum-wahl .btn-group button { flex: 1; padding: 9px 6px; }
  .periode-nav__liste { flex: 1; min-width: 0; font-size: 16px; padding: 10px 34px 10px 12px; }

  /* Reiter und Blöcke der Einstellungen */
  .reiter { gap: 1px 4px; margin-bottom: 16px; }
  .reiter button { font-size: .92rem; padding: 10px 12px; }
  .einst-block { padding: 18px 0; }
  .einst-block > h3 { font-size: 1.06rem; }
  .einst-block > .beschreibung { font-size: .88rem; }
  .card__head h3 { font-size: 1.02rem; }
  /* Auf dem Handy bekommt der Name die erste Zeile für sich, alles
     Weitere rutscht darunter. */
  .sortier-liste__item  { padding: 11px; gap: 8px; flex-wrap: wrap; }
  .sortier-liste__name  { flex: 1 1 60%; min-width: 140px; }
  .sortier-liste__konto { flex: 1 1 100px; width: auto; min-width: 90px; }
  .designer__vorschau { position: static; }

  /* Schaltflächen bequem treffbar */
  .btn { padding: 11px 16px; font-size: .92rem; }
  .btn--sm { padding: 9px 13px; font-size: .87rem; }
  .btn--icon { padding: 10px; }
  .chip { padding: 8px 14px; font-size: .88rem; }
  .btn-group button { padding: 10px 15px; font-size: .89rem; }
  .kpi { padding: 13px 14px; }
  /* Beträge schrumpfen mit, statt in zwei Zeilen zu brechen */
  .kpi__value { font-size: clamp(.98rem, 4.5vw, 1.42rem); white-space: nowrap; }
  .kpi__label { font-size: .74rem; }
  .grid { gap: 12px; }
  .grid--kpi { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .card__body { padding: 14px; }
  .card__head { padding: 13px 14px; flex-wrap: wrap; gap: 3px 10px; }
  .card__head .hint { font-size: .73rem; }
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%; max-height: 94dvh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation: hoch .26s var(--ease);
  }
  @keyframes hoch { from { transform: translateY(100%); } to { transform: none; } }
  .modal__foot { padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px)); }
  .modal__foot .btn { flex: 1; justify-content: center; }
  .toasts { left: 12px; right: 12px; max-width: none; }
  table.data { min-width: 460px; }
  .summen { width: 100%; }
  .page-head { align-items: flex-start; }
}

/* Auf sehr breiten Schirmen mehr Luft */
@media (min-width: 1700px) {
  .main { padding: 26px 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Drucken: nur den Inhalt, keine Navigation */
@media print {
  .sidebar, .topbar, .tabbar, .fab-leiste, .toasts, .btn { display: none !important; }
  .app { display: block; }
  .main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  body { background: #fff; }
}

/* ------------------------------------------------------- TWINT-Kasse */
/* Der Code soll den Bildschirm füllen: der Kunde scannt ihn aus einem
   halben Meter Entfernung, oft bei Tageslicht. Deshalb weisser Grund
   unabhängig vom Erscheinungsbild – dunkel scannt schlechter. */
.twint-kasse {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 4px 0;
}
.twint-kasse__code {
  width: 100%; max-width: min(70vh, 520px); aspect-ratio: 1;
  background: #fff; border-radius: 14px; padding: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .12);
}
.twint-kasse__code img {
  width: 100%; height: 100%; object-fit: contain;
  image-rendering: pixelated;   /* scharfe Kanten statt weichgezeichneter Module */
}
/* Warte- und Fehlerzustand liegen im weissen Quadrat, damit es beim
   Auslesen nicht springt. Dunkler Text, der Grund ist ja weiss. */
.twint-kasse__warten,
.twint-kasse__fehlt { color: #555; text-align: center; }
.twint-kasse__fehlt {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 0 18px; max-width: 40ch;
}
.twint-kasse__fehlt svg { width: 34px; height: 34px; opacity: .5; }
.twint-kasse__betrag {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.twint-kasse__betrag strong { font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 700; }
.twint-kasse__hinweis { text-align: center; max-width: 34ch; }
.twint-kasse__knopf { width: min(100%, 420px); }

/* TWINT-Farbe, damit der Knopf am Kundentisch sofort gefunden wird */
.btn--twint { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.btn--twint:hover { background: #2b2b48; border-color: #2b2b48; }
