/*
 * Handgeschriebenes CSS ohne Werkzeugkette.
 *
 * Farben liegen als Variablen vor, damit ein spaeterer Dunkelmodus nur die
 * Variablen tauschen muss statt jeder Regel.
 */

:root {
    --bg:        #f7f7f6;
    --surface:   #ffffff;
    --border:    #e2e2df;
    --text:      #1c1c1a;
    --muted:     #6b6b66;
    --accent:    #0f766e;
    --ok:        #15803d;
    --warn:      #b45309;
    --fail:      #b91c1c;
    --radius:    10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:      #16161a;
        --surface: #1f1f24;
        --border:  #33333a;
        --text:    #ececea;
        --muted:   #9a9a95;
        --accent:  #2dd4bf;
    }
}

*, *::before, *::after { box-sizing: border-box; }

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

body.plain {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.card {
    width: 100%;
    max-width: 40rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

h1 { margin: 0 0 .25rem; font-size: 1.5rem; line-height: 1.25; }

.muted  { color: var(--muted); font-size: .9rem; }
.note   { margin-top: 1.5rem; }
.status-text { margin: 1rem 0; }
.status-code { font-size: 3rem; margin-bottom: 0; }

a { color: var(--accent); }

code {
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: .875em;
    background: var(--bg);
    padding: .1em .35em;
    border-radius: 4px;
}

/* --- Statusliste ------------------------------------------------------- */

.checks { width: 100%; border-collapse: collapse; margin-top: 1.5rem; }

.checks tr { border-top: 1px solid var(--border); }
.checks tr:first-child { border-top: 0; }

.checks th,
.checks td { padding: .6rem .5rem; text-align: left; font-weight: 400; vertical-align: top; }

.checks th { width: 45%; }

.check-state  { width: 1.5rem; }
.check-detail { color: var(--muted); font-size: .9rem; word-break: break-word; }

.dot {
    display: inline-block;
    width: .7rem; height: .7rem;
    border-radius: 50%;
    background: var(--muted);
}

.dot-ok   { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-fail { background: var(--fail); }

/* --- Meldungen --------------------------------------------------------- */

.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin: 0 0 1rem;
    font-size: .95rem;
}

.alert-status  { border-color: var(--ok);   }
.alert-warning { border-color: var(--warn); }
.alert-error   { border-color: var(--fail); }

.foot { margin-top: 1.5rem; color: var(--muted); font-size: .8rem; }

/* --- Formulare --------------------------------------------------------- */

.form { margin-top: 1.5rem; }

.field { display: block; margin-bottom: 1rem; }

.field > span {
    display: block;
    margin-bottom: .3rem;
    font-size: .9rem;
    font-weight: 500;
}

.field input {
    width: 100%;
    padding: .6rem .7rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Bestaetigungscodes werden Ziffer fuer Ziffer abgelesen - Festbreitenschrift
   und Sperrung verringern Vertipper spuerbar. */
.code-input {
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 1.3rem;
    letter-spacing: .4em;
    text-align: center;
}

.btn {
    display: inline-block;
    padding: .6rem 1.2rem;
    font: inherit;
    font-weight: 500;
    color: #fff;
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { filter: brightness(1.08); }

.btn-secondary {
    color: var(--text);
    background: transparent;
    border-color: var(--border);
}

/* --- Zwei-Faktor-Einrichtung -------------------------------------------- */

.steps { padding-left: 1.2rem; margin: 1.5rem 0; }
.steps li { margin-bottom: 1rem; }

.secret,
.codes li {
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem .8rem;
    /* Damit sich ein langer Schluessel auf schmalen Bildschirmen umbricht,
       statt die Seite waagerecht scrollen zu lassen. */
    word-break: break-all;
}

.secret { font-size: 1.05rem; letter-spacing: .08em; margin: .5rem 0; }

.codes { list-style: none; padding: 0; display: grid; gap: .4rem; margin: 1.2rem 0; }

.recovery { margin-top: 2rem; }
.recovery summary { cursor: pointer; font-size: .9rem; color: var(--muted); }

/* --- Uebersicht --------------------------------------------------------- */

.head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: .75rem;
    margin: 1.5rem 0;
}

.tile {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem;
}

.tile-value { display: block; font-size: 1.6rem; font-weight: 600; line-height: 1.2; }
.tile-label { display: block; font-size: .8rem; color: var(--muted); }

h2 { font-size: 1.05rem; margin: 1.75rem 0 .5rem; }

/* --- Layout der Verwaltungsoberflaeche ---------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: .75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 600; }

.topbar nav { display: flex; gap: .25rem; }

.topbar nav a {
    padding: .4rem .75rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: .95rem;
}

.topbar nav a:hover { background: var(--bg); }

.topbar nav a[aria-current="page"] {
    background: var(--bg);
    font-weight: 600;
    /* Nicht nur Fettdruck: Ein zweites Signal, damit die aktive Seite auch
       bei schwachem Kontrast erkennbar bleibt. */
    box-shadow: inset 0 -2px 0 var(--accent);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

.page { max-width: 68rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.btn-small { padding: .35rem .7rem; font-size: .85rem; }

.btn-danger { background: var(--fail); }

/* --- Panels und Spalten -------------------------------------------------- */

.cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.panel h2 { margin-top: 0; }

.panel.danger { border-color: var(--fail); }

.pairs { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; }
.pairs dt { color: var(--muted); font-size: .9rem; }
.pairs dd { margin: 0; }

.notice {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    margin: 1rem 0;
    font-size: .95rem;
}

/* --- Tabellen ------------------------------------------------------------ */

/* Der Rahmen scrollt, nicht die Seite: Eine waagerecht scrollende Seite ist
   auf dem Mobilgeraet praktisch unbedienbar. */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

.grid { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .95rem; }
.grid thead { background: var(--bg); }
.grid th, .grid td { padding: .7rem .8rem; text-align: left; vertical-align: top; }
.grid thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.grid tbody tr { border-top: 1px solid var(--border); }
.grid .right { text-align: right; }
.tabular { font-variant-numeric: tabular-nums; }
.block { display: block; }
.small { font-size: .85rem; }

/* --- Formulare, erweitert ------------------------------------------------ */

.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }
.field.narrow { max-width: 8rem; }
.field.inline { margin-bottom: 0; }

.field select,
.field textarea {
    width: 100%;
    padding: .6rem .7rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.field-error { display: block; margin-top: .3rem; color: var(--fail); font-size: .85rem; }
.hint { display: block; margin-top: .3rem; color: var(--muted); font-size: .82rem; }

.inputgroup { display: flex; align-items: stretch; }
.inputgroup input { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.inputgroup .suffix {
    display: flex;
    align-items: center;
    padding: 0 .7rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--muted);
    font-size: .9rem;
    white-space: nowrap;
}

.filterbar {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }

/* --- Protokoll ----------------------------------------------------------- */

.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: .5rem 0; border-top: 1px solid var(--border); font-size: .95rem; }
.log li:first-child { border-top: 0; }

.error-box {
    margin: .5rem 0 0;
    padding: .6rem .8rem;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: .82rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Nur fuer Screenreader – Statusfarben duerfen nicht die einzige
   Informationsquelle sein (Farbfehlsichtigkeit, Barrierefreiheit). */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
