:root {
    --bg: #f6f7f9;
    --flaeche: #ffffff;
    --rand: #dfe3e8;
    --text: #1b1f24;
    --text-leise: #5c6670;
    --akzent: #1f6feb;
    --akzent-text: #ffffff;

    --gruen: #1a7f37;
    --gruen-bg: #dcfce7;
    --orange: #bc4c00;
    --orange-bg: #fff1e5;
    --rot: #cf222e;
    --rot-bg: #ffebe9;
    --stop: #57606a;
    --stop-bg: #eaeef2;

    --radius: 8px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --flaeche: #161b22;
        --rand: #30363d;
        --text: #e6edf3;
        --text-leise: #8d96a0;
        --akzent: #4493f8;

        --gruen: #3fb950;
        --gruen-bg: #12261a;
        --orange: #db6d28;
        --orange-bg: #2b1a10;
        --rot: #f85149;
        --rot-bg: #2b1416;
        --stop: #8d96a0;
        --stop-bg: #21262d;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Kopfzeile ---------- */
.kopf {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 1.5rem;
    height: 56px;
    background: var(--flaeche);
    border-bottom: 1px solid var(--rand);
    position: sticky;
    top: 0;
    z-index: 10;
}

.marke {
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    color: var(--text);
    white-space: nowrap;
}
.marke span { color: var(--akzent); font-weight: 500; }

.kopf nav { display: flex; gap: 0.25rem; overflow-x: auto; }

.kopf nav a {
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-leise);
    white-space: nowrap;
}
.kopf nav a:hover { background: var(--bg); color: var(--text); }
.kopf nav a.active { background: var(--akzent); color: var(--akzent-text); }

main { flex: 1; padding: 1.5rem; max-width: 1100px; width: 100%; margin: 0 auto; }

/* ---------- Typografie ---------- */
h1 { font-size: 1.5rem; margin: 0 0 0.35rem; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; }
.untertitel { color: var(--text-leise); margin: 0 0 1.75rem; }

/* ---------- Karten ---------- */
.karte {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.karte > h2 { padding-bottom: 0.65rem; border-bottom: 1px solid var(--rand); }
.karte .hinweis { color: var(--text-leise); font-size: 0.87rem; margin: -0.5rem 0 1rem; }

/* ---------- Formular ---------- */
.feld { margin-bottom: 1rem; }
.feld label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9rem; }
.feld .erklaerung { color: var(--text-leise); font-size: 0.83rem; margin-top: 0.3rem; }

input[type=text], input[type=password], input[type=number], select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--rand);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }
input[type=checkbox] { width: auto; margin-right: 0.5rem; }

.raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 1.25rem; }

.knopf {
    padding: 0.5rem 1.1rem;
    border: 1px solid var(--rand);
    border-radius: 6px;
    background: var(--flaeche);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
}
.knopf:hover:not(:disabled) { border-color: var(--akzent); color: var(--akzent); }
.knopf:disabled { opacity: 0.5; cursor: not-allowed; }
.knopf.primaer { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.knopf.primaer:hover:not(:disabled) { filter: brightness(1.1); color: var(--akzent-text); }

.knopfleiste { display: flex; gap: 0.65rem; align-items: center; flex-wrap: wrap; }

/* ---------- Meldungen ---------- */
.meldung { padding: 0.65rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.meldung.erfolg { background: var(--gruen-bg); color: var(--gruen); }
.meldung.fehler  { background: var(--rot-bg); color: var(--rot); }
.meldung.warnung { background: var(--orange-bg); color: var(--orange); }

/* ---------- Statuspunkt ---------- */
.status { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.87rem; color: var(--text-leise); }
.punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--stop); flex-shrink: 0; }
.punkt.gesetzt { background: var(--gruen); }
.punkt.fehlt { background: var(--orange); }

/* ---------- Ampel ---------- */
.ampel { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-weight: 600; font-size: 0.85rem; }
.ampel.gruen  { background: var(--gruen-bg);  color: var(--gruen); }
.ampel.orange { background: var(--orange-bg); color: var(--orange); }
.ampel.rot    { background: var(--rot-bg);    color: var(--rot); }
.ampel.stop   { background: var(--stop-bg);   color: var(--stop); }

/* ---------- Tabelle ---------- */
.tabelle-umbruch { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--rand); }
th { font-weight: 600; color: var(--text-leise); font-size: 0.85rem; }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
tr.summe td { font-weight: 700; border-top: 2px solid var(--rand); border-bottom: none; }

/* ---------- Blazor-Standards ---------- */
h1:focus { outline: none; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--gruen); }
.invalid { outline: 1px solid var(--rot); }
.validation-message { color: var(--rot); font-size: 0.85rem; }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 0.7rem 1.25rem;
    background: var(--rot-bg);
    color: var(--rot);
    box-shadow: 0 -1px 4px rgba(0,0,0,.2);
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ---------- Anmeldeseiten ---------- */
.anmelde-huelle {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.anmelde-karte {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 430px;
}
.anmelde-karte h1 { font-size: 1.3rem; }
.anmelde-karte .untertitel { margin-bottom: 1.5rem; font-size: 0.92rem; }
.anmelde-karte form button[type=submit] { width: 100%; margin-top: 0.5rem; }
.anmelde-karte details { margin-top: 0.5rem; font-size: 0.9rem; }

/* ======================================================================
   Trefferdarstellung

   Bewusst als Karten statt als Tabelle. Eine Tabelle mit acht Spalten ist
   auf einem Telefon unlesbar, und genau dort wird das Werkzeug im Laden
   gebraucht - beim Retail-Arbitrage steht man vor dem Regal, nicht am
   Schreibtisch. Die Karte trägt dieselben Zahlen, ordnet sie aber
   untereinander statt nebeneinander.
   ====================================================================== */

.treffer {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.treffer-karte {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-left: 4px solid var(--rand);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    display: grid;
    gap: 0.75rem;
}

/* Der farbige Streifen macht das Urteil erkennbar, ohne dass man liest. */
.treffer-karte.gruen  { border-left-color: var(--gruen); }
.treffer-karte.orange { border-left-color: var(--orange); }
.treffer-karte.rot    { border-left-color: var(--rot); }
.treffer-karte.stop   { border-left-color: var(--stop); }

.treffer-kopf {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.treffer-titel {
    flex: 1;
    min-width: 200px;
    font-weight: 600;
    line-height: 1.35;
}

.treffer-kennung {
    font-size: 0.8rem;
    color: var(--text-leise);
    font-weight: 400;
    margin-top: 0.15rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.treffer-kennung a { color: var(--akzent); text-decoration: none; }
.treffer-kennung a:hover { text-decoration: underline; }

/* ---------- Kennzahlen ----------
   Automatisch umbrechendes Raster: vier Spalten am Schreibtisch, zwei auf
   dem Telefon - ohne eigene Umbruchpunkte, allein über die Mindestbreite. */
.kennzahlen {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 0.5rem;
}

.kennzahl {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.5rem 0.65rem;
}

.kennzahl .wert {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.kennzahl .bezeichnung {
    font-size: 0.72rem;
    color: var(--text-leise);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.1rem;
}

.kennzahl.gut .wert  { color: var(--gruen); }
.kennzahl.mittel .wert { color: var(--orange); }
.kennzahl.schlecht .wert { color: var(--rot); }

.treffer-begruendung {
    font-size: 0.85rem;
    color: var(--text-leise);
    border-top: 1px solid var(--rand);
    padding-top: 0.6rem;
}

/* ---------- Keepa-Diagramm ---------- */
.diagramm {
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    overflow: hidden;
    background: #ffffff;   /* Keepa liefert das Bild mit hellem Grund */
}

.diagramm img {
    display: block;
    width: 100%;
    height: auto;
}

.diagramm-leiste {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.diagramm-leiste button {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    color: var(--text-leise);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
}
.diagramm-leiste button.aktiv {
    background: var(--akzent);
    border-color: var(--akzent);
    color: var(--akzent-text);
}

/* ---------- Aufklappbare Bereiche ---------- */
details.block {
    border-top: 1px solid var(--rand);
    padding-top: 0.6rem;
}
details.block > summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--akzent);
    list-style: none;
}
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::before { content: "▸ "; }
details.block[open] > summary::before { content: "▾ "; }
details.block > div { margin-top: 0.6rem; }

/* ---------- Shopauswahl ---------- */
.shopgruppe {
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.6rem;
}

.shopgruppe-kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.shopgruppe-kopf strong { font-size: 0.9rem; }

.shopliste {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.3rem 0.75rem;
}

.shopliste label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    font-size: 0.9rem;
    margin: 0;
    cursor: pointer;
}

/* ---------- Fortschritt ---------- */
.fortschritt {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: 0.87rem;
    color: var(--text-leise);
}

.fortschritt .punkt-laeuft {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--akzent);
    flex-shrink: 0;
    animation: pulsieren 1.2s ease-in-out infinite;
}

@keyframes pulsieren {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

/* Wer Bewegung im Betriebssystem abgeschaltet hat, soll sie hier nicht sehen. */
@media (prefers-reduced-motion: reduce) {
    .fortschritt .punkt-laeuft { animation: none; }
}

/* ---------- Zusammenfassung eines Suchlaufs ---------- */
.bilanz {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.bilanz .kennzahl { text-align: center; }

/* ======================================================================
   Kleine Bildschirme

   Getestet gegen 360 px Breite - das ist ein gewöhnliches Telefon im
   Hochformat. Kein Element darf dort waagerecht überstehen.
   ====================================================================== */
@media (max-width: 700px) {
    body { font-size: 16px; }          /* verhindert das Hineinzoomen bei Eingaben in iOS */

    main { padding: 1rem 0.85rem; }

    .kopf {
        height: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.6rem 0.85rem;
    }
    .kopf nav { gap: 0.15rem; padding-bottom: 0.15rem; }
    .kopf nav a { padding: 0.4rem 0.65rem; font-size: 0.9rem; }

    h1 { font-size: 1.25rem; }
    .untertitel { margin-bottom: 1.25rem; font-size: 0.92rem; }

    .karte { padding: 0.9rem; }

    /* Bedienelemente auf Fingergröße, nicht auf Mauszeigergröße. */
    .knopf, button, input, select {
        min-height: 44px;
    }

    .knopfleiste { display: flex; flex-direction: column; gap: 0.5rem; }
    .knopfleiste .knopf { width: 100%; }

    .kennzahl .wert { font-size: 1.05rem; }

    /* Tabellen bleiben scrollbar, statt die Seite zu sprengen. */
    .tabelle-umbruch { margin: 0 -0.85rem; padding: 0 0.85rem; }
}

@media (max-width: 400px) {
    .kennzahlen { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Druck ----------
   Damit sich eine Trefferliste als Einkaufszettel ausdrucken lässt. */
@media print {
    .kopf, .knopfleiste, .diagramm-leiste, .fortschritt { display: none; }
    .karte, .treffer-karte { break-inside: avoid; border-color: #999; }
    body { background: #fff; font-size: 11pt; }
}
