/* ============================================================
   pdUK-Liquiditätsrechner — Design im Befund-Trainer-Stil.
   Ein Akzent (Grün), Light "Studio" + Dark (prefers-color-scheme).
   Mobile-first, Karten, große Kennzahlen.
   ============================================================ */

:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  /* LIGHT · STUDIO */
  --bg: #eaeee9;
  --surface: #ffffff;
  --surface-2: #f4f6f2;
  --line: #dde3dc;
  --line-soft: #e9ede7;
  --ink: #16201b;
  --ink-2: #56625a;
  --ink-3: #8d978f;
  --accent: #15734b;
  --accent-press: #0f5c3b;
  --accent-ink: #126043;
  --accent-soft: #e2ede7;
  --on-accent: #ffffff;
  --gold: #b9892f;
  --gold-soft: #f3ead7;
  --blue: #2f6f9b;
  --blue-soft: #e4eef4;
  --on-blue: #ffffff;
  --r-card: 20px;
  --r-el: 13px;
  --r-pill: 999px;
  --shadow: 0 1px 2px rgba(18,40,28,.05), 0 10px 26px rgba(18,40,28,.07);
  --shadow-lg: 0 2px 6px rgba(18,40,28,.07), 0 24px 50px rgba(18,40,28,.14);
  --bar-track: #e4e9e3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1612;
    --surface: #15211b;
    --surface-2: #1c2b23;
    --line: #2a3a31;
    --line-soft: #213029;
    --ink: #eef3ef;
    --ink-2: #9fb0a5;
    --ink-3: #6b7d72;
    --accent: #34c98a;
    --accent-press: #2bb077;
    --accent-ink: #5cdca2;
    --accent-soft: rgba(52,201,138,.12);
    --on-accent: #06150e;
    --gold: #e0b465;
    --gold-soft: rgba(224,180,101,.12);
    --blue: #7bb6dc;
    --blue-soft: rgba(123,182,220,.12);
    --on-blue: #08161f;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 30px rgba(0,0,0,.4);
    --shadow-lg: 0 2px 8px rgba(0,0,0,.4), 0 28px 60px rgba(0,0,0,.55);
    --bar-track: #243329;
  }
}

* , *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* ---------- layout shell ---------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.app-body { flex: 1; padding: 0 18px calc(120px + env(safe-area-inset-bottom)); }
.safe-top { height: max(20px, env(safe-area-inset-top)); }
.stack > * + * { margin-top: 14px; }

/* ---------- header ---------- */
.head { padding: 14px 2px 6px; display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.brand-mark .ms { font-size: 24px; }
.brand-txt h1 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.brand-txt p { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.kicker {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent-ink); font-weight: 400;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow); padding: 18px;
}
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card-h .ms { font-size: 19px; color: var(--accent-ink); }
.card-h h2 { font-size: 13.5px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }

/* ---------- hero KPIs — dunkle Karte, grüne Kacheln ---------- */
.hero .card-h { margin-bottom: 6px; }
.hero .card-h h2 { color: var(--ink); font-size: 16.5px; letter-spacing: .02em; }
.hero .card-h .ms { font-size: 22px; }
.hero-lead { font-size: 12.5px; color: var(--ink-2); margin: 2px 0 16px; }
.kpis { display: grid; gap: 12px; }
.kpi {
  background: var(--accent); color: var(--on-accent);
  border: 1px solid var(--accent); border-radius: var(--r-el); padding: 15px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow);
}
.kpi-label { display: flex; align-items: center; gap: 11px; font-size: 13.5px; font-weight: 700; }
.kpi-label .ms { font-size: 21px; opacity: .95; }
.kpi-label small { display: block; font-weight: 400; font-size: 11px; opacity: .8; margin-top: 1px; }
.kpi-val { font-family: var(--mono); font-size: 21px; font-weight: 400; letter-spacing: -.02em; white-space: nowrap; }
.kpi-val .u { font-size: 12px; opacity: .72; margin-left: 2px; }
/* Liquidität: farblich abgesetzt (blau) — das Kapital, das im Unternehmen bleibt */
.kpi-liq { background: var(--blue); border-color: var(--blue); color: var(--on-blue); margin-top: 12px; }

/* ---------- sub metrics row ---------- */
.mrow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.metric { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-el); padding: 12px; text-align: center; }
.metric .v { font-family: var(--mono); font-size: 16px; font-weight: 400; color: var(--ink); letter-spacing: -.02em; }
.metric .l { font-size: 10.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.3; }

/* ---------- sliders ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.field-top label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field-top .val { font-family: var(--mono); font-size: 14px; color: var(--accent-ink); font-weight: 400; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: 999px; background: var(--bar-track); outline: none; margin: 6px 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: var(--shadow);
  cursor: pointer; transition: transform .08s;
}
input[type=range]::-webkit-slider-thumb:active { transform: scale(1.12); }
input[type=range]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface);
  border: 3px solid var(--accent); box-shadow: var(--shadow); cursor: pointer;
}
.seg { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--r-el); border: 1px solid var(--line-soft); }
.seg button {
  flex: 1; border: none; background: transparent; color: var(--ink-2); font-family: var(--font);
  font-size: 12.5px; font-weight: 600; padding: 9px 6px; border-radius: 9px; cursor: pointer; transition: all .12s;
}
.seg button[aria-pressed=true] { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow); }

/* Betriebsmodus — hervorgehobene Akzent-Box ganz oben, grüner aktiver Button */
.field-mode { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r-el); padding: 12px 12px 11px; margin-bottom: 18px; }
.field-mode .field-top label { color: var(--accent-ink); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.field-mode .field-top label .ms { font-size: 19px; }
.seg-mode { background: var(--surface); }
.seg-mode button[aria-pressed=true] { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); }
.mode-hint { font-size: 12px; color: var(--ink-2); margin: 9px 2px 0; line-height: 1.45; }

/* ---------- advanced toggle ---------- */
.adv-toggle {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; border: none; color: var(--ink-2); font-family: var(--font);
  font-size: 12.5px; font-weight: 600; padding: 10px; cursor: pointer;
}
.adv-toggle .ms { font-size: 18px; transition: transform .2s; }
.adv-toggle[aria-expanded=true] .ms { transform: rotate(180deg); }
.adv { display: none; padding-top: 4px; }
.adv.open { display: block; }

/* ---------- chart ---------- */
.chart-wrap { position: relative; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.leg { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); }
.leg .dot { width: 11px; height: 11px; border-radius: 3px; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
svg.chart .ax { fill: var(--ink-3); font-family: var(--mono); font-size: 11px; }
svg.chart .a-vz { fill: var(--gold-soft); stroke: none; }
svg.chart .a-frei { fill: var(--accent-soft); stroke: none; }
svg.chart .l-kap { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
svg.chart .l-vz { fill: none; stroke: var(--gold); stroke-width: 2; stroke-dasharray: 5 4; stroke-linejoin: round; }
svg.chart .l-cmp { fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 4 4; stroke-linejoin: round; opacity: .8; }

/* ---------- detail list ---------- */
.dlist { font-size: 13px; }
.dlist .ditem { border-top: 1px solid var(--line-soft); }
.dlist .ditem:first-child { border-top: none; }
.dlist .row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; align-items: baseline; }
.dlist .row .k { color: var(--ink-2); display: inline-flex; align-items: center; gap: 1px; }
.dlist .row .v { font-family: var(--mono); color: var(--ink); white-space: nowrap; }
.dlist .info-btn { -webkit-appearance: none; appearance: none; background: none; border: none; color: var(--ink-3); cursor: pointer; padding: 2px 2px 2px 4px; line-height: 0; }
.dlist .info-btn .ms { font-size: 15px; }
.dlist .info-btn[aria-expanded=true] { color: var(--accent-ink); }
.dlist .exp { display: none; font-size: 12px; color: var(--ink-2); line-height: 1.55; padding: 0 0 12px; max-width: 48ch; }
.dlist .exp.open { display: block; }

/* ---------- CTA ---------- */
.cta { text-align: center; }
.cta h3 { font-size: 16px; margin: 0 0 4px; }
.cta p { font-size: 13px; color: var(--ink-2); margin: 0 0 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; background: var(--accent); color: var(--on-accent); border: none;
  font-family: var(--font); font-size: 15px; font-weight: 700; padding: 15px;
  border-radius: var(--r-el); cursor: pointer; text-decoration: none; box-shadow: var(--shadow);
  transition: background .12s, transform .06s;
}
.btn:active { transform: translateY(1px); background: var(--accent-press); }
.btn-ghost { background: var(--surface); color: var(--accent-ink); border: 1px solid var(--line); box-shadow: none; }

.footnote { font-size: 11px; color: var(--ink-3); text-align: center; line-height: 1.5; padding: 4px 8px; }
.footnote a { color: var(--ink-2); }

/* ---------- Footer-Links (QR-Verteilung) ---------- */
.footer-links { font-size: 11px; color: var(--ink-3); text-align: center; line-height: 1.6; padding: 2px 8px 4px; }
.footer-links a { color: var(--ink-3); text-decoration: none; }
.footer-links a:hover { color: var(--ink-2); text-decoration: underline; }
.footer-links .sep { margin: 0 6px; opacity: .6; }

/* ---------- Termin-Buchungs-Funnel ---------- */
.bk-step h3 { font-size: 16px; margin: 0 0 4px; }
.bk-step > p { font-size: 13px; color: var(--ink-2); margin: 0 0 14px; }
.bk-alt { font-size: 12px; color: var(--ink-3); margin: 10px 0 0; }
.bk-alt a { color: var(--accent-ink); }

.bk-daynav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.bk-daylabel { flex: 1; text-align: center; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.bk-nav {
  -webkit-appearance: none; appearance: none; cursor: pointer; flex: none;
  width: 38px; height: 38px; border-radius: var(--r-el);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  display: grid; place-items: center;
}
.bk-nav:disabled { opacity: .4; cursor: default; }
.bk-nav .ms { font-size: 20px; }

.bk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; min-height: 44px; }
.bk-slot {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--r-pill); padding: 10px 6px; font-size: 13px; font-weight: 600;
  font-family: var(--font); transition: background .12s, color .12s, border-color .12s;
}
.bk-slot:hover { border-color: var(--accent); }
.bk-slot[aria-pressed=true] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.bk-msg { font-size: 12.5px; line-height: 1.45; margin: 12px 0 0; text-align: left; }
.bk-msg.err { color: #c0392b; }
.bk-msg.muted { color: var(--ink-3); }
@media (prefers-color-scheme: dark) { .bk-msg.err { color: #ff8a7a; } }

.bk-actions { display: flex; gap: 10px; margin-top: 16px; }
.bk-actions .btn { width: auto; flex: 1; }
.bk-actions .btn-ghost { flex: 0 0 auto; }

.bk-chosen {
  display: flex; align-items: center; gap: 8px; text-align: left;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r-el);
  padding: 10px 12px; font-size: 13px; font-weight: 600; color: var(--accent-ink); margin-bottom: 14px;
}
.bk-chosen .ms { font-size: 19px; }

.bk-fld { text-align: left; margin-bottom: 12px; }
.bk-fld label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.bk-fld input, .bk-fld textarea {
  width: 100%; font-family: var(--font); font-size: 14px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-el);
  padding: 11px 12px; outline: none; transition: border-color .12s;
}
.bk-fld input:focus, .bk-fld textarea:focus { border-color: var(--accent); }
.bk-fld textarea { resize: vertical; }

.bk-consent { display: flex; align-items: flex-start; gap: 9px; text-align: left; font-size: 12px; color: var(--ink-2); line-height: 1.45; margin-top: 4px; }
.bk-consent input { flex: none; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); }
.bk-consent a { color: var(--accent-ink); }

.bk-done-icon { color: var(--accent); margin-bottom: 6px; }
.bk-done-icon .ms { font-size: 44px; }

/* sticky install hint */
.install {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--ink); color: var(--bg); font-size: 12.5px; font-weight: 600;
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow-lg);
  display: none; align-items: center; gap: 8px; cursor: pointer; max-width: 92vw;
}
.install.show { display: inline-flex; }
.install .ms { font-size: 18px; }
.install .x { opacity: .6; margin-left: 4px; }

/* Schnellstart-Chips */
.chips {
  display: flex; align-items: center; gap: 8px; margin-bottom: 18px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips-label { font-size: 12px; font-weight: 600; color: var(--ink-2); flex: 0 0 auto; }
.chip {
  flex: 0 0 auto; -webkit-appearance: none; appearance: none; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px; font-weight: 600;
  font-family: inherit; white-space: nowrap; transition: background .12s, color .12s, border-color .12s;
}
.chip:hover, .chip:active { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }

/* Flussdiagramm "So funktioniert's" */
.flow-wrap { width: 100%; }
.flow-svg { width: 100%; height: auto; display: block; }
.flow-box { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.5; }
.flow-box-in { stroke: var(--ink-3); }
.flow-box-a { stroke: var(--accent); }
.flow-box-b { stroke: var(--blue); }
.flow-box-out { fill: var(--surface); stroke: var(--line-soft); stroke-dasharray: 4 4; }
.flow-title { fill: var(--ink); font-size: 13px; font-weight: 700; }
.flow-title-a { fill: var(--accent-ink); }
.flow-title-b { fill: var(--blue); }
.flow-out-title { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.flow-sub { fill: var(--ink-2); font-size: 9.5px; }
.flow-label { font-size: 9px; font-weight: 600; }
.flow-label-a { fill: var(--accent-ink); }
.flow-label-b { fill: var(--blue); }
.flow-path { fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.flow-path-a { stroke: var(--accent); }
.flow-path-b { stroke: var(--blue); }
.flow-path-dash { stroke-dasharray: 5 4; }

.chart-note { font-size: 11px; color: var(--ink-3); line-height: 1.5; margin: 10px 2px 0; }

.estimate-note {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 10.5px; color: var(--ink-3); line-height: 1.45;
  padding: 0 8px; margin: -2px 0 0;
}
.estimate-note .ms { font-size: 13px; color: var(--ink-3); flex: none; margin-top: 1px; }
.flow-arrowhead { fill: var(--ink-3); }
.flow-dot { stroke: none; }
.flow-dot-a { fill: var(--accent); }
.flow-dot-b { fill: var(--blue); }

@media (prefers-reduced-motion: reduce) {
  .flow-dot { display: none; }
}

/* Umschalter zwischen Unternehmer- und Mitarbeiter-Rechner (beide Seiten) */
.switch-link {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink-2); text-decoration: none; font-size: 13px;
  background: var(--surface); transition: border-color .15s, color .15s;
}
.switch-link:hover { border-color: var(--accent); color: var(--accent); }
.switch-link .ms { font-size: 18px; }
