/* net.D Dashboard - Basis-Styling
 *
 * Loest das Kernproblem der Altversion: dort hing das Aussehen an generierten
 * Streamlit-Klassen (.st-emotion-cache-asc41u), die jedes Update umbenennt.
 * Hier eigene Klassen und CSS-Variablen.
 */

:root {
    --gruen: #0cff00;
    --gruen-dunkel: #0a9e00;
    --anthrazit: #2b2b2b;

    --bg: #f6f7f8;
    --flaeche: #ffffff;
    --flaeche-alt: #f0f1f3;
    --rand: #dfe2e6;
    --text: #1c1f23;
    --text-leise: #5d656e;
    --schatten: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 4%);

    --positiv: #0a8a3c;
    --negativ: #c0392b;

    --radius: 10px;
    --spalte: 1280px;

    /* Diagrammfarben. Werden von js/charts.js gelesen und an Plotly
     * uebergeben. Getrennt je Erscheinungsbild, weil das Markengruen #0CFF00
     * auf weissem Grund fuer grosse Flaechen zu grell ist - hier deshalb eine
     * abgedunkelte Variante als Leitfarbe. */
    --chart-1: #0a9e00;
    --chart-2: #1069c9;
    --chart-3: #d97f00;
    --chart-4: #8244cf;
    --chart-5: #00969b;
    --chart-6: #cc3f63;
    --chart-7: #5f6b78;
    --chart-8: #5d8f00;
    --chart-text: #5d656e;
    /* ACHTUNG klassische rgba()-Schreibweise, nicht rgb(0 0 0 / 9%):
     * Plotlys Farbparser versteht die moderne, leerzeichengetrennte Syntax mit
     * Prozent-Alpha nicht. Er verwirft dann den Alphawert und zeichnet die
     * Gitterlinien deckend schwarz. Gilt fuer alle Variablen, die an Plotly
     * uebergeben werden - nicht fuer die uebrigen im Stylesheet. */
    --chart-gitter: rgba(0, 0, 0, 0.09);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #17191c;
        --flaeche: #212428;
        --flaeche-alt: #282c31;
        --rand: #343941;
        --text: #e8eaed;
        --text-leise: #9aa3ad;
        --schatten: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 14px rgb(0 0 0 / 25%);
        --positiv: #35d07f;
        --negativ: #ff6b5b;

        /* Auf dunklem Grund darf das Markengruen in voller Saettigung stehen. */
        --chart-1: #0cff00;
        --chart-2: #56a8ff;
        --chart-3: #ffb648;
        --chart-4: #c391ff;
        --chart-5: #3ad9d9;
        --chart-6: #ff829f;
        --chart-7: #9aa3ad;
        --chart-8: #a8e63a;
        --chart-text: #9aa3ad;
        /* klassische Schreibweise, siehe Hinweis oben */
        --chart-gitter: rgba(255, 255, 255, 0.11);
    }
}

* { box-sizing: border-box; }

/* Muss vor allen display-Regeln stehen und sie schlagen: eine eigene Klasse
 * mit display:flex uebersteuert sonst das [hidden] des Browsers, und das
 * Element bleibt trotz Attribut sichtbar. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Kopfzeile ---------- */
.kopf {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    height: 58px;
    background: var(--anthrazit);
    color: #fff;
    border-bottom: 3px solid var(--gruen);
    position: sticky;
    top: 0;
    z-index: 20;
}

.kopf .marke {
    font-weight: 650;
    letter-spacing: -0.01em;
    font-size: 1.05rem;
    white-space: nowrap;
}

.kopf .marke b { color: var(--gruen); }

.nav {
    display: flex;
    gap: 0.25rem;
    margin-left: 1rem;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    color: #cfd4da;
    white-space: nowrap;
    font-size: 0.9rem;
}
.nav a:hover { background: rgb(255 255 255 / 8%); color: #fff; }
.nav a[aria-current="page"] { background: var(--gruen); color: #08150a; font-weight: 600; }

.kopf .nutzer {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: #cfd4da;
    white-space: nowrap;
}

.abmelden {
    background: transparent;
    border: 1px solid #4a5058;
    color: #cfd4da;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}
.abmelden:hover { border-color: var(--gruen); color: var(--gruen); }

/* ---------- Layout ---------- */
.inhalt {
    max-width: var(--spalte);
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem;
}

h1 { font-size: 1.6rem; margin: 0 0 0.25rem; letter-spacing: -0.02em; }

.datenstand { color: var(--text-leise); font-size: 0.88rem; margin-bottom: 1.5rem; }

.abschnitt { margin: 2rem 0 1rem; display: flex; align-items: baseline; gap: 0.75rem; }
.abschnitt h2 { font-size: 1.1rem; margin: 0; font-weight: 620; }
.abschnitt .linie { flex: 1; height: 2px; border-radius: 2px; }
.abschnitt.bsa .linie { background: linear-gradient(90deg, #f39c12, transparent); }
.abschnitt.ftth .linie { background: linear-gradient(90deg, var(--gruen), transparent); }

/* ---------- Karten & KPIs ---------- */
.raster { display: grid; gap: 1rem; }
.raster.vier { grid-template-columns: repeat(4, 1fr); }
.raster.drei { grid-template-columns: repeat(3, 1fr); }
.raster.zwei { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 980px) {
    .raster.vier { grid-template-columns: repeat(2, 1fr); }
    .raster.drei, .raster.zwei { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .raster.vier { grid-template-columns: 1fr; }
}

.karte {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--schatten);
}

.kpi .titel {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-leise);
    margin-bottom: 0.4rem;
}
.kpi .wert {
    font-size: 2rem;
    font-weight: 660;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.kpi .delta { font-size: 0.9rem; font-weight: 600; margin-left: 0.4rem; }
.kpi .delta.plus { color: var(--positiv); }
.kpi .delta.minus { color: var(--negativ); }
.kpi .zusatz { margin-top: 0.5rem; font-size: 0.82rem; color: var(--text-leise); }
.kpi .zusatz div { margin-top: 0.15rem; }

/* ---------- Hinweisbanner ---------- */
.banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    background: color-mix(in srgb, var(--gruen) 14%, var(--flaeche));
    border: 1px solid color-mix(in srgb, var(--gruen) 45%, transparent);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.banner a { font-weight: 600; }

/* ---------- Filterleiste ---------- */
.filterleiste {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--schatten);
    transition: opacity 0.15s;
}
.filterleiste.laedt { opacity: 0.55; pointer-events: none; }

.filter-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-leise);
    font-weight: 600;
    margin-right: 0.25rem;
}
.filter-trenner, .filter-inline {
    font-size: 0.82rem;
    color: var(--text-leise);
    margin: 0 0.1rem;
    display: inline;
}
.filter-hinweis {
    font-size: 0.78rem;
    color: var(--text-leise);
    margin-left: auto;
    max-width: 22rem;
    line-height: 1.35;
}

.preset {
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--rand);
    border-radius: 999px;
    background: var(--flaeche-alt);
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}
.preset:hover { border-color: var(--gruen); }
.preset[aria-pressed="true"] {
    background: var(--gruen);
    border-color: var(--gruen);
    color: #08150a;
    font-weight: 620;
}

.filterleiste input[type="date"] {
    width: auto;
    margin: 0;
    padding: 0.3rem 0.5rem;
    font-size: 0.82rem;
}

/* ---------- Drilldown ---------- */
.drilldown-kopf {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.drilldown-kopf h3 { margin: 0; font-size: 0.95rem; font-weight: 620; }
.drilldown-kopf p { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--text-leise); }
.drilldown-zu {
    background: transparent;
    border: 1px solid var(--rand);
    border-radius: 6px;
    color: var(--text-leise);
    cursor: pointer;
    font: inherit;
    padding: 0.2rem 0.5rem;
    line-height: 1;
}
.drilldown-zu:hover { border-color: var(--negativ); color: var(--negativ); }

/* ---------- Diagrammkarten ---------- */
.chart-karte { padding: 1rem 1.1rem 0.6rem; }

.chart-kopf { margin-bottom: 0.4rem; }
.chart-kopf h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 620;
    letter-spacing: -0.01em;
}
.chart-kopf p {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    color: var(--text-leise);
}

.chart { width: 100%; }

/* Solange Plotly noch nicht gezeichnet hat, kein harter Sprung im Layout. */
.chart:empty::after {
    content: "";
    display: block;
    height: 100%;
    background: linear-gradient(
        90deg, transparent, var(--flaeche-alt) 40%, transparent 80%
    );
    opacity: 0.6;
    border-radius: 6px;
}

/* Aufklappbarer Detailbereich (ersetzt st.expander) */
details.aufklapp {
    margin-top: 0.75rem;
    border-top: 1px solid var(--rand);
    padding-top: 0.6rem;
}
details.aufklapp summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-leise);
    font-weight: 560;
    list-style: none;
}
details.aufklapp summary::-webkit-details-marker { display: none; }
details.aufklapp summary::before { content: "▸ "; }
details.aufklapp[open] summary::before { content: "▾ "; }
details.aufklapp summary:hover { color: var(--text); }

/* ---------- Login ---------- */
.login-seite {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1100px 500px at 50% -12%, rgb(12 255 0 / 9%), transparent 70%),
        var(--bg);
}

.login-karte {
    width: 100%;
    max-width: 380px;
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: 14px;
    padding: 2rem;
    box-shadow: var(--schatten);
}

.login-karte .marke {
    font-size: 1.35rem;
    font-weight: 680;
    letter-spacing: -0.02em;
    margin-bottom: 0.2rem;
}
.login-karte .marke b { color: var(--gruen-dunkel); }
@media (prefers-color-scheme: dark) {
    .login-karte .marke b { color: var(--gruen); }
}
.login-karte .unter { color: var(--text-leise); font-size: 0.88rem; margin-bottom: 1.5rem; }

/* Nur im Login untereinander. Global gesetzt wuerde diese Regel die
 * Filterleiste zerreissen - sie steht weiter unten in der Datei und gewinnt
 * bei gleicher Spezifitaet gegen .filter-inline. */
.login-karte label {
    display: block;
    font-size: 0.85rem;
    font-weight: 560;
    margin-bottom: 0.3rem;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--rand);
    border-radius: 8px;
    background: var(--flaeche-alt);
    color: var(--text);
    font: inherit;
}
input:focus {
    outline: 2px solid var(--gruen);
    outline-offset: 1px;
    border-color: transparent;
}

.knopf {
    width: 100%;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 8px;
    background: var(--gruen);
    color: #08150a;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}
.knopf:hover { background: #0ae600; }

.fehler {
    background: color-mix(in srgb, var(--negativ) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--negativ) 40%, transparent);
    color: var(--negativ);
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

/* ---------- Tabellen ---------- */
.tabelle {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.tabelle th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-leise);
    font-weight: 600;
    padding: 0.5rem 0.5rem 0.5rem 0;
    border-bottom: 1px solid var(--rand);
    position: sticky;
    top: 0;
    background: var(--flaeche);
}
.tabelle td {
    padding: 0.45rem 0.5rem 0.45rem 0;
    border-bottom: 1px solid var(--rand);
    font-variant-numeric: tabular-nums;
}
.tabelle tbody tr:hover { background: var(--flaeche-alt); }

/* Breite Tabellen scrollen in sich, die Seite bleibt ruhig. */
.tabelle-rahmen { overflow-x: auto; }

/* ---------- Google Analytics: FAQ-Kurzliste ---------- */
.faq-liste {
    margin: 0.6rem 0 0;
    padding-left: 1.3rem;
    font-size: 0.88rem;
    line-height: 1.6;
}

/* ---------- Nutzerverwaltung ---------- */
.formular .feldreihe {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
}
.formular label {
    display: block;
    font-size: 0.8rem;
    font-weight: 560;
    color: var(--text-leise);
}
.formular input, .formular select {
    width: 100%;
    margin: 0.25rem 0 0;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--rand);
    border-radius: 8px;
    background: var(--flaeche-alt);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}

.knopf.schmal { width: auto; padding: 0.5rem 1.2rem; }

.hinweis {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
    color: var(--text-leise);
    line-height: 1.45;
}
.hinweis code {
    background: var(--flaeche-alt);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

/* Einmalige Passwortanzeige - soll auffallen und ablesbar sein */
.passwort-karte { border-left: 4px solid var(--gruen); }
.passwort-karte h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.passwort {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    user-select: all;
    word-break: break-all;
}

form.inline { display: inline; margin: 0; }
form.inline select {
    width: auto;
    margin: 0;
    padding: 0.2rem 0.4rem;
    font-size: 0.82rem;
    border: 1px solid var(--rand);
    border-radius: 6px;
    background: var(--flaeche-alt);
    color: var(--text);
    font-family: inherit;
}

.tabelle td.aktionen { white-space: nowrap; }
button.klein {
    padding: 0.25rem 0.55rem;
    font: inherit;
    font-size: 0.78rem;
    border: 1px solid var(--rand);
    border-radius: 6px;
    background: var(--flaeche-alt);
    color: var(--text);
    cursor: pointer;
    margin-right: 0.25rem;
}
button.klein:hover { border-color: var(--gruen); }
button.klein.warnung:hover { border-color: var(--negativ); color: var(--negativ); }

.tabelle tr.inaktiv td { opacity: 0.5; }
.tabelle .ja { color: var(--positiv); font-weight: 560; }
.tabelle .nein { color: var(--negativ); font-weight: 560; }
.tabelle .fest {
    font-size: 0.72rem;
    color: var(--text-leise);
    border: 1px solid var(--rand);
    border-radius: 4px;
    padding: 0.05rem 0.3rem;
    margin-left: 0.2rem;
}

/* ---------- Hilfeseite ---------- */
.einleitung {
    margin: 0 0 1rem;
    color: var(--text-leise);
    font-size: 0.92rem;
    max-width: 60rem;
}

.inhaltsverzeichnis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 1rem 1.5rem;
    margin-bottom: 2rem;
}
.ivz-titel {
    display: block;
    font-weight: 620;
    font-size: 0.9rem;
    text-decoration: none;
    margin-bottom: 0.35rem;
}
.ivz-titel:hover { color: var(--gruen-dunkel); }
.inhaltsverzeichnis ul {
    margin: 0;
    padding-left: 1rem;
    list-style: none;
}
.inhaltsverzeichnis li { margin: 0.15rem 0; }
.inhaltsverzeichnis li a {
    font-size: 0.84rem;
    color: var(--text-leise);
    text-decoration: none;
}
.inhaltsverzeichnis li a:hover { color: var(--text); text-decoration: underline; }

.hilfe-eintrag {
    margin-bottom: 0.75rem;
    /* Sprungmarke nicht unter die klebende Kopfzeile schieben */
    scroll-margin-top: 5rem;
}
.hilfe-eintrag h3 { margin: 0 0 0.35rem; font-size: 1rem; font-weight: 620; }
.hilfe-eintrag .was { margin: 0 0 0.6rem; max-width: 60rem; }

.etikett {
    display: inline-block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 650;
    color: var(--text-leise);
    margin-right: 0.4rem;
}

.hilfe-eintrag .quelle {
    margin: 0 0 0.6rem;
    font-size: 0.86rem;
    color: var(--text-leise);
}

.hilfe-eintrag .regeln {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.9rem;
}
.hilfe-eintrag .regeln li { margin: 0.2rem 0; max-width: 58rem; }

.hilfe-hinweis {
    margin: 0.8rem 0 0;
    padding: 0.6rem 0.8rem;
    background: var(--flaeche-alt);
    border-left: 3px solid var(--chart-3);
    border-radius: 0 6px 6px 0;
    font-size: 0.87rem;
    line-height: 1.5;
    max-width: 58rem;
}

/* Sprungmarken der Abschnittsüberschriften ebenfalls freihalten */
.abschnitt[id] { scroll-margin-top: 4.5rem; }

/* ---------- Fusszeile ---------- */
.fuss {
    max-width: var(--spalte);
    margin: 0 auto;
    padding: 1.5rem;
    border-top: 1px solid var(--rand);
    color: var(--text-leise);
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
