:root {
  color-scheme: light dark;
  --grund: #f6f7f9;
  --flaeche: #ffffff;
  --text: #1b1f24;
  --leise: #5b6470;
  --linie: #dde1e6;
  --akzent: #1f6feb;
  --akzent-text: #ffffff;
  --gruen: #1a7f37;
  --gelb: #b58100;
  --rot: #cf222e;
  --grau: #8c959f;
  --schatten: 0 1px 2px rgb(0 0 0 / 0.06);
  --rund: 12px;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #0d1117;
    --flaeche: #161b22;
    --text: #e6edf3;
    --leise: #9198a1;
    --linie: #30363d;
    --akzent: #4493f8;
    --akzent-text: #0d1117;
    --gruen: #3fb950;
    --gelb: #d29922;
    --rot: #f85149;
    --grau: #6e7681;
    --schatten: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

button, input, select { font: inherit; color: inherit; }

.kopf {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}
.kopf h1 { font-size: 1.15rem; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zurueck { border: 0; background: none; font-size: 1.8rem; line-height: 1; padding: 0 8px 4px 0; cursor: pointer; }
.netz { font-size: 0.8rem; padding: 2px 8px; border-radius: 99px; background: var(--gelb); color: #fff; }

main { padding: 16px; max-width: 760px; margin: 0 auto; outline: none; }

.leiste {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  background: var(--flaeche);
  border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.leiste a {
  flex: 1;
  text-align: center;
  padding: 14px 4px;
  color: var(--leise);
  text-decoration: none;
  font-weight: 500;
}
.leiste a.aktiv { color: var(--akzent); }
.zahl {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--akzent);
  color: var(--akzent-text);
  font-size: 0.75rem;
  line-height: 1.4em;
}

.hinweis {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--rund);
  background: var(--text);
  color: var(--grund);
  z-index: 10;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}

h2 { font-size: 1rem; color: var(--leise); font-weight: 600; margin: 24px 0 8px; }
h2:first-child { margin-top: 0; }
.leer { color: var(--leise); text-align: center; padding: 32px 8px; }
.klein { font-size: 0.85rem; color: var(--leise); }

/* Kacheln */
.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kachel {
  display: block;
  text-align: left;
  border: 1px solid var(--linie);
  border-left: 6px solid var(--grau);
  border-radius: var(--rund);
  background: var(--flaeche);
  box-shadow: var(--schatten);
  padding: 12px;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  min-height: 96px;
}
.kachel .k-titel { font-size: 0.85rem; color: var(--leise); }
.kachel .k-wert { font-size: 1.4rem; font-weight: 650; margin: 2px 0; word-break: break-word; }
.kachel .k-text { font-size: 0.85rem; }
.status-gruen { border-left-color: var(--gruen); }
.status-gelb { border-left-color: var(--gelb); }
.status-rot { border-left-color: var(--rot); }
.status-grau { border-left-color: var(--grau); }

/* Posteingang */
.filter { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; scrollbar-width: none; }
.chip {
  flex: none;
  border: 1px solid var(--linie);
  background: var(--flaeche);
  border-radius: 99px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}
.chip.an { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }

.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.eintrag {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 4px 10px;
  align-items: start;
  padding: 12px;
  border-radius: var(--rund);
  background: var(--flaeche);
  border: 1px solid var(--linie);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--schatten);
}
.eintrag .punkt { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.eintrag.neu .punkt { background: var(--akzent); }
.eintrag.neu .e-titel { font-weight: 650; }
.eintrag.erledigt { opacity: 0.6; }
.eintrag.erledigt .e-titel { text-decoration: line-through; }
.e-titel { overflow-wrap: anywhere; }
.e-zeit { font-size: 0.8rem; color: var(--leise); white-space: nowrap; }
.e-zeile { grid-column: 2 / 4; font-size: 0.9rem; color: var(--leise); overflow-wrap: anywhere; }
.stufe { font-size: 0.75rem; padding: 1px 6px; border-radius: 6px; margin-right: 6px; border: 1px solid currentColor; }
.stufe-dringend { color: var(--rot); }
.stufe-normal { color: var(--akzent); }
.stufe-leise { color: var(--grau); }

.mehr { display: block; width: 100%; margin-top: 12px; }

/* Detail */
.meta { font-size: 0.85rem; color: var(--leise); margin-bottom: 12px; }
.meldungskasten { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--rund); padding: 12px; margin-bottom: 12px; }
.rahmen { width: 100%; border: 1px solid var(--linie); border-radius: var(--rund); background: var(--flaeche); min-height: 200px; display: block; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.knopf {
  border: 1px solid var(--linie);
  background: var(--flaeche);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
}
.knopf.haupt { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.knopf:disabled { opacity: 0.5; cursor: default; }
.ereignis { font-size: 0.85rem; color: var(--leise); }

/* Vorlagen */
.v-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.v-liste li { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--rund); padding: 12px; display: flex; gap: 12px; }
.v-liste img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; }
.v-liste .v-titel { font-weight: 600; overflow-wrap: anywhere; }
.v-liste .v-text { color: var(--leise); white-space: pre-wrap; overflow-wrap: anywhere; }
.v-liste a { color: var(--akzent); }
.v-tabelle-huelle { overflow-x: auto; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--rund); }
.v-tabelle { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.v-tabelle th, .v-tabelle td { padding: 8px 10px; border-bottom: 1px solid var(--linie); text-align: left; white-space: nowrap; }
.v-tabelle th { cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--flaeche); }
.v-tabelle td.zahl-zelle, .v-tabelle th.zahl-zelle { text-align: right; font-variant-numeric: tabular-nums; }
.v-tabelle tr:last-child td { border-bottom: 0; }
.v-status .kachel { cursor: default; }
.v-status { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

/* Formulare */
.feld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.feld input { padding: 10px 12px; border: 1px solid var(--linie); border-radius: 10px; background: var(--flaeche); }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--rund); padding: 16px; margin-bottom: 12px; }
.geraet { display: flex; align-items: center; gap: 12px; }
.geraet > div { flex: 1; }
.widerrufen { opacity: 0.55; }

.qr { display: block; width: min(320px, 100%); margin: 12px auto; background: #fff; padding: 12px; border-radius: var(--rund); }
.code { font: 600 1.6rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: 0.15em; text-align: center; }

.frage { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.45); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.frage .karte { width: min(480px, 100%); margin: 0 0 calc(64px + env(safe-area-inset-bottom)); }
