:root {
  --hg: #0b1220;
  --hg-karte: #121c2e;
  --hg-feld: #0d1726;
  --rand: #243246;
  --text: #e8edf6;
  --text-leise: #93a2b8;
  --akzent: #3b82f6;
  --akzent-dunkel: #1d4ed8;
  --gut: #22c55e;
  --warnung: #f59e0b;
  --fehler: #ef4444;
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--hg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .2rem; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: .98rem; margin: 1.1rem 0 .4rem; color: var(--text-leise); text-transform: uppercase; letter-spacing: .04em; }
code { background: var(--hg-feld); padding: .1rem .3rem; border-radius: 4px; }

/* Kopf und Navigation */
.kopf {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1rem; background: #0a1020; border-bottom: 1px solid var(--rand);
  position: sticky; top: 0; z-index: 20;
  padding-top: max(.7rem, env(safe-area-inset-top));
}
.marke { font-weight: 700; color: var(--text); letter-spacing: .02em; }
.navigation { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; min-width: 0; }
.navigation a {
  padding: .4rem .7rem; border-radius: var(--radius); color: var(--text-leise); font-size: .95rem;
}
.navigation a.gewaehlt, .navigation a:hover { background: var(--hg-karte); color: var(--text); text-decoration: none; }
.kopf-rechts { display: flex; align-items: center; gap: .6rem; }
.netz { font-size: .8rem; color: var(--text-leise); }
.netz.gut { color: var(--gut); }
.netz.offen { color: var(--warnung); }

.inhalt { padding: 1rem; max-width: 1150px; margin: 0 auto; padding-bottom: 4rem; }

/* Zählerleiste für nicht übertragene Daten */
.zaehlerleiste {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .55rem 1rem; font-weight: 600; font-size: .92rem;
}
.zaehlerleiste.leer { display: none; }
.zaehlerleiste.warnung { background: #4a2f05; color: #fde68a; border-bottom: 1px solid #6b4306; }
.zaehlerleiste.gut { background: #052e1a; color: #a7f3d0; border-bottom: 1px solid #065f36; }

/* Karten */
.karte { background: var(--hg-karte); border: 1px solid var(--rand); border-radius: var(--radius); margin-bottom: 1rem; overflow: hidden; }
.karte-kopf { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem .9rem; border-bottom: 1px solid var(--rand); background: #0f1a2b; }
.karte-inhalt { padding: .9rem; min-width: 0; }
.kopfzeile { margin-bottom: 1rem; }
.warnkarte { background: #4a2f05; border: 1px solid #6b4306; border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; color: #fde68a; }
.warnkarte h3 { color: #fde68a; margin-top: 0; }
.warnliste { color: var(--warnung); }

/* Zahlen */
.zahlenreihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.zahlenkarte { background: var(--hg-karte); border: 1px solid var(--rand); border-radius: var(--radius); padding: .8rem; display: flex; flex-direction: column; gap: .2rem; }
.zahlenkarte.warnung { border-color: var(--warnung); }
.zahl { font-size: 1.8rem; font-weight: 700; }
.zahl-titel { color: var(--text-leise); font-size: .85rem; }

/* Formulare */
.formular { display: flex; flex-direction: column; gap: .7rem; }
.formular.zweispaltig { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .7rem; }
.feld { display: flex; flex-direction: column; gap: .25rem; }
.feld-titel { font-size: .82rem; color: var(--text-leise); }
.feld-hinweis { font-size: .78rem; color: var(--text-leise); }
input, select, textarea {
  background: var(--hg-feld); color: var(--text); border: 1px solid var(--rand);
  border-radius: 8px; padding: .55rem .6rem; font: inherit; font-size: 1rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: 1px; }
textarea { resize: vertical; }
.schalter { display: flex; align-items: center; gap: .45rem; font-size: .9rem; color: var(--text-leise); }
.schalter input { width: auto; }
.versteckt { display: none; }

/* Knöpfe */
.knopf {
  background: var(--hg-feld); color: var(--text); border: 1px solid var(--rand);
  border-radius: 8px; padding: .55rem .9rem; font: inherit; font-size: .95rem; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
}
.knopf:hover { border-color: var(--akzent); }
.knopf.wichtig { background: var(--akzent-dunkel); border-color: var(--akzent); color: #fff; font-weight: 600; }
.knopf.leise { color: var(--text-leise); }
.knopf.gewaehlt { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.knopfreihe { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0; }
.knopfreihe.klein .knopf { padding: .35rem .6rem; min-height: 34px; font-size: .85rem; }
a.knopf { text-decoration: none; }

/* Tabellen */
.tabelle-rahmen { overflow-x: auto; max-width: 100%; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabelle th { text-align: left; padding: .5rem .55rem; color: var(--text-leise); font-weight: 600; border-bottom: 1px solid var(--rand); white-space: nowrap; }
.tabelle td { padding: .5rem .55rem; border-bottom: 1px solid #1b263a; vertical-align: top; }
.tabelle tr:last-child td { border-bottom: none; }

/* Mängel */
.mangel-liste { display: flex; flex-direction: column; gap: .5rem; }
.mangel-zeile { display: flex; align-items: center; justify-content: space-between; gap: .8rem; background: var(--hg-feld); border: 1px solid var(--rand); border-radius: 8px; padding: .6rem .7rem; }
.mangel-zeile-rechts { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.mangel-block { background: var(--hg-feld); border: 1px solid var(--rand); border-radius: 8px; padding: .6rem .7rem; }
.mangel-block summary { cursor: pointer; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.mangel-detail { padding-top: .6rem; }
.abzeichen { font-size: .76rem; padding: .15rem .45rem; border-radius: 999px; background: #1b2740; color: var(--text-leise); }
.abzeichen.gut { background: #07351f; color: #86efac; }
.abzeichen.offen { background: #4a2f05; color: #fde68a; }
.abzeichen.warnung { background: #4a2f05; color: #fde68a; }

/* Erfassung */
.aufnahme-kopf { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.aufnahme-aktionen { display: flex; gap: .5rem; flex-wrap: wrap; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .5rem; }
.kachel { background: var(--hg-feld); border: 1px solid var(--rand); border-radius: 10px; color: var(--text); padding: .9rem .5rem; min-height: 64px; font-size: .95rem; cursor: pointer; }
.kachel.gewaehlt { background: var(--akzent-dunkel); border-color: var(--akzent); font-weight: 600; }
.baustein-liste { display: flex; flex-direction: column; gap: .35rem; max-height: 320px; overflow-y: auto; margin-top: .4rem; }
.baustein { display: flex; justify-content: space-between; gap: .6rem; align-items: center; background: var(--hg-feld); border: 1px solid var(--rand); border-radius: 8px; padding: .6rem .7rem; color: var(--text); text-align: left; cursor: pointer; min-height: 48px; }
.baustein.gewaehlt { border-color: var(--akzent); background: #16233c; }
.schwere-wahl { display: flex; gap: .5rem; flex-wrap: wrap; }
.foto-bereich { margin-top: .4rem; }
.galerie { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-top: .6rem; }
.galerie-eintrag { background: var(--hg-feld); border: 1px solid var(--rand); border-radius: 8px; padding: .4rem; display: flex; flex-direction: column; gap: .35rem; }
.vorschau { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; background: #000; }
.vorschau.leer { display: flex; align-items: center; justify-content: center; color: var(--text-leise); font-size: .8rem; }
.zuordnung { display: flex; gap: .6rem; align-items: center; margin-bottom: .4rem; }

/* Reiter */
.reiter { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; min-width: 0; }

/* Texte */
.leise { color: var(--text-leise); font-size: .9rem; margin: .2rem 0; }
.hinweis { color: var(--text-leise); font-size: .85rem; background: var(--hg-feld); border-left: 3px solid var(--akzent); padding: .5rem .7rem; border-radius: 0 6px 6px 0; }
.warnbalken { background: #4a2f05; color: #fde68a; padding: .55rem .7rem; border-radius: 8px; font-weight: 600; }
.gutbalken { background: #052e1a; color: #a7f3d0; padding: .55rem .7rem; border-radius: 8px; font-weight: 600; }
.warnung-text { color: var(--warnung); font-weight: 600; }
.vorschau-json { background: #080e1a; border: 1px solid var(--rand); border-radius: 8px; padding: .7rem; overflow-x: auto; font-size: .8rem; max-height: 420px; }

/* Anmeldung */
.anmeldung { max-width: 380px; margin: 12vh auto; padding: 0 1rem; }

/* Dialog */
.dialog-huelle { position: fixed; inset: 0; background: rgba(4, 8, 16, .75); display: flex; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; z-index: 40; }
.dialog { background: var(--hg-karte); border: 1px solid var(--rand); border-radius: 12px; width: min(820px, 100%); margin: 2vh 0 6vh; }
.dialog-kopf { display: flex; align-items: center; justify-content: space-between; padding: .8rem .9rem; border-bottom: 1px solid var(--rand); position: sticky; top: 0; background: var(--hg-karte); border-radius: 12px 12px 0 0; }
.dialog-kopf h3 { margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 1.05rem; }
.dialog-zu { background: none; border: none; color: var(--text-leise); font-size: 1.1rem; cursor: pointer; padding: .3rem .5rem; }
.dialog-inhalt { padding: .9rem; }
.dialog-fuss { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem .9rem; border-top: 1px solid var(--rand); position: sticky; bottom: 0; background: var(--hg-karte); }

/* Markierung / Unterschrift */
.markier-leiste { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.markier-farben { display: flex; gap: .3rem; }
.farbpunkt { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff3; cursor: pointer; }
.markier-flaeche, .unterschrift-flaeche { max-width: 100%; border: 1px solid var(--rand); border-radius: 8px; touch-action: none; background: #000; }
.unterschrift-flaeche { background: #fff; }

/* Toasts */
.toast-bereich { pointer-events: none; position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 60; width: min(560px, calc(100% - 2rem)); }
.toast { pointer-events: auto; padding: .7rem .9rem; border-radius: 8px; font-size: .92rem; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.toast-info { background: #1b2740; color: var(--text); }
.toast-erfolg { background: #07351f; color: #a7f3d0; }
.toast-warnung { background: #4a2f05; color: #fde68a; }
.toast-fehler { background: #45121a; color: #fecaca; }

@media (max-width: 640px) {
  .kopf { flex-direction: column; align-items: stretch; gap: .45rem; padding: .6rem .8rem; }
  .marke { font-size: 1.05rem; }
  .kopf > * { max-width: 100%; }
  .navigation { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: .15rem; width: 100%; max-width: 100%; }
  .navigation::-webkit-scrollbar { display: none; }
  .navigation a { font-size: .88rem; padding: .35rem .55rem; white-space: nowrap; }
  .kopf-rechts { justify-content: space-between; }
  .inhalt { padding: .7rem; }
  h1 { font-size: 1.2rem; }
  .formular.zweispaltig { grid-template-columns: 1fr; }
  /* Tabellen lieber waagerecht scrollen als Wörter umbrechen */
  .tabelle { min-width: 560px; }
  .zahlenreihe { grid-template-columns: repeat(2, 1fr); }
  .reiter { overflow-x: auto; flex-wrap: nowrap; }
  .reiter .knopf { white-space: nowrap; }
}
