/* ZinsWerk – Design Tokens */
:root {
  --brand: #0e5e54;
  --brand-strong: #0a463f;
  --brand-soft: #e0f0ed;
  --brand-contrast: #f4fbf9;
  --accent: #e8a33d;
  --accent-soft: #fdf3e3;

  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-alt: #eef3f1;
  --border: #d8e2df;
  --text: #1c2a27;
  --text-muted: #5b6f6a;

  --chart-line: #0e5e54;
  --chart-area: rgba(14, 94, 84, 0.16);
  --chart-area-line: rgba(14, 94, 84, 0.45);
  --chart-grid: #dde6e3;
  --chart-text: #5b6f6a;
  --scen-1: #b0743a;
  --scen-2: #3a6ab0;
  --scen-3: #8a4c9e;

  --danger: #b03a3a;
  --shadow: 0 1px 2px rgba(16, 42, 38, 0.06), 0 8px 24px rgba(16, 42, 38, 0.07);
  --radius: 14px;
  --font-body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --font-num: "Spline Sans Mono", "Consolas", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #35a894;
    --brand-strong: #55c2ae;
    --brand-soft: #14332e;
    --brand-contrast: #0b1614;
    --accent: #e8b463;
    --accent-soft: #2e2416;

    --bg: #0e1513;
    --surface: #16201d;
    --surface-alt: #1d2b27;
    --border: #2b3b36;
    --text: #e4edea;
    --text-muted: #93a8a2;

    --chart-line: #4cc2ac;
    --chart-area: rgba(76, 194, 172, 0.18);
    --chart-area-line: rgba(76, 194, 172, 0.5);
    --chart-grid: #24332e;
    --chart-text: #93a8a2;
    --scen-1: #d99a5b;
    --scen-2: #6f9bd9;
    --scen-3: #b57cc9;

    --danger: #e07a7a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand-claim { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

/* Intro */
.intro { padding: 28px 0 8px; max-width: 720px; }
.intro h1 { margin: 0 0 8px; font-size: 1.6rem; letter-spacing: -0.02em; line-height: 1.2; }
.intro p { margin: 0; color: var(--text-muted); }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 18px 0 40px;
}

.results-col { display: grid; gap: 18px; align-content: start; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel h2 { margin: 0 0 14px; font-size: 1.05rem; letter-spacing: -0.01em; }
.panel-sub { margin: -8px 0 14px; font-size: 0.87rem; color: var(--text-muted); }

/* Form */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 5px; }
.hint { color: var(--text-muted); font-weight: 500; font-size: 0.8rem; }

.input-unit {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
  overflow: hidden;
  transition: border-color 0.15s;
}

.input-unit:focus-within { border-color: var(--brand); }

.input-unit input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 600 1rem var(--font-num);
  padding: 10px 12px;
  outline: none;
  appearance: textfield;
}

.input-unit .unit {
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.input-unit-small input { padding: 7px 10px; font-size: 0.9rem; }
.input-unit-small .unit { padding: 0 10px; font-size: 0.78rem; }

/* Toggle */
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.toggle-track {
  flex: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background 0.15s;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.toggle input:checked + .toggle-track { background: var(--brand); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.toggle-label { font-weight: 600; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 7px; }

.field-toggle { margin-top: 18px; }
.field-toggle .hint { margin: 8px 0 0; }

/* Results */
.result-hero {
  background: linear-gradient(135deg, var(--brand-soft), var(--surface-alt));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.result-hero-label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.result-hero-value { display: block; font: 700 clamp(1.7rem, 6vw, 2.3rem)/1.2 var(--font-num); color: var(--brand-strong); letter-spacing: -0.02em; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0 0 16px;
}

.result-item {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 10px 12px;
}

.result-item dt { font-size: 0.76rem; font-weight: 700; color: var(--text-muted); }
.result-item dd { margin: 2px 0 0; font: 600 1.05rem var(--font-num); }
.result-item-strong { outline: 1px solid var(--brand); outline-offset: -1px; }
.result-item-strong dd { color: var(--brand-strong); }

.split-bar {
  height: 12px;
  border-radius: 999px;
  background: var(--chart-area);
  overflow: hidden;
  border: 1px solid var(--border);
}

.split-bar-eingezahlt {
  height: 100%;
  width: 50%;
  background: var(--brand);
  border-radius: 999px 0 0 999px;
  transition: width 0.25s ease;
}

.split-bar-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0 0; font-size: 0.8rem; color: var(--text-muted); }

.legend-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.legend-chip::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.legend-eingezahlt::before { background: var(--brand); }
.legend-gewinn::before { background: var(--chart-area); border: 1px solid var(--chart-area-line); }
.legend-wert::before { background: var(--chart-line); height: 3px; border-radius: 2px; }

/* Chart */
.chart-wrap { position: relative; }
.chart-wrap canvas { display: block; width: 100%; touch-action: pan-y; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px 11px;
  font-size: 0.78rem;
  line-height: 1.45;
  min-width: 150px;
  z-index: 5;
}

.chart-tooltip strong { font-family: var(--font-num); font-weight: 600; }
.chart-tooltip .tt-title { font-weight: 800; margin-bottom: 2px; }
.chart-tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
.chart-tooltip .tt-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 0; font-size: 0.8rem; color: var(--text-muted); }

/* Scenarios */
.scenario-master { margin-bottom: 14px; }

.scenario-rows { display: grid; gap: 10px; }
.scenario-rows[data-disabled="true"] { opacity: 0.45; pointer-events: none; }

.scenario-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 10px 12px;
}

.scenario-row .input-unit { background: var(--surface); }
.scenario-result { font: 600 0.92rem var(--font-num); color: var(--text-muted); grid-column: 1 / -1; }

.scen-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.scen-dot-1 { background: var(--scen-1); }
.scen-dot-2 { background: var(--scen-2); }
.scen-dot-3 { background: var(--scen-3); }

/* Waiting widget */
.waiting-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

.waiting-item {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.waiting-item strong { font: 700 1.15rem var(--font-num); }
.waiting-label { font-size: 0.76rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.waiting-item-diff { background: var(--accent-soft); }
.waiting-item-diff strong { color: var(--danger); }
#wait-hint { margin: 10px 0 0; }

/* Ad slot */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.ad-slot-label { font-size: 0.72rem; color: var(--text-muted); letter-spacing: 0.14em; text-transform: uppercase; }

/* Disclaimer */
.disclaimer-panel p { margin: 0; font-size: 0.84rem; color: var(--text-muted); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-inner { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; }
.footer-nav { display: flex; gap: 16px; }

/* Buttons */
.btn {
  font: 700 0.88rem var(--font-body);
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 15px;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}

.btn:disabled { cursor: not-allowed; opacity: 0.6; }

.btn-premium {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--accent);
}

.btn-premium:hover { filter: brightness(0.97); }

.btn-primary { background: var(--brand); color: var(--brand-contrast); width: 100%; padding: 12px; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); width: 100%; margin-top: 8px; }
.btn-ghost:hover { background: var(--surface-alt); }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: 600 0.85rem var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:hover { color: var(--text); }

/* Modals */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 440px;
  width: calc(100vw - 32px);
  box-shadow: var(--shadow);
}

.modal::backdrop { background: rgba(10, 20, 18, 0.55); }
.modal-body { padding: 22px; }
.modal-body h2 { margin: 0 0 10px; font-size: 1.15rem; }
.modal-body p { margin: 0 0 12px; font-size: 0.92rem; }

.premium-list { margin: 0 0 16px; padding-left: 20px; font-size: 0.9rem; }
.premium-list li { margin-bottom: 4px; }

.todo-note {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

/* Erste-Schritte-Hilfe */
.header-actions { display: flex; align-items: center; gap: 10px; }

.help-btn {
  inline-size: 2rem;
  block-size: 2rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.help-btn:hover,
.help-btn:focus-visible { color: var(--brand); border-color: var(--brand); }

.tour-intro { color: var(--text-muted); }

.tour-steps { margin: 0 0 1rem; padding-left: 1.25rem; display: grid; gap: 0.6rem; }
.tour-steps li { font-size: 0.92rem; }
.tour-steps li strong { color: var(--brand-strong); }

.know-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.know-box h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.know-box ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.4rem; }
.know-box li { font-size: 0.9rem; color: var(--text-muted); }

/* Tablet / Desktop */
@media (min-width: 760px) {
  .intro { padding-top: 40px; }
  .intro h1 { font-size: 2rem; }
  .layout { grid-template-columns: 320px 1fr; align-items: start; }
  .inputs-panel { position: sticky; top: 76px; }
  .scenario-row { grid-template-columns: 1fr 150px auto; }
  .scenario-result { grid-column: auto; text-align: right; min-width: 110px; }
  .waiting-grid { grid-template-columns: repeat(3, 1fr); }
}
