/* Komponenten nach DESIGN.md. Farben ausschließlich über Tokens aus tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px; line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.3px; }
h1 { font-size: 24px; white-space: nowrap; }
h2 { font-size: 18px; }
:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: Consolas, 'SFMono-Regular', Menlo, monospace; font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ── Kopfleiste ─────────────────────────────────────────────── */
.kopfleiste {
  position: sticky; top: 0; z-index: 80; height: var(--kopf-h);
  display: flex; align-items: center; gap: 20px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.marke { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: -.2px; }
.marke svg { width: 26px; height: 26px; color: var(--accent-strong); }
.hauptnav { display: flex; gap: 4px; margin-left: 8px; }
.hauptnav a {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px;
  border-radius: 999px; font-weight: 700; color: var(--text-2);
  border: 1px solid transparent;
}
.hauptnav a:hover { background: var(--accent-softer); }
.hauptnav a.on { background: var(--gelb-soft); border-color: var(--gelb-ring); color: var(--text); }
.kopf-rechts { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.benutzer { font-weight: 700; color: var(--text-2); }
@media (max-width: 760px) {
  .kopfleiste { gap: 8px; padding: 0 16px; }
  .kopfleiste .marke span { display: none; }
  .hauptnav { margin-left: 0; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
  .hauptnav::-webkit-scrollbar { display: none; }
  .hauptnav a { padding: 0 10px; }
  .benutzer { display: none; }
  .inhalt { padding: 0 16px 32px; }
}

/* ── Seite ──────────────────────────────────────────────────── */
.inhalt { max-width: 1280px; margin: 0 auto; padding: 0 24px 48px; }
.nachrichten { display: grid; gap: 8px; margin: 16px 0 0; }
.nachricht {
  padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); font-weight: 700;
}
.nachricht.success { background: var(--ok-bg); color: var(--ok-fg); }
.nachricht.error   { background: var(--bad-bg); color: var(--bad-fg); }
.nachricht.warning { background: var(--warn-bg); color: var(--warn-fg); }

/* ── Seitenkopf ─────────────────────────────────────────────── */
.seiten-kopf {
  position: sticky; top: var(--kopf-h); z-index: 60;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 10px 0 14px; background: var(--bg); box-shadow: var(--shadow-kopf);
}
.seiten-kopf .rechts { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
@media (max-width: 760px) {
  .seiten-kopf { grid-template-columns: 1fr; }
  .seiten-kopf .rechts { justify-content: flex-start; }
  h1 { white-space: normal; }
}

/* ── Knöpfe: genau drei Sorten ──────────────────────────────── */
.btn, .btn-sek, .btn-gefahr {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 999px;
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
}
.btn { background: var(--accent-strong); color: var(--primaer-schrift); }
.btn:hover { background: var(--accent-dark); }
.btn-sek { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-sek:hover { border-color: var(--accent); background: var(--accent-softer); }
.btn-gefahr { background: var(--surface); border-color: var(--bad-fg); color: var(--bad-fg); }
.btn-gefahr:hover { background: var(--bad-bg); }
.btn svg, .btn-sek svg, .btn-gefahr svg { width: 16px; height: 16px; }

/* ── Glas-Kapsel ────────────────────────────────────────────── */
.glas-leiste {
  display: flex; gap: 12px; align-items: center; flex-wrap: nowrap;
  width: fit-content; max-width: 100%; margin: 0 auto; padding: 7px 10px;
  border-radius: 999px; border: 1px solid var(--glas-rand);
  background: var(--glas-fond);
  -webkit-backdrop-filter: blur(20px) saturate(185%); backdrop-filter: blur(20px) saturate(185%);
  box-shadow: var(--glas-schatten);
}
@supports not (backdrop-filter: blur(1px)) { .glas-leiste { background: var(--surface); } }
.glas-leiste .btn-sek { border: none; background: transparent; }
.glas-leiste .btn-sek:hover { background: var(--accent-softer); }
@media (max-width: 620px) { .glas-leiste { flex-wrap: wrap; border-radius: 22px; width: 100%; } }

.suche { position: relative; }
.suche svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--text-2); pointer-events: none; }
.suche input[type="search"] {
  height: 36px; width: 260px; max-width: 100%; padding: 0 12px 0 36px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
}
.suche input::placeholder { color: var(--text-3); }
.suche input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); outline: none; }

.filter { position: relative; }
.filter-knopf {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  border-radius: var(--radius-sm); border: none; background: transparent;
  font: inherit; font-weight: 700; color: var(--text); cursor: pointer;
}
.filter-knopf:hover { background: var(--accent-softer); }
.filter-knopf svg { width: 16px; height: 16px; color: var(--accent-strong); }
.filter-knopf .anzahl { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--gelb-soft); color: var(--text); font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.filter-menue {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 70; min-width: 260px;
  padding: 14px; border-radius: var(--radius-lg); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--glas-schatten);
  display: none; gap: 10px;
}
.filter-menue[data-offen] { display: grid; }
.filter-menue label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.filter-menue .zeile { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* ── Formularfelder ─────────────────────────────────────────── */
input[type="text"], input[type="email"], input[type="number"], input[type="date"],
input[type="password"], input[type="tel"], input[type="search"], select, textarea {
  height: 38px; padding: 0 12px; width: 100%;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); outline: none; }
select[multiple] { height: auto; min-height: 120px; padding: 6px; }
.fehler { color: var(--bad-fg); font-weight: 700; font-size: 12px; }
.hilfe { color: var(--text-3); font-size: 12px; }

/* ── Etikett (grau, keine Aktion) ───────────────────────────── */
.etikett {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px;
  border-radius: 999px; background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--border); font-size: 11px; font-weight: 700; letter-spacing: .3px;
}

/* ── Status-Pillen ──────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.pill-ok   { background: var(--ok-bg);   color: var(--ok-fg); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill-bad  { background: var(--bad-bg);  color: var(--bad-fg); }
.pill-info { background: var(--info-bg); color: var(--info-fg); }
.pill-neu  { background: var(--gelb-soft); color: var(--text); }

/* ── Tabellen: Zeilen als Karten ────────────────────────────── */
table.karten { width: 100%; border-collapse: separate; border-spacing: 0 5px; }
table.karten thead th {
  position: sticky; top: calc(var(--kopf-h) + var(--seiten-kopf-h)); z-index: 50;
  height: 66px; padding: 0 16px; text-align: left;
  background: linear-gradient(var(--kopf-ueberlagerung), var(--kopf-ueberlagerung)), var(--surface-3);
  font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--text);
}
table.karten thead th:first-child { border-radius: 22px 0 0 22px; padding-left: 20px; }
table.karten thead th:last-child  { border-radius: 0 22px 22px 0; }
table.karten thead th.num { text-align: right; }
table.karten tbody td {
  height: 56px; padding: 10px 16px; background: var(--surface); font-size: 14px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
table.karten tbody td:first-child { border-left: 1px solid var(--border); border-radius: 22px 0 0 22px; padding-left: 20px; }
table.karten tbody td:last-child  { border-right: 1px solid var(--border); border-radius: 0 22px 22px 0; }
table.karten tbody tr[data-href] { cursor: pointer; }
table.karten tbody tr:hover td { background: var(--accent-softer); border-color: var(--accent-ring); }
table.karten tbody tr.gewaehlt td { background: var(--gelb-soft); }
table.karten .leer td { text-align: center; color: var(--text-2); font-weight: 700; height: 80px; }
table.karten .haupt { font-weight: 700; }
table.karten .neben { display: block; font-size: 12px; color: var(--text-2); font-weight: 600; }
/* Kein overflow auf Listenseiten, sonst wird der Wrapper zum Scroll-Container und
   der sticky Tabellenkopf klebt am Wrapper statt unter dem Seitenkopf. In Karten,
   Reitern und auf schmalen Bildschirmen ist der Kopf deshalb nicht sticky. */
.karte .tabelle-wrap, .dtab-inhalt .tabelle-wrap { overflow-x: auto; }
.karte table.karten thead th, .dtab-inhalt table.karten thead th { position: static; }
@media (max-width: 760px) {
  .tabelle-wrap { overflow-x: auto; }
  table.karten thead th, .karte table.karten thead th { position: static; }
}

/* ── Seitenwahl ─────────────────────────────────────────────── */
.seitenwahl { display: flex; align-items: center; gap: 6px; }
.seitenwahl a, .seitenwahl span.aktuell, .seitenwahl span.luecke {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 999px; font-weight: 700;
}
.seitenwahl a { border: 1px solid var(--border-strong); background: var(--surface); }
.seitenwahl a:hover { border-color: var(--accent); background: var(--accent-softer); }
.seitenwahl span.aktuell { background: var(--gelb-soft); border: 1px solid var(--gelb-ring); }
.seitenwahl span.luecke { color: var(--text-3); }
.zeilen-wahl { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-2); font-size: 12px; }
.zeilen-wahl select { width: auto; height: 34px; }

/* ── Kennzahlen und Karten ──────────────────────────────────── */
.kennzahlen { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 16px 0 20px; }
.kennzahl { padding: 14px 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.kennzahl .label { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .6px; }
.kennzahl .wert { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kennzahl .neben { font-size: 12px; color: var(--text-2); font-weight: 600; }
.kennzahl .wert-klein { font-size: 18px; }
.abstand-unten { margin-bottom: 16px; }
.karte { padding: 18px 20px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.karte + .karte { margin-top: 16px; }
.karte-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* ── Detailansicht ──────────────────────────────────────────── */
.detail-kopf { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 16px; padding: 18px 0 6px; }
.detail-kopf .titel { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-kopf .unterzeile { margin-top: 4px; color: var(--text-2); font-weight: 600; }
@media (max-width: 760px) { .detail-kopf { grid-template-columns: 1fr; } }

.dtab-leiste { display: flex; gap: 6px; padding: 6px; margin: 0 auto 16px; width: fit-content; max-width: 100%; overflow-x: auto; background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; }
.dtab { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 999px; font: inherit; font-size: 14px; font-weight: 800; color: var(--text-2); background: transparent; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.dtab svg { width: 16px; height: 16px; }
.dtab:hover { background: var(--accent-softer); }
.dtab.on { background: var(--gelb-soft); border-color: var(--gelb-ring); color: var(--text); }
.dtab.on svg { color: var(--accent-strong); }
.dtab-inhalt { display: none; }
.dtab-inhalt.on { display: block; }

.field { display: grid; grid-template-columns: minmax(150px, 230px) minmax(0, 1fr); gap: 10px 20px; padding: 11px 0; border-bottom: 1px solid var(--border); align-items: start; }
.field > label, .field > .bez { font-size: 13px; font-weight: 700; color: var(--text-2); padding-top: 9px; }
.field > .bez { padding-top: 0; }
.field > div { max-width: 420px; }
.field .wert { font-weight: 600; min-height: 20px; }
.field:last-child { border-bottom: none; }
@media (max-width: 760px) { .field { grid-template-columns: 1fr; gap: 4px; } .field > label { padding-top: 0; } }
.form-aktionen { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ── Dialog ─────────────────────────────────────────────────── */
dialog.dialog { padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
dialog.dialog::backdrop { background: var(--dialog-schleier); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog-kopf { padding: 14px 20px; background: var(--surface-3); font-weight: 800; font-size: 16px; }
.dialog-text { padding: 18px 20px; font-weight: 600; }
.dialog-fuss { display: flex; gap: 10px; justify-content: flex-end; padding: 0 20px 18px; }

/* ── Login ──────────────────────────────────────────────────── */
.login-seite { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-karte { width: min(400px, 100%); padding: 28px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.login-karte .marke { margin-bottom: 20px; font-size: 20px; }
.login-karte .field { grid-template-columns: 1fr; gap: 6px; }
.login-karte .field > label { padding-top: 0; }
.login-karte .field > div { max-width: none; }

/* ── Theme-Schalter ─────────────────────────────────────────── */
.theme-knopf { width: 38px; height: 38px; padding: 0; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.theme-knopf:hover { border-color: var(--accent); background: var(--accent-softer); }
.theme-knopf svg { width: 18px; height: 18px; }
.theme-knopf .mond { display: none; }
html[data-theme="dark"] .theme-knopf .sonne { display: none; }
html[data-theme="dark"] .theme-knopf .mond { display: block; }

/* ── Formulare / Dokumente ──────────────────────────────────── */
textarea.mono-text, .dokument-text { font-family: Consolas, 'SFMono-Regular', Menlo, monospace; font-size: 13px; line-height: 1.55; }
.dokument-text { margin: 0; white-space: pre-wrap; word-wrap: break-word; color: var(--text); font-weight: 500; }
.karte.dokument { padding: 28px 32px; max-width: 860px; }
.zweispaltig { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.zweispaltig form .field > div { max-width: none; }
.platzhalter-hilfe dl { margin: 0; display: grid; gap: 6px; }
.platzhalter-hilfe dt code { font-family: Consolas, Menlo, monospace; font-size: 12px; font-weight: 700; background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }
.platzhalter-hilfe dd { margin: 0 0 6px; font-size: 12px; color: var(--text-2); font-weight: 600; }
@media (max-width: 960px) { .zweispaltig { grid-template-columns: 1fr; } }
.schalter-liste { display: grid; gap: 8px; }
.schalter { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.schalter input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent-strong); margin: 0; }
.schmal { max-width: 140px; }
.dtab .anzahl { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.detail-kopf .glas-leiste form { display: contents; }
.abstand-oben { margin-top: 24px; }

/* ── Aufklappmenü und Toast ─────────────────────────────────── */
.karte-kopf .aktionen { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dropdown { position: relative; }
.dropdown-menue {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70; min-width: 230px;
  padding: 6px; border-radius: var(--radius-lg); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--glas-schatten); display: none;
}
.dropdown-menue[data-offen] { display: grid; gap: 2px; }
.dropdown-menue a, .dropdown-menue button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); border: none; background: transparent; text-align: left;
  font: inherit; font-weight: 700; color: var(--text); cursor: pointer;
}
.dropdown-menue a:hover, .dropdown-menue button:hover { background: var(--accent-softer); }
.dropdown-menue svg { width: 16px; height: 16px; color: var(--accent-strong); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); z-index: 90;
  padding: 10px 16px; border-radius: 999px; background: var(--text); color: var(--bg);
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── Exposé ─────────────────────────────────────────────────── */
.bilder-platzhalter { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.bilder-platzhalter.klein { grid-template-columns: repeat(3, 1fr); }
.bild-kachel { aspect-ratio: 4 / 3; max-height: 200px; border-radius: var(--radius); background: var(--surface-3); border: 1px dashed var(--border-strong); }
.bild-kachel:first-child { grid-row: span 2; aspect-ratio: auto; }
.bilder-platzhalter.klein .bild-kachel:first-child { grid-row: auto; aspect-ratio: 4 / 3; }
.bilder-hinweis { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; font-weight: 800; color: var(--text-2); pointer-events: none; }
.expose-text h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); margin: 18px 0 6px; }
.expose-text p { margin: 0; font-weight: 500; max-width: 820px; line-height: 1.6; }
.merkmale { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
@media (max-width: 760px) { .bilder-platzhalter { grid-template-columns: repeat(2, 1fr); } .bild-kachel:first-child { grid-row: auto; aspect-ratio: 4 / 3; } }
.formset-tabelle tbody td { height: auto; padding: 8px 10px; }
.formset-tabelle input, .formset-tabelle select { height: 34px; min-width: 110px; }
.formset-tabelle thead th { position: static; height: 44px; }
.schalter.klein { font-size: 12px; white-space: nowrap; }
[data-formset] > .btn-sek { margin-top: 8px; }

.leer-hinweis { padding: 40px 20px; text-align: center; color: var(--text-2); font-weight: 700; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
