/* PrivIT Portal — beide Instanzen, hell + dunkel. Instanz-Farben kommen als
   CSS-Variablen aus app.js (Status-API); Basis-Look ist ruhig, dokumentenhaft,
   mit klarer Akzentführung. WCAG-AA-Kontraste in beiden Themes. */

:root {
  /* Instanz-Farben (werden von app.js überschrieben) */
  --ci-primaer: #060E1E;
  --ci-akzent: #9339FD;
  --ci-akzent2: #6BE49D;

  /* Helles Theme */
  --hintergrund: #f6f7f9;
  --flaeche: #ffffff;
  --flaeche-2: #eef0f4;
  --text: #17202e;
  --text-2: #4c5a6e;
  --linie: #d7dce4;
  --fokus: #1a5fff;
  --fehler: #b3261e;
  --ok: #1b7f4d;
  --schatten: 0 1px 3px rgba(10, 20, 40, .08), 0 8px 24px rgba(10, 20, 40, .06);
}
:root[data-theme="dunkel"] {
  --hintergrund: #0d1420;
  --flaeche: #16202f;
  --flaeche-2: #1e2a3c;
  --text: #e8edf4;
  --text-2: #9fadc0;
  --linie: #2c3a4f;
  --fokus: #7ab0ff;
  --fehler: #ffb4ab;
  --ok: #7fd8a8;
  --schatten: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--hintergrund); color: var(--text);
  min-height: 100vh; display: flex; flex-direction: column;
}
.verborgen { display: none !important; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--flaeche); padding: .5rem 1rem; z-index: 99; }
.skip-link:focus { left: .5rem; top: .5rem; }
:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; border-radius: 4px; }

/* Kopf */
.kopf {
  display: flex; align-items: center; gap: 1rem; padding: .65rem 1.25rem;
  background: var(--ci-primaer); color: #fff;
  border-bottom: 3px solid var(--ci-akzent);
}
.kopf-logo {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; min-width: 44px; padding: 3px 6px; border-radius: 10px; background: #ffffff; flex-shrink: 0;
}
.kopf-logo img { display: block; max-height: 38px; max-width: 96px; width: auto; height: auto; }
.kopf-marke { display: flex; flex-direction: column; line-height: 1.2; }
#marke-firma { font-weight: 650; letter-spacing: .02em; }
.kopf-kurz { font-size: .78rem; opacity: .85; }
.kopf-nav { display: flex; gap: .25rem; margin-left: 1rem; flex-wrap: wrap; }
.kopf-nav a {
  color: #fff; text-decoration: none; padding: .35rem .7rem; border-radius: 6px; font-size: .95rem;
  opacity: .85;
}
.kopf-nav a:hover { opacity: 1; background: rgba(255,255,255,.12); }
.kopf-nav a[aria-current="page"] { opacity: 1; background: rgba(255,255,255,.16); box-shadow: inset 0 -2px 0 var(--ci-akzent2); }
.kopf-rechts { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.icon-knopf {
  background: transparent; border: 0; color: inherit; cursor: pointer; padding: .45rem;
  border-radius: 8px; position: relative; display: inline-flex;
}
.kopf .icon-knopf:hover { background: rgba(255,255,255,.15); }
.glocke-zahl {
  position: absolute; top: 2px; right: 2px; background: var(--ci-akzent2); color: #06301c;
  border-radius: 999px; font-size: .68rem; font-weight: 700; min-width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.glocke-feld {
  position: absolute; right: 1rem; top: 3.4rem; z-index: 50; width: min(360px, 92vw);
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px;
  box-shadow: var(--schatten); padding: .5rem; max-height: 60vh; overflow: auto;
}
.glocke-eintrag { padding: .5rem .6rem; border-radius: 8px; font-size: .92rem; }
.glocke-eintrag.neu { background: var(--flaeche-2); }
.glocke-eintrag .zeit { color: var(--text-2); font-size: .8rem; display: block; }

/* Layout */
.haupt { flex: 1; width: min(1080px, 100% - 2rem); margin: 1.5rem auto; }
.fuss { text-align: center; color: var(--text-2); font-size: .82rem; padding: 1rem; }

/* Karten & Formulare */
.karte {
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px;
  box-shadow: var(--schatten); padding: 1.5rem; margin-bottom: 1.25rem;
}
.karte-schmal { max-width: 460px; margin: 8vh auto 0; }
.auth-marke { text-align: center; margin-bottom: 1.25rem; }
.auth-marke .bogen {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 14px; border-radius: 16px; margin: 0 auto .8rem;
  background: #ffffff; border: 1px solid var(--linie);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ci-akzent) 25%, transparent);
}
.auth-marke .bogen img { display: block; max-height: 96px; max-width: 200px; width: auto; height: auto; }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.12rem; margin: 1.1rem 0 .5rem; }
.untertitel { color: var(--text-2); margin: 0 0 1rem; font-size: .95rem; }

label { display: block; font-weight: 600; font-size: .92rem; margin: .8rem 0 .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="file"] {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--linie); border-radius: 8px;
  background: var(--flaeche); color: var(--text); font: inherit;
}
.hinweis { font-size: .84rem; color: var(--text-2); margin-top: .25rem; }

.knopf {
  display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
  border: 0; border-radius: 8px; padding: .6rem 1.1rem; font: inherit; font-weight: 600;
  background: var(--ci-akzent); color: #fff;
}
.knopf:hover { filter: brightness(1.08); }
.knopf:disabled { opacity: .55; cursor: wait; }
.knopf-zweit { background: var(--flaeche-2); color: var(--text); border: 1px solid var(--linie); }
.knopf-still { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.4); padding: .35rem .8rem; font-weight: 500; }
.knopf-reihe { display: flex; gap: .6rem; margin-top: 1.1rem; flex-wrap: wrap; }
.knopf-breit { width: 100%; justify-content: center; margin-top: 1.1rem; }

.fehlertext { color: var(--fehler); font-size: .92rem; margin-top: .6rem; min-height: 1.2em; }
.trenner { display: flex; align-items: center; gap: .8rem; color: var(--text-2); font-size: .85rem; margin: 1rem 0; }
.trenner::before, .trenner::after { content: ""; flex: 1; border-top: 1px solid var(--linie); }

/* Listen / Tabellen */
.tabelle { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tabelle th { text-align: left; color: var(--text-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; padding: .5rem .6rem; border-bottom: 2px solid var(--linie); }
.tabelle td { padding: .55rem .6rem; border-bottom: 1px solid var(--linie); vertical-align: middle; }
.tabelle-scroll { overflow-x: auto; }
.leer-block { text-align: center; color: var(--text-2); padding: 2.5rem 1rem; }
.leer-block .knopf { margin-top: 1rem; }

.raum-gitter { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.raum-karte {
  background: var(--flaeche); border: 1px solid var(--linie); border-left: 4px solid var(--ci-akzent);
  border-radius: 12px; padding: 1rem 1.1rem; cursor: pointer; box-shadow: var(--schatten);
  text-align: left; font: inherit; color: inherit; width: 100%;
}
.raum-karte:hover { border-left-color: var(--ci-akzent2); transform: translateY(-1px); }
.raum-karte h3 { margin: 0 0 .2rem; font-size: 1.02rem; }
.raum-karte .meta { color: var(--text-2); font-size: .84rem; }
.raum-karte.geschlossen { opacity: .6; border-left-color: var(--linie); }

.abzeichen { display: inline-block; border-radius: 999px; font-size: .76rem; font-weight: 650; padding: .12rem .6rem; }
.abzeichen-aktiv { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.abzeichen-zu { background: var(--flaeche-2); color: var(--text-2); }
.abzeichen-neu { background: color-mix(in srgb, var(--ci-akzent) 16%, transparent); color: var(--ci-akzent); }

.kopfzeile { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kopfzeile h1 { margin: 0; }

.recovery-liste { columns: 2; font-family: Consolas, monospace; font-size: 1.02rem; background: var(--flaeche-2); border-radius: 10px; padding: 1rem 1.4rem; }
.recovery-liste li { margin: .2rem 0; break-inside: avoid; }
.qr-bild { display: block; margin: .8rem auto; border-radius: 10px; background: #fff; padding: 8px; }
.code-anzeige { font-family: Consolas, monospace; background: var(--flaeche-2); padding: .3rem .6rem; border-radius: 6px; word-break: break-all; display: inline-block; }

/* Onboarding: Dokument-Anzeige, Checkboxen, Status */
select {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--linie); border-radius: 8px;
  background: var(--flaeche); color: var(--text); font: inherit;
}
.dok-text {
  background: var(--flaeche-2); border: 1px solid var(--linie); border-radius: 10px;
  padding: 1rem 1.2rem; max-height: 46vh; overflow-y: auto; font-size: .93rem;
}
.dok-text p { margin: .4rem 0; }
.dok-titelzeile { font-weight: 700; letter-spacing: .03em; margin-top: .8rem !important; }
.dok-warnung, .warn-banner {
  background: color-mix(in srgb, #e6a700 16%, transparent);
  border-left: 4px solid #b8860b; border-radius: 6px;
  padding: .5rem .7rem !important; font-size: .88rem;
}
.check-zeile {
  display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; font-size: .95rem;
  margin: .7rem 0; padding: .6rem .7rem; background: var(--flaeche-2); border-radius: 8px; cursor: pointer;
}
.check-zeile input { margin-top: .2rem; width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.status-liste { list-style: none; padding: 0; margin: 0; }
.status-liste li { display: flex; gap: .6rem; align-items: baseline; padding: .3rem 0; flex-wrap: wrap; }
.tab-leiste { display: flex; gap: .3rem; border-bottom: 2px solid var(--linie); margin-bottom: 1.1rem; flex-wrap: wrap; }
.tab {
  background: transparent; border: 0; font: inherit; color: var(--text-2); cursor: pointer;
  padding: .5rem .9rem; border-radius: 8px 8px 0 0; font-weight: 600;
}
.tab:hover { color: var(--text); background: var(--flaeche-2); }
.tab-aktiv { color: var(--ci-akzent); box-shadow: inset 0 -3px 0 var(--ci-akzent); }
.kpi-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-bottom: 1.25rem; }
.kpi { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: .8rem 1rem; box-shadow: var(--schatten); }
.kpi-wert { font-size: 1.7rem; font-weight: 700; line-height: 1.1; color: var(--ci-akzent); }
.kpi-dringend .kpi-wert { color: var(--fehler); }
.kpi-label { font-size: .8rem; color: var(--text-2); }
.abzeichen-dringend { background: color-mix(in srgb, var(--fehler) 18%, transparent); color: var(--fehler); }
.nachrichten-liste { display: flex; flex-direction: column; gap: .5rem; max-height: 40vh; overflow-y: auto; margin-bottom: .8rem; }
.nachricht { background: var(--flaeche-2); border-radius: 10px; padding: .5rem .8rem; max-width: 85%; }
.nachricht.eigene { align-self: flex-end; border-left: 3px solid var(--ci-akzent); }

.meldung {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--hintergrund); padding: .6rem 1.2rem; border-radius: 10px;
  box-shadow: var(--schatten); z-index: 100; max-width: 92vw;
}
.meldung.fehler { background: var(--fehler); color: #fff; }

@media (max-width: 640px) {
  .kopf { flex-wrap: wrap; padding: .55rem .8rem; }
  .kopf-nav { order: 3; width: 100%; margin-left: 0; }
  .haupt { width: calc(100% - 1.5rem); margin-top: 1rem; }
  .recovery-liste { columns: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* E2E-Sicherungscode (CSP verbietet Inline-Style-Attribute) */
.code-anzeige { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.25rem; letter-spacing: .06em; user-select: all; text-align: center; }
/* Drag & Drop auf die Upload-Karte */
.karte.drop-aktiv { outline: 2px dashed var(--ci-akzent); outline-offset: -6px; }
