:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1c2430; --muted: #6b7684;
  --line: #e2e7ee; --accent: #2f6fed; --accent-d: #1f52bd; --strong: #0d1522;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.container { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 24px; margin: 0 0 4px; }
.version { font-size: 12px; color: var(--muted); font-weight: 400; background: none; border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 7px; cursor: pointer; vertical-align: middle; }
.version:hover { background: #eef4ff; color: var(--accent); border-color: var(--accent); }

/* Changelog-Modal */
.changelog h4 { margin: 16px 0 6px; color: var(--strong); }
.changelog h4:first-child { margin-top: 0; }
.changelog ul { margin: 0 0 8px; padding-left: 20px; }
.changelog li { margin: 4px 0; font-size: 13.5px; line-height: 1.5; }
.subtitle { color: var(--muted); margin: 0 0 20px; max-width: 820px; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(20,30,50,.04); }
h2 { font-size: 16px; margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.dropzone { display: block; border: 2px dashed #c4cdda; border-radius: 10px;
  padding: 26px; text-align: center; cursor: pointer; transition: .15s; background: #fafbfd; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #eef4ff; }
.dropzone p { margin: 3px 0; }
.actions { margin-top: 12px; }

button { font: inherit; cursor: pointer; border-radius: 7px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; padding: 7px 14px; }
button:hover { background: var(--accent-d); }
button:disabled { opacity: .5; cursor: default; }
.btn-secondary { background: #fff; color: var(--accent); }
.btn-secondary:hover { background: #eef4ff; }
.btn-link { background: none; border: none; color: var(--accent); padding: 0 4px; font-size: 13px; text-decoration: underline; }
.btn-link:hover { background: none; color: var(--accent-d); }

.status { margin-top: 10px; font-size: 13px; color: var(--muted); }
.status.err { color: #c0392b; }

/* Filterleiste */
.filter-bar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: 16px;
  background: #eef3fc; border: 1px solid #c9d6ee; border-radius: 10px; padding: 12px 16px; margin-bottom: 18px;
  box-shadow: 0 2px 6px rgba(20,30,50,.08); }
.fgroup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flabel { font-weight: 600; font-size: 12.5px; color: var(--strong); }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.fselect { font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.kpi { background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-lbl { font-size: 12px; color: var(--muted); }
.kpi-val { font-size: 24px; font-weight: 700; color: var(--strong); }
.kpi-delta { font-size: 12px; font-weight: 700; white-space: nowrap; }
.kpi-up { color: #1f9d55; }
.kpi-down { color: #c0392b; }
.kpi-chart { margin-top: 2px; }
.lc-val { fill: var(--strong); font-size: 13px; font-weight: 600; text-anchor: middle; }

/* Section head */
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.sec-tools { display: flex; gap: 8px; align-items: center; }
.sec-tools input { padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; min-width: 220px; }
.count { font-size: 12px; color: var(--muted); font-weight: 400; }

/* Tabellen */
.table-wrap { overflow-x: auto; margin-top: 10px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid th, table.grid td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.grid th { position: sticky; top: 0; background: #f3f6fb; cursor: pointer; user-select: none; font-size: 12px; color: var(--strong); }
table.grid th:hover { background: #e8eefb; }
table.grid td.r, table.grid th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.strong { font-weight: 700; color: var(--strong); }
table.grid tr.clickable:hover td { background: #eef4ff; cursor: pointer; }
table.grid tbody tr:nth-child(even) td { background: #fafbfd; }
table.grid tfoot td { position: sticky; bottom: 0; background: #eef2f8; font-weight: 700;
  color: var(--strong); border-top: 2px solid #cdd6e4; }

/* Firmen-Chips in der Kundentabelle (aus welchen Mandanten der Kunde kauft) */
.firm-chip { display: inline-block; padding: 1px 8px; margin-right: 4px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: #fff; background: var(--c, #888); }

/* Sparkline-Trend je Zeile (Linie + Gesamtänderung %) */
.spark-wrap { display: inline-flex; align-items: center; gap: 6px; }
.spark { display: block; flex: 0 0 auto; }
.spark-lbl { font-size: 11px; font-variant-numeric: tabular-nums; }

/* Wachstums-% zwischen den Jahren */
.g-up { color: #1a8f52; font-weight: 600; }
.g-down { color: #d1495b; font-weight: 600; }
table.grid td .g-up, table.grid td .g-down { font-variant-numeric: tabular-nums; }

/* Tab-Leiste für die Tabellen-Bereiche */
.tabbar { display: flex; gap: 4px; margin: 4px 0 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabbar .tab { padding: 8px 16px; border: none; background: none; cursor: pointer; font-size: 14px;
  font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabbar .tab:hover { color: var(--strong); }
.tabbar .tab.active { color: var(--strong); border-bottom-color: #2f6fed; }

/* In sich scrollbare Tabelle mit fixiertem Kopf + Summenzeile */
.table-wrap.scroll { max-height: 62vh; overflow: auto; }
.table-wrap.scroll table.grid th { z-index: 2; }
.table-wrap.scroll table.grid tfoot td { z-index: 2; }

/* Filter: Dropdown + Segment-Toggle */
.fsel { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: #fff; color: var(--strong); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; vertical-align: middle; }
.seg-btn { padding: 5px 12px; border: none; background: #fff; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn:hover { background: #f3f6fb; }
.seg-btn.active { background: #2f6fed; color: #fff; font-weight: 600; }
.seg-btn.active:hover { background: #2f6fed; }

/* Liniencharts */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 24px; }
.chart-title { font-size: 13px; margin: 0 0 6px; color: var(--strong); }
svg.lc { width: 100%; height: auto; display: block; }
.lc-grid { stroke: #e6ebf2; stroke-width: 1; }
.lc-ytick { fill: var(--muted); font-size: 11px; text-anchor: end; }
.lc-xtick { fill: var(--muted); font-size: 11px; text-anchor: middle; }

/* Zeitverlauf */
.legend { display: flex; gap: 16px; margin: 8px 0 4px; font-size: 12.5px; flex-wrap: wrap; }
.legend .lg-title { font-weight: 600; color: var(--strong); margin-right: 4px; }
.legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart { display: flex; gap: 18px; align-items: flex-end; padding-top: 10px; overflow-x: auto; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 60px; }
.bars { display: flex; gap: 3px; align-items: flex-end; height: 160px; }
.bar { width: 16px; border-radius: 3px 3px 0 0; }
.bar-lbl { font-size: 12px; font-weight: 600; }
.bar-sum { font-size: 11px; color: var(--muted); }

/* Modal */
.modal { border: none; border-radius: 12px; padding: 0; max-width: 900px; width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(15,22,34,.45); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { background: #fff; color: var(--muted); border: 1px solid var(--line); font-size: 20px; line-height: 1; padding: 2px 10px; }
.modal-body { padding: 16px 20px 22px; }
.modal-body .dd-h { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 0 8px; }
.modal-body .dd-h + .timeline { margin-bottom: 18px; }
