/*
 * SparMan – Oberfläche.
 *
 * Zwei Vorgaben bestimmen den Entwurf:
 *  - Zuerst das Handy. Belege werden an der Kasse fotografiert, nicht am
 *    Schreibtisch. Alles muss mit einer Hand bedienbar sein.
 *  - Großzügige Schrift und ruhige Farben. Die App wird täglich benutzt und
 *    soll auch bei schlechtem Licht im Laden gut lesbar sein.
 */

:root {
    --gruen: #1f6f4a;
    --gruen-hell: #e8f3ed;
    --rot: #a6301f;
    --rot-hell: #fbeae7;
    --gelb: #8a6100;
    --gelb-hell: #fdf4e0;
    --blau-hell: #eaf1f8;
    --text: #1d211f;
    --grau: #6a716d;
    --linie: #dfe3e0;
    --flaeche: #ffffff;
    --hintergrund: #f6f7f6;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--hintergrund);
    color: var(--text);
    font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

/* --- Kopfzeile --- */
.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--gruen);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
    padding-top: max(10px, env(safe-area-inset-top));
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; }
.brand span { font-weight: 300; }
.brand small { font-weight: 400; opacity: .65; font-size: 12px; margin-left: 4px; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a {
    color: #fff; text-decoration: none; padding: 6px 10px;
    border-radius: 8px; font-size: 15px; opacity: .85;
}
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.18); opacity: 1; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 18px 16px 96px; }

h1 { font-size: 26px; margin: 6px 0 18px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
h3 { font-size: 17px; margin: 22px 0 8px; }

/* --- Hinweise --- */
.hinweis {
    padding: 12px 14px; border-radius: var(--radius); margin: 0 0 16px;
    border-left: 4px solid var(--grau); background: var(--flaeche);
}
.hinweis.ok { border-color: var(--gruen); background: var(--gruen-hell); }
.hinweis.fehler { border-color: var(--rot); background: var(--rot-hell); }
.hinweis.warnung { border-color: var(--gelb); background: var(--gelb-hell); }
.hinweis.info { border-color: #2b6cb0; background: var(--blau-hell); }
.hinweis a { color: inherit; font-weight: 600; }

/* --- Kacheln --- */
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kacheln.klein { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.kachel {
    background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
    padding: 16px; display: flex; flex-direction: column; gap: 4px;
    text-decoration: none; color: inherit;
}
.kachel .wert { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kachel .titel { font-size: 13px; color: var(--grau); }
.kachel.gut { background: var(--gruen-hell); border-color: #bcdcc9; }
.kachel.gut .wert { color: var(--gruen); }
.kachel.achtung { background: var(--gelb-hell); border-color: #e8d09a; }
.kachel.fehler { background: var(--rot-hell); border-color: #e6bdb5; }
.kachel.laeuft { background: var(--blau-hell); border-color: #c3d6ea; }
a.kachel:hover { border-color: var(--gruen); }

/* --- Listen --- */
.liste { list-style: none; margin: 0; padding: 0; }
.zeile {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
    padding: 12px 14px; margin-bottom: 8px;
}
.zeile.warn { border-color: #e8d09a; background: var(--gelb-hell); }
.zeile > a { text-decoration: none; color: inherit; flex: 1; min-width: 0; }
.haupttext { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nebentext { display: block; font-size: 13px; color: var(--grau); }
.rechts { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.betrag { font-weight: 700; white-space: nowrap; }

/* --- Marken --- */
.marke {
    display: inline-block; padding: 2px 8px; border-radius: 99px;
    font-size: 12px; background: #eceeed; color: var(--grau); white-space: nowrap;
}
.marke.gut, .marke.confirmed { background: var(--gruen-hell); color: var(--gruen); }
.marke.fehler, .marke.failed { background: var(--rot-hell); color: var(--rot); }
.marke.extracted { background: var(--gelb-hell); color: var(--gelb); }
.marke.queued, .marke.new { background: var(--blau-hell); color: #2b6cb0; }
.marke.lokal { background: #efe7fa; color: #5b3a9b; }
.marke.risiko-hoch { background: var(--rot-hell); color: var(--rot); }
.marke.risiko-mittel { background: var(--gelb-hell); color: var(--gelb); }
.marke.risiko-gering { background: var(--gruen-hell); color: var(--gruen); }

/* --- Filterleiste --- */
.filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filter a {
    padding: 7px 14px; border-radius: 99px; text-decoration: none;
    background: var(--flaeche); border: 1px solid var(--linie); color: var(--grau); font-size: 15px;
}
.filter a.on { background: var(--gruen); border-color: var(--gruen); color: #fff; }

/* --- Formulare --- */
label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--grau); }
label > input, label > select, label > textarea, .mit-auge {
    display: block; width: 100%; margin-top: 5px;
}
input, select, textarea, .knopf, button {
    font: inherit;
}
input[type=text], input[type=password], input[type=email], input[type=url],
input:not([type]), select, textarea {
    width: 100%; padding: 11px 12px; border: 1px solid var(--linie);
    border-radius: 10px; background: var(--flaeche); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gruen); outline-offset: 1px; }

.mit-auge { position: relative; }
.mit-auge input { padding-right: 46px; }
.auge {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: none; border: none; font-size: 19px; cursor: pointer;
    padding: 6px 8px; opacity: .5; line-height: 1;
}
.auge:hover, .auge.an { opacity: 1; }

button, .knopf {
    display: inline-block; padding: 11px 18px; border-radius: 10px;
    border: 1px solid var(--linie); background: var(--flaeche); color: var(--text);
    cursor: pointer; text-decoration: none; text-align: center;
}
button:hover, .knopf:hover { border-color: var(--gruen); }
button.haupt, .knopf.haupt {
    background: var(--gruen); border-color: var(--gruen); color: #fff; font-weight: 600;
}
button.haupt:hover { background: #195c3d; }
button.klein { padding: 6px 12px; font-size: 14px; }
button.gefahr { color: var(--rot); border-color: #e6bdb5; }
.knopf.gross { padding: 22px; font-size: 19px; width: 100%; cursor: pointer; }
form.inline { display: inline; }
.aktionen { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.schalter { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.haken { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); }
.haken input { width: auto; margin: 0; }
.paar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* --- Tabellen --- */
.tabelle, .daten { width: 100%; border-collapse: collapse; background: var(--flaeche);
    border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.tabelle th, .tabelle td, .daten th, .daten td {
    padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--linie); font-size: 15px;
}
.tabelle th { background: #f0f2f1; font-size: 13px; color: var(--grau); }
.tabelle tr:last-child td, .daten tr:last-child td { border-bottom: none; }
.daten th { width: 40%; color: var(--grau); font-weight: 500; }
.r { text-align: right; }
.grund { color: var(--grau); font-size: 13px; }
.pfand td { color: var(--grau); font-style: italic; }
.code { display: block; font-size: 11px; color: var(--grau); font-family: monospace; }
.klein-text { font-size: 13px; }

/* Breite Tabellen dürfen auf dem Handy scrollen, statt die Seite zu sprengen. */
.positionen { display: block; overflow-x: auto; white-space: nowrap; }

/* --- Belegansicht --- */
.beleg-ansicht { display: grid; grid-template-columns: 1fr; gap: 20px; }
.beleg-bild img { width: 100%; border-radius: var(--radius); border: 1px solid var(--linie); background: var(--flaeche); }
@media (min-width: 860px) {
    .beleg-ansicht { grid-template-columns: 3fr 2fr; align-items: start; }
    .beleg-bild { position: sticky; top: 80px; }
}

/* --- Karten und Blöcke --- */
.karten { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 18px; }
.karte h2 { margin-top: 0; }
.karte.aufnahme { border-color: var(--gruen); }
.block {
    background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 10px;
}
.block.aus { opacity: .55; }
.block summary { cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.block[open] summary { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--linie); }
.block.neu summary { color: var(--gruen); }

.rolle { background: #fafbfa; border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px; }
.rolle-titel { display: block; font-weight: 600; color: var(--text); font-size: 16px; }
.rolle-text { display: block; font-size: 13px; margin-bottom: 8px; }

/* --- Anmeldung --- */
.anmeldung { max-width: 380px; margin: 8vh auto; background: var(--flaeche);
    border: 1px solid var(--linie); border-radius: 16px; padding: 28px; }
.anmeldung h1 { text-align: center; font-size: 30px; margin: 0 0 4px; color: var(--gruen); }
.anmeldung h1 span { font-weight: 300; }
.anmeldung .unter { text-align: center; color: var(--grau); font-size: 14px; margin: 0 0 24px; }
.anmeldung button.haupt { width: 100%; }
.wechsel { text-align: center; margin-top: 16px; font-size: 14px; }
.wechsel a, .zurueck a { color: var(--gruen); }

/* --- Sonstiges --- */
.leer { text-align: center; padding: 44px 20px; background: var(--flaeche);
    border: 1px dashed var(--linie); border-radius: var(--radius); }
.leer p { color: var(--grau); max-width: 460px; margin: 0 auto 14px; }
.fussnote { font-size: 13px; color: var(--grau); }
.zurueck { margin: 0 0 8px; font-size: 14px; }

/* Der Knopf, auf den es ankommt: einen Beleg hinzufügen. Immer erreichbar,
   in Daumenreichweite, auch mit einer Hand. */
.fab {
    position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--gruen); color: #fff; font-size: 34px; line-height: 58px;
    text-align: center; text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.22);
    z-index: 30;
}
.fab:hover { background: #195c3d; }
