/* Kontor – „Kontor Night“: tiefes Tintenblau, Messing-Akzent, Inter. Helles Theme über [data-theme=light]. */
@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/Inter-Regular.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/Inter-Medium.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/Inter-SemiBold.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/Inter-Bold.woff") format("woff"); }

:root {
  color-scheme: dark;
  --bg: #070a12;
  --surface: #0d1323;
  --surface-2: #121a2d;
  --surface-3: #18223a;
  --line: rgba(148, 163, 196, .12);
  --line-strong: rgba(148, 163, 196, .22);
  --text: #edf1f8;
  --muted: #8f9bb3;
  --faint: #5f6b85;
  --gold: #f3b94d;
  --gold-hi: #ffdc8f;
  --grad: linear-gradient(135deg, #ffe3a3 0%, #f3b94d 42%, #df8a2c 100%);
  --accent: var(--gold);
  --accent-soft: rgba(243, 185, 77, .12);
  --accent-ink: #1b1204;
  --ring: rgba(243, 185, 77, .35);
  --ok: #3ddc97;
  --open: #6ea8ff;
  --bad: #ff6b81;
  --warn: #f5a524;
  --violet: #b392f0;
  --shadow: 0 24px 48px -28px rgba(0, 0, 0, .75);
  --panel-hi: linear-gradient(180deg, rgba(255, 255, 255, .028), rgba(255, 255, 255, 0) 40%);
  --glow-a: rgba(243, 185, 77, .09);
  --glow-b: rgba(91, 99, 241, .11);
  --r: 14px;
  --r-s: 9px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --surface-3: #ebf0f7;
  --line: rgba(15, 23, 42, .09);
  --line-strong: rgba(15, 23, 42, .17);
  --text: #0f1729;
  --muted: #536077;
  --faint: #8792a7;
  --gold: #c98a1c;
  --gold-hi: #e6a83d;
  --grad: linear-gradient(135deg, #f7cd73 0%, #e3992f 50%, #c4741b 100%);
  --accent-soft: rgba(201, 138, 28, .12);
  --ring: rgba(201, 138, 28, .3);
  --ok: #059669;
  --open: #2563eb;
  --bad: #e11d48;
  --warn: #c2770c;
  --violet: #7c3aed;
  --shadow: 0 18px 40px -26px rgba(15, 23, 42, .35);
  --panel-hi: none;
  --glow-a: rgba(227, 153, 47, .10);
  --glow-b: rgba(91, 99, 241, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; color: var(--text); font: 14px/1.5 var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 8% -12%, var(--glow-a), transparent 60%),
    radial-gradient(900px 560px at 100% -8%, var(--glow-b), transparent 62%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-hi); }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 8px; }
code { font-size: 12px; background: var(--surface-3); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }
.num, td.num, .amount { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: rgba(243, 185, 77, .35); }

/* ---------- Grundgerüst ---------- */
#app { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
#app.booting, #app.auth { display: block; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 16px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 19, 35, .92), rgba(9, 13, 24, .92)); backdrop-filter: blur(12px); z-index: 30; }
[data-theme="light"] .rail { background: rgba(255, 255, 255, .86); }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-mark { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 8px 22px -8px rgba(243, 185, 77, .7), inset 0 1px 0 rgba(255, 255, 255, .45); }
.brand-mark svg { width: 20px; height: 20px; }
.brand b { font-size: 17px; font-weight: 700; display: block; line-height: 1.15; letter-spacing: -0.02em; }
.brand > div > span { font-size: 12px; color: var(--muted); display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .btn.primary { width: 100%; justify-content: center; margin-bottom: 10px; }
.search-btn { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 11px; margin-bottom: 16px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font: 13px var(--font); cursor: pointer; }
.search-btn:hover { border-color: var(--line-strong); color: var(--text); }
.search-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
kbd { font: 600 11px var(--font); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface-3); color: var(--muted); }
.search-btn kbd { margin-left: auto; white-space: nowrap; }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-s); color: var(--muted); font-weight: 500; transition: background .15s, color .15s; }
.rail nav a:hover { background: var(--surface-2); color: var(--text); }
.rail nav a.active { background: var(--accent-soft); color: var(--text); }
.rail nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); box-shadow: 0 0 12px rgba(243, 185, 77, .6); }
.rail nav a.active svg { color: var(--gold); }
.rail nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail nav .count { margin-left: auto; font-size: 11px; background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-weight: 700; line-height: 18px; }
.rail-foot { margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-size: 13px; }
.rail-foot .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.icon-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mobile-bar { display: none; }

main#view { min-width: 0; padding: 32px 40px 72px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head .actions select { width: auto; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: inline-flex; gap: 6px; align-items: center; }
.crumb::before { content: "←"; }
.crumb:hover { color: var(--text); }

/* ---------- Bedienelemente ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); padding: 8px 14px; border-radius: var(--r-s);
  font: 550 13.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; line-height: 1.25; transition: border-color .15s, background .15s, box-shadow .2s, transform .1s; }
.btn:hover { border-color: var(--faint); color: var(--text); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--grad); border-color: transparent; color: var(--accent-ink); font-weight: 650; box-shadow: 0 8px 20px -10px rgba(243, 185, 77, .75), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn.primary:hover { box-shadow: 0 10px 26px -8px rgba(243, 185, 77, .85), inset 0 1px 0 rgba(255, 255, 255, .5); color: var(--accent-ink); filter: brightness(1.04); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); min-width: 250px; padding: 5px; z-index: 40; display: none; }
.menu.open .menu-list { display: block; animation: pop .14s ease-out; }
.menu-list button, .menu-list a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 11px; border-radius: 7px; font: 13.5px var(--font); color: var(--text); cursor: pointer; }
.menu-list button:hover, .menu-list a:hover { background: var(--surface-3); color: var(--text); }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu-list .danger { color: var(--bad); }
.menu-list small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; font-weight: 400; }
/* Nachtragen & Import */
.x-sum { padding-bottom: 10px; }
.nowrap { white-space: nowrap; }
.field .opt { display: inline; color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 4px; }
.import-head { display: flex; align-items: center; gap: 10px; }
#i-text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; width: 100%; }
#i-preview .list td, #i-preview .list th { padding: 8px 12px; font-size: 13px; }
#i-preview .list thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.limit-hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.limit-hint a { color: var(--gold-hi); }

@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 550; min-width: 0; }
label.field .hint, .field .hint { font-weight: 400; color: var(--faint); font-size: 12px; }
input, select, textarea { font: 14px var(--font); color: var(--text); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-s); padding: 8px 11px; width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--ring); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238f9bb3' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; }
select option { background: var(--surface-2); color: var(--text); }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--gold); padding: 0; }
input[type=date] { color-scheme: inherit; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { margin-top: 2px; flex: none; }
.check small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.grid { display: grid; gap: 16px 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }

.panel { background: var(--panel-hi), var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.panel > .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.panel > .panel-head a.small { font-weight: 550; }
.panel > .panel-body { padding: 20px; }
.panel + .panel { margin-top: 18px; }
.section-title { font-size: 13px; font-weight: 650; margin: 0 0 12px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: separate; border-spacing: 0; }
table.list th.num { text-align: right; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
table.list th:first-child { border-top-left-radius: var(--r); }
table.list th:last-child { border-top-right-radius: var(--r); }
table.list td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr.click { cursor: pointer; transition: background .12s; }
table.list tbody tr.click:hover td { background: var(--surface-2); }
table.list .strong { font-weight: 600; }
table.list .sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
table.list tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.who-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; letter-spacing: 0; text-transform: uppercase;
  background: linear-gradient(135deg, hsl(var(--h, 210) 62% 52%), hsl(calc(var(--h, 210) + 35) 70% 40%)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }
.avatar.lg { width: 54px; height: 54px; border-radius: 15px; font-size: 20px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; padding: 3px 10px 3px 8px; border-radius: 999px;
  background: color-mix(in srgb, currentColor 13%, transparent); border: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.s-draft { color: var(--muted); }
.s-open, .s-partial { color: var(--open); }
.s-overdue { color: var(--bad); }
.s-paid, .s-accepted { color: var(--ok); }
.s-cancelled, .s-rejected, .s-invoiced { color: var(--faint); }
.s-credit { color: var(--violet); }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; flex-wrap: wrap; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font: 550 13px var(--font); color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.filters input[type=search] { max-width: 280px; padding-left: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%238f9bb3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 11px center; }
.filters select { width: auto; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 16px; }
.empty .btn { margin-top: 14px; }

/* ---------- Übersicht ---------- */
.setup { border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); background: linear-gradient(120deg, var(--accent-soft), transparent 70%), var(--surface); border-radius: var(--r); padding: 18px 20px; margin-bottom: 20px; }
.setup h2 { font-size: 15px; margin-bottom: 3px; }
.setup ol { margin: 14px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.setup li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.setup li::before { content: ""; width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--line-strong); }
.setup li.done { color: var(--muted); }
.setup li.done::before { border-color: var(--ok); background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23062a1b' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center/10px no-repeat; }
.setup li a { font-weight: 600; }

.hero { border: 1px solid transparent; border-radius: 18px; box-shadow: var(--shadow);
  background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(135deg, rgba(255, 220, 143, .55), rgba(243, 185, 77, .06) 38%, rgba(110, 168, 255, .28)) border-box; overflow: hidden; position: relative; }
.hero::after { content: ""; position: absolute; inset: auto -10% -60% 40%; height: 120%; background: radial-gradient(closest-side, rgba(243, 185, 77, .10), transparent); pointer-events: none; }
.year-head { display: grid; grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); gap: 32px; padding: 26px 28px 22px; align-items: stretch; position: relative; z-index: 1; }
.big-figure .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.big-figure .value { font-size: 46px; line-height: 1.05; font-weight: 700; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; margin: 8px 0 18px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 6px 22px rgba(243, 185, 77, .25)); }
.big-figure dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; font-size: 13px; }
.big-figure dt { color: var(--muted); }
.big-figure dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; }
.delta.up { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.delta.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, transparent); }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { transition: opacity .15s; transform-box: fill-box; transform-origin: bottom; }
.chart .bar.future { opacity: .25; }
.chart .bar.dim { opacity: .45; }
.chart.grow .bar { animation: grow .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 45ms); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.chart .prev { stroke: var(--muted); stroke-width: 2; stroke-linecap: round; opacity: .7; }
.chart text { font: 500 11px var(--font); fill: var(--faint); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .hit { fill: transparent; cursor: default; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; font-size: 12.5px; box-shadow: var(--shadow); white-space: nowrap; transform: translateX(-50%); opacity: 0; transition: opacity .12s; z-index: 5; }
.chart-tip.on { opacity: 1; }
.chart-tip b { display: block; font-size: 13px; margin-bottom: 4px; }
.chart-tip div { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); }
.chart-tip div span:last-child { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--grad); margin-right: 6px; vertical-align: -1px; }
.legend i.prev { background: none; border-top: 2px solid var(--muted); height: 0; width: 12px; border-radius: 0; vertical-align: 3px; }

.limit { padding: 18px 28px 22px; border-top: 1px solid var(--line); position: relative; z-index: 1; }
.limit-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 12px; flex-wrap: wrap; }
.ruler { position: relative; height: 10px; background: var(--surface-3); border-radius: 6px; }
.ruler .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--grad); box-shadow: 0 0 18px rgba(243, 185, 77, .45); min-width: 4px; }
.ruler .fill.warn { background: linear-gradient(90deg, #f5a524, #ff8a3d); }
.ruler .fill.bad { background: linear-gradient(90deg, #ff6b81, #e11d48); }
.ruler .tick { position: absolute; top: -5px; bottom: -5px; width: 2px; border-radius: 1px; background: var(--text); opacity: .7; }
.ruler-labels { position: relative; height: 36px; font-size: 12px; color: var(--muted); }
.ruler-labels span { position: absolute; top: 8px; transform: translateX(-50%); white-space: nowrap; text-align: center; line-height: 1.3; }
.ruler-labels span.end { transform: translateX(-100%); text-align: right; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.kpi { background: var(--panel-hi), var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; grid-template-columns: 40px 1fr; gap: 4px 14px; align-items: center; box-shadow: var(--shadow); }
.kpi .ico { grid-row: span 3; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--tone, var(--gold)); background: color-mix(in srgb, var(--tone, var(--gold)) 14%, transparent); border: 1px solid color-mix(in srgb, var(--tone, var(--gold)) 25%, transparent); align-self: start; }
.kpi .ico svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kpi .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .v.bad { color: var(--bad); }
.kpi .d { font-size: 12px; color: var(--faint); }
.kpi a { color: inherit; }
.kpi a:hover { color: var(--gold); }

.cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.cols > div > .panel + .panel { margin-top: 18px; }
.rows { list-style: none; margin: 0; padding: 4px 0; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px 20px; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows .main { min-width: 0; display: flex; align-items: center; gap: 12px; }
.rows .main > div { min-width: 0; }
.rows .main:not(:has(> .avatar, > .rank)) { display: block; }
.rows .main b { font-weight: 600; }
.rows .main .sub { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows li.click { cursor: pointer; transition: background .12s; }
.rows li.click:hover { background: var(--surface-2); }
.share { height: 5px; background: var(--surface-3); border-radius: 3px; margin-top: 7px; width: 150px; overflow: hidden; }
.share span { display: block; height: 100%; background: var(--grad); border-radius: 3px; }
.rank { width: 22px; color: var(--faint); font-weight: 650; font-variant-numeric: tabular-nums; flex: none; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--line-strong); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 19px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.k-note::before, .timeline li.k-call::before, .timeline li.k-meeting::before, .timeline li.k-mail_in::before { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 10px rgba(243, 185, 77, .5); }
.timeline li.k-payment::before { background: var(--ok); border-color: var(--ok); }
.timeline li.k-mail::before { background: var(--open); border-color: var(--open); }
.timeline li.k-error::before { background: var(--bad); border-color: var(--bad); }
.timeline .when { font-size: 12px; color: var(--faint); }
.timeline .what { white-space: pre-wrap; }
.timeline .what a { color: var(--text); }
.timeline .what a:hover, .timeline .when a:hover { color: var(--gold); }
.timeline .when a { color: var(--muted); font-weight: 550; }
.timeline .del { float: right; visibility: hidden; }
.timeline li:hover .del { visibility: visible; }

/* ---------- Beleg-Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 1180px; }
.editor .panel + .panel { margin-top: 18px; }
.editor .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.editor .side .panel + .panel { margin-top: 0; }
.editor .side > p { grid-column: 1 / -1; margin: 0; }
.totals-box { margin: 20px 0 4px auto; width: min(380px, 100%); padding: 16px 20px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.panel-title { font-size: 13px; font-weight: 650; color: var(--muted); margin: 0 0 16px; display: flex; align-items: center; gap: 8px; }
.panel-title .ic { color: var(--gold); }
.totals { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.totals td { padding: 6px 0; color: var(--muted); }
.totals td:last-child { text-align: right; color: var(--text); }
.totals tr.grand td { font-weight: 700; font-size: 22px; color: var(--text); border-top: 1px solid var(--line-strong); padding-top: 14px; letter-spacing: -0.02em; }
.totals tr.grand td:last-child { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lines-head, .line { display: grid; grid-template-columns: 26px minmax(0, 1fr) 84px 100px 108px 80px 110px 32px; gap: 8px; align-items: start; }
.lines-head { font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.lines-head .r { text-align: right; }
.line { padding: 12px 0; border-bottom: 1px solid var(--line); }
.line .pos { color: var(--faint); padding-top: 9px; font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.line textarea { min-height: 34px; height: 34px; margin-top: 6px; font-size: 13px; }
.line .sum { padding-top: 9px; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.line .rm { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 8px 4px; border-radius: 6px; font-size: 13px; }
.line .rm:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.lines.no-tax .lines-head, .lines.no-tax .line { grid-template-columns: 26px minmax(0, 1fr) 84px 100px 108px 110px 32px; }
.lines.no-tax .taxcol { display: none; }
.add-line { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.add-line select { width: auto; }
.period-toggle { display: inline-flex; gap: 2px; margin-top: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; width: max-content; }
.period-toggle label { display: flex; gap: 6px; align-items: center; cursor: pointer; padding: 4px 10px; border-radius: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.period-toggle label:has(input:checked) { background: var(--surface-3); color: var(--text); }
.period-toggle input { display: none; }
.placeholder-hint { font-size: 12px; color: var(--faint); margin-top: 6px; }
.placeholder-hint code { font-size: 11px; }
.dirty-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); margin-right: 8px; vertical-align: 4px; box-shadow: 0 0 10px var(--warn); }

/* ---------- Beleg-Ansicht ---------- */
.doc-view { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 20px; align-items: start; }
.pdf-frame { width: 100%; height: calc(100vh - 170px); min-height: 640px; border: 1px solid var(--line); border-radius: var(--r); background: #2a2f3a; display: block; box-shadow: var(--shadow); }
.doc-total { padding: 20px; border-bottom: 1px solid var(--line); }
.doc-total .label { font-size: 12.5px; color: var(--muted); }
.doc-total .value { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.facts .sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 4px 0; }
.facts .grand { font-weight: 700; font-size: 15px; color: var(--text); }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 14px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #2ac78a, var(--ok)); box-shadow: 0 0 12px var(--ok); }
.notice { border-radius: 11px; padding: 11px 14px; font-size: 13px; margin-bottom: 14px; border: 1px solid; }
.notice.info { background: color-mix(in srgb, var(--open) 10%, transparent); border-color: color-mix(in srgb, var(--open) 28%, transparent); }
.notice.warn { background: color-mix(in srgb, var(--warn) 10%, transparent); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.bad { background: color-mix(in srgb, var(--bad) 10%, transparent); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice.ok { background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Kunde ---------- */
.cust-title { display: flex; gap: 16px; align-items: center; }
.contact-lines { color: var(--muted); font-size: 13.5px; display: flex; gap: 6px 18px; flex-wrap: wrap; margin-top: 6px; }
.note-form { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; margin-bottom: 20px; align-items: start; }
.note-form textarea { min-height: 38px; height: 38px; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line); color: var(--muted); margin-right: 5px; }

/* ---------- Einstellungen ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-image: var(--grad) 1; border-bottom: 2px solid; }
.settings-form { max-width: 880px; }
.logo-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-box .preview { width: 190px; height: 74px; border: 1px dashed var(--line-strong); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fff; color: #8792a7; font-size: 12px; overflow: hidden; padding: 6px; }
.logo-box img { max-width: 100%; max-height: 100%; }
.save-bar { position: sticky; bottom: 0; padding: 20px 0 8px; display: flex; gap: 12px; align-items: center; background: linear-gradient(transparent, var(--bg) 40%); }
.qr-box { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.qr-box .qr { width: 184px; height: 184px; border-radius: 12px; padding: 8px; background: #fff; }
.qr-box .qr svg { width: 100%; height: 100%; }
code.secret { font-size: 13px; padding: 5px 9px; word-break: break-all; display: inline-block; }
.method-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.method-cards label { display: flex; flex-direction: column; gap: 4px; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-2); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.method-cards label b { font-size: 13.5px; }
.method-cards label span { font-size: 12px; color: var(--muted); }
.method-cards label:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 3px var(--ring); }
.method-cards input { display: none; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }

/* ---------- Modal, Befehlspalette, Toasts ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(3, 6, 12, .62); backdrop-filter: blur(6px); display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px; z-index: 50; overflow-y: auto; animation: fade .15s ease-out; }
[data-theme="light"] .modal-back { background: rgba(15, 23, 42, .32); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--panel-hi), var(--surface); border: 1px solid var(--line-strong); border-radius: 18px; width: 100%; max-width: 580px; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .7); animation: pop .18s ease-out; }
.modal.wide { max-width: 780px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modal-head .x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.modal-head .x:hover { color: var(--text); background: var(--surface-2); }

.palette { position: fixed; inset: 0; z-index: 60; background: rgba(3, 6, 12, .55); backdrop-filter: blur(6px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px; animation: fade .12s ease-out; }
[data-theme="light"] .palette { background: rgba(15, 23, 42, .3); }
.palette-box { width: 100%; max-width: 640px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .8); overflow: hidden; animation: pop .16s ease-out; }
.palette-box input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; font-size: 16px; padding: 18px 20px; box-shadow: none !important; }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 10px 12px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.palette-item .pi { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); flex: none; }
.palette-item .pi svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.palette-item .pt { flex: 1; min-width: 0; }
.palette-item .pt span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .pa { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.palette-item.on { background: var(--accent-soft); }
.palette-item.on .pi { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 35%, transparent); }
.palette-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 70; }
.toast { background: var(--surface-3); color: var(--text); padding: 11px 16px; border-radius: 11px; font-size: 13.5px; box-shadow: var(--shadow); max-width: 400px; border: 1px solid var(--line-strong); border-left: 3px solid var(--ok); animation: toast-in .2s ease-out; }
.toast.bad { border-left-color: var(--bad); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Anmeldung ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; position: relative; overflow: hidden; }
.aurora { position: absolute; inset: -20%; pointer-events: none; filter: blur(70px); opacity: .9; }
.aurora i { position: absolute; border-radius: 50%; }
.aurora i:nth-child(1) { width: 46vw; height: 46vw; left: 8%; top: 4%; background: radial-gradient(circle, rgba(243, 185, 77, .30), transparent 65%); animation: drift 22s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { width: 40vw; height: 40vw; right: 6%; top: 18%; background: radial-gradient(circle, rgba(91, 99, 241, .30), transparent 65%); animation: drift 26s ease-in-out infinite alternate-reverse; }
.aurora i:nth-child(3) { width: 34vw; height: 34vw; left: 34%; bottom: 0; background: radial-gradient(circle, rgba(45, 212, 191, .16), transparent 65%); animation: drift 30s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(6vw, 4vh) scale(1.12); } }
.auth-grid { position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%); -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%); }
.auth-card { position: relative; width: 100%; max-width: 420px; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(16px); border: 1px solid var(--line-strong); border-radius: 20px; padding: 32px; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .8); }
.auth-card .brand { padding: 0 0 24px; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card .grid { margin-top: 20px; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 11px; margin-top: 4px; font-size: 14.5px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- Responsiv ---------- */
@media (max-width: 1180px) {
  .doc-view { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pdf-frame { height: 72vh; min-height: 420px; }
  .method-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  #app { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: 270px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 60px rgba(0, 0, 0, .5); }
  #app.nav-open .rail { transform: none; }
  .mobile-bar { display: flex; position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 10px 14px; align-items: center; gap: 12px; }
  .mobile-bar b { flex: 1; }
  main#view { padding: 20px 14px 56px; }
  h1 { font-size: 22px; }
  .year-head { grid-template-columns: 1fr; padding: 20px; gap: 18px; }
  .big-figure .value { font-size: 38px; }
  .limit { padding: 16px 20px 18px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { grid-template-columns: 1fr; padding: 14px; }
  .kpi .ico { display: none; }
  .kpi .v { font-size: 18px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lines-head { display: none; }
  .line, .lines.no-tax .line { grid-template-columns: 1fr 1fr 1fr; }
  .line .pos { display: none; }
  .line .namecell { grid-column: 1 / -1; }
  .line .sum { grid-column: span 2; }
  .note-form { grid-template-columns: 1fr; }
  .setup ol { grid-template-columns: 1fr; }
  .ruler-labels span.cur { display: none; }
  .method-cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print { .rail, .mobile-bar, .page-head .actions { display: none; } #app { display: block; } body { background: #fff; } }
.avatar svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
