/* Dunkles Thema, bewusst nicht steril: warmes Anthrazit statt reinem Schwarz,
   sichtbare Kartenkanten, keine Farbverläufe/Schatten-Spielereien.
   Farbwerte aus dem dataviz-Skill (references/palette.md), dunkler Satz. */

:root {
  --flaeche:        #0d0d0d;   /* Seitenhintergrund */
  --karte:          #1a1a19;   /* Kartenflaeche */
  --karte-rand:     rgba(255,255,255,0.10);
  --text-primaer:   #ffffff;
  --text-sekundaer: #c3c2b7;
  --text-gedaempft: #898781;
  --gitterlinie:    #2c2c2a;
  --achse:          #383835;
  --akzent:         #3987e5;
  --gut:            #0ca30c;
  --warnend:        #fab219;
  --kritisch:       #d03b3b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--flaeche);
  color: var(--text-primaer);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }

.kopfzeile {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--karte-rand);
  background: #131312;
  position: sticky;   /* bleibt beim Scrollen oben sichtbar, auf Nicos Wunsch */
  top: 0;
  z-index: 20;
}
.kopfzeile .titel { font-weight: 600; font-size: 16px; letter-spacing: 0.2px; }
.kopfzeile nav { display: flex; gap: 20px; flex-wrap: wrap; row-gap: 8px; }
.kopfzeile nav a { color: var(--text-sekundaer); font-size: 14px; }
.kopfzeile nav a.aktiv { color: var(--text-primaer); font-weight: 600; }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 14px; color: var(--text-sekundaer); font-weight: 600;
     text-transform: uppercase; letter-spacing: 0.4px; }
.unterzeile { color: var(--text-gedaempft); font-size: 13px; margin: 0 0 24px; }

.karte {
  background: var(--karte);
  border: 1px solid var(--karte-rand);
  border-radius: 10px;
  padding: 20px 24px;
}

.raster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* Diagramme haben ein festes viewBox-Koordinatensystem, aber keine feste
   Pixelgroesse mehr -- sie skalieren mit der Kartenbreite, ohne zu verzerren
   (das Seitenverhaeltnis kommt aus dem viewBox). width:100% statt nur
   max-width: ein Diagramm soll die Kachel auch dann ausfuellen, wenn die
   Kachel breiter ist als die urspruengliche Pixelbreite -- vorher blieb es
   auf seiner intrinsischen Breite stehen und liess Leerraum. Der Donut ist
   bewusst ausgenommen: als kompakter Ring neben seiner Legende soll er nicht
   auf volle Kartenbreite aufgeblasen werden. */
.karte svg { display: block; width: 100%; height: auto; }
.zweispaltig > .karte { min-width: 0; }
.raster > .kachel { min-width: 0; }
.donut-mitte svg { width: auto; max-width: 200px; }

.kachel .beschriftung {
  font-size: 12px;
  color: var(--text-gedaempft);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kachel .wert { font-size: 26px; font-weight: 600; margin-top: 4px; }
.kachel .zusatz { font-size: 12px; color: var(--text-sekundaer); margin-top: 2px; }

/* Zwei zusammengehoerige Werte in einer Kachel uebereinander (z. B. "KH
   gesamt" direkt ueber "KH je Bolus-Einheit") statt nebeneinander im Raster
   -- garantiert "darunter" auf jeder Bildschirmgroesse, nicht nur bei
   genug Spalten (Nicos Wunsch 22.09.2026). */
.kachel .teil + .teil {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--karte-rand);
}

.zweispaltig {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 24px;
}
@media (max-width: 720px) { .zweispaltig { grid-template-columns: 1fr; } }

.donut-legende { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; font-size: 13px; }
.donut-legende .zeile { display: flex; align-items: center; gap: 8px; color: var(--text-sekundaer); }
.donut-legende .punkt { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.donut-mitte { display: flex; justify-content: center; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--gitterlinie); }
th { color: var(--text-gedaempft); font-weight: 600; font-size: 11px; text-transform: uppercase;
     letter-spacing: 0.3px; padding-bottom: 12px; }
tr:hover td { background: rgba(255,255,255,0.03); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 100px; font-size: 11px; font-weight: 600; }
.badge.bolus   { background: rgba(57,135,229,0.18); color: #85b6f2; }
.badge.basal   { background: rgba(201,133,0,0.20); color: #e0a83f; }
.badge.kh      { background: rgba(217,89,38,0.18); color: #f0a274; }
.badge.notiz   { background: rgba(137,135,129,0.18); color: var(--text-sekundaer); }
.badge.teststreifen, .badge.keton { background: rgba(213,81,129,0.18); color: #ecabc4; }
.badge.sensorwechsel { background: rgba(12,163,12,0.18); color: #6fd66f; }
.badge.gut     { background: rgba(12,163,12,0.18); color: #6fd66f; }
.badge.info    { background: rgba(57,135,229,0.18); color: #85b6f2; }
.badge.warnend { background: rgba(250,178,25,0.18); color: #f7cb6b; }
.badge.kritisch { background: rgba(208,59,59,0.20); color: #ef8f8f; }

form.formular { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
form.formular label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-sekundaer); }
form.formular input, form.formular select {
  background: #111110; border: 1px solid var(--achse); border-radius: 6px;
  padding: 8px 10px; color: var(--text-primaer); font-size: 14px; font-family: inherit;
}
form.formular input:focus, form.formular select:focus { outline: 1px solid var(--akzent); border-color: var(--akzent); }
.formular-aktion { grid-column: 1 / -1; display: flex; justify-content: flex-end; margin-top: 4px; }
button {
  background: var(--akzent); color: #fff; border: none; border-radius: 6px;
  padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
button:hover { filter: brightness(1.1); }

.suchfeld { margin-bottom: 16px; }
.suchfeld input { width: 100%; max-width: 320px; }

.datumsleiste { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.datumsleiste select { min-width: 160px; }
.datumsleiste a.pfeil {
  border: 1px solid var(--achse); border-radius: 6px; padding: 7px 12px; color: var(--text-primaer);
}
.datumsleiste a.pfeil:hover { background: rgba(255,255,255,0.06); text-decoration: none; }

.leer { color: var(--text-gedaempft); font-size: 13px; padding: 20px 0; text-align: center; }

/* Ereignis-Popup (Tagesansicht): natives <dialog>, damit Bearbeiten/Abgleich
   aus der reinen Ansicht-Tabelle heraus ist (Nicos Wunsch 21.08.2026).
   Kein JavaScript-Framework -- nur showModal() zum Oeffnen, Schliessen laeuft
   ueber method="dialog" ganz ohne Skript. */
dialog.ereignis-popup {
  background: var(--karte);
  color: var(--text-primaer);
  border: 1px solid var(--karte-rand);
  border-radius: 12px;
  padding: 22px;
  width: min(560px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
}
dialog.ereignis-popup::backdrop { background: rgba(0,0,0,0.6); }
.popup-schliessen {
  float: right; background: transparent; color: var(--text-sekundaer);
  border: 1px solid var(--achse); border-radius: 6px; width: 30px; height: 30px;
  padding: 0; font-size: 14px; line-height: 1;
}
.popup-schliessen:hover { background: rgba(255,255,255,0.06); color: var(--text-primaer); }

/* Schnellfoto-Knopf (Fotos-Seite): grosse Tippflaeche fuers Handy, oeffnet
   ueber capture="environment" direkt die Kamera (Nicos Wunsch 21.08.2026). */
.schnellfoto-knopf {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--akzent); color: #fff; border-radius: 10px;
  padding: 18px 22px; font-size: 15px; font-weight: 600; cursor: pointer;
  min-width: 220px; text-align: center;
}
.schnellfoto-knopf:hover { filter: brightness(1.1); }

/* Hover-Tooltip am Glukoseverlauf (Tagesansicht): Nicos Wunsch 23.09.2026,
   Wert+Uhrzeit+Trend beim Darueberfahren sehen, ohne zu klicken. */
.glukoseverlauf-hover-flaeche { cursor: crosshair; }
.glukoseverlauf-tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--karte); border: 1px solid var(--karte-rand); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; color: var(--text-primaer); white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* Handy im Heimnetz (Nicos Wunsch 21.08.2026, erweitert 23.09.2026): Kopfzeile
   bricht um statt zu ueberlaufen, Nav-Links und Kacheln bekommen mehr
   Tippflaeche/Zeilenumbruch. ECHTER FUND 23.09.2026: dieser Block stand bis
   hierhin VOR den ungeschuetzten `main`/`.karte`/`.raster`-Regeln weiter oben
   im Dokument -- bei gleicher Selektor-Spezifitaet gewinnt in CSS die spaeter
   im Dokument stehende Regel, unabhaengig von der Media-Query. Die spaeteren,
   unbedingten Regeln haben die mobile Anpassung dadurch die ganze Zeit
   stillschweigend ueberschrieben (nur `.kopfzeile` blieb wirksam, weil es
   nirgendwo sonst nochmal definiert wird) -- deshalb sah die App auf dem
   Handy trotz vorhandener Regeln wie die volle Desktop-Breite aus. */
@media (max-width: 480px) {
  .kopfzeile { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 16px; }
  .kopfzeile nav { gap: 14px 16px; }
  main { padding: 16px 16px 40px; }
  .karte { padding: 14px 16px; }
  .raster { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
}
