:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1c2330;
  --muted: #5d6676;
  --line: #e1e4ea;
  --accent: #1f5fa8;
  --accent-soft: #e7eff9;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--accent); }
.laden { padding: 2rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #16263d; color: #dfe6f0; padding: 1.2rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.side .brand { font-weight: 700; font-size: 1.05rem; padding: .2rem .6rem 1rem; color: #fff; }
.side .brand small { display: block; font-weight: 400; color: #9fb0c6; font-size: .8rem; }
.side a { color: #dfe6f0; text-decoration: none; padding: .5rem .7rem; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: rgba(255,255,255,.08); }
.side a.aktiv { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.side .spacer { flex: 1; }
.side .wer { font-size: .85rem; color: #9fb0c6; padding: .5rem .7rem; }
.side .count { background: #e0a43a; color: #16263d; border-radius: 99px; font-size: .75rem; padding: 0 .45rem; font-weight: 700; }
main { padding: 1.6rem 2rem 3rem; max-width: 1200px; width: 100%; }
.kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.kopf h1 { margin: 0; }
.kopf .sub { color: var(--muted); margin-top: .2rem; }
.zurueck { display: inline-block; margin-bottom: .6rem; text-decoration: none; font-size: .9rem; }

/* Karten */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kennzahl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.kennzahl .wert { font-size: 1.8rem; font-weight: 700; }
.kennzahl .label { color: var(--muted); font-size: .9rem; }
.kennzahl.hinweis .wert { color: var(--warn); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr.klick { cursor: pointer; }
tr.klick:hover td { background: #f7f9fc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabelle-wrap { overflow-x: auto; }

/* Formulare */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
input, select, textarea { width: 100%; font: inherit; padding: .5rem .6rem; border: 1px solid #c9ced8; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; }
textarea { min-height: 110px; resize: vertical; }
.feld { margin-bottom: .9rem; }
.feld .hilfe { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.formgrid .voll { grid-column: 1 / -1; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }

/* Buttons */
button, .btn { font: inherit; border: 1px solid transparent; background: var(--accent); color: #fff; padding: .5rem .9rem; border-radius: 8px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
button:hover, .btn:hover { filter: brightness(1.08); }
button.zweit, .btn.zweit { background: #fff; color: var(--accent); border-color: #c4d3e6; }
button.gefahr { background: #fff; color: var(--bad); border-color: #efc2bd; }
button.klein, .btn.klein { padding: .25rem .55rem; font-size: .85rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
.aktionen { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Badges & Fortschritt */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eceff3; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.balken { height: 8px; background: #e7eaef; border-radius: 99px; overflow: hidden; }
.balken > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.balken.ok > span { background: var(--ok); }

/* Reiter */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.aktiv { color: var(--accent); border-bottom-color: var(--accent); }

/* Listen */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { padding: .7rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.liste li:last-child { border-bottom: 0; }
.gruppe-titel { margin: 1.2rem 0 .4rem; font-size: .95rem; color: var(--muted); }
.daten { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.daten dt { color: var(--muted); }
.daten dd { margin: 0; }

/* Test */
.frage { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.frage:last-child { border-bottom: 0; }
.frage .option { display: flex; gap: .6rem; align-items: flex-start; padding: .4rem .5rem; border-radius: 8px; font-weight: 400; cursor: pointer; }
.frage .option:hover { background: #f4f7fb; }
.option.richtig { background: var(--ok-soft); }
.option.falsch { background: var(--bad-soft); }
.ergebnis { font-size: 1.3rem; font-weight: 700; }
.frage-edit { border: 1px solid var(--line); border-radius: 8px; padding: .9rem; margin-bottom: .8rem; background: #fafbfc; }
.frage-edit .opt { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; }

/* Login */
.login { max-width: 380px; margin: 10vh auto; }
.login h1 { text-align: center; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 1rem; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; padding: 1.4rem; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.breit { max-width: 860px; }
.modal h2 { margin-bottom: 1rem; }
.modal .fuss { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.fehler { background: var(--bad-soft); color: var(--bad); padding: .5rem .7rem; border-radius: 8px; margin-bottom: .8rem; font-size: .9rem; }

#toast { position: fixed; bottom: 1.2rem; right: 1.2rem; background: #16263d; color: #fff; padding: .7rem 1rem; border-radius: 8px; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 60; }
#toast.zeigen { opacity: 1; transform: none; }

.leer { color: var(--muted); padding: 1rem 0; }
.suche { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.suche input, .suche select { max-width: 260px; }

/* Navigation: Register-Überschriften */
.side .nav-kopf { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8ea2bc; padding: .9rem .7rem .2rem; }
.tabs .tab-kopf { padding: .55rem .2rem .55rem .9rem; color: #9aa3b2; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; align-self: center; }

/* Nachweise */
.nachweis { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .8rem; background: #fff; }
.nachweis .nw-kopf { display: flex; justify-content: space-between; gap: .8rem; flex-wrap: wrap; align-items: flex-start; }
.nachweis .nw-kopf h3 { margin: 0 0 .2rem; }
.nachweis details > summary { cursor: pointer; color: var(--accent); font-size: .9rem; margin: .4rem 0; }
.nachweis-daten { margin: .6rem 0; }
.nachweis-daten dd { margin-bottom: .3rem; }
.bestaetigungen { border-top: 1px dashed var(--line); padding-top: .5rem; margin-top: .5rem; display: grid; gap: .15rem; }
.rueckfrage { background: var(--warn-soft); color: var(--warn); padding: .4rem .6rem; border-radius: 6px; margin-top: .3rem; }
.kb-tabelle td { padding: .25rem .4rem; }
.hinweis-box { background: var(--accent-soft); border-radius: 8px; padding: .7rem .9rem; font-size: .9rem; margin-bottom: 1rem; }
.hinweis-box.warn { background: var(--warn-soft); color: #5e3a00; }
.einwilligung-text { max-height: 45vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: .9rem; background: #fafbfc; font-size: .9rem; }

/* Verlaufsdiagramm */
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin: .8rem 0; }
.mini { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem .2rem; }
.mini figcaption { font-size: .85rem; margin-bottom: .2rem; min-height: 2.4em; }
.mini svg { width: 100%; height: auto; display: block; }
.mini .raster { stroke: #e7eaef; stroke-width: 1; }
.mini .achse { font-size: 10px; fill: #6b7383; }
.mini .linie { stroke-width: 2.5; }
.mini .linie.selbst { stroke: var(--accent); }
.mini .linie.fremd { stroke: #c27c0e; stroke-dasharray: 5 4; }
.mini .punkt.selbst { fill: var(--accent); }
.mini .punkt.fremd { fill: #fff; stroke: #c27c0e; stroke-width: 2; }
.legende .lg { display: inline-block; width: 22px; height: 0; border-top: 3px solid var(--accent); vertical-align: middle; margin: 0 .3rem 0 .6rem; }
.legende .lg:first-child { margin-left: 0; }
.legende .lg.fremd { border-top: 3px dashed #c27c0e; }
.ez-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.ez-karte { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
.ez-karte h3 { margin-bottom: .4rem; }
.ez-zeile { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .3rem 0; }

/* Druck */
#druck { display: none; }
.unterschriften { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 3rem; }
.unterschriften div { border-top: 1px solid #000; padding-top: .3rem; font-size: .85rem; }
@media print {
  body { background: #fff; }
  #app, #modal-root, #toast { display: none !important; }
  #druck { display: block; padding: 0; font-size: 11pt; }
  #druck .daten { grid-template-columns: 180px 1fr; }
  #druck .badge { border: 1px solid #999; background: none; }
}

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; padding: .6rem; }
  .side .brand { width: 100%; padding-bottom: .3rem; }
  .side .spacer { display: none; }
  main { padding: 1rem; }
  .formgrid { grid-template-columns: 1fr; }
}
