/* ============================================================
   Rechnungen – Dark Design System (nur Dark Mode)
   ============================================================ */

:root {
  color-scheme: dark; /* native Controls (Datepicker, Scrollbars, Dialoge) dunkel */

  --bg: #0c0e14;
  --bg-soft: #111420;
  --card: #141826;
  --card-hover: #1a1f30;
  --elevated: #1b2032;
  --line: #262c40;
  --line-soft: #1e2333;

  --text: #e8ebf5;
  --text-dim: #9aa3bd;
  --muted: #6f7995;

  --brand: #6d5cff;
  --brand-hover: #7f70ff;
  --brand-soft: rgba(109, 92, 255, .16);
  --brand-line: rgba(109, 92, 255, .45);

  --green: #34d399;
  --green-soft: rgba(52, 211, 153, .13);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .13);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .13);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, .13);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

/* Eigene display-Regeln (z. B. für label) dürfen das hidden-Attribut nicht überstimmen. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(109, 92, 255, .10), transparent 60%),
    radial-gradient(700px 400px at 95% 0%, rgba(52, 211, 153, .06), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 13px; margin: 0 0 16px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 10px; }
a { color: var(--brand-hover); }

code {
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--text-dim);
}

::selection { background: var(--brand-soft); color: #fff; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232a3d; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #303954; background-clip: content-box; }

/* ---------- Icons (eigenes SVG-Set) ---------- */

.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px; pointer-events: none;
}
.i.lg { width: 20px; height: 20px; }
.btn .i { margin: 0; }
.btn.icon .i { width: 17px; height: 17px; }

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */

.sidebar {
  width: 236px; flex: none;
  background: rgba(17, 20, 32, .82);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line-soft);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; gap: 11px; align-items: center; padding: 0 6px; }
.brand .logo {
  width: 38px; height: 38px; flex: none; color: #fff;
  display: grid; place-items: center; border-radius: 11px;
  background: linear-gradient(140deg, var(--brand), #9d5cff);
  box-shadow: 0 6px 18px rgba(109, 92, 255, .35);
}
.brand strong { display: block; font-size: 14px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

nav { display: flex; flex-direction: column; gap: 2px; }
.nav {
  display: flex; align-items: center; gap: 10px;
  text-align: left; padding: 9px 12px; border: 0; background: transparent;
  border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: 13.5px;
  color: var(--text-dim); transition: background .15s, color .15s;
}
.nav .ico { width: 17px; height: 17px; opacity: .9; }
.nav:hover { background: var(--card-hover); color: var(--text); }
.nav.active { background: var(--brand-soft); color: #fff; font-weight: 600; box-shadow: inset 0 0 0 1px var(--brand-line); }
.nav .count { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--bg-soft); padding: 1px 7px; border-radius: 999px; }
.nav.active .count { background: rgba(255,255,255,.12); color: #fff; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.status-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--bg-soft); color: var(--text-dim); border: 1px solid var(--line-soft);
}
.status-line.link { text-decoration: none; transition: background .15s, color .15s, border-color .15s; }
.status-line.link:hover { background: var(--card-hover); color: var(--text); border-color: var(--line); }
.status-line .ico { width: 14px; height: 14px; opacity: .85; }
.status-line .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--muted); }
.status-line.ok .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-line.bad .dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

/* ---------- Main ---------- */

main { flex: 1; padding: 26px 32px 80px; max-width: 1240px; min-width: 0; }
.view { display: none; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.spacer { flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card .card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.card .card-head h2 { margin: 0; }

/* ---------- Stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 15px 17px; position: relative; overflow: hidden;
}
.stat::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--muted); opacity: .8; }
.stat.a::after { background: var(--brand); }
.stat.b::after { background: var(--amber); }
.stat.c::after { background: var(--red); }
.stat.d::after { background: var(--green); }
.stat span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.stat b { display: block; font-size: 22px; margin-top: 5px; font-weight: 650; letter-spacing: -.02em; }
.stat small { display: block; color: var(--text-dim); font-size: 12px; margin-top: 2px; }

/* ---------- Dashboard ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; inset: -40% -30% auto auto; width: 160px; height: 160px;
  background: radial-gradient(circle, var(--kpi-glow, rgba(109,92,255,.18)), transparent 65%);
  pointer-events: none;
}
.kpi {
  transition: transform .18s cubic-bezier(.2,.8,.2,1), border-color .18s, box-shadow .18s;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--line); box-shadow: 0 10px 26px rgba(0,0,0,.32); }
.kpi .k-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.kpi .k-ico {
  width: 26px; height: 26px; padding: 5px; border-radius: 8px;
  background: var(--kpi-chip, var(--brand-soft)); color: var(--kpi-color, var(--brand-hover));
  vertical-align: 0;
}

/* Mini-Visualisierung im Fuß jeder KPI-Karte */
.kpi .k-spark { margin-top: 10px; height: 34px; }
.kpi .k-spark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.kpi .k-spark .s-line { fill: none; stroke: var(--kpi-color, var(--brand)); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.kpi .k-spark .s-area { fill: var(--kpi-area, rgba(109,92,255,.20)); }
.kpi .k-spark .s-dot { fill: var(--kpi-color, var(--brand)); }
.kpi .k-meter { margin-top: 12px; }
.kpi .k-meter .track { height: 6px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.kpi .k-meter .track i { display: block; height: 100%; border-radius: 99px; background: var(--kpi-color, var(--brand)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.kpi .k-meter .m-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.kpi .k-val { font-size: 26px; font-weight: 650; letter-spacing: -.025em; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { color: var(--text-dim); font-size: 12px; }
.kpi .trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; }
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }
.trend.flat { color: var(--muted); }
.kpi.violet { --kpi-glow: rgba(109,92,255,.20); --kpi-color: #9d8bff; --kpi-chip: rgba(109,92,255,.16); --kpi-area: rgba(109,92,255,.20); }
.kpi.green  { --kpi-glow: rgba(52,211,153,.16); --kpi-color: var(--green); --kpi-chip: var(--green-soft); --kpi-area: rgba(52,211,153,.16); }
.kpi.amber  { --kpi-glow: rgba(251,191,36,.16); --kpi-color: var(--amber); --kpi-chip: var(--amber-soft); --kpi-area: rgba(251,191,36,.16); }
.kpi.red    { --kpi-glow: rgba(248,113,113,.16); --kpi-color: var(--red); --kpi-chip: var(--red-soft); --kpi-area: rgba(248,113,113,.16); }

.dash-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 16px; align-items: start; }
.dash-grid.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 1050px) { .dash-grid, .dash-grid.even { grid-template-columns: 1fr; } }

.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-dim); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.chart { width: 100%; height: 240px; display: block; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .bar-paid { fill: url(#gPaid); }
.chart .bar-open { fill: url(#gOpen); }
.chart .bar-hit { fill: transparent; cursor: default; }
.chart .col-label { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.chart .col-label.now { fill: var(--text); font-weight: 600; }

/* Spalte beim Überfahren hervorheben */
.chart .col-bg { fill: #fff; opacity: 0; transition: opacity .15s; }
.chart g.col:hover .col-bg { opacity: .035; }
.chart g.col rect.bar-paid, .chart g.col rect.bar-open { transition: filter .15s; }
.chart g.col:hover rect.bar-paid, .chart g.col:hover rect.bar-open { filter: brightness(1.25); }

/* Durchschnittslinie */
.chart .avg-line { stroke: var(--green); stroke-width: 1.2; stroke-dasharray: 4 4; opacity: .75; }
.chart .avg-label { fill: var(--green); font-size: 9.5px; font-weight: 600; }

/* Balken wachsen beim Rendern von unten heraus */
.chart .bars { transform-origin: center bottom; animation: growBars .55s cubic-bezier(.2,.8,.2,1); }
@keyframes growBars { from { transform: scaleY(.01); opacity: .3; } to { transform: scaleY(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chart .bars { animation: none; } }

/* Gestapelte Gesamtübersicht über den Einzelbalken */
.aging-total { margin-bottom: 16px; }
.aging-total .stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--bg-soft); gap: 2px; }
.aging-total .stack i { display: block; height: 100%; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.aging-total .stack i:first-child { border-radius: 99px 0 0 99px; }
.aging-total .stack i:last-child { border-radius: 0 99px 99px 0; }
.aging-total .cap { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.aging-total .cap b { font-size: 20px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.aging-total .cap span { font-size: 11.5px; color: var(--muted); }

.aging { display: flex; flex-direction: column; gap: 13px; }
.aging .a-row { cursor: default; }
.aging .a-row:hover .a-head span:first-child { color: var(--text); }
.aging .a-row .a-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.aging .a-row .a-head span:first-child { color: var(--text-dim); }
.aging .a-row .a-head span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.aging .track { height: 8px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.aging .fill { height: 100%; border-radius: 99px; transition: width .5s cubic-bezier(.2,.8,.2,1); }

.ranklist { display: flex; flex-direction: column; gap: 12px; }
.rank { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; }
.rank .pos { color: var(--muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.rank .name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .amount { font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 600; }
.rank .track { grid-column: 2 / 4; height: 5px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; margin-top: -4px; }
.rank .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #9d5cff); border-radius: 99px; }

.timeline { display: flex; flex-direction: column; gap: 2px; }
.tl-item { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.tl-item:last-child { border-bottom: 0; }
.tl-item .tl-ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--bg-soft); color: var(--text-dim); }
.tl-item .tl-ico .i { width: 14px; height: 14px; vertical-align: 0; }
.tl-item.paid .tl-ico { color: var(--green); }
.tl-item.sent .tl-ico { color: var(--blue); }
.tl-item.remind .tl-ico { color: var(--amber); }
.tl-item.paid .tl-ico { background: var(--green-soft); }
.tl-item.sent .tl-ico { background: var(--blue-soft); }
.tl-item.remind .tl-ico { background: var(--amber-soft); }
.tl-item .tl-text { font-size: 13px; line-height: 1.45; }
.tl-item .tl-text b { font-weight: 600; }
.tl-item .tl-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.todo { display: flex; flex-direction: column; }
.todo-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.todo-item:last-child { border-bottom: 0; }
.todo-item .t-main { flex: 1; min-width: 0; }
.todo-item .t-main strong { font-size: 13.5px; }
.todo-item .t-main .sub-line { margin-top: 2px; }
.todo-item .t-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.todo-item .days { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--red-soft); color: var(--red); font-weight: 600; white-space: nowrap; }
.todo-item .days.soon { background: var(--amber-soft); color: var(--amber); }

.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick button {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 13px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); cursor: pointer; font: inherit; font-size: 13px;
  transition: .15s;
}
.quick button:hover { background: var(--card-hover); border-color: var(--brand-line); transform: translateY(-1px); }
.quick button .q-ico { width: 19px; height: 19px; color: var(--brand-hover); }
.quick button small { display: block; color: var(--muted); font-size: 11px; }

/* ---------- Dashboard: Feinschliff ---------- */

/* Karten heben sich beim Überfahren leicht ab */
#view-dashboard .card { transition: border-color .18s, box-shadow .18s; }
#view-dashboard .card:hover { border-color: var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.26); }

/* Überschrift mit farbigem Akzentstrich */
#view-dashboard .card h2 { display: flex; align-items: center; gap: 9px; }
#view-dashboard .card h2::before {
  content: ''; width: 3px; height: 13px; border-radius: 99px; flex: none;
  background: linear-gradient(180deg, var(--brand), #9d5cff);
}

/* Karten blenden beim Laden gestaffelt ein */
#view-dashboard.view.active .kpi,
#view-dashboard.view.active .dash-grid > .card { animation: rise .4s cubic-bezier(.2,.8,.2,1) backwards; }
#view-dashboard.view.active .kpi:nth-child(2) { animation-delay: .04s; }
#view-dashboard.view.active .kpi:nth-child(3) { animation-delay: .08s; }
#view-dashboard.view.active .kpi:nth-child(4) { animation-delay: .12s; }
#view-dashboard.view.active .dash-grid > .card:nth-child(2) { animation-delay: .06s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  #view-dashboard.view.active .kpi,
  #view-dashboard.view.active .dash-grid > .card { animation: none; }
}

/* Zeilen in Listen reagieren auf die Maus */
.todo-item { border-radius: var(--radius-sm); padding-left: 10px; padding-right: 10px; margin: 0 -10px; transition: background .12s; }
.todo-item:hover { background: var(--card-hover); }
.rank { padding: 4px 8px; margin: 0 -8px; border-radius: var(--radius-sm); transition: background .12s; }
.rank:hover { background: var(--card-hover); }
.tl-item { padding-left: 8px; padding-right: 8px; margin: 0 -8px; border-radius: var(--radius-sm); transition: background .12s; }
.tl-item:hover { background: var(--card-hover); }

/* ---------- Formulare ---------- */

input, select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; background: var(--bg-soft); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: #59627d; }
input:hover, select:hover, textarea:hover { border-color: #323a52; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); background: var(--card);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input[type="date"] { min-height: 36px; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }
input[type="search"]::-webkit-search-cancel-button { filter: invert(.6); cursor: pointer; }
textarea { resize: vertical; min-height: 70px; }

label { display: block; font-size: 11.5px; color: var(--text-dim); margin-bottom: 14px; font-weight: 500; }
label input, label select, label textarea { margin-top: 5px; }
label.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--text); margin-bottom: 0; cursor: pointer; }
label.check input { width: auto; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
label.check span small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.hint.warn { color: var(--amber); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--elevated);
  cursor: pointer; font: inherit; font-size: 13.5px; color: var(--text);
  transition: background .15s, border-color .15s, transform .06s, color .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--card-hover); border-color: #333c56; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(140deg, var(--brand), #8b5cff);
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px rgba(109, 92, 255, .3);
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--card-hover); }
.btn.icon { padding: 6px 9px; font-size: 13px; background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.icon:hover { background: var(--card-hover); border-color: var(--line); color: var(--text); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: rgba(248, 113, 113, .35); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* ---------- Filter-Chips ---------- */

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--text-dim); cursor: pointer; font: inherit; font-size: 12.5px;
  transition: .15s;
}
.chip:hover { color: var(--text); border-color: #333c56; }
.chip.active { background: var(--brand-soft); border-color: var(--brand-line); color: #fff; font-weight: 600; }
.chip b { margin-left: 6px; opacity: .65; font-weight: 500; }

/* ---------- Tabellen ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  font-weight: 600; white-space: nowrap; background: var(--bg-soft);
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text-dim); }
.table th .arrow { opacity: 0; margin-left: 4px; }
.table th.sorted .arrow { opacity: 1; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--card-hover); }
.table tr:last-child td { border-bottom: 0; }
.right, td.right, th.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.sub-line { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 2px; justify-content: flex-end; }

.table.items { margin-bottom: 4px; }
.table.items th { background: transparent; padding: 8px 6px; }
.table.items td { padding: 4px 6px; border-bottom: 0; }
.table.items input { padding: 8px 10px; }
.table.items .drag { cursor: grab; color: var(--muted); text-align: center; user-select: none; }
.table.items .drag .i { width: 15px; height: 15px; opacity: .7; }
.table.items .drag:hover .i { opacity: 1; }
.table.items tr.dragging { opacity: .4; }

.empty { text-align: center; color: var(--muted); padding: 42px 20px; }
.empty .big { width: 34px; height: 34px; display: block; margin: 0 auto 12px; opacity: .45; stroke-width: 1.4; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  text-transform: capitalize; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.entwurf { background: var(--bg-soft); color: var(--text-dim); box-shadow: inset 0 0 0 1px var(--line); }
.badge.versendet { background: var(--blue-soft); color: var(--blue); }
.badge.bezahlt { background: var(--green-soft); color: var(--green); }
.badge.ueberfaellig { background: var(--red-soft); color: var(--red); }

.tag { font-size: 11px; color: var(--muted); background: var(--bg-soft); border: 1px solid var(--line-soft); padding: 1px 7px; border-radius: 5px; }

/* ---------- Summen ---------- */

.totals {
  margin: 18px 0 0 auto; width: 320px; font-size: 14px;
  background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px;
}
.totals div { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text-dim); }
.totals div span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.totals .sum { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 11px; font-size: 17px; font-weight: 700; color: var(--text); }
.totals .sum span:last-child { color: #fff; }
.totals .note { font-size: 11.5px; color: var(--muted); padding-top: 6px; display: block; }

/* ---------- Dialoge ---------- */

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  width: min(580px, 94vw); background: var(--elevated); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(6, 8, 14, .72); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .16s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.dialog { padding: 22px 24px 20px; }
.dialog h2 { font-size: 16px; text-transform: none; letter-spacing: -.01em; color: var(--text); margin-bottom: 4px; }
.dialog .dialog-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
dialog.narrow { width: min(430px, 94vw); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(90px);
  background: var(--elevated); color: var(--text);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 12px 20px; border-radius: 11px;
  opacity: 0; transition: .25s cubic-bezier(.2,.8,.2,1); z-index: 99; max-width: 90vw;
  display: flex; align-items: center; gap: 10px; font-size: 13.5px;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast::before { content: '✓'; color: var(--green); font-weight: 700; }
.toast.error { border-color: rgba(248, 113, 113, .4); }
.toast.error::before { content: '!'; color: var(--red); }
.toast.info::before { content: '…'; color: var(--blue); }

/* ---------- Ladebalken ---------- */

#loader {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--brand), #34d399);
  z-index: 200; transition: width .2s, opacity .3s; opacity: 0;
}
#loader.on { opacity: 1; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px;
  }
  nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .nav .count { display: none; }
  .side-foot { margin: 0; flex-direction: row; }
  main { padding: 18px 14px 60px; }
  .totals { width: 100%; }
  .head h1 { font-size: 19px; }
}

/* ============================================================
   Anmeldung
   ============================================================ */

.auth-screen {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  padding: 24px; background: var(--bg);
  background-image:
    radial-gradient(760px 420px at 20% -10%, rgba(109, 92, 255, .22), transparent 62%),
    radial-gradient(620px 380px at 88% 8%, rgba(52, 211, 153, .10), transparent 60%);
}
.auth-screen[hidden] { display: none; }

.auth-box {
  width: min(400px, 100%); background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 30px 30px 24px; box-shadow: var(--shadow-lg);
  animation: authIn .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes authIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--brand), #9d5cff); box-shadow: 0 8px 20px rgba(109, 92, 255, .38);
}
.auth-brand .logo .i { width: 21px; height: 21px; }
.auth-brand strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.auth-brand small { display: block; color: var(--muted); font-size: 12px; }

.auth-tabs { display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 11px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-dim); font: inherit; font-size: 13.5px; cursor: pointer; transition: .15s;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { background: var(--card-hover); color: #fff; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.auth-tab[hidden] { display: none; }
.auth-tabs:has(.auth-tab[hidden]) { display: none; }

.auth-hint {
  font-size: 12.5px; color: var(--text-dim); background: var(--brand-soft);
  border: 1px solid var(--brand-line); border-radius: var(--radius-sm);
  padding: 10px 13px; margin: 0 0 18px;
}
.auth-hint[hidden] { display: none; }

#authForm .btn { width: 100%; justify-content: center; margin-top: 4px; }
.auth-error {
  font-size: 13px; color: var(--red); background: var(--red-soft);
  border: 1px solid rgba(248, 113, 113, .3); border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 0 0 14px;
}
.auth-error[hidden] { display: none; }

.auth-foot { text-align: center; font-size: 13px; color: var(--muted); margin: 18px 0 0; }
.auth-foot[hidden] { display: none; }
.linkish { background: 0; border: 0; padding: 0; font: inherit; color: var(--brand-hover); cursor: pointer; text-decoration: underline; }
.auth-back { display: block; text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; text-decoration: none; }
.auth-back:hover { color: var(--text-dim); }

/* Benutzerzeile in der Seitenleiste */
.status-line.user { gap: 10px; }
.status-line.user[hidden] { display: none; }
.status-line .avatar {
  width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), #9d5cff); color: #fff; font-size: 12px; font-weight: 700;
}
.status-line .who { min-width: 0; line-height: 1.3; }
.status-line .who b { display: block; color: var(--text); font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-line .who small { color: var(--muted); font-size: 10.5px; }
.status-line .logout {
  margin-left: auto; background: 0; border: 0; padding: 4px; border-radius: 7px;
  color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: .15s;
}
.status-line .logout:hover { background: var(--red-soft); color: var(--red); }
.status-line .logout .i { width: 15px; height: 15px; }

.role-pill { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--bg-soft); color: var(--text-dim); box-shadow: inset 0 0 0 1px var(--line); }
.role-pill.admin { background: var(--brand-soft); color: #c3baff; box-shadow: inset 0 0 0 1px var(--brand-line); }
.you-pill { font-size: 10.5px; color: var(--muted); margin-left: 6px; }
