/* Simson-Tank. Werkzeugoberflaeche: heller Grund, ein Akzent, Ziffern in Mono. */

@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/jetbrains-mono-latin-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-21BB;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/jetbrains-mono-latin-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-21BB;
}

:root {
  color-scheme: light;

  --ground: #f2f2ef;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --ink: #16181c;
  --ink-2: #565b63;
  --ink-3: #696e75;
  --line: #e2e2dc;
  --line-strong: #cfcfc7;

  --accent: #1a4f8a;
  --accent-ink: #ffffff;
  --accent-soft: #e7eef7;

  --full: #2b7a4b;
  --low: #a8710f;
  --reserve: #ac2018;
  --reserve-soft: #fbeceb;

  --r-1: 4px;
  --r-2: 8px;
  --r-3: 14px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

  --shadow-1: 0 1px 2px rgba(20, 22, 26, .06), 0 2px 8px rgba(20, 22, 26, .04);
  --shadow-2: 0 2px 6px rgba(20, 22, 26, .1), 0 12px 28px rgba(20, 22, 26, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ground: #131519;
    --surface: #1a1d22;
    --surface-2: #20242a;
    --ink: #eceef1;
    --ink-2: #a3a9b2;
    --ink-3: #868d96;
    --line: #2a2f36;
    --line-strong: #3a4048;

    --accent: #7fb2ea;
    --accent-ink: #0f141b;
    --accent-soft: #1e2a38;

    --full: #5cb783;
    --low: #d3a13f;
    --reserve: #ef7168;
    --reserve-soft: #331d1b;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, .45), 0 12px 28px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

/* Schlaegt die Klassenregeln, die sonst versteckte Knoepfe wieder anzeigen. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

* { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid var(--ground); }
*::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.0625rem; }
h3 { font-size: 0.9375rem; }
p { margin: 0; }

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.02em;
}

.icon { width: 1.25em; height: 1.25em; flex: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Grundgeruest */

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  padding-top: calc(var(--s-3) + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.topbar h1 .icon { color: var(--accent); }

main {
  flex: 1;
  padding: var(--s-4);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.view[hidden] { display: none; }
.view { display: flex; flex-direction: column; gap: var(--s-4); }

/* Untere Navigation */

.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 186px));
  justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 4px 8px;
  min-height: 52px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  transition: color .15s ease;
}

.tabs a[aria-current='page'] { color: var(--accent); font-weight: 600; }
.tabs a:active { background: var(--surface-2); }
.tabs .icon { width: 22px; height: 22px; }

/* Flaechen */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-4);
}

.panel > h2 { margin-bottom: var(--s-3); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}

.section-head .hint { font-size: 0.75rem; color: var(--ink-3); }

/* Reichweite */

.range {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-5) var(--s-4) var(--s-4);
}

.range-main {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
}

.range-main .value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 3.5rem;
  line-height: 1;
  letter-spacing: -0.045em;
}

.range-main .unit { font-size: 1.0625rem; font-weight: 600; color: var(--ink-2); }
.range-caption { margin-top: var(--s-1); color: var(--ink-2); font-size: 0.9375rem; }
.range.is-reserve .range-main .value { color: var(--reserve); }
.range-unknown {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-2);
}

/* Tankskala */

.gauge { margin: var(--s-4) 0 var(--s-4); }
.gauge svg { display: block; width: 100%; height: auto; }
.gauge .track { fill: var(--surface-2); stroke: var(--line); }
.gauge .reserve-zone { fill: var(--reserve-soft); }
.gauge .fill { fill: var(--full); }
.gauge.low .fill { fill: var(--low); }
.gauge.reserve .fill { fill: var(--reserve); }
.gauge .tick { stroke: var(--line-strong); stroke-width: 1; }
.gauge .needle { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.gauge .reserve-line { stroke: var(--reserve); stroke-width: 1.5; }
.gauge .label { fill: var(--ink-3); font-size: 10px; font-family: var(--sans); }
.gauge .label-strong { fill: var(--ink-2); font-weight: 600; }
.gauge .reserve-label { fill: var(--reserve); font-size: 9px; font-weight: 600; }
.gauge .scale {
  fill: var(--ink-3);
  font-size: 10px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.gauge .scale-unit { font-family: var(--sans); }

.facts { display: grid; gap: var(--s-2); }

.fact {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
}

.fact:first-child { border-top: 0; }
.fact dt { color: var(--ink-2); }
.fact dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.fact dd small { font-family: var(--sans); font-weight: 400; color: var(--ink-3); }

/* Meldungen */

.note {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
  padding: var(--s-3);
  border-radius: var(--r-2);
  font-size: 0.9375rem;
  line-height: 1.45;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.note .icon { color: var(--ink-3); margin-top: 1px; }
.note strong { color: var(--ink); font-weight: 600; }
.note.warn { background: var(--reserve-soft); border-color: color-mix(in srgb, var(--reserve) 30%, transparent); color: color-mix(in srgb, var(--reserve) 78%, var(--ink)); }
.note.warn .icon { color: var(--reserve); }
.note.warn strong { color: inherit; }

/* Bedienelemente */

button, input, select { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: 0 var(--s-4);
  border-radius: var(--r-2);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}

.btn:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
  min-height: 44px;
  padding: 0 var(--s-2);
  font-weight: 500;
}
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { color: var(--reserve); }
.btn-danger:hover { background: var(--reserve-soft); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-2);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* Formulare */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }

.field input[type='text'],
.field input[type='number'],
.field input[type='date'],
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--s-3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  caret-color: var(--accent);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input[inputmode='decimal'],
.field input[type='number'] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder { color: var(--ink-3); }
.field .help { font-size: 0.75rem; color: var(--ink-3); }
.field .error { font-size: 0.75rem; color: var(--reserve); }
.field.is-invalid input { border-color: var(--reserve); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

.check {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 48px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  cursor: pointer;
}

.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check span { font-size: 0.9375rem; }
.check small { display: block; font-size: 0.75rem; color: var(--ink-3); }

.quick {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px var(--s-2);
}

.quick label { grid-column: 1 / -1; font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
.quick input { grid-column: 1; }
.quick .btn { grid-column: 2; }
.quick .help { grid-column: 1 / -1; margin: 0; font-size: 0.75rem; color: var(--ink-3); }

/* Dialog */

dialog {
  width: min(520px, calc(100vw - 24px));
  border: 0;
  border-radius: var(--r-3);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  box-shadow: var(--shadow-2);
  margin: auto;
}

dialog::backdrop { background: rgba(16, 18, 22, .45); backdrop-filter: blur(2px); }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4);
  border-bottom: 1px solid var(--line);
}

.dialog-body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.dialog-foot { padding: var(--s-4); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: var(--s-3); }
.dialog-foot .btn { flex: 1 1 40%; }
.dialog-foot [data-delete] { flex: 1 1 100%; order: 2; border-color: transparent; }

/* Kennzahlen */

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-4) var(--s-3); }
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric .k { font-size: 0.75rem; color: var(--ink-2); }
.metric .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.375rem; font-weight: 700; letter-spacing: -0.03em; }
.metric .v small { font-size: 0.75rem; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.metric.wide { grid-column: 1 / -1; }

/* Diagramme */

.chart { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 9px; font-family: var(--sans); }
.chart .value { fill: var(--ink-2); font-size: 9px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }
.chart .band { fill: color-mix(in srgb, var(--accent) 9%, transparent); }
.chart .mean { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .dot-out { fill: var(--accent); stroke: var(--accent); }
.chart .bar { fill: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.chart .bar-strong { fill: var(--accent); }
.chart .mark { stroke: var(--reserve); stroke-width: 1.5; stroke-dasharray: 3 2; }
.chart .mark-label { fill: var(--reserve); }
.chart .reserve-band { fill: color-mix(in srgb, var(--reserve) 14%, transparent); }
.chart .reserve-line { stroke: color-mix(in srgb, var(--reserve) 55%, transparent); stroke-width: 1; }

/* Liste */

.entries { list-style: none; margin: 0; padding: 0; }

.entries li + li .entry { border-top: 1px solid var(--line); }

.entry {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px var(--s-3);
  width: 100%;
  padding: var(--s-3) var(--s-2);
  margin: 0 calc(var(--s-2) * -1);
  border: 0;
  border-radius: var(--r-2);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}

.entry:hover { background: var(--surface-2); }
.entry:active { background: var(--accent-soft); }

.entry .when { grid-column: 1; grid-row: 1; font-size: 0.9375rem; font-weight: 600; }
.entry .meta { grid-column: 1; grid-row: 2; font-size: 0.8125rem; color: var(--ink-2); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.entry .rate {
  grid-column: 2;
  grid-row: 1 / span 2;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
}
.entry .rate small { display: block; font-size: 0.75rem; font-weight: 400; color: var(--ink-3); font-family: var(--sans); letter-spacing: 0; }
.entry .rate.none { color: var(--ink-3); font-weight: 400; }
.entry .tags { grid-column: 1 / -1; grid-row: 3; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.tag {
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: var(--r-1);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.lede {
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.5;
  max-width: 46ch;
}

.lede strong { color: var(--ink); font-weight: 600; }
.lede + .metrics { margin-top: var(--s-4); }

.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.stack-tight { gap: var(--s-2); margin-top: var(--s-3); }

.caption {
  margin-top: var(--s-3);
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--ink-3);
}

/* Leerer Zustand */

.empty { text-align: center; padding: var(--s-6) var(--s-4); display: flex; flex-direction: column; align-items: center; gap: var(--s-3); }
.empty .icon { width: 32px; height: 32px; color: var(--ink-3); }
.empty h2 { font-size: 1.0625rem; }
.empty p { color: var(--ink-2); font-size: 0.9375rem; max-width: 30ch; text-wrap: balance; }

.footnote { font-size: 0.75rem; color: var(--ink-3); text-align: center; padding: var(--s-2) 0 var(--s-4); }

/* Kurzmeldung */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--ground);
  padding: 10px var(--s-4);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s cubic-bezier(.2, .9, .3, 1);
  z-index: 40;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 560px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  main { padding: var(--s-5); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
