/* CSE Dashboard - Optik wie Outlook Center (Segoe UI, CSE-Blau, helle Karten).
   Dark Mode dreifach: System (prefers-color-scheme), Teams (html.dunkel via app.js). */

:root {
  --blau: #005a9e;
  --blau-dunkel: #004578;
  --blau-hell: #e8f1f8;
  --papier: #faf9f8;
  --karte: #ffffff;
  --text: #323130;
  --text-leise: #605e5c;
  --rand: #edebe9;
  --ok: #107c10;
  --ok-grund: #e6f2e6;
  --warn: #d83b01;
  --warn-grund: #fbeae4;
  --schatten: 0 1px 3px rgba(0, 0, 0, .08);
}

@media (prefers-color-scheme: dark) {
  :root:not(.hell) {
    --blau: #4a9edd;
    --blau-dunkel: #005a9e;
    --blau-hell: #1e2a36;
    --papier: #1b1a19;
    --karte: #252423;
    --text: #f3f2f1;
    --text-leise: #a19f9d;
    --rand: #3b3a39;
    --ok: #6ccb5f;
    --ok-grund: #1e2f1e;
    --warn: #f1707b;
    --warn-grund: #35211c;
    --schatten: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

:root.dunkel {
  --blau: #4a9edd;
  --blau-dunkel: #005a9e;
  --blau-hell: #1e2a36;
  --papier: #1b1a19;
  --karte: #252423;
  --text: #f3f2f1;
  --text-leise: #a19f9d;
  --rand: #3b3a39;
  --ok: #6ccb5f;
  --ok-grund: #1e2f1e;
  --warn: #f1707b;
  --warn-grund: #35211c;
  --schatten: 0 1px 3px rgba(0, 0, 0, .4);
}

/* In Teams soll die App nahtlos wirken: Teams-Theme "dark" setzt html.dunkel,
   der Nutzer-Systemmodus ist dann egal. html.hell erzwingt hell. */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--papier);
}

button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blau); }

button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--feld-aktiv, #d9a300);
  outline-offset: 2px;
}

/* ---------- Kopf ---------- */
#kopf {
  background: var(--blau-dunkel);
  color: #fff;
  padding: 0 16px;
}
#kopf-innen {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 10px;
}
#kopf h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
#kopf h1 img {
  border-radius: 8px; /* wie im Orga Portal: Birne randlos auf weissem Quadrat */
  display: block;
}
#btn-theme {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .5);
  color: #fff;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  margin: 0 0 10px auto; /* rechtsbuendig, solange die Reiter (v2) versteckt sind */
}
#btn-theme:hover { border-color: #fff; }
#reiter:not([hidden]) + #btn-theme { margin-left: 0; }
#reiter { display: flex; gap: 4px; margin-left: auto; }
#reiter button {
  font-weight: 600;
  color: rgba(255, 255, 255, .75);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 6px 14px 10px;
}
#reiter button:hover { color: #fff; }
#reiter button.aktiv { color: #fff; border-bottom-color: #fff; }
#btn-konto {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .5);
  color: #fff;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  margin-bottom: 10px;
}
#btn-konto:hover { background: var(--blau-dunkel); border-color: #fff; }

/* Nachgeruestete gemeinsame Kopf-Knoepfe (↔ cse-breite.js, ↻/Version cse-reload.js):
   sie kopieren die Klasse des Theme-Knopfs - der ist hier aber per ID gestylt,
   deshalb kamen sie als rohe WEISSE Standard-Knoepfe daher (Nutzer-Report 31.07.).
   Gleiche Optik wie #btn-theme, per ID zugewiesen: */
#btn-breite, #btn-version {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .5);
  color: #fff;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  margin-bottom: 10px;
}
#btn-breite:hover, #btn-version:hover { border-color: #fff; }

main, #anmeldung, #fehler {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

/* ---------- Anmeldung / Meldungen ---------- */
.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  box-shadow: var(--schatten);
  padding: 16px;
}
.mitte {
  max-width: 380px;
  margin: 40px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.primaer {
  background: var(--blau);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-weight: 600;
}
.primaer:hover { background: var(--blau-dunkel); }
.leise {
  background: transparent;
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 7px 14px;
}
.hinweis { color: var(--text-leise); font-size: 12.5px; }

/* ---------- Abschnitte ---------- */
section h2 {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-leise);
  margin: 26px 0 10px;
}
main section:first-child h2 { margin-top: 0; }

/* ---------- Stat-Kacheln ---------- */
.stat-zeile {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  box-shadow: var(--schatten);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat .titel { color: var(--text-leise); font-size: 12.5px; }
.stat .wert {
  font-size: 29px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat .unter { font-size: 12.5px; color: var(--text-leise); }
.stat .unter .warn-text { color: var(--warn); font-weight: 600; }

/* ---------- Bereichs-Karten ---------- */
.karten-gitter {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 12px;
}
.bereich {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  box-shadow: var(--schatten);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  transition: box-shadow .15s, transform .15s;
  text-decoration: none;
  color: inherit;
}
a.bereich:hover, button.bereich:hover {
  box-shadow: 0 3px 10px rgba(0, 0, 0, .14);
  transform: translateY(-1px);
}
@media (prefers-reduced-motion: reduce) {
  .bereich, a.bereich:hover, button.bereich:hover { transition: none; transform: none; }
}
.bereich.bald { border-style: dashed; opacity: .7; }
.bereich-kopf { display: flex; align-items: center; gap: 8px; }
.bereich-symbol {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--blau-hell);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex: none;
}
.bereich-name { font-weight: 600; }
.bereich-quelle { font-size: 11.5px; color: var(--text-leise); }
.pillen { display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; }
.pille {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px;
  border-radius: 20px;
  padding: 2px 9px;
  background: var(--blau-hell);
}
.pille.ok { background: var(--ok-grund); }
.pille.warn { background: var(--warn-grund); }
.pille b { font-variant-numeric: tabular-nums; }
.pille.ok .glyph { color: var(--ok); }
.pille.warn .glyph { color: var(--warn); }
.pille.lade { color: var(--text-leise); }

/* ---------- App-Kacheln ---------- */
/* Der Behaelter traegt die Gruppen (Ueberschrift + eigenes Gitter je Gruppe),
   das Gitter selbst sitzt in .app-gitter-reihe. */
.app-gitter { display: block; }
.app-gitter-reihe {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}
.app-gruppe {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-leise);
  margin: 18px 0 8px;
}
.app-gitter > .app-gruppe:first-child { margin-top: 0; }
.app-kachel {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 11px 10px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: box-shadow .15s;
  text-decoration: none;
  color: inherit;
}
.app-kachel:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, .14); }
.app-kachel .symbol { font-size: 20px; }
.app-kachel .name { font-weight: 600; font-size: 13px; }
.app-kachel .pfad { font-size: 11px; color: var(--text-leise); }
.app-kachel.bald {
  border-style: dashed;
  opacity: .65;
  cursor: default;
}
.app-kachel.bald:hover { box-shadow: none; }
.app-kachel .bald-band {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--warn);
}

/* ---------- Team-Ansicht ---------- */
#team-kopfzeile {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
#team-kopfzeile label { font-weight: 600; }
#team-wahl {
  font: inherit;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--rand);
  background: var(--karte);
  color: var(--text);
  min-width: 220px;
}
#team-info { color: var(--text-leise); font-size: 12.5px; }

.zwei-spalten {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  align-items: start;
}
.panel {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  box-shadow: var(--schatten);
  padding: 13px 15px;
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-leise);
}
.zeilen-liste { list-style: none; margin: 0; padding: 0; }
.zeilen-liste li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 2px;
  border-top: 1px solid var(--rand);
}
.zeilen-liste li:first-child { border-top: none; }
.zeilen-liste .symbol { flex: none; width: 22px; text-align: center; }
.zeilen-liste .inhalt { flex: 1; min-width: 0; }
.zeilen-liste .inhalt a { font-weight: 600; text-decoration: none; }
.zeilen-liste .inhalt a:hover { text-decoration: underline; }
.zeilen-liste .unter { display: block; font-size: 11.5px; color: var(--text-leise); }
.zaehl-chip {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--blau-hell);
  border-radius: 12px;
  padding: 2px 9px;
}
.zaehl-chip.warn { background: var(--warn-grund); color: var(--warn); }
.zaehl-chip.ok { background: var(--ok-grund); color: var(--ok); }

/* Team-Ansicht: Abschnitts-Überschriften wie in der zentralen Übersicht */
#ansicht-team h2 {
  font-size: 12.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-leise); margin: 24px 0 10px;
}
#ansicht-team section:first-of-type h2 { margin-top: 6px; }

.demo-band {
  background: var(--warn-grund);
  border-bottom: 1px solid var(--rand);
  text-align: center;
  padding: 5px 16px;
  font-size: 12.5px;
}

[hidden] { display: none !important; }
.lade-text { color: var(--text-leise); }
