/* SafeGuard – Oberfläche. Farben nur über Variablen (heller und dunkler Modus). */
:root {
  --hg: #f4f6fa;
  --flaeche: #ffffff;
  --flaeche-2: #eef1f6;
  --rand: #d9dee7;
  --text: #1b2433;
  --text-2: #5b6578;
  --akzent: #2257c4;
  --akzent-hell: #e3ecfb;
  --auf-akzent: #ffffff;
  --gefahr: #c0362c;
  --gefahr-hell: #fbe6e4;
  --ok: #1d7a46;
  --warn: #9a6200;
  --warn-hell: #fff4dc;
  --schatten: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .08);
  --radius: 10px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --hg: #0f141c;
    --flaeche: #171e29;
    --flaeche-2: #1f2834;
    --rand: #2c3746;
    --text: #e6ebf2;
    --text-2: #9aa6b8;
    --akzent: #5b8ff0;
    --akzent-hell: #1c2c4a;
    --auf-akzent: #0b1220;
    --gefahr: #f0675c;
    --gefahr-hell: #3a1d1b;
    --ok: #4cc785;
    --warn: #f0b44c;
    --warn-hell: #3a2d12;
    --schatten: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--hg); color: var(--text); font: 15px/1.45 var(--schrift); -webkit-font-smoothing: antialiased; }
#app { min-height: 100%; display: flex; flex-direction: column; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
a { color: var(--akzent); }
code, .mono { font-family: var(--mono); }
hr { border: 0; border-top: 1px solid var(--rand); margin: .25rem 0; }
[hidden] { display: none !important; }

/* ---------- Eingaben ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--flaeche); border: 1px solid var(--rand); border-radius: 8px;
  padding: .55rem .7rem; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: -1px; border-color: transparent; }
input[readonly] { background: var(--flaeche-2); color: var(--text-2); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--akzent); }
input[type=range] { padding: 0; accent-color: var(--akzent); }
.feld { display: block; margin: 0 0 .9rem; }
.beschriftung { display: block; font-size: .85rem; font-weight: 600; color: var(--text-2); margin-bottom: .3rem; }
.hinweis, .klein { font-size: .85rem; color: var(--text-2); }
small.hinweis { display: block; margin-top: .3rem; }
.haken { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.haken-reihe { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.drei { display: grid; grid-template-columns: 1.3fr 1.3fr 1fr; gap: 0 .8rem; }
.mit-knoepfen { display: flex; gap: .4rem; align-items: center; }
.mit-knoepfen > .feld { flex: 1; margin: 0; }
.mit-knoepfen > input, .mit-knoepfen > select { flex: 1; }

/* ---------- Knöpfe ---------- */
button, .knopf {
  font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--rand); background: var(--flaeche); color: var(--text);
  padding: .5rem .9rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  white-space: nowrap;
}
button:hover, .knopf:hover { background: var(--flaeche-2); }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, .knopf:focus-visible, a:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
button.haupt, .knopf.haupt { background: var(--akzent); border-color: var(--akzent); color: var(--auf-akzent); }
button.haupt:hover, .knopf.haupt:hover { filter: brightness(1.08); background: var(--akzent); }
button.gefahr { color: var(--gefahr); border-color: var(--gefahr); background: transparent; }
button.gefahr:hover { background: var(--gefahr-hell); }
button.breit, .knopf.breit { width: 100%; padding: .7rem; }
button.klein { padding: .3rem .6rem; font-size: .85rem; }
.icon { background: transparent; border-color: transparent; padding: .35rem .5rem; font-size: 1.05rem; line-height: 1; color: var(--text-2); }
.icon:hover { background: var(--flaeche-2); color: var(--text); }
.icon.klein { font-size: .95rem; padding: .25rem .4rem; }
a.icon { text-decoration: none; border-radius: 8px; display: inline-flex; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

/* ---------- Meldungen ---------- */
.fehler { color: var(--gefahr); }
.fehler:empty { display: none; }
div.fehler { margin: .5rem 0; font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.warnung { color: var(--warn); }
.hinweis-box { background: var(--akzent-hell); border-radius: 8px; padding: .7rem .9rem; margin: .5rem 0 1rem; }
p.warnung { background: var(--warn-hell); padding: .6rem .8rem; border-radius: 8px; }
#meldungen { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 100; width: min(92vw, 520px); }
.meldung { background: var(--text); color: var(--hg); padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--schatten); transition: opacity .4s, transform .4s; }
.meldung.fehler { background: var(--gefahr); color: #fff; }
.meldung.weg { opacity: 0; transform: translateY(8px); }

/* ---------- Anmeldung ---------- */
.anmeldung { flex: 1; display: grid; place-items: center; padding: 2rem 1rem; }
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 16px; box-shadow: var(--schatten); padding: 2rem; width: min(100%, 440px); }
.karte .marke { margin-bottom: 1.25rem; }
.karte form { margin-top: 1rem; }
.unten { text-align: center; margin: 1rem 0 0; font-size: .9rem; }
.marke { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; }
.marke img { display: block; }
.staerke { height: 6px; background: var(--flaeche-2); border-radius: 3px; overflow: hidden; margin: -.5rem 0 .3rem; }
.staerke + small.hinweis { margin: 0 0 .9rem; }
.staerke.klein { margin: .35rem 0 0; height: 4px; }
.staerke span { display: block; height: 100%; width: 0; background: var(--gefahr); transition: width .2s; }
.staerke[data-stufe="1"] span { background: #e07b2b; }
.staerke[data-stufe="2"] span { background: #d6b318; }
.staerke[data-stufe="3"] span, .staerke[data-stufe="4"] span { background: var(--ok); }
.wh-schluessel { font: 600 1.15rem/1.6 var(--mono); letter-spacing: .03em; background: var(--flaeche-2); border: 1px dashed var(--rand); border-radius: 8px; padding: .9rem; word-break: break-all; text-align: center; margin: .75rem 0; user-select: all; }
.wahl { display: grid; gap: .6rem; }
.wahl-knopf { flex-direction: column; align-items: flex-start; white-space: normal; text-align: left; padding: .9rem 1rem; gap: .2rem; }
.wahl-knopf span { font-weight: 400; color: var(--text-2); font-size: .9rem; }

/* ---------- Kopf ---------- */
.kopf { display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; background: var(--flaeche); border-bottom: 1px solid var(--rand); position: sticky; top: 0; z-index: 10; }
.marke-link { color: inherit; text-decoration: none; }
.marke-link .marke { font-size: 1.05rem; }
.marke-link img { width: 30px; height: 30px; }
.firmenwahl { width: auto; max-width: 260px; }
.firmenname { color: var(--text-2); font-weight: 600; }
.suche { flex: 1; max-width: 520px; margin-left: auto; }
.platz { flex: 1; }
.menue-knopf { position: relative; }
.aufklapp { position: absolute; z-index: 50; background: var(--flaeche); border: 1px solid var(--rand); border-radius: 10px; box-shadow: var(--schatten); padding: .3rem; min-width: 220px; display: flex; flex-direction: column; }
.aufklapp button { border: 0; justify-content: flex-start; font-weight: 500; padding: .55rem .7rem; background: transparent; }
.aufklapp button:hover, .aufklapp button:focus { background: var(--flaeche-2); outline: none; }

/* ---------- Tresor ---------- */
#inhalt { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tresor { flex: 1; display: grid; grid-template-columns: 230px minmax(260px, 380px) 1fr; min-height: 0; height: calc(100vh - 53px); }
.seitenleiste { border-right: 1px solid var(--rand); padding: .75rem .5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav { justify-content: flex-start; border: 0; background: transparent; font-weight: 500; padding: .45rem .6rem; width: 100%; color: var(--text); }
.nav-text { overflow: hidden; text-overflow: ellipsis; flex: 1; text-align: left; }
.nav.aktiv { background: var(--akzent-hell); color: var(--akzent); font-weight: 600; }
.nav .anzahl, .liste-kopf .anzahl { font-size: .8rem; color: var(--text-2); font-weight: 500; }
.nav-titel { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 700; padding: .9rem .6rem .3rem; display: flex; align-items: center; justify-content: space-between; }
.liste { border-right: 1px solid var(--rand); overflow-y: auto; background: var(--flaeche); }
.liste-kopf { display: flex; align-items: center; gap: .5rem; padding: .9rem 1rem .6rem; position: sticky; top: 0; background: var(--flaeche); flex-wrap: wrap; border-bottom: 1px solid var(--rand); }
.liste-kopf h2 { flex: 0 1 auto; }
.liste-kopf .icon { margin-left: auto; }
.eintraege { list-style: none; margin: 0; padding: .3rem; }
.eintrag { width: 100%; justify-content: flex-start; border: 0; background: transparent; padding: .55rem .6rem; gap: .7rem; font-weight: 500; text-align: left; }
.eintrag.aktiv { background: var(--akzent-hell); }
.eintrag-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.eintrag .titel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eintrag .unter { font-size: .82rem; color: var(--text-2); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stern { color: #d6a10f; }
.marke-klein { font-size: .8rem; color: var(--text-2); }
.avatar { --farbton: 220; flex: none; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 1rem;
  background: hsl(var(--farbton) 60% 92%); color: hsl(var(--farbton) 55% 32%); }
@media (prefers-color-scheme: dark) { .avatar { background: hsl(var(--farbton) 35% 22%); color: hsl(var(--farbton) 70% 78%); } }
.ansicht-kopf .avatar { width: 48px; height: 48px; font-size: 1.3rem; border-radius: 12px; }
.leer { padding: 2rem 1rem; text-align: center; color: var(--text-2); }
.leer.gross { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.schloss { font-size: 3rem; opacity: .5; }
.detail { overflow-y: auto; padding: 1.25rem 1.5rem; }
.ansicht, .bearbeiten { max-width: 760px; }
.ansicht-kopf { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.ansicht-kopf > div:nth-child(3) { flex: 1; min-width: 0; }
.ansicht-kopf small { color: var(--text-2); }
.kopf-aktionen { display: flex; gap: .3rem; align-items: center; flex: none; }
.zeilen { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); }
.zeile { display: grid; grid-template-columns: 150px 1fr auto; gap: .8rem; align-items: center; padding: .65rem .9rem; border-top: 1px solid var(--rand); }
.zeile:first-child { border-top: 0; }
.beschr { font-size: .85rem; color: var(--text-2); font-weight: 600; }
.wert { overflow-wrap: anywhere; min-width: 0; }
.wert.mehrzeilig { white-space: pre-wrap; }
.wert.verdeckt { letter-spacing: .1em; color: var(--text-2); }
.aktionen { display: flex; gap: .1rem; }
.fuss { font-size: .82rem; color: var(--text-2); margin-top: .8rem; }
.totp { display: inline-flex; align-items: center; gap: .6rem; }
.totp-code { font: 700 1.3rem var(--mono); letter-spacing: .06em; color: var(--akzent); }
.totp.bald .totp-code { color: var(--gefahr); }
.totp-ring { --anteil: 1; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--text-2);
  background: conic-gradient(var(--akzent) calc(var(--anteil) * 360deg), var(--flaeche-2) 0); position: relative; }
.totp-ring::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--flaeche); }
.totp-ring { isolation: isolate; }
.totp-ring::before { z-index: -1; }
.verlauf-eintrag { border: 1px solid var(--rand); border-radius: 8px; margin-bottom: .6rem; overflow: hidden; }
.verlauf-kopf { padding: .5rem .9rem; background: var(--flaeche-2); font-size: .9rem; }
.pw-feld { width: 100%; }
.eigene-felder { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.feld-zeile { display: grid; grid-template-columns: 1fr 1.5fr auto auto; gap: .4rem; align-items: center; }
.generator-ausgabe { font-size: 1.15rem; background: var(--flaeche-2); border-radius: 8px; padding: .8rem; word-break: break-all; margin-bottom: .3rem; user-select: all; }
.nur-schmal { display: none; }

/* ---------- Seiten (Konto, Benutzer …) ---------- */
.seite { padding: 1.5rem; max-width: 980px; width: 100%; margin: 0 auto; overflow-y: auto; }
.abschnitt { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.abschnitt h2 { margin-bottom: .8rem; }
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th { text-align: left; font-size: .8rem; color: var(--text-2); font-weight: 700; padding: .4rem .5rem; border-bottom: 1px solid var(--rand); }
.tabelle td { padding: .55rem .5rem; border-bottom: 1px solid var(--rand); vertical-align: middle; }
.tabelle select { width: auto; }
.protokoll td { font-size: .88rem; }
.bericht { margin: .5rem 0 1rem; }
.qr { display: block; width: 200px; height: 200px; margin: .5rem auto; background: #fff; padding: 8px; border-radius: 8px; }
progress { width: 100%; height: 10px; margin-top: .8rem; accent-color: var(--akzent); }
.gefahrenzone { border-top: 1px solid var(--rand); margin-top: 1.25rem; padding-top: 1rem; }
.teilen .mit-knoepfen select:first-child { flex: 2; }

/* ---------- Dialog ---------- */
.dialog-huelle { position: fixed; inset: 0; background: rgba(10, 16, 28, .45); display: grid; place-items: center; z-index: 60; padding: 1rem; }
.dialog { background: var(--flaeche); border-radius: 14px; box-shadow: var(--schatten); width: min(100%, 520px); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.dialog.breit { width: min(100%, 760px); }
.dialog-kopf { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem .5rem; }
.dialog-inhalt { padding: .25rem 1.25rem 1rem; overflow-y: auto; }
.dialog-fehler { color: var(--gefahr); font-weight: 600; padding: 0 1.25rem; }
.dialog-fehler:empty { display: none; }
.dialog-fuss { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.25rem 1.1rem; border-top: 1px solid var(--rand); }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 1100px) {
  .tresor { grid-template-columns: 200px 300px 1fr; }
}
@media (max-width: 820px) {
  .tresor { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - 53px); }
  .seitenleiste { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--rand); padding: .4rem; }
  .seitenleiste .nav { width: auto; white-space: nowrap; }
  .seitenleiste .nav .anzahl { margin-left: .3rem; }
  .nav-titel { display: none; }
  .detail { display: none; padding: 1rem; }
  body.zeige-detail .detail { display: block; }
  body.zeige-detail .liste, body.zeige-detail .seitenleiste { display: none; }
  .nur-schmal { display: inline-flex; }
  .zeile { grid-template-columns: 1fr auto; }
  .zeile .beschr { grid-column: 1 / -1; }
  .kopf { flex-wrap: wrap; }
  .suche { order: 10; flex-basis: 100%; max-width: none; }
  .drei, .zwei { grid-template-columns: 1fr; }
  .seite { padding: 1rem; }
}

/* Automatische Aktualisierung */
.update-leiste { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; justify-content: center; background: var(--flaeche); border: 1px solid var(--akzent); border-radius: 12px; box-shadow: var(--schatten); padding: .6rem .9rem; width: max-content; max-width: 94vw; }

/* QR-Codes einlesen (Google Authenticator, otpauth) */
.tabelle-huelle { overflow-x: auto; margin: .6rem 0; }
.qr-rahmen { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin: .5rem 0; }
.qr-video { width: 100%; max-width: 420px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #000; }
.qr-status { color: var(--text-2); font-size: .9rem; text-align: center; margin: 0; }
.qr-text { margin-top: .6rem; }
.qr-text input { margin-top: .4rem; width: 100%; }
.totp-zeile { display: flex; gap: .4rem; }
.totp-zeile input { flex: 1; min-width: 0; }
