/* Zählerstand – Gestaltung angelehnt an das Cortex-Dashboard (Petrol + Gold) */
:root {
  --bg-deep: #002B36;
  --bg-nav: #001F28;
  --bg-input: #001F28;
  --card: linear-gradient(135deg, #003B49 0%, #002530 100%);
  --gold: #E8C97D;
  --gold-hell: #F0D9A0;
  --gold-grad: linear-gradient(135deg, #B8922A 0%, #E8C97D 100%);
  --text: #F5F0E8;
  --text-2: #C9D4D2;
  --muted: #9DB0AE;
  --label: #A8B8B6;
  --unter: #6CC4E0;          /* unter Abschlag / unter Durchschnitt */
  --ueber: #F0A04B;          /* über Abschlag / über Durchschnitt */
  --fehler: #FF8A80;
  --vorjahr: #3E7F8C;
  --referenz: #5A7A82;
  --rand: rgba(200, 168, 76, 0.2);
  --rand-stark: rgba(200, 168, 76, 0.45);
  --radius: 16px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-deep); color: var(--text);
  font: 15px/1.4 Inter, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

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

/* ── Kopf ─────────────────────────────────────────── */
.kopf { padding: 20px 20px 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kopf h1 { margin: 0; font: 700 20px Montserrat, sans-serif; color: var(--gold); letter-spacing: .02em; }
.kopf .unter { font-size: 13px; color: var(--muted); }
.konto {
  width: 44px; height: 44px; border-radius: 22px; flex-shrink: 0;
  border: 1px solid rgba(200,168,76,.5); background: #003B49; color: var(--gold);
  font: 600 15px Montserrat, sans-serif;
}

main { flex: 1; padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 12px; }

/* ── Karten ───────────────────────────────────────── */
.karte { background: var(--card); border: 1px solid var(--rand); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.karte.hervor { border-color: rgba(200,168,76,.35); }
.karte.warn { border-color: rgba(240,160,75,.55); }
.label { font-size: 13px; color: var(--label); text-transform: uppercase; letter-spacing: .08em; }
.gross { font: 500 36px var(--mono); }
.mittel { font: 500 26px var(--mono); }
.mono { font-family: var(--mono); }
.zeile { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.leise { color: var(--muted); }
.trenner { height: 1px; background: rgba(255,255,255,.06); }
.ueber { color: var(--ueber); font-weight: 600; }
.unter-farbe { color: var(--unter); font-weight: 600; }
.klein { font-size: 12px; }

/* Medium-Zeile */
.medium { display: flex; align-items: center; gap: 12px; }
.medium .icon { width: 40px; height: 40px; border-radius: 12px; background: rgba(232,201,125,.12); display: grid; place-items: center; flex-shrink: 0; }
.medium .icon svg { width: 22px; height: 22px; stroke: var(--gold); }
.medium .mitte { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.medium .rechts { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.medium .name { font-weight: 600; }
.balken { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; display: flex; }
.balken > span { display: block; height: 100%; }
.balken.dick { height: 8px; border-radius: 4px; }

/* Hinweis / Aufforderung */
.hinweis { border: 1px dashed rgba(200,168,76,.5); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.hinweis .text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hinweis strong { color: var(--gold); font-size: 14px; }

/* ── Knöpfe & Formulare ───────────────────────────── */
.knopf {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: none;
  background: var(--gold-grad); color: #000; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.knopf.voll { width: 100%; min-height: 52px; font: 700 16px Montserrat, sans-serif; }
.knopf.zweit { background: transparent; color: var(--text-2); border: 1px solid rgba(200,168,76,.35); font-weight: 500; }
.knopf:disabled { opacity: .5; cursor: default; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid rgba(200,168,76,.3); background: transparent; color: var(--text-2); font-size: 13px; }
.chip[aria-pressed="true"] { border-color: var(--gold); background: rgba(232,201,125,.15); color: var(--gold); font-weight: 600; }
.reiter { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; background: var(--bg-nav); border-radius: 14px; padding: 4px; }
.reiter button { min-height: 44px; border-radius: 10px; border: none; background: transparent; color: var(--text-2); }
.reiter button[aria-selected="true"] { background: var(--gold-grad); color: #000; font-weight: 600; }

label.feld { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.eingabe {
  min-height: 48px; width: 100%; border-radius: 12px; border: 1px solid rgba(200,168,76,.35);
  background: var(--bg-input); color: var(--text); padding: 0 14px; font-size: 16px;
}
.eingabe.gross-eingabe { min-height: 60px; font: 500 28px var(--mono); border-color: var(--gold); }
.eingabe::placeholder { color: #6F8684; }
.zwei { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wahl { display: flex; gap: 8px; }
.wahl label { flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; border: 1px solid rgba(200,168,76,.3); color: var(--text-2); font-size: 14px; }
.wahl label:has(input:checked) { border-color: var(--gold); color: var(--gold); }
.wahl input { accent-color: var(--gold); }
.meldung { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--text-2); }
.meldung.ok { background: rgba(108,196,224,.1); }
.meldung.warn { background: rgba(240,160,75,.12); }
.meldung.fehler { background: rgba(255,138,128,.12); color: var(--fehler); }
.meldung svg { width: 20px; height: 20px; flex-shrink: 0; }
.fehlertext { color: var(--fehler); font-size: 13px; min-height: 18px; }

/* ── Diagramm ─────────────────────────────────────── */
.diagramm { position: relative; height: 170px; display: flex; align-items: flex-end; gap: 3px; border-bottom: 1px solid rgba(255,255,255,.12); padding-top: 22px; }
.diagramm .gruppe {
  flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; position: relative;
  min-width: 0; padding: 0; border: none; border-radius: 6px 6px 0 0; background: transparent;
}
.diagramm .gruppe:hover { background: rgba(232,201,125,.05); }
.diagramm .gruppe[aria-pressed="true"] { background: rgba(232,201,125,.12); }
.diagramm .saeule { display: block; width: 40%; max-width: 12px; border-radius: 2px 2px 0 0; }
.detail { background: var(--bg-nav); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.detail .zeile span:first-child { display: flex; align-items: center; gap: 6px; }
.punkt { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.punkt.akt { background: var(--gold); }
.punkt.vj { background: var(--vorjahr); }
.punkt.vvj { background: transparent; border: 1.5px solid var(--referenz); }
.diagramm .vj { background: var(--vorjahr); }
.diagramm .akt { background: var(--gold); }
.diagramm .marke { position: absolute; top: -20px; font-size: 11px; color: var(--gold); white-space: nowrap; }
.achse { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); text-align: center; font-size: 11px; color: var(--muted); margin-top: -6px; }
.legende { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legende span { display: flex; align-items: center; gap: 6px; }
.legende i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* Einstellungen */
.formular { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid rgba(255,255,255,.06); padding-top: 12px; }
select.eingabe { appearance: auto; }
.tarif { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.06); }
.link { min-height: 36px; padding: 0 4px; border: none; background: transparent; color: var(--gold); font-size: 13px; }

.jahre { display: flex; flex-direction: column; gap: 6px; }
.jahre .j { display: grid; grid-template-columns: 44px 1fr 86px; gap: 8px; align-items: center; font-size: 13px; }

/* ── Navigation ───────────────────────────────────── */
/* immer am unteren Fensterrand eingeblendet, unabhängig von der Seitenlänge */
nav.unten {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 4;
  width: 100%; max-width: 520px; border-top: 1px solid var(--rand); background: var(--bg-nav);
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px;
}
main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
/* PC / breite Fenster: schwebende Leiste mit Abstand zum Rand */
@media (min-width: 600px) {
  nav.unten { bottom: 16px; width: calc(100% - 32px); max-width: 488px; border: 1px solid var(--rand-stark);
    border-radius: 18px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
  main { padding-bottom: 112px; }
}
nav.unten a { min-height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); text-decoration: none; }
nav.unten a[aria-current="page"] { color: var(--gold); }
nav.unten svg { width: 22px; height: 22px; }

/* ── Anmeldung ────────────────────────────────────── */
.anmeldung { max-width: 420px; margin: 0 auto; padding: 48px 20px; display: flex; flex-direction: column; gap: 16px; }
.anmeldung h1 { font: 700 26px Montserrat, sans-serif; color: var(--gold); margin: 0; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: 216px; align-self: center; }
.qr img { display: block; width: 200px; height: 200px; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; font: 500 15px var(--mono); }
.codes span { background: var(--bg-input); border-radius: 8px; padding: 8px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%); background: #003B49; border: 1px solid var(--rand-stark); color: var(--text); padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 10; max-width: 90vw; }
.menue { position: absolute; right: 16px; top: 68px; background: #003B49; border: 1px solid var(--rand-stark); border-radius: 12px; padding: 6px; z-index: 5; min-width: 200px; }
.menue button, .menue a { display: flex; align-items: center; color: var(--text); text-decoration: none; font: inherit; width: 100%; min-height: 44px; text-align: left; padding: 0 12px; border: none; background: transparent; border-radius: 8px; }
.menue button:hover, .menue a:hover { background: rgba(232,201,125,.1); }
.leer { color: var(--muted); text-align: center; padding: 40px 0; }

@media (prefers-reduced-motion: no-preference) {
  .karte, .hinweis { animation: rein .25s ease-out both; }
  @keyframes rein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* Hauskosten: Fälligkeitsmonate */
.monatswahl { border: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.monatswahl legend { margin-bottom: 6px; }
.monatswahl label { display: flex; align-items: center; gap: 4px; font-size: 13px; min-height: 36px; }
details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }

/* Jahresübersicht */
.tabelle-rahmen { overflow-x: auto; margin: 0 -4px; }
.tabelle { width: 100%; border-collapse: collapse; font: 12px var(--mono); }
.tabelle th, .tabelle td { padding: 5px 6px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--rand); }
.tabelle th:first-child { text-align: left; font-family: Inter, system-ui, sans-serif; }
.tabelle thead th { color: var(--label); font: 600 11px Inter, system-ui, sans-serif; }
.tabelle tfoot tr:first-child { font-weight: 700; }
.tabelle tfoot tr:first-child th, .tabelle tfoot tr:first-child td { border-top: 2px solid var(--rand-stark); }
.zwei-spalten { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.zwei-spalten > div { display: flex; flex-direction: column; gap: 6px; }
.druck-kopf { display: flex; flex-direction: column; gap: 2px; }
.druck-gesamt { border-top: 2px solid var(--rand-stark); padding-top: 8px; font-size: 16px; }

@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .kopf, nav.unten, .nicht-drucken, .menue, .toast { display: none !important; }
  main { padding: 0 !important; max-width: none !important; }
  .karte { background: none; border: none; padding: 0; }
  .leise, .label, .tabelle thead th { color: #555 !important; }
  .tabelle { font-size: 9.5pt; }
  .tabelle th, .tabelle td { border-color: #ccc; }
  .tabelle tfoot tr:first-child th, .tabelle tfoot tr:first-child td, .druck-gesamt { border-color: #000; }
  .tabelle-rahmen { overflow: visible; }
}
