/* Purser · KDB.one – Oberfläche
 * Markenfarbe: Verlauf Violett → Magenta. Text in Navy, Flächen in hellem Blaugrau.
 * Keine Inline-Styles (CSP), alles über Klassen.
 */

:root {
  --brand-1: #863bf3;
  --brand-2: #f716b1;
  --brand: linear-gradient(120deg, var(--brand-1), var(--brand-2));
  --brand-soft: linear-gradient(120deg, rgb(134 59 243 / 0.10), rgb(247 22 177 / 0.10));

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --subtle: #eef0f6;
  --text: #001f4d;
  --muted: #5f6b85;
  --border: #dadfea;
  --accent: #7a35e6;
  --accent-text: #6a2bd4;
  --focus: rgb(134 59 243 / 0.35);

  --success: #128a5c;
  --success-bg: #e6f6ef;
  --warning: #9a6200;
  --warning-bg: #fff5df;
  --error: #c4224a;
  --error-bg: #fdebef;
  --info: #0b6fa8;
  --info-bg: #e7f3fb;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(0 31 77 / 0.05), 0 8px 24px rgb(0 31 77 / 0.06);
  --shadow-lift: 0 2px 4px rgb(0 31 77 / 0.06), 0 14px 32px rgb(0 31 77 / 0.10);
  --appbar: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1024;
    --surface: #111a33;
    --surface-2: #0e1630;
    --subtle: #18233f;
    --text: #e9edf7;
    --muted: #9aa6c2;
    --border: #263252;
    --accent: #b388ff;
    --accent-text: #c3a1ff;
    --focus: rgb(179 136 255 / 0.4);
    --success: #4fd29a;
    --success-bg: #0f2e25;
    --warning: #f3c063;
    --warning-bg: #33280f;
    --error: #ff7d99;
    --error-bg: #3a1424;
    --info: #6cc3f5;
    --info-bg: #0f2a3d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / 0.35), 0 14px 32px rgb(0 0 0 / 0.35);
  }
}

/* --- Grundlagen ---------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; margin: 0; font-weight: 750; }
h2 { font-size: 1.12rem; margin: 0 0 0.9rem; font-weight: 700; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; }
p { margin: 0 0 0.8rem; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
code { font-size: 0.88em; background: var(--subtle); padding: 0.1em 0.35em; border-radius: 6px; }
small, .help { color: var(--muted); font-size: 0.84rem; }
.help { display: block; margin-top: 0.3rem; }
.num, .amount { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.pre { white-space: pre-line; }
.muted { color: var(--muted); }
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* --- App-Gerüst ---------------------------------------------------------- */

.app { min-height: 100vh; }

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: var(--appbar);
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.25rem 0.5rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 6px 12px rgb(134 59 243 / 0.35)); }
.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name strong { font-size: 1.15rem; letter-spacing: -0.01em; }
.brand-name span { color: var(--muted); font-size: 0.78rem; }

.nav { display: flex; gap: 0.15rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a, .nav button, .account-menu-panel a, .account-menu-panel button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav button { justify-content: flex-start; box-shadow: none; }
.nav a:hover, .nav button:hover, .account-menu-panel a:hover, .account-menu-panel button:hover {
  background: var(--subtle); color: var(--text); text-decoration: none; box-shadow: none; filter: none;
}
.nav a[aria-current="page"] {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgb(134 59 243 / 0.28);
}
.account-menu { position: relative; flex: none; }
.account-menu summary { list-style: none; cursor: pointer; border-radius: 50%; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu-panel {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 30; min-width: 14rem;
  display: grid; gap: 0.15rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow);
}
.account-menu-panel a, .account-menu-panel button {
  width: 100%; border: 0; border-radius: 10px; background: none; color: var(--muted);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; box-shadow: none;
}
.account-menu-panel button { justify-content: flex-start; }
.account-menu-panel form { margin: 0; }
.account-name { margin: 0.25rem 0.75rem 0.4rem; font-weight: 650; }

.user-chip {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.75rem 0.25rem;
  color: var(--muted); font-size: 0.85rem;
}
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 0.85rem; flex: none;
}

.practice-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  background: var(--warning-bg); color: var(--warning);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
}

.practice-band {
  padding: 0.45rem 1.5rem;
  background: repeating-linear-gradient(-45deg, var(--warning-bg) 0 14px, transparent 14px 28px),
    var(--warning-bg);
  color: var(--warning);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
}

.main {
  padding: 2rem 2.25rem 4rem;
}
.content { max-width: 88rem; margin: 0 auto; }
.content.wide { max-width: 104rem; }

.topbar, .tabbar { display: none; }

/* --- Seitenkopf ---------------------------------------------------------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-head .sub { margin: 0.4rem 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.back {
  display: flex; width: fit-content; align-items: center; gap: 0.35rem; margin-bottom: 0.9rem;
  color: var(--muted); font-weight: 600; font-size: 0.9rem; text-decoration: none;
}
.back:hover { color: var(--text); text-decoration: none; }

/* --- Karten -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.5rem;
  margin: 0 0 1.25rem;
}
.card > h2:first-child { margin-top: 0; }
.card h2 + .help:first-of-type { margin-top: -0.5rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.warning { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: var(--warning-bg); }
.card.warning ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.card-head h2 { margin: 0; }
.proposals .card-head h2 { display: flex; align-items: center; gap: 0.4rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }
.section-title { margin: 1.6rem 0 0.8rem; }
.form-section { margin-top: 1.6rem; padding-top: 1.3rem; border-top: 1px solid var(--border); }
.form-section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.sidebar-right { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

/* --- Dashboard ----------------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 1.8rem 1.9rem;
  border-radius: 20px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 18px 40px rgb(134 59 243 / 0.30);
  margin-bottom: 1.5rem;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 255 255 / 0.28), transparent 65%);
}
.hero h1 { color: #fff; font-size: 1.9rem; }
.hero p { margin: 0.4rem 0 1.2rem; opacity: 0.92; max-width: 40rem; }
.hero .quick { display: flex; flex-wrap: wrap; gap: 0.6rem; position: relative; z-index: 1; }
.hero .btn {
  background: rgb(255 255 255 / 0.16);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 0.35);
  box-shadow: none;
  backdrop-filter: blur(4px);
}
.hero .btn:hover { background: rgb(255 255 255 / 0.28); }
.hero .btn.solid { background: #fff; color: #6a2bd4; border-color: #fff; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
  display: block;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); text-decoration: none; }
.stat .label { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.84rem; font-weight: 600; }
.stat .value { display: block; margin-top: 0.45rem; font-size: 1.55rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat .hint { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.8rem; }
.stat-icon {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand-soft); color: var(--accent-text);
}
.stat-icon .icon { width: 16px; height: 16px; }

.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar-value { fill: var(--muted); font-size: 10px; font-family: var(--font); }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--border);
}
.list-plain li:last-child { border-bottom: 0; }
.list-plain .title { font-weight: 600; }
.list-plain .meta { color: var(--muted); font-size: 0.84rem; }

/* --- Buttons ------------------------------------------------------------- */

button, .btn, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 16px rgb(134 59 243 / 0.25);
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, filter 0.15s;
}
button:hover, .btn:hover { text-decoration: none; filter: brightness(1.05); box-shadow: 0 10px 22px rgb(134 59 243 / 0.32); }
button:active, .btn:active { transform: translateY(1px); }

button.secondary, .btn.secondary {
  background: var(--surface);
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: none;
}
button.secondary:hover, .btn.secondary:hover { background: var(--subtle); }
button.ghost, .btn.ghost { background: transparent; color: var(--muted); box-shadow: none; }
button.ghost:hover, .btn.ghost:hover { background: var(--subtle); color: var(--text); }
button.danger, .btn.danger { background: var(--error); box-shadow: 0 6px 16px rgb(196 34 74 / 0.22); }
button.link {
  padding: 0; border: 0; background: none; box-shadow: none; color: var(--accent-text);
  font-weight: 600;
}
button.link:hover { text-decoration: underline; filter: none; box-shadow: none; }
button.link.danger-text { color: var(--error); }
button.small, .btn.small { padding: 0.4rem 0.75rem; font-size: 0.86rem; border-radius: 10px; }

.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; margin-top: 1.25rem; }
.actions .spacer { flex: 1; }

/* --- Formulare ----------------------------------------------------------- */

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }

input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus);
}
input[type="checkbox"], input[type="radio"] {
  width: 1.15rem; height: 1.15rem; padding: 0; accent-color: var(--brand-1); vertical-align: -0.2em;
}
input[type="file"] { padding: 0.5rem; background: var(--surface-2); border-style: dashed; }
textarea { resize: vertical; min-height: 2.8rem; }
select { appearance: none; padding-right: 2.2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }

.field { margin-bottom: 1rem; }
form p { margin: 0 0 1rem; }
.errorlist { color: var(--error); font-size: 0.85rem; list-style: none; padding: 0; margin: 0.3rem 0 0; }
.field .errorlist { display: block; }
.field:has(.errorlist) input, .field:has(.errorlist) select, .field:has(.errorlist) textarea { border-color: var(--error); }
.row { display: grid; grid-template-columns: 1fr 2fr 9rem; gap: 0 1rem; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 0 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 0.6fr); gap: 0 1rem; align-items: end; }
.grid3.even { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label.inline { display: inline-flex; gap: 0.5rem; align-items: center; font-weight: 500; margin: 0; }
.field.checkbox { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.field.checkbox label { margin: 0; }
.field.checkbox .help { flex-basis: 100%; margin: 0; }

fieldset.line {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 1rem;
  padding: 1rem 1.1rem 0.4rem;
  background: var(--surface-2);
}
fieldset.line legend {
  padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--brand-soft);
  color: var(--accent-text); font-size: 0.8rem; font-weight: 700;
}
fieldset.line.new { border-style: dashed; background: transparent; }
.line-remove { margin: -0.3rem 0 0.7rem; font-size: 0.86rem; color: var(--muted); }

.dropzone {
  display: grid; gap: 1rem; padding: 1.2rem; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-2);
}

.search { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; margin-bottom: 1.2rem; }
.search .input-icon { position: relative; flex: 1 1 18rem; }
.search .input-icon .icon { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input-icon input { padding-left: 2.4rem; }

/* --- Tabellen ------------------------------------------------------------ */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-2); }
td a { font-weight: 600; }
.card table th { background: transparent; }

/* --- Abzeichen ----------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  background: var(--subtle); color: var(--muted);
  font-size: 0.78rem; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-final, .badge-finalized { background: var(--success-bg); color: var(--success); }
.badge-cancelled, .badge-discarded, .badge-voided { background: var(--error-bg); color: var(--error); }
.badge-cancellation { background: var(--brand-soft); color: var(--accent-text); }
.badge-draft, .badge-inbox { background: var(--info-bg); color: var(--info); }
.badge-archived { background: var(--subtle); color: var(--muted); }
.badge-pay-paid { background: var(--success-bg); color: var(--success); }
.badge-pay-open, .badge-pay-partial { background: var(--info-bg); color: var(--info); }
.badge-pay-overdue { background: var(--warning-bg); color: var(--warning); }
.tabs .count.alert { background: var(--warning); color: var(--surface); }

/* --- Daten-Listen -------------------------------------------------------- */

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.55rem 1.5rem; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: 0; }
.totals {
  margin: 1rem 0 0 auto; max-width: 22rem; padding: 1rem 1.2rem; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
}
.totals.facts { grid-template-columns: 1fr auto; }
.totals dd { text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.15rem; font-weight: 750; padding-top: 0.5rem; border-top: 1px solid var(--border); }

/* --- Meldungen ----------------------------------------------------------- */

.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; gap: 0.6rem; }
.messages li {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.8rem 1rem; border-radius: 12px;
  background: var(--info-bg); color: var(--info);
  border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
  font-weight: 550;
  animation: pop-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.messages li.success { background: var(--success-bg); color: var(--success); }
.messages li.warning { background: var(--warning-bg); color: var(--warning); }
.messages li.error { background: var(--error-bg); color: var(--error); }
.messages li.celebrate {
  background: var(--surface);
  color: var(--text);
  border: 2px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--brand) border-box;
  box-shadow: 0 10px 28px rgb(134 59 243 / 0.20);
}
.messages li.celebrate .icon { color: var(--brand-2); animation: spin-in 0.7s ease-out; }

@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes spin-in { from { transform: rotate(-90deg) scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Leerzustand --------------------------------------------------------- */

.empty {
  display: grid; justify-items: center; gap: 0.6rem; text-align: center;
  padding: 2.5rem 1.5rem; border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--muted);
}
.empty-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px;
  background: var(--brand-soft); color: var(--accent-text);
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty strong { color: var(--text); font-size: 1.05rem; }

/* --- Reiter -------------------------------------------------------------- */

/* Reiter brechen um statt abgeschnitten zu werden; viele Reiter stehen in benannten Gruppen */
.tabs {
  display: inline-flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.3rem; margin: 0 0 1.2rem;
  border-radius: 14px; background: var(--subtle); max-width: 100%;
}
.tab-groups { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 1rem; margin: 0 0 1.2rem; }
.tab-group { display: grid; gap: 0.25rem; min-width: 0; max-width: 100%; }
.tab-group-label {
  padding-left: 0.6rem; color: var(--muted); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.tab-groups .tabs { margin: 0; }
@media (max-width: 40rem) {
  .tab-groups { display: grid; }
  .tab-group .tabs { display: flex; }
}
.tabs a {
  padding: 0.45rem 0.95rem; border-radius: 10px; color: var(--muted); font-weight: 650;
  text-decoration: none; font-size: 0.9rem; white-space: nowrap; flex: none;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

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

.entrance {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 15% 20%, rgb(134 59 243 / 0.55), transparent 45%),
    radial-gradient(circle at 85% 80%, rgb(247 22 177 / 0.45), transparent 45%),
    #0b1230;
}
.entrance-card {
  width: min(100%, 26rem);
  padding: 2rem 2rem 1.5rem;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 30px 60px rgb(0 0 0 / 0.35);
}
.entrance-card .brand { justify-content: center; margin-bottom: 1.4rem; padding: 0; }
.entrance-card h1 { font-size: 1.35rem; text-align: center; margin-bottom: 1.2rem; }
.entrance-card button { width: 100%; }
.entrance-card hr { border: 0; border-top: 1px solid var(--border); margin: 1.3rem 0; }
.entrance-card .button-group { display: grid; gap: 0.6rem; }
.entrance-foot { margin-top: 1.2rem; text-align: center; color: rgb(255 255 255 / 0.7); font-size: 0.8rem; }
.entrance .practice-chip { margin: 0 auto 1rem; display: flex; width: max-content; }

.button-group { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.button-group.vertical { flex-direction: column; }
.danger-zone { margin-top: 0.5rem; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: block; } }
@media (pointer: coarse) { .no-touch { display: none; } }

/* --- Mobil --------------------------------------------------------------- */

@media (max-width: 82rem) {
  .appbar .nav svg { display: none; }
  .appbar { gap: 0.75rem; padding: 0 1rem; }
  .appbar .brand-name span { display: none; }
}

@media (max-width: 64rem) {
  .appbar { display: none; }
  .practice-band { padding: 0.35rem 1rem; font-size: 0.75rem; }
  .main { padding: 1.2rem 1rem calc(6.5rem + env(safe-area-inset-bottom)); }

  .topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand-mark { width: 32px; height: 32px; }

  .tabbar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    padding: 0.4rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar summary {
    display: grid; justify-items: center; gap: 0.15rem; padding: 0.3rem 0;
    color: var(--muted); font-size: 0.68rem; font-weight: 650; text-decoration: none;
    list-style: none; cursor: pointer;
  }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar .icon { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"], .tabbar details[open] summary { color: var(--accent-text); }
  .tabbar .fab {
    justify-self: center; display: grid; place-items: center;
    width: 58px; height: 58px; margin-top: -1.6rem; padding: 0; border-radius: 20px;
    background: var(--brand); color: #fff;
    box-shadow: 0 12px 26px rgb(134 59 243 / 0.45);
  }
  .tabbar .fab .icon { width: 28px; height: 28px; }
  .tabbar details { position: relative; }
  .tabbar .menu {
    position: absolute; right: 0; bottom: calc(100% + 0.8rem); min-width: 13rem;
    display: grid; padding: 0.4rem; border-radius: 16px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lift);
  }
  .tabbar .menu button:hover { filter: none; box-shadow: none; background: var(--subtle); }
  .tabbar .menu a, .tabbar .menu button {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 0.75rem; border-radius: 10px;
    background: none; border: 0; box-shadow: none; color: var(--text); font: inherit;
    font-size: 0.92rem; font-weight: 600; justify-content: flex-start; width: 100%;
  }
  .tabbar .menu form { margin: 0; }

  h1 { font-size: 1.45rem; }
  .hero { padding: 1.4rem 1.3rem; border-radius: 18px; }
  .hero h1 { font-size: 1.5rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
  .stat .value { font-size: 1.25rem; }
  .grid.two, .grid.sidebar-right { grid-template-columns: 1fr; }
  .card { padding: 1.1rem 1.1rem; }
  .page-head { align-items: flex-start; }
}

@media (max-width: 40rem) {
  .row, .grid2, .grid4 { grid-template-columns: 1fr; }
  .grid4.compact { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > :first-child { grid-column: 1 / -1; }
  th, td { padding: 0.7rem 0.75rem; }
  .hide-mobile { display: none; }
  .facts { grid-template-columns: 1fr; gap: 0.1rem; }
  .facts dd { margin-bottom: 0.6rem; }
  .totals.facts { grid-template-columns: 1fr auto; gap: 0.4rem 1rem; }
  .totals.facts dd { margin: 0; }
  .actions button, .actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Ohne Anmeldung (z. B. Fehlerseiten): kein Platz für die Seitenleiste */

.brand-name .practice-chip { padding: 0.05rem 0.4rem; font-size: 0.62rem; vertical-align: 1px; }

/* Belege: Kamera-Knopf und Ablagefläche */
.camera { position: relative; }
.camera input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.camera .btn { width: 100%; padding: 1rem; font-size: 1.05rem; border-radius: 16px; }
.dropzone label { margin-bottom: 0.4rem; }
.upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
/* Ablagefläche: das (unsichtbare) Dateifeld liegt darüber und nimmt Klick und abgelegte Dateien an */
.file-drop { position: relative; display: flex; align-items: center; min-height: 5.5rem; padding: 0.9rem 1rem;
  border: 2px dashed var(--border); border-radius: 12px; background: var(--surface); transition: border-color 0.15s, background 0.15s; }
.file-drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop-text { display: flex; gap: 0.7rem; align-items: center; pointer-events: none; }
.file-drop-text .icon { flex: none; width: 1.6rem; height: 1.6rem; color: var(--brand-1); }
.file-drop-text small { display: block; color: var(--muted); font-size: 0.82rem; }
.file-drop.over, .file-drop:focus-within { border-color: var(--brand-1); background: var(--brand-soft); }
.file-chosen { list-style: none; margin: 0.5rem 0 0; padding: 0; font-size: 0.88rem; }
.file-chosen:empty { display: none; }
.file-chosen li { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.15rem 0; border-bottom: 1px solid var(--border); }
.file-chosen li.summary { font-weight: 600; border-bottom: 0; }
.file-chosen li.too-many { color: var(--error); font-weight: 600; border-bottom: 0; }
.file-chosen .size { color: var(--muted); white-space: nowrap; }
.file-chosen li.failed .size { color: var(--error); font-weight: 600; white-space: normal; text-align: right; }
.file-chosen li.done .size a::before { content: "✓ "; }
@media (max-width: 40rem) { .upload-row { grid-template-columns: 1fr; } }
.file-cell { display: flex; align-items: center; gap: 0.6rem; }
.file-cell .icon { color: var(--accent-text); }
.entrance-card .page-head { justify-content: center; margin-bottom: 0.4rem; }
.entrance-card .page-head h1 { margin-bottom: 0.6rem; }

/* Auswertungen */
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.value.negative, td.negative { color: var(--error); }
.year-select select { width: auto; min-width: 7rem; }
.list-plain.euer li { display: block; padding: 0; }
.list-plain.euer summary, .list-plain.euer .sum, .list-plain.euer .sub li {
  display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem 0; cursor: pointer;
}
.list-plain.euer summary::-webkit-details-marker { display: none; }
.list-plain.euer summary span:first-child::before { content: "›"; display: inline-block; width: 1rem; color: var(--muted); transition: transform 0.15s; }
.list-plain.euer details[open] summary span:first-child::before { transform: rotate(90deg); }
.list-plain.euer .sub { list-style: none; margin: 0 0 0.6rem 1rem; padding: 0; color: var(--muted); font-size: 0.9rem; }
.list-plain.euer .sub li { padding: 0.3rem 0; cursor: default; }
.list-plain.euer .sum { font-weight: 750; border-top: 2px solid var(--border); cursor: default; }
/* EÜR mit Vorjahresspalte; Hinweis auf Vorjahreswerte */
.card.prior-note p { margin: 0; }
.card.prior-note p + p { margin-top: 0.4rem; }
.list-plain.euer.with-prev summary > span:first-child, .list-plain.euer.with-prev .sum > span:first-child,
.list-plain.euer.with-prev li.head > span:first-child { flex: 1; }
.list-plain.euer.with-prev .amount { min-width: 7rem; text-align: right; }
.list-plain.euer .amount.prev { color: var(--muted); font-weight: 400; }
.list-plain.euer li.head { display: flex; gap: 1rem; padding: 0 0 0.2rem; font-size: 0.8rem; color: var(--muted); }
@media (max-width: 640px) { .list-plain.euer .amount.prev { display: none; } }
.list-plain.euer li.plain { display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem 0 0.65rem 1rem; }
.subtabs { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; align-items: center; margin: 0 0 1rem; }
.subtabs a:not(.btn) { font-weight: 600; text-decoration: none; }
.subtabs .btn { margin-left: auto; }
table.aveuer td:first-child, table.aveuer td:nth-child(3), table.aveuer td:nth-child(4) { width: 3.5rem; }
tr.group td { background: var(--surface-2); padding-top: 0.7rem; }
#aveuer h3 { margin: 1.2rem 0 0.4rem; }
tr.sum td { font-weight: 750; background: var(--surface-2); }
.chart .bar-out { fill: color-mix(in srgb, var(--muted) 55%, transparent); }
.legend { display: flex; gap: 0.5rem; align-items: center; color: var(--muted); font-size: 0.84rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.dot.in { background: var(--brand); }
.dot.out { background: color-mix(in srgb, var(--muted) 55%, transparent); }
@media (max-width: 64rem) { .stats.three { grid-template-columns: 1fr 1fr; } }

/* Privat */
.hero.forecast .big { font-size: 2.4rem; font-weight: 800; margin: 0.2rem 0 0.4rem; letter-spacing: -0.02em; }
.hero.forecast h2 { color: #fff; margin: 0; }
.eyebrow.light { color: rgb(255 255 255 / 0.8); }
.row-line { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; }
.list-plain.euer li.total .row-line { font-weight: 750; border-top: 2px solid var(--border); }
.source-row { padding: 0.8rem 0; border-bottom: 1px solid var(--border); }
.source-row .grid2 { margin: 0.5rem 0; }
details > summary { cursor: pointer; font-weight: 600; color: var(--accent-text); margin: 0.6rem 0; }
.logo-preview { max-height: 60px; max-width: 220px; background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--border); }
.product-pick select { background-color: var(--surface-2); }

/* --- Bank -------------------------------------------------------------- */
.stats.bank-accounts { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
a.stat { color: inherit; text-decoration: none; }
a.stat:hover { text-decoration: none; border-color: var(--brand); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.filter-bar .tabs { margin: 0; }
.filter-bar select, .filter-bar input[type="search"] { width: auto; min-width: 9rem; margin: 0; }
.filter-bar input[type="search"] { flex: 1 1 12rem; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 0.6rem; }
.bulk-actions .spacer { flex: 1; }
.bank-table td.check, .bank-table th.check { width: 2rem; padding-right: 0; }
.suggestion { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.suggestion > span { min-width: 0; color: var(--muted); }
.suggestion.sure > span { color: var(--text); }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.suggestions li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 12px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0; }
tr.reversed td { color: var(--muted); }
tr.reversed td:not(:first-child) { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.amount-big { font-size: 1.6rem; font-weight: 750; color: var(--text); font-variant-numeric: tabular-nums; }
.amount-big.negative { color: var(--error); }
.rule-box, .help-box { margin-top: 0.8rem; padding: 0.7rem 0.9rem; border: 1px dashed var(--border); border-radius: 12px; }
.rule-box summary, .help-box summary { cursor: pointer; font-weight: 600; color: var(--accent-text); }
.help-box ul { margin: 0.6rem 0; padding-left: 1.2rem; color: var(--muted); }
.help-box p { color: var(--muted); }
@media (max-width: 720px) {
  .suggestion { flex-direction: column; align-items: flex-start; }
  /* Ohne sichtbare Ankreuzfelder keine Sammelaktionen: sonst bucht ein Tipp die ganze Seite */
  .bank-table .check, .bulk .bulk-only { display: none; }
}
.hint-box { display: flex; gap: 0.5rem; align-items: flex-start; padding: 0.7rem 0.9rem; border-radius: 12px; background: var(--brand-soft); color: var(--accent-text); }
.hint-box .icon { flex: none; margin-top: 0.15rem; }

/* --- Auswertungen: Einzelposten, Trend, Jahresübersicht ----------------- */
.trend { font-weight: 700; }
.trend.up { color: var(--success); }
.trend.down { color: var(--error); }
.show-mobile { display: none; }
@media (max-width: 720px) { .show-mobile { display: block; } }
.list-plain.euer .entries { margin: 0 0 0.8rem 1rem; box-shadow: none; border: 1px solid var(--border); }
.list-plain.euer .entries table { font-size: 0.88rem; }
.result-row { display: flex; justify-content: space-between; align-items: center; font-size: 1.15rem; }
.result-row strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.result-row .negative { color: var(--error); }
.matrix table { font-size: 0.84rem; white-space: nowrap; }
.matrix .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 14rem; white-space: normal; }
.matrix tr.group td { font-weight: 750; padding-top: 1rem; background: var(--surface); }
.matrix tr.position td { font-weight: 650; }
.matrix tr.account td.sticky { padding-left: 1.6rem; font-weight: 400; }
.matrix tr.sum td.sticky { background: var(--surface-2); }
.matrix tr.result td { border-top: 2px solid var(--border); }
table.bookings td .help a { color: var(--muted); }

/* --- Vorauszahlungen (Privat) -------------------------------------------- */

.prepayment-plan { margin-top: 1rem; }
.prepayment-paid form { margin-top: 0.5rem; }
@media (max-width: 40rem) {
  table.prepayments thead { display: none; }
  table.prepayments tr { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--border); }
  table.prepayments td { display: block; border: 0; }
  table.prepayments td:nth-child(n + 3) { grid-column: 1 / -1; padding-top: 0; }
  table.prepayments .grid2 { grid-template-columns: 1fr; }
}

/* --- Journal ------------------------------------------------------------- */

table.journal tr.entry-start td { border-top: 2px solid var(--border); }
table.journal td[rowspan] { vertical-align: top; }
.euer-line { color: var(--muted); font-weight: 400; }

/* --- Beleg erfassen: Beleg links, Angaben rechts ---------------------------- */

.capture.with-preview {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem; align-items: start;
}
.capture-main { min-width: 0; }
.capture-main > .card:first-child, .capture-main > .hint-box:first-child { margin-top: 0; }
.capture-preview {
  position: sticky; top: calc(var(--appbar) + 1rem); height: calc(100vh - var(--appbar) - 2rem);
  min-height: 28rem;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--subtle);
}
.capture-preview iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.capture-preview a { display: block; height: 100%; }
.capture-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.with-preview .capture-form .actions {
  position: sticky; bottom: 0; z-index: 2; margin: 1.25rem -1.5rem -1.35rem; padding: 0.8rem 1.5rem;
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
@media (max-width: 64rem) {
  .capture.with-preview { grid-template-columns: 1fr; }
  .capture-preview { position: static; height: auto; min-height: 0; }
  .capture-preview.is-pdf { display: none; }  /* PDF auf dem Handy: „Ansehen“ oben öffnet ihn ganz */
  .capture-preview img { height: auto; max-height: 50vh; }
  .with-preview .capture-form .actions { position: static; margin: 0; padding: 0; border: 0; background: none; }
}

/* --- Suchfeld für Konten (app.js) ---------------------------------------- */

.combobox { position: relative; }
.combobox input { width: 100%; }
.combobox-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 20rem; overflow-y: auto; margin: 0; padding: 0.25rem 0; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.combobox-list li { padding: 0.5rem 0.85rem; cursor: pointer; }
.combobox-list li.combobox-count {
  cursor: default; font-size: 0.8rem; color: var(--muted); background: var(--subtle); padding: 0.4rem 0.85rem;
}
.combobox-list li[aria-selected="true"] { background: var(--subtle); }
.combobox-list li:hover { background: var(--subtle); }
.combobox-name { display: block; font-weight: 600; }
.combobox-meta { display: block; font-size: 0.82rem; color: var(--muted); }

/* --- Bank: Ansichten, Filter, Zuordnung, Seitenleiste ----------------------- */

.bank-views {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 0 1rem;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.bank-view {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.95rem 1.2rem; color: var(--text);
  font-weight: 650; text-decoration: none; border-right: 1px solid var(--border);
}
.bank-view:last-child { border-right: 0; }
.bank-view:hover { text-decoration: none; background: var(--surface-2); }
.bank-view svg { flex: none; }
.bank-view .count {
  min-width: 1.8rem; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.85rem; text-align: center;
  color: #fff; background: var(--muted);
}
.view-vorschlaege svg, .view-vorschlaege .count { --c: var(--info); }
.view-offen svg, .view-offen .count { --c: var(--warning); }
.view-vorschlaege .count, .view-offen .count { background: var(--c); }
.view-vorschlaege svg, .view-offen svg { color: var(--c); }
.view-vorschlaege[aria-current="page"] { background: var(--info-bg); box-shadow: inset 0 -3px 0 var(--info); }
.view-offen[aria-current="page"] { background: var(--warning-bg); box-shadow: inset 0 -3px 0 var(--warning); }
.view-alle[aria-current="page"] { background: var(--subtle); box-shadow: inset 0 -3px 0 var(--muted); }

.bank-filters {
  display: grid; grid-template-columns: 1.2fr 0.9fr 0.9fr 0.8fr 1.6fr auto; gap: 0 0.8rem; align-items: end;
  margin-bottom: 1rem;
}
.bank-filters .field { margin: 0; }
.bank-filters button { margin-bottom: 0.1rem; }

.bank-table td.assign { min-width: 15rem; }
.assign-cell, .assign-cell .assign-link { display: flex; align-items: center; gap: 0.7rem; }
.assign-cell .assign-link { color: inherit; text-decoration: none; width: 100%; }
.assign-cell > span:nth-child(2), .assign-link > span:last-child { flex: 1; min-width: 0; }
.bank-table td.proposal { background: var(--info-bg); }
.bank-table td.todo { background: var(--warning-bg); }
.bank-table td.todo .assign-link > span:last-child { color: var(--warning); font-weight: 650; }
.assign-icon {
  flex: none; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 10px;
  background: var(--surface); color: var(--muted); box-shadow: var(--shadow);
}
.proposal .assign-icon { color: var(--info); }
.todo .assign-icon { color: var(--warning); }
.done .assign-icon { color: var(--success); }
.assign-actions { display: flex; gap: 0.3rem; flex: none; }
.bank-table .account-name { font-size: 0.75rem; }
.tx-date { font-variant-numeric: tabular-nums; margin-right: 0.5rem; }

.proposal-bar {
  position: sticky; bottom: 1rem; z-index: 5; display: flex; align-items: center; gap: 1rem;
  margin: 1rem 0 0; padding: 0.8rem 1rem 0.8rem 1.2rem; border-radius: var(--radius);
  background: #2d3142; color: #fff; box-shadow: var(--shadow);
}
.proposal-bar span { flex: 1; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(15 20 35 / 0.45); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51; width: min(38rem, 100vw);
  display: flex; flex-direction: column; background: var(--surface); box-shadow: -8px 0 32px rgb(0 0 0 / 0.18);
  overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; }
.drawer-head h2 { margin: 0; }
.drawer-tx { padding: 1rem 1.25rem; background: var(--surface-2); border-block: 1px solid var(--border); }
.drawer-tx p { margin: 0.4rem 0; }
.drawer-tx-row { display: flex; justify-content: space-between; gap: 1rem; margin: 0.3rem 0; }
.drawer-tx details { margin-top: 0.5rem; }
.drawer-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-bottom: 1px solid var(--border); }
.drawer-tabs a {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.85rem 0.5rem;
  color: var(--muted); font-weight: 650; text-decoration: none; text-align: center; font-size: 0.9rem;
}
.drawer-tabs a[aria-current="page"] { color: var(--accent-text); box-shadow: inset 0 -3px 0 var(--accent); }
.drawer-body { padding: 1rem 1.25rem 1.5rem; }
.drawer-search { display: flex; gap: 0.6rem; margin-bottom: 0.8rem; }
.drawer-search input { flex: 1; margin: 0; }
.drawer-actions { display: flex; gap: 0.6rem; margin-top: 1rem; position: sticky; bottom: 0; padding: 0.6rem 0; background: var(--surface); }
.drawer-actions .spacer { flex: 1; }
.stacked-actions { display: grid; gap: 0.6rem; }
.doc-pick { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.doc-pick li + li { border-top: 1px solid var(--border); }
.doc-pick label { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0.9rem; cursor: pointer; margin: 0; font-weight: 400; }
.doc-pick label:hover { background: var(--surface-2); }
.doc-pick input { flex: none; width: auto; margin: 0; }
.doc-main { flex: 1; min-width: 0; }
.doc-amount { flex: none; font-weight: 650; font-variant-numeric: tabular-nums; }
.doc-amount.negative { color: var(--error); }

@media (max-width: 64rem) {
  .bank-filters { grid-template-columns: 1fr 1fr; }
  .bank-filters .search { grid-column: 1 / -1; }
}
@media (max-width: 40rem) {
  .bank-views { grid-template-columns: 1fr; }
  .bank-view { border-right: 0; border-bottom: 1px solid var(--border); }
  .bank-table td.assign { min-width: 0; }
  .proposal-bar { bottom: calc(5.5rem + env(safe-area-inset-bottom)); flex-wrap: wrap; }
}
button:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.drawer-proposals { padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.drawer-proposals h3 { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.6rem; font-size: 1rem; }
.private-area { display: grid; gap: 0.6rem; }
.private-area h3, .private-rest { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 1rem; }
.private-rest { margin: 1.4rem 0 0.6rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.private-area .drawer-form { margin: 0; }
.drawer-proposals li.unusable { opacity: 0.7; }
.drawer-proposals .drawer-actions { position: static; }

/* --- Privat: Reiter ------------------------------------------------------ */

.tabs .count {
  display: inline-block; min-width: 1.3rem; margin-left: 0.25rem; padding: 0 0.4rem; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 0.75rem; line-height: 1.3rem; text-align: center;
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-head .section-title { margin-bottom: 0.6rem; }
details.card > summary { margin: 0; list-style: none; display: flex; align-items: center; gap: 0.4rem; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 0.8rem; }
.capture-payment, #abzug { margin-bottom: 1.25rem; }
.hint-box + .hint-box, .hint-box + .hero, .hint-box + .stats { margin-top: 0.75rem; }
.hint-box.warning { background: var(--warning-bg, #fff4e5); color: var(--warning, #8a5300); }
.hint-box.error { background: var(--error-bg, #fde8ee); color: var(--error); }
.hint-box.error a:not(.btn), .hint-box.warning a:not(.btn) { color: inherit; text-decoration: underline; }
.hero.forecast + .stats { margin-top: 1.25rem; }
.withheld-edit summary { font-size: 0.85rem; margin: 0.2rem 0 0; }
.withheld-edit form { min-width: 16rem; text-align: left; margin-top: 0.4rem; }
.certificate .card-head h3 { margin: 0; font-size: 1rem; }

/* --- Privat: Werbungskosten ---------------------------------------------- */

.wk-gauge .card-head h2, .card.vorsorge .card-head h2 { margin: 0; }
.wk-gauge .amount.big, .card.vorsorge .amount.big { font-size: 1.5rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.gauge { height: 10px; border-radius: 999px; background: var(--subtle); overflow: hidden; margin: 0.8rem 0; }
.gauge span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #d63ac5); }
.guide h3 { margin: 1.2rem 0 0.4rem; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.guide-topic { border-top: 1px solid var(--border); padding: 0.1rem 0; }
.guide-topic > summary { color: var(--text); margin: 0.55rem 0; }
.guide-topic p { margin: 0.3rem 0 0.6rem; }
.guide-topic form, .guide-topic .btn { margin-bottom: 0.7rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline-form input[type="number"] { width: 6rem; }
.suggestion-accept { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0 0 0.3rem; }
.suggestion-accept input { width: 6.5rem; text-align: right; }
.advisor .card-head h2 { display: flex; align-items: center; gap: 0.4rem; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0.6rem 0; }
.suggestions-form th.check, .suggestions-form td.check { width: 2rem; }
.suggestions-form .amount-input { width: 6.5rem; text-align: right; }
.certificate-upload { margin: 0.4rem 0 0.8rem; }
.certificate-upload form { margin: 0.4rem 0; }
.claude-notes { margin: 0.3rem 0; max-width: 32rem; }
.claude-notes summary { font-size: 0.85rem; margin: 0.2rem 0; }
.claude-notes p { font-size: 0.85rem; color: var(--muted); margin: 0.3rem 0; white-space: normal; }

/* --- Hinweise für die Kanzlei -------------------------------------------- */

details.notes { margin: 0.25rem 0 0; font-size: 0.88rem; }
details.notes > summary { font-size: 0.82rem; font-weight: 600; color: var(--muted); margin: 0.15rem 0; }
details.notes.has-notes > summary { color: var(--accent-text); }
details.notes[open] { padding: 0.5rem 0.6rem; border-radius: 10px; background: var(--subtle); max-width: 34rem; }
.note-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warning, #9a6200); vertical-align: middle; }
.note { padding: 0.4rem 0; border-bottom: 1px solid var(--border); text-align: left; }
.note.unconfirmed { border-left: 3px solid var(--accent); padding-left: 0.5rem; }
.note p { margin: 0.25rem 0; white-space: normal; }
.note-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.note-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.note-actions form { margin: 0; }
.note-edit summary, .note-actions .link { font-size: 0.8rem; margin: 0; }
.note-edit form, .note-add { display: grid; gap: 0.35rem; margin-top: 0.4rem; }
.note-add textarea, .note-edit textarea { width: 100%; font: inherit; }
.notes-overview li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.tx-notes details.notes { max-width: 40rem; }

/* Vorsorge: Kategorie je Abzug */
.category-form { display: block; margin-top: 0.3rem; }
.category-form select { font-size: 0.85rem; padding: 0.2rem 0.4rem; max-width: 100%; }
.category-form select.needs-choice { border-color: var(--warning); background: var(--warning-bg); }
.card.vorsorge .hint-box { margin-top: 0.5rem; }

/* Fahrten: gestellte Mahlzeiten */
.meals-provided { border: 0; padding: 0; margin: 0.4rem 0 0; min-width: 0; }
.meals-provided legend { font-weight: 600; font-size: 0.9rem; padding: 0; margin-bottom: 0.2rem; }

/* Belegliste: Suche und Sortierung */
.receipt-filters { grid-template-columns: minmax(0, 2fr) minmax(0, 0.8fr) minmax(0, 1.4fr) auto auto; }
th .sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
th .sort-link:hover { color: var(--text); text-decoration: underline; }
@media (max-width: 760px) {
  .receipt-filters { grid-template-columns: 1fr 1fr; }
  .receipt-filters .search { grid-column: 1 / -1; }
}

/* Manuelle Buchungen: Filter nach Art und Menü „Neue Buchung“ */
.manual-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 1rem; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.filter-chips a {
  padding: 0.35rem 0.8rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
  font-weight: 600; font-size: 0.9rem; text-decoration: none; background: var(--surface);
}
.filter-chips a:hover { color: var(--text); }
.filter-chips a[aria-current="page"] { color: var(--text); border-color: var(--accent); box-shadow: var(--shadow); }
.filter-chips .count { margin-left: 0.25rem; color: var(--muted); font-weight: 500; }
.new-menu { position: relative; }
.new-menu summary { list-style: none; cursor: pointer; }
.new-menu summary::-webkit-details-marker { display: none; }
.new-menu-items {
  position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 20; min-width: 19rem;
  display: grid; padding: 0.4rem; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.new-menu-items a { display: grid; gap: 0.1rem; padding: 0.6rem 0.8rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.new-menu-items a:hover { background: var(--subtle); }
.new-menu-items small { color: var(--muted); font-size: 0.82rem; }
@media (max-width: 760px) { .new-menu-items { right: auto; left: 0; min-width: min(19rem, 90vw); } }

/* Beleg: „Mit Claude (neu) lesen“ über der Erfassung */
.reread { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin: 0 0 0.8rem; }
.reread .help { margin: 0; }

/* Beleg erfassen: Gesamtbetrag und „Noch aufzuteilen“ */
.total-row { align-items: end; }
.split-status { display: grid; gap: 0.1rem; padding: 0.55rem 0.8rem; border-radius: 12px; background: var(--subtle); margin-bottom: 0.9rem; }
.split-status .label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.split-status strong { font-variant-numeric: tabular-nums; }
.split-status.open { background: var(--warning-bg); color: var(--warning); }
.split-status.done { background: var(--success-bg, var(--subtle)); color: var(--success, var(--text)); }

/* Beleg in Fremdwährung: Euro-Betrag aus der Bank */
.foreign-box { margin: 0 0 0.9rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 12px; }
.foreign-box summary { cursor: pointer; font-weight: 600; display: flex; gap: 0.4rem; align-items: center; }
.foreign-box[open] summary { margin-bottom: 0.6rem; }
.foreign-search { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.foreign-search input { flex: 1 1 8rem; min-width: 0; }
.foreign-search select { flex: 0 0 auto; width: auto; }
.foreign-box .error-text { color: var(--error); }

/* Beleg erfassen: Bankumsatz gleich mit auswählen */
.match-choice { display: flex; gap: 0.6rem; align-items: flex-start; width: 100%; cursor: pointer; }
.match-choice input { margin-top: 0.25rem; flex: none; }
.match.none { padding-block: 0.5rem; }
.match:has(input:checked) { border-color: var(--brand-1); box-shadow: 0 0 0 1px var(--brand-1); }

/* Beleg: passende Bankumsätze nach dem Erfassen */
.match-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.match { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.7rem 0.8rem; border: 1px solid var(--border); border-radius: 12px; }
.match.strong { border-color: var(--success); background: var(--success-bg); }
.match-info { display: grid; gap: 0.15rem; min-width: 0; }
.match-info span { overflow-wrap: anywhere; }

/* Bank › Konten: Online-Abruf */
.online-fetch { margin-top: 1.4rem; }
.connection { border: 1px solid var(--border); border-radius: 12px; padding: 0.8rem 0.9rem; margin: 0.8rem 0; }
.connection.attention { border-color: var(--warning); background: var(--warning-bg); }
.connection-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.6rem; align-items: center; }
.connection-head .row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.connection-accounts { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
.connection-accounts li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; align-items: center; }
.connection-accounts code { font-size: 0.82rem; }
.connect-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 0 0.8rem; align-items: end; margin-top: 1rem; }
@media (max-width: 760px) { .connect-form { grid-template-columns: 1fr; } }

/* Bankumsatz: Dublette */
.card.attention { border-color: var(--warning); background: var(--warning-bg); }
.duplicate-mark summary { cursor: pointer; font-weight: 600; }

/* Privat › Werbungskosten: Übersicht und Gruppen */
.deduction-summary .gauge { margin: 0.55rem 0 0.2rem; height: 6px; }
.page-actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0 0 1.25rem; }
.deduction-section .card-head h2 { margin: 0; }
.deduction-section .amount.big { font-size: 1.35rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.deduction-groups > li { display: block; padding: 0; }
.deduction-groups details { width: 100%; }
.deduction-groups .group-line { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.7rem 0; margin: 0; color: inherit; text-decoration: none; font-weight: 600; list-style: none; }
.deduction-groups summary.group-line::-webkit-details-marker { display: none; }
.deduction-groups summary.group-line .title::before { content: "›"; display: inline-block; width: 1rem; color: var(--muted); transition: transform 0.15s; }
.deduction-groups details[open] > summary.group-line .title::before { transform: rotate(90deg); }
.deduction-groups a.group-line .title::before { content: "→"; display: inline-block; width: 1rem; color: var(--muted); }
.deduction-groups .group-line small { font-weight: 400; margin-left: 0.35rem; }
.deduction-groups .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.deduction-items { margin: 0 0 0.8rem 1rem; border-left: 2px solid var(--border); padding-left: 0.9rem; }
.deduction-items .deduction-row { display: block; padding: 0.55rem 0; }
.deduction-row .row-line { display: flex; justify-content: space-between; gap: 1rem; }
.deduction-row .row-line .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.deduction-row .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.9rem; margin-top: 0.2rem; }
.deduction-row .meta form { margin: 0; }
.deduction-row details.notes { margin-top: 0.2rem; }
.deduction-row details.notes > summary { font-size: 0.82rem; font-weight: 500; margin: 0.2rem 0; }
.vorsorge-caps { margin-top: 0.4rem; }
textarea.letter-text { width: 100%; font: inherit; line-height: 1.5; margin: 0.4rem 0 0.8rem; }

/* Startseite: Einnahmen und Ausgaben je Monat */
.flow-chart .card-head { gap: 0.75rem; }
.flow-totals { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; margin: 0.25rem 0 0.75rem; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.flow-totals strong { display: block; color: var(--text); font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.flow-key { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.2rem; }
.flow-key.income { background: var(--success); }
.flow-key.expense { background: var(--error); }
.flow-chart .grid { stroke: var(--border); stroke-width: 1; }
.flow-chart .baseline { stroke: var(--muted); stroke-width: 1; }
.flow-chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.flow-chart .area { stroke: none; opacity: 0.12; }
.flow-chart .line.income, .flow-chart .dot.income { stroke: var(--success); }
.flow-chart .line.expense, .flow-chart .dot.expense { stroke: var(--error); }
.flow-chart .area.income { fill: var(--success); }
.flow-chart .area.expense { fill: var(--error); }
.flow-chart .dot { fill: var(--surface, #fff); stroke-width: 2; }
@media (max-width: 640px) { .flow-chart .axis { font-size: 17px; } .flow-chart .dot { r: 5; } }
.flow-chart .year-select { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }

/* Offene Posten: je Kunde bzw. Lieferant aufklappbar */
.open-groups { padding: 0.2rem 1.1rem; }
.open-groups > li { display: block; padding: 0; border-bottom: 1px solid var(--border); }
.open-groups > li:last-child { border-bottom: 0; }
.open-groups details { width: 100%; }
.open-groups .group-line { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.75rem 0; margin: 0; color: inherit; font-weight: 600; list-style: none; }
.open-groups summary.group-line::-webkit-details-marker { display: none; }
.open-groups summary.group-line .title::before { content: "›"; display: inline-block; width: 1rem; color: var(--muted); transition: transform 0.15s; }
.open-groups details[open] > summary.group-line .title::before { transform: rotate(90deg); }
.open-groups .group-line small { font-weight: 400; margin-left: 0.35rem; }
.open-groups .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.open-groups .total { font-weight: 750; }
.open-groups .open-items { margin: 0 0 0.9rem 1rem; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.open-groups .open-items table { font-size: 0.92rem; }
.open-groups .open-items th, .open-groups .open-items td { padding-left: 0; }
.open-groups .open-items th:last-child, .open-groups .open-items td:last-child { padding-right: 0; }
@media (max-width: 720px) {
  .open-groups { padding: 0.1rem 0.9rem; }
  .open-groups .open-items { margin-left: 0; }
}

/* Belegerfassung: Hinweis „Mögliches Anlagegut“, Zuordnen und weiter */
.asset-hints { margin-bottom: 1rem; }
.asset-hints ul { margin: 0.4rem 0; padding-left: 1.1rem; }
.asset-hints li { margin: 0.3rem 0; }
.asset-hints li .btn { margin-left: 0.4rem; vertical-align: middle; }
.asset-hints .check { display: flex; gap: 0.5rem; align-items: center; font-weight: 600; margin-top: 0.4rem; }
.asset-hints .check input { width: auto; }
.match-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }

/* Nachbuchungen eines festgeschriebenen Jahres (EÜR, Umsatzsteuer) */
details.late-items { display: block; margin-bottom: 1rem; }
details.late-items > summary { display: flex; gap: 0.5rem; align-items: flex-start; cursor: pointer; list-style: none; }
details.late-items > summary::-webkit-details-marker { display: none; }
details.late-items > summary .icon { flex: none; margin-top: 0.15rem; }
details.late-items .table-wrap { margin-top: 0.6rem; background: var(--surface, #fff); border-radius: 8px; }

/* --- Prüfliste (Festschreiben) und „Zu erledigen“ ----------------------- */
.checklist, .todo-list { list-style: none; margin: 0.6rem 0 1rem; padding: 0; display: grid; gap: 0.45rem; }
.checklist li, .todo-list li { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: 12px; }
.checklist li > div, .todo-list li > div { min-width: 0; flex: 1; }
.checklist .check-icon, .todo-list .todo-icon { flex: none; margin-top: 0.1rem; }
.checklist li.ok { color: var(--muted); border-style: dashed; }
.checklist li.ok .check-icon { color: var(--success); }
.checklist li.open, .todo-list li.warning { background: var(--warning-bg); border-color: transparent; }
.checklist li.open .check-icon, .todo-list li.warning .todo-icon { color: var(--warning); }
.checklist li.info .check-icon, .todo-list li.info .todo-icon { color: var(--info); }
.checklist li.blocking { background: var(--error-bg); border-color: transparent; }
.checklist li.blocking .check-icon { color: var(--error); }
.lock-form { display: grid; gap: 0.8rem; justify-items: start; }
.confirm-check { align-items: flex-start; }
.todo-list li .todo-count { font-weight: 750; font-variant-numeric: tabular-nums; }
.todo-list li a.todo-go { flex: none; align-self: center; }

/* Bank › Seitenleiste: Summe der gewählten Belege und Differenz (wie Lexware) */
.drawer-sum { display: grid; gap: 0.2rem; margin: 0.6rem 0; padding: 0.6rem 0.8rem; border-radius: 12px; background: var(--subtle); font-size: 0.92rem; }
.drawer-sum > div { display: flex; justify-content: space-between; gap: 0.6rem; }
.drawer-sum strong { font-variant-numeric: tabular-nums; }
.drawer-sum.done { background: var(--success-bg, var(--subtle)); color: var(--success, var(--text)); }
.drawer-sum.open { background: var(--warning-bg); color: var(--warning); }
.difference { display: grid; gap: 0.35rem; margin: 0 0 0.6rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 12px; }
.difference legend { font-weight: 600; padding: 0 0.3rem; }
.doc-amount small { display: block; font-weight: 400; }

/* Bank › Sammelaktion „Kategorisieren“ */
.bulk-category { position: relative; }
.bulk-category > summary { list-style: none; cursor: pointer; }
.bulk-category > summary::-webkit-details-marker { display: none; }
.bulk-category-body { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 30; width: min(26rem, 90vw); display: grid; gap: 0.5rem; padding: 0.9rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface, var(--bg)); box-shadow: 0 12px 32px rgb(0 0 0 / 0.14); }
.difference [hidden] { display: none; }
