/* Dunkelgraues Theme – immer, unabhängig von der Systemeinstellung */
:root {
  --bg: #1e1f22;
  --surface: #2a2b2f;
  --surface-2: #323338;
  --line: #3c3d42;
  --text: #e8e8ea;
  --muted: #9a9ba1;
  --accent: #8fb4ff;
  --accent-soft: #2f3644;
  --on-accent: #16181d;
  --pos: #6fcf97;
  --neg: #f28b82;
  --warn-bg: #3d3524;
  --warn: #f2c66d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* Layout: Seitenleiste + volle Breite */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; text-align: left; }
.nav button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.on { background: var(--accent-soft); color: var(--text); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-foot .btn { justify-content: center; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pos); flex: none; }
.dot.off { background: var(--neg); }
main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.topbar .h2 { font-size: 17px; min-width: 130px; }
.monthnav { display: flex; align-items: center; gap: 8px; }
.monthnav h1 { min-width: 170px; text-align: center; }
.search { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; width: min(320px, 100%); }
.section { margin-bottom: 14px; }
.cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.linkbtn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 500; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--text); }
.acchead h1 { margin: 0; }
.accbal { text-align: right; }
.accbal .value { font-size: 24px; font-weight: 600; }

/* Kontokacheln */
.accgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.acc { text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: border-color .15s, transform .15s; }
.acc:hover { border-color: var(--accent); transform: translateY(-1px); }
.acc .an { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc .ab { font-size: 20px; font-weight: 600; }
.acc .af { font-size: 12px; color: var(--muted); display: flex; gap: 10px; }
.acc .spark { height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.acc .spark > div { height: 100%; background: var(--accent); }

/* Diagramme */
.chartbox { position: relative; }
.chartbox svg, #donut svg, #a-donut svg { display: block; width: 100%; }
.chartbox text, .donut text { fill: var(--muted); font-size: 12px; font-family: var(--sans); }
.hit { cursor: pointer; }
.hit:hover { opacity: .8; }
.tip { position: fixed; z-index: 60; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 260px; }
.donutwrap { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 22px; align-items: center; }
.donutleg { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.donutleg div { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.donutleg div:hover { background: var(--surface-2); }
.donutleg .num { margin-left: auto; }
.legend span.line::before { height: 3px; border-radius: 2px; vertical-align: 3px; }

.btn { text-decoration: none; color: inherit; }


.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--neg); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn svg { width: 16px; height: 16px; }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; background: var(--accent-soft); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { margin: 0 0 14px; font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.g21 { grid-template-columns: 2fr 1fr; margin-bottom: 14px; }
.g11 { grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; }
.two { grid-template-columns: 1.15fr 1fr; }
@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } .g21 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, 1fr); } .g11, .g3 { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand span, .brand { font-size: 0; gap: 0; padding: 0; } .brand img { width: 26px; height: 26px; }
  .nav { flex-direction: row; } .nav button { padding: 8px; } .nav button span { display: none; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; } .side-foot .pill { display: none; }
  main { padding: 16px 14px 60px; }
  .accgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .donutwrap { grid-template-columns: 1fr; }
}

.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
@media (max-width: 480px) { .kpi .value { font-size: 20px; } }

.monthbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.monthbar h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; min-width: 160px; }
.iconbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; width: 34px; height: 34px; cursor: pointer; display: grid; place-items: center; }
.iconbtn:disabled { opacity: .35; cursor: default; }

/* Kategorien */
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 7px 0; cursor: pointer; border-radius: 8px; }
.cat-row:hover .cat-name { color: var(--accent); }
.cat-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.track > div { height: 100%; border-radius: 4px; }

/* Trend */
.trend { width: 100%; height: 220px; display: block; }
.trend text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Umsätze */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select, .field input, .field select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; min-width: 0;
}
.filters input[type=search] { flex: 1 1 220px; }
.tx { display: grid; grid-template-columns: 74px 1fr auto; gap: 2px 12px; padding: 11px 6px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.tx:hover { background: var(--surface-2); }
.tx .date { color: var(--muted); font-size: 13px; }
.tx .who { font-weight: 500; }
.tx .what { grid-column: 2; font-size: 13px; color: var(--muted); }
.tx .amt { text-align: right; font-weight: 600; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.pending { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.daysum { display: flex; justify-content: space-between; padding: 14px 6px 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 560px) { .tx { grid-template-columns: 1fr auto; } .tx .date { display: none; } .tx .what { grid-column: 1; } }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-body { padding: 20px; }
.dlg-body h3 { margin: 0 0 4px; font-size: 18px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.field { display: grid; gap: 5px; margin-top: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 14px; }
.check input { margin-top: 3px; }

/* Verbinden */
.connect { max-width: 560px; margin: 40px auto; text-align: center; }
.connect h1 { font-size: 26px; letter-spacing: -.02em; margin: 10px 0 8px; }
.banks { display: grid; gap: 8px; margin-top: 14px; text-align: left; }
.bank { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.bank:hover { border-color: var(--accent); }
.bank img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; background: #fff; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login input { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 16px 0 12px; }
.login .btn { width: 100%; justify-content: center; padding: 10px; }
.err { color: var(--neg); font-size: 14px; margin-top: 10px; }

.inline-input { border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; width: 170px; background: var(--surface-2); }
.tx .acct { font-size: 12px; color: var(--muted); }
.donutwrap svg { max-width: 230px; margin: 0 auto; }
.donutleg { max-width: 420px; }

.catchips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: 5px 8px 5px 12px; font-size: 14px; }
.chip .kind { font-size: 11px; color: var(--muted); }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 15px; }
.chip button:hover { color: var(--text); }
.acc .atag { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
