/* Kleinvieh: Handy zuerst, dasselbe Bausystem wie Susis Saftladen.
   Grundsaetze: grosse Tippflaechen (nichts unter 44 Pixel), wenig auf einem Bildschirm,
   Zahlen in Tabellenziffern, damit Spalten untereinander stehen.
   Die Farbe kommt vom Namen: Weidegruen auf hellem Heu. Warnungen in Rost, damit sie sich
   vom Gruen abheben, ohne gleich nach Alarm auszusehen. */

:root {
    color-scheme: light;
    --grund: #f4f6f1;
    --karte: #ffffff;
    --rand: #dde3d6;
    --text: #1f2620;
    --leise: #66705f;
    --akzent: #3d6b4f;
    --akzent-dunkel: #2f5540;
    --akzent-leise: #e8f0ea;
    --warn: #9a430d;
    --warn-leise: #fbeee4;
    --warn-rand: #f0d4c0;
    --alarm: #a01b1b;
    --alarm-leise: #fdf0f0;
    --alarm-rand: #f0d0d0;
    --balken: #3d6b4f;
    --r: 14px;
    --schatten: 0 1px 2px rgba(31, 38, 32, .06), 0 4px 14px rgba(31, 38, 32, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--grund);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

.huelle { max-width: 680px; margin: 0 auto; padding: 0 16px 110px; }

/* ── Kopf ─────────────────────────────────────────────────────────────── */
header.kopf {
    position: sticky; top: 0; z-index: 20;
    background: var(--grund);
    border-bottom: 1px solid var(--rand);
    padding: 12px 0 10px;
    margin-bottom: 18px;
}
.kopf-innen {
    max-width: 680px; margin: 0 auto; padding: 0 16px;
    display: flex; align-items: center; gap: 10px;
}
.marke { font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; text-decoration: none; color: var(--text); }
.marke span { color: var(--akzent); }
.kopf-rest { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* Umschalter privat / geschaeftlich / alles. Klein, weil er selten gebraucht wird. */
.blick { display: flex; border: 1px solid var(--rand); border-radius: 999px; overflow: hidden; }
.blick a {
    padding: 6px 11px; font-size: .78rem; font-weight: 600; text-decoration: none;
    color: var(--leise); white-space: nowrap;
}
.blick a.an { background: var(--akzent); color: #fff; }

/* ── Karten ───────────────────────────────────────────────────────────── */
.karte {
    background: var(--karte);
    border: 1px solid var(--rand);
    border-radius: var(--r);
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--schatten);
}
.karte h2 {
    margin: 0 0 12px; font-size: .85rem; letter-spacing: .05em;
    text-transform: uppercase; color: var(--leise);
    display: flex; align-items: baseline; gap: 8px;
}
.karte h2 .rechts { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.karte.blank { padding: 0; overflow: hidden; }
.karte.blank h2 { padding: 16px 16px 0; }
.karte.warn { border-color: var(--warn-rand); background: var(--warn-leise); }
.karte.warn h2 { color: var(--warn); }
h1 { font-size: 1.5rem; margin: 0 0 16px; letter-spacing: -.02em; text-wrap: balance; }
h1 .klein { font-weight: 400; }

/* ── Tasten ───────────────────────────────────────────────────────────── */
.taste, button.taste, a.taste {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 52px; padding: 12px 18px;
    border: 1px solid var(--rand); border-radius: var(--r);
    background: var(--karte); color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none; text-align: center;
    cursor: pointer;
}
.taste:active { transform: translateY(1px); }
.taste.haupt { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.taste.haupt:hover { background: var(--akzent-dunkel); }
.taste.still { min-height: 44px; font-weight: 500; color: var(--leise); }
.taste.klein { width: auto; min-height: 40px; padding: 8px 14px; font-size: .9rem; }
.taste.gefahr { color: var(--alarm); border-color: var(--alarm-rand); background: var(--alarm-leise); }
.taste + .taste { margin-top: 10px; }
.tastenreihe { display: flex; gap: 10px; flex-wrap: wrap; }
.tastenreihe .taste { flex: 1 1 0; }
.tastenreihe .taste + .taste { margin-top: 0; }

/* ── Formulare ────────────────────────────────────────────────────────── */
label { display: block; font-weight: 600; margin: 0 0 6px; font-size: .92rem; }
.hint { color: var(--leise); font-weight: 400; font-size: .85rem; display: block; margin-top: 3px; }
input[type=text], input[type=number], input[type=password], input[type=date],
input[type=email], input[type=search], select, textarea {
    width: 100%; min-height: 50px; padding: 11px 14px;
    border: 1px solid var(--rand); border-radius: 10px;
    background: var(--karte); color: var(--text);
    font: inherit; font-variant-numeric: tabular-nums;
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
.taste:focus-visible, a:focus-visible, button:focus-visible, summary:focus-visible {
    outline: 3px solid var(--akzent); outline-offset: 2px;
}
textarea { min-height: 76px; resize: vertical; }
.feld { margin-bottom: 14px; }
.paar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dreier { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
input.betrag { font-size: 1.6rem; font-weight: 700; min-height: 64px; }
.haken { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; margin-bottom: 12px; }
.haken input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--akzent); }

/* Schnellwahl fuer den Takt und die Vertragsart: antippbare Kacheln statt Aufklappliste */
.wahl { display: grid; gap: 8px; }
.wahl.nebeneinander { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.wahl label {
    display: flex; flex-direction: column; justify-content: center; gap: 2px; margin: 0;
    padding: 11px 13px; min-height: 50px;
    border: 1px solid var(--rand); border-radius: 10px; background: var(--karte);
    font-weight: 600; cursor: pointer;
}
.wahl label .hint { margin: 0; }
.wahl input { position: absolute; opacity: 0; pointer-events: none; }
.wahl label:has(input:checked) {
    border-color: var(--akzent); background: var(--akzent-leise);
    box-shadow: inset 0 0 0 1px var(--akzent);
}
.wahl label:has(input:focus-visible) { outline: 3px solid var(--akzent); outline-offset: 2px; }

details.mehr { border-top: 1px solid var(--rand); margin-top: 6px; padding-top: 6px; }
details.mehr > summary {
    cursor: pointer; font-weight: 600; color: var(--akzent-dunkel);
    min-height: 44px; display: flex; align-items: center; list-style: none;
}
details.mehr > summary::-webkit-details-marker { display: none; }
details.mehr > summary::before { content: "+"; width: 1.2em; font-weight: 700; }
details.mehr[open] > summary::before { content: "\2212"; }
.abschnitt { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--leise);
             margin: 18px 0 10px; font-weight: 700; }

/* ── Zahlen zeigen ────────────────────────────────────────────────────── */
.zahlen { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.zahl { padding: 12px 14px; border-radius: 10px; background: var(--grund); border: 1px solid var(--rand); min-width: 0; }
.zahl .wert { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; }
.zahl .was { color: var(--leise); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.zahl.betont { background: var(--akzent-leise); border-color: #c9dccf; }
.zahl.betont .wert { color: var(--akzent-dunkel); }

/* ── Listen ───────────────────────────────────────────────────────────── */
.eintrag {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px; border-top: 1px solid var(--rand);
    text-decoration: none; color: inherit; min-height: 60px;
}
.karte.blank h2 + .eintrag, .karte.blank > .eintrag:first-child { border-top: 0; }
.eintrag:hover { background: var(--grund); }
.eintrag .haupt { min-width: 0; flex: 1; }
.eintrag .wo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eintrag .wann { color: var(--leise); font-size: .85rem; }
.eintrag .rechts { margin-left: auto; text-align: right; white-space: nowrap; }
.eintrag .rechts .gross { font-weight: 700; font-variant-numeric: tabular-nums; }
.eintrag .rechts .leise { color: var(--leise); font-size: .82rem; font-variant-numeric: tabular-nums; }
.eintrag.beendet .wo { color: var(--leise); text-decoration: line-through; }
.eintrag .ankreuz { width: 24px; height: 24px; flex: none; accent-color: var(--akzent); }

/* ── Marken ───────────────────────────────────────────────────────────── */
.marker {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: .72rem; font-weight: 600; letter-spacing: .02em; vertical-align: 1px;
    background: var(--grund); border: 1px solid var(--rand); color: var(--leise); white-space: nowrap;
}
.marker.gut { background: var(--akzent-leise); border-color: #c9dccf; color: var(--akzent-dunkel); }
.marker.warn { background: var(--warn-leise); border-color: var(--warn-rand); color: var(--warn); }
.marker.alarm { background: var(--alarm-leise); border-color: var(--alarm-rand); color: var(--alarm); }

/* Das Preisschild neben einer Frist: DIE Zahl, die handeln laesst. */
.frist { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--warn-rand); text-decoration: none; color: inherit; }
.frist:first-of-type { border-top: 0; padding-top: 0; }
.frist .datum { text-align: center; min-width: 58px; flex: none; }
.frist .datum .t { font-size: 1.35rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.frist .datum .m { font-size: .72rem; text-transform: uppercase; color: var(--warn); font-weight: 700; }
.frist .was { flex: 1; min-width: 0; }
.frist .was b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frist .schild { font-weight: 800; color: var(--warn); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── Meldungen ────────────────────────────────────────────────────────── */
.meldung { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.meldung.gut { background: var(--akzent-leise); border: 1px solid #c9dccf; color: var(--akzent-dunkel); }
.meldung.fehler { background: var(--alarm-leise); border: 1px solid var(--alarm-rand); color: var(--alarm); }
.meldung.warn { background: var(--warn-leise); border: 1px solid var(--warn-rand); color: var(--warn); }

/* ── Balken (Zahlen-Seite) ────────────────────────────────────────────── */
.balkenzeile { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; padding: 6px 0; }
.balkenzeile .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.balkenzeile .spur { height: 10px; border-radius: 999px; background: var(--grund); border: 1px solid var(--rand); overflow: hidden; }
.balkenzeile .spur span { display: block; height: 100%; background: var(--balken); border-radius: 999px; }
.balkenzeile .betrag { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; text-align: right; min-width: 78px; }

/* Kassenvorschau: senkrechte Saeulen, weil der Blick ueber zwoelf Monate von links nach rechts geht */
.saeulen { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 140px; margin: 8px 0 4px; }
.saeulen .s { background: var(--balken); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.saeulen .s.hoch { background: var(--warn); opacity: 1; }
.saeulen-achse { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: .68rem; color: var(--leise); text-align: center; }

table.daten { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.daten th, table.daten td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--rand); font-size: .9rem; }
table.daten th { color: var(--leise); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
table.daten .r { text-align: right; }
.rollt { overflow-x: auto; }

/* Urteilsraster auf der Abo-Seite */
.raster { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.raster span { aspect-ratio: 1; border-radius: 4px; background: var(--grund); border: 1px solid var(--rand); }
.raster span.gebraucht { background: var(--akzent); border-color: var(--akzent); }
.raster span.kaum { background: #9cc2a9; border-color: #9cc2a9; }
.raster span.nie { background: var(--warn-leise); border-color: var(--warn); }

/* Die drei Knoepfe fuer ein Urteil */
.urteil { padding: 12px 0; border-top: 1px solid var(--rand); }
.urteil:first-of-type { border-top: 0; padding-top: 0; }
.urteil .kopfzeile { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.urteil .kopfzeile b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drei { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.drei label {
    margin: 0; display: flex; align-items: center; justify-content: center; min-height: 46px;
    border: 1px solid var(--rand); border-radius: 10px; font-weight: 600; font-size: .9rem; cursor: pointer;
    background: var(--karte);
}
.drei input { position: absolute; opacity: 0; pointer-events: none; }
.drei label:has(input:checked) { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.drei label.nie:has(input:checked) { background: var(--warn); border-color: var(--warn); }
.drei label:has(input:focus-visible) { outline: 3px solid var(--akzent); outline-offset: 2px; }

/* Kuendigungs-Korb: schwebt ueber der Fusszeile, sobald etwas angekreuzt ist */
.korb {
    position: fixed; left: 0; right: 0; bottom: 64px; z-index: 25;
    padding: 0 16px calc(env(safe-area-inset-bottom, 0) + 6px); pointer-events: none;
}
.korb-innen {
    max-width: 680px; margin: 0 auto; pointer-events: auto;
    background: var(--text); color: var(--grund); border-radius: var(--r);
    padding: 12px 16px; display: flex; gap: 12px; align-items: center;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}
.korb-innen b { font-variant-numeric: tabular-nums; }
.korb-innen button { margin-left: auto; background: none; border: 1px solid currentColor; color: inherit;
                     border-radius: 8px; padding: 6px 10px; font: inherit; font-size: .85rem; cursor: pointer; }
.korb[hidden] { display: none; }

/* ── Fusszeile mit den Hauptwegen ─────────────────────────────────────── */
nav.fuss {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; background: var(--karte); border-top: 1px solid var(--rand);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
nav.fuss a {
    flex: 1; text-align: center; padding: 10px 2px 12px; position: relative;
    text-decoration: none; color: var(--leise); font-weight: 600;
    font-size: clamp(.64rem, 2.7vw, .78rem); white-space: nowrap;
}
nav.fuss a.hier { color: var(--akzent); box-shadow: inset 0 2px 0 var(--akzent); }
nav.fuss a .zeichen { display: block; font-size: 1.2rem; line-height: 1.3; }
nav.fuss a .zaehler {
    position: absolute; top: 5px; left: 50%; margin-left: 8px;
    background: var(--warn); color: #fff; border-radius: 999px; font-size: .66rem;
    min-width: 17px; height: 17px; line-height: 17px; padding: 0 4px;
}

.leer { text-align: center; color: var(--leise); padding: 24px 12px; }
.klein { font-size: .85rem; color: var(--leise); }
.rechts { text-align: right; }
.zahl-r { text-align: right; font-variant-numeric: tabular-nums; }
.store { display: flex; gap: 10px; align-items: flex-start; }
hr.trenn { border: 0; border-top: 1px solid var(--rand); margin: 16px 0; }
.nur-fuer-leser { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (min-width: 560px) {
    .zahlen.vier { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* Dunkler Modus. Ganz unten, damit er alles davor sicher ueberschreibt. Es werden nur die
   Merkmale umgestellt; jede Regel oben holt ihre Farbe aus ihnen. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --grund: #141915;
        --karte: #1c231e;
        --rand: #2d3830;
        --text: #e6ebe4;
        --leise: #9aa697;
        --akzent: #6fae86;
        --akzent-dunkel: #93c7a6;
        --akzent-leise: #1e2f25;
        --warn: #e7a26d;
        --warn-leise: #2c2219;
        --warn-rand: #4a3524;
        --alarm: #f0a0a0;
        --alarm-leise: #2a1c1c;
        --alarm-rand: #4a2b2b;
        --balken: #6fae86;
        --schatten: none;
    }
    :root:not([data-theme="light"]) .taste.haupt,
    :root:not([data-theme="light"]) .blick a.an,
    :root:not([data-theme="light"]) .drei label:has(input:checked) { color: #10150f; }
    :root:not([data-theme="light"]) .zahl.betont,
    :root:not([data-theme="light"]) .marker.gut,
    :root:not([data-theme="light"]) .meldung.gut { border-color: #2f4a39; }
    :root:not([data-theme="light"]) .raster span.kaum { background: #3f6b50; border-color: #3f6b50; }
}
