/* ============================================================
   KFZ-Vollkosten-Rechner – Stylesheet
   Mobile-first, Light/Dark via prefers-color-scheme
   ============================================================ */

:root {
  /* Farbpalette – Petrol / Sand / Signal */
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --text: #1c2523;
  --text-muted: #5b6a66;
  --border: #d8ded9;
  --primary: #0e5a52;
  --primary-soft: #d9ebe7;
  --accent: #e2762a;
  --accent-text: #ffffff;
  --pos: #1f7a4d;
  --neg: #b3403a;

  /* Kategorien der Kostenaufteilung */
  --c-dep: #0e5a52;
  --c-energy: #e2762a;
  --c-ins: #3d7ea6;
  --c-tax: #8a5fa8;
  --c-maint: #b8973a;
  --c-fix: #7c8a85;

  /* Chart-Serienfarben */
  --line-a: #0e5a52;
  --line-b: #e2762a;
  --grid-line: #d8ded9;

  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 35, 30, 0.08), 0 4px 16px rgba(20, 35, 30, 0.06);
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614;
    --surface: #1a2320;
    --surface-2: #222d29;
    --text: #e8ede9;
    --text-muted: #9aaba4;
    --border: #31403a;
    --primary: #4db6a4;
    --primary-soft: #1d3a34;
    --accent: #f08c42;
    --accent-text: #1c1206;
    --pos: #57c98a;
    --neg: #e07a72;

    --c-dep: #4db6a4;
    --c-energy: #f08c42;
    --c-ins: #6aa9cf;
    --c-tax: #b18cd0;
    --c-maint: #d4b45e;
    --c-fix: #93a39d;

    --line-a: #4db6a4;
    --line-b: #f08c42;
    --grid-line: #31403a;

    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

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

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

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }
.tagline { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.header-actions { display: flex; gap: 0.5rem; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-accent { background: var(--accent); color: var(--accent-text); }
.btn-accent:not(:disabled):hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

.help-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: none;
}

.btn-link {
  font: inherit;
  background: none;
  border: none;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* ---------- Hinweis-Badge ---------- */
.note-badge {
  background: var(--primary-soft);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
  margin: 0.5rem 0 1.25rem;
}

/* ---------- Szenario-Formulare ---------- */
.scenarios { display: grid; gap: 1rem; }

.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.scenario-card h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }

.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.dot-a { background: var(--line-a); }
.dot-b { background: var(--line-b); }

.field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.75rem; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.field-row .field { margin-bottom: 0.75rem; }

input[type="number"], select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  width: 100%;
}
input[type="number"]:focus, select:focus, input[type="range"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.hint { font-size: 0.8rem; color: var(--text-muted); margin: -0.25rem 0 0.75rem; }
.ev-hint { color: var(--primary); font-weight: 600; }

.mode-switch { flex-direction: row; flex-wrap: wrap; gap: 1rem; }
.radio { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; }

details.tax-help { margin: 0 0 0.9rem; font-size: 0.85rem; }
details.tax-help summary { cursor: pointer; color: var(--primary); font-weight: 600; }
details.tax-help p { margin: 0.5rem 0 0; color: var(--text-muted); }

/* ---------- km-Panel ---------- */
.km-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-top: 1rem;
}
.km-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.km-head output { font-size: 1.3rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.km-scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); }

input[type="range"] {
  width: 100%;
  margin: 0.75rem 0 0.25rem;
  accent-color: var(--primary);
}

/* ---------- Ad-Slot ---------- */
.ad-slot {
  margin: 1.25rem 0;
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
}
.ad-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); }

/* ---------- Ergebnis ---------- */
.section-title { font-size: 1.15rem; margin: 2rem 0 1rem; }

.result-grid { display: grid; gap: 1rem; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.result-card h3 { font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }

.kpis { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 0.75rem 0 1rem; }
.kpi { display: flex; flex-direction: column; }
.kpi-value { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.stackbar {
  display: flex;
  height: 26px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}
.stackbar span { display: block; height: 100%; min-width: 0; }
.seg-dep { background: var(--c-dep); }
.seg-energy { background: var(--c-energy); }
.seg-ins { background: var(--c-ins); }
.seg-tax { background: var(--c-tax); }
.seg-maint { background: var(--c-maint); }
.seg-fix { background: var(--c-fix); }

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding: 0;
  margin: 0.9rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-dep { background: var(--c-dep); }
.sw-energy { background: var(--c-energy); }
.sw-ins { background: var(--c-ins); }
.sw-tax { background: var(--c-tax); }
.sw-maint { background: var(--c-maint); }
.sw-fix { background: var(--c-fix); }

.diff-card {
  margin-top: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  font-size: 1.02rem;
}
.diff-card p { margin: 0; }
.diff-card .pos { color: var(--pos); font-weight: 800; }
.diff-card .neg { color: var(--neg); font-weight: 800; }

/* ---------- Charts ---------- */
.chart-section { margin-top: 1rem; }
.canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem;
  overflow-x: auto;
}
.canvas-wrap canvas { display: block; width: 100%; height: auto; max-width: 100%; }
.chart-note { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0 0; }

/* ---------- Tabelle ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: 0.92rem; }
th, td { text-align: right; padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--surface-2); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
tbody tr:last-child td { border-bottom: none; }
tr.total-row td { font-weight: 800; border-top: 2px solid var(--text); }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}
.site-footer nav { display: flex; gap: 1.25rem; }

/* ---------- Modals ---------- */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 32rem;
  width: calc(100% - 2rem);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(10, 15, 13, 0.55); }
.modal h2 { font-size: 1.15rem; }
.modal .price { font-size: 1.1rem; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }

.help-steps { margin: 0.75rem 0 0; padding-left: 1.4rem; display: grid; gap: 0.6rem; font-size: 0.92rem; }
.help-steps li { padding-left: 0.2rem; }
.help-subtitle { font-size: 0.95rem; margin: 1.1rem 0 0.4rem; }
.help-know { margin: 0; padding-left: 1.4rem; display: grid; gap: 0.35rem; font-size: 0.88rem; color: var(--text-muted); }

/* ---------- Print ---------- */
.print-only { display: none; }

@media print {
  .no-print, .ad-slot, .header-actions, .site-footer nav { display: none !important; }
  .print-only { display: inline; font-size: 0.8rem; font-weight: 400; color: #444; }
  body { background: #fff; color: #000; font-size: 12px; }
  .result-card, .diff-card, .table-wrap, .canvas-wrap { box-shadow: none; border-color: #999; }
  .canvas-wrap { overflow: visible; }
  .chart-section { break-inside: avoid; }
  main { padding-bottom: 0; }
}

/* ---------- Desktop ---------- */
@media (min-width: 760px) {
  .scenarios { grid-template-columns: 1fr 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .brand h1 { font-size: 1.55rem; }
}
