/* Edikte-Monitor – ruhige Arbeitsliste (Marke Immo-in-Not) */
:root {
  --primaer: #1e40af;
  --primaer-dunkel: #1e3a8a;
  --primaer-hell: #3b82f6;
  --akzent: #f59e0b;
  --erfolg: #10b981;
  --gefahr: #ef4444;
  --text: #1f2937;
  --text-grau: #6b7280;
  --rahmen: #e5e7eb;
  --flaeche: #f9fafb;
  --karte: #ffffff;
  --weiss: #ffffff;
  /* abgeleitet für WCAG-AA-Kontrast bei Text/Knöpfen */
  --link: var(--primaer);
  --knopf-ja: #047857;
  --nein-text: #b91c1c;
  --gelb-text: #1f2937;
  --gelb-flaeche: #fef3c7;
  --hinweis-flaeche: #eff6ff;
  /* bleibt im Dunkelmodus dunkel: weißer Text darauf muss lesbar sein */
  --gefahr-flaeche: #b91c1c;
  --fokus: #3b82f6;
  --navi-hoehe: 64px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e2e8f0;
    --text-grau: #94a3b8;
    --rahmen: #334155;
    --flaeche: #0f172a;
    --karte: #1e293b;
    --link: #93c5fd;
    --nein-text: #fca5a5;
    --gelb-flaeche: #422006;
    --gelb-text: #fde68a;
    --hinweis-flaeche: #172554;
    --fokus: #93c5fd;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--flaeche);
  overflow-wrap: anywhere;
}
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.leise { color: var(--text-grau); font-size: 0.9rem; }
.hinweis { color: var(--text-grau); padding: 16px 0; }
.fehler { color: var(--nein-text); font-weight: 600; padding: 8px 0; }

/* ── Bänder ───────────────────────────────────────────────── */
.demo-band {
  position: fixed; top: env(safe-area-inset-top); right: 8px; z-index: 30;
  background: var(--akzent); color: #1f2937; font-size: 0.75rem; font-weight: 700;
  padding: 2px 10px; border-radius: 0 0 6px 6px; letter-spacing: 0.04em; pointer-events: none;
}
.verbindung {
  position: sticky; top: 0; z-index: 25; background: var(--gefahr-flaeche); color: #fff;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); text-align: center; font-weight: 600;
}
.stand-band {
  background: var(--hinweis-flaeche); color: var(--text); text-align: center; font-weight: 600;
  padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top)); border-bottom: 1px solid var(--rahmen);
}
.start {
  min-height: 60dvh; display: grid; place-content: center; justify-items: center; gap: 16px;
  padding: 24px 16px; color: var(--text-grau); font-weight: 600;
}

/* ── Anmeldung ────────────────────────────────────────────── */
.anmeldung { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-karte {
  width: 100%; max-width: 380px; background: var(--karte); border: 1px solid var(--rahmen);
  border-radius: 14px; padding: 28px 24px; display: flex; flex-direction: column; gap: 8px;
}
.login-logo { border-radius: 14px; align-self: center; }
.login-karte h1 { text-align: center; font-size: 1.5rem; color: var(--link); }
.login-karte .leise { text-align: center; margin-bottom: 12px; }
.login-karte label { font-weight: 600; margin-top: 8px; }
.login-karte input, .suchfeld {
  min-height: 48px; padding: 10px 14px; font-size: 16px; border: 1px solid var(--rahmen);
  border-radius: 10px; background: var(--karte); width: 100%;
}
.login-karte .knopf { margin-top: 16px; }

/* ── Knöpfe ───────────────────────────────────────────────── */
.knopf {
  min-height: 48px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; text-align: center;
  transition: background-color 150ms, opacity 150ms;
}
.knopf:disabled { opacity: 0.55; cursor: progress; }
.knopf[data-gesperrt] { cursor: not-allowed; }
.knopf-primaer { background: var(--primaer); color: #fff; }
.knopf-primaer:hover { background: var(--primaer-dunkel); }
.knopf-ja { background: var(--knopf-ja); color: #fff; }
.knopf-nein { background: transparent; color: var(--nein-text); border-color: currentColor; }
.knopf-leise, .knopf-klein { background: transparent; color: var(--text); border-color: var(--rahmen); }
.knopf-klein { font-weight: 500; color: var(--text-grau); }
.knopf-gelb { background: var(--akzent); color: #1f2937; }
.knopf-gross { width: 100%; font-size: 1.05rem; }
.knopf[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--karte), 0 0 0 5px currentColor; }
.knopf-ja[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--karte), 0 0 0 5px var(--knopf-ja); }
.knopf[aria-pressed="true"]::before { content: "✓ "; white-space: pre; }

/* ── Navigation ───────────────────────────────────────────── */
.navi {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  background: var(--karte); border-top: 1px solid var(--rahmen);
  padding-bottom: env(safe-area-inset-bottom);
}
.navi-marke { display: none; }
.navi a {
  flex: 1; min-height: var(--navi-hoehe); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; text-decoration: none; color: var(--text-grau);
  font-size: 0.75rem; font-weight: 600; position: relative;
}
.navi a[aria-current="page"] { color: var(--link); }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--primaer); color: #fff; font-size: 0.7rem; line-height: 20px;
  text-align: center; font-variant-numeric: tabular-nums;
}

/* ── Spalten (Handy: eine Ansicht) ───────────────────────── */
.spalten { padding-bottom: calc(var(--navi-hoehe) + env(safe-area-inset-bottom) + 16px); }
.spalte-detail { display: none; }
body.mit-detail .spalte-liste { display: none; }
body.mit-detail .spalte-detail { display: block; }

.panel { padding: 0 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.kopf {
  padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.kopf h1 { font-size: 1.5rem; }
.umschalter { display: inline-flex; border: 1px solid var(--rahmen); border-radius: 10px; overflow: hidden; align-self: flex-start; background: var(--karte); }
.umschalter button {
  min-height: 48px; padding: 0 16px; border: 0; background: transparent;
  color: var(--text-grau); font-weight: 600; cursor: pointer;
}
.umschalter button[aria-pressed="true"] { background: var(--primaer); color: #fff; }
.such-info { font-weight: 600; min-height: 1.5em; }
.abschnitt { font-size: 1.1rem; margin: 20px 0 10px; }
.anzahl { color: var(--text-grau); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ── Karten ───────────────────────────────────────────────── */
.karten { display: flex; flex-direction: column; gap: 12px; }
.karte {
  background: var(--karte); border: 1px solid var(--rahmen); border-radius: 12px; overflow: hidden;
  transition: transform 180ms ease, opacity 180ms ease;
}
.karte.weg { transform: translateX(-40%); opacity: 0; }
.karte-link {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; color: inherit; text-decoration: none;
}
.karte-link:hover .karte-titel { color: var(--link); }
.karte-link[aria-current="true"] { box-shadow: inset 4px 0 0 var(--primaer); background: var(--hinweis-flaeche); }
.karte-titel { font-size: 17px; font-weight: 600; line-height: 1.3; }
.karte-ort, .karte-fakten { color: var(--text-grau); font-size: 0.95rem; }
.karte-fakten { font-variant-numeric: tabular-nums; }
.karte-eigentuemer { font-size: 0.95rem; }
.termin { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; font-variant-numeric: tabular-nums; }
.termin-datum { font-weight: 700; font-size: 1.05rem; color: var(--link); }
.termin-rel { color: var(--text-grau); font-size: 0.9rem; font-weight: 600; }
.termin-vorbei .termin-datum { color: var(--text-grau); text-decoration: line-through; }
.termin-leer { color: var(--text-grau); font-size: 0.9rem; }
.karte-aktionen {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px 14px;
}
.karte-aktionen .knopf-klein { grid-column: 1 / -1; }
.karte-aktionen .fehler { grid-column: 1 / -1; }

.marken { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.marke {
  font-size: 0.8rem; font-weight: 600; padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--rahmen); color: var(--text-grau);
}
.marke-gelb { background: var(--akzent); border-color: var(--akzent); color: #1f2937; }
.marke-hinweis { background: var(--hinweis-flaeche); color: var(--link); border-color: transparent; }

.leer { text-align: center; padding: 48px 16px; color: var(--text-grau); }
.leer-titel { font-size: 1.25rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* ── Detail ───────────────────────────────────────────────── */
.detail-leiste {
  /* --band-hoehe setzt app.js, solange das Offline-Band oben klebt */
  position: sticky; top: var(--band-hoehe, 0px); z-index: 5; background: var(--flaeche);
  padding: env(safe-area-inset-top) 8px 0; border-bottom: 1px solid var(--rahmen);
}
.knopf-zurueck {
  min-height: 48px; display: inline-flex; align-items: center; gap: 4px; padding: 0 12px 0 4px;
  background: none; border: 0; color: var(--link); font-weight: 600; cursor: pointer;
}
.detail-inhalt { padding: 0 16px 24px; }
.leer-detail { color: var(--text-grau); padding: 48px 0; text-align: center; }
.detail { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.detail-kopf { padding: 16px 0 4px; display: flex; flex-direction: column; gap: 4px; }
.detail-titel { font-size: 1.5rem; line-height: 1.25; }
.detail-titel:focus { outline: none; }
.detail-ort { color: var(--text-grau); }

.block {
  background: var(--karte); border: 1px solid var(--rahmen); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.block h2 { color: var(--text-grau); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.8rem; }
.block h3 { font-size: 0.95rem; }
.block ol { margin: 0; padding-left: 1.4em; }
.felder { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.feld dt { color: var(--text-grau); font-size: 0.85rem; }
.feld dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.feld:first-child { grid-column: 1 / -1; }
.termin-gross { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: baseline; font-size: 1.35rem; color: var(--link); }
.termin-gross .termin-rel { font-size: 0.95rem; }
.text { white-space: pre-line; }
.notizen { font-size: 0.95rem; }
details summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--link); }
.hinweis-box { background: var(--hinweis-flaeche); border-radius: 8px; padding: 10px 12px; }

.unterlagen { display: flex; flex-direction: column; gap: 12px; }
.dateien ul { list-style: none; margin: 4px 0 0; padding: 0; }
.links { display: flex; flex-direction: column; }
.link-zeile {
  min-height: 48px; display: flex; align-items: center; border-top: 1px solid var(--rahmen);
  font-weight: 600; text-decoration: none;
}
.link-zeile::after { content: "↗"; margin-left: auto; padding-left: 8px; color: var(--text-grau); }

.entscheid-gruppe { display: grid; gap: 12px; }
.entscheid { display: flex; flex-direction: column; gap: 4px; }
.entscheid .knopf { width: 100%; }
.erklaerung { color: var(--text-grau); font-size: 0.875rem; }
.detail-fuss { color: var(--text-grau); font-size: 0.85rem; padding: 4px 0 8px; }

.mehr-name { font-weight: 600; font-size: 1.1rem; }
#panel-mehr .block { margin-bottom: 12px; }

/* ── Leiste (Rückgängig) ──────────────────────────────────── */
.leiste {
  position: fixed; left: 16px; right: 16px; z-index: 40;
  bottom: calc(var(--navi-hoehe) + env(safe-area-inset-bottom) + 12px);
  display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 16px; min-height: 56px;
  background: #1f2937; color: #fff; border-radius: 12px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: transform 180ms, opacity 180ms;
}
.leiste.offen { transform: none; opacity: 1; pointer-events: auto; }
.leiste span { flex: 1; }
.leiste-knopf {
  min-height: 48px; padding: 0 16px; border: 0; border-radius: 8px; background: transparent;
  color: #93c5fd; font-weight: 700; cursor: pointer;
}

/* ── Desktop: Seitenleiste + Liste + Detail ───────────────── */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 220px 1fr; height: 100dvh; }
  .navi {
    position: static; flex-direction: column; border-top: 0; border-right: 1px solid var(--rahmen);
    padding: 16px 12px; gap: 4px; background: var(--karte);
  }
  .navi-marke { display: block; font-weight: 700; color: var(--link); padding: 4px 12px 16px; font-size: 1.05rem; }
  .navi a {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px;
    padding: 0 12px; border-radius: 10px; font-size: 1rem;
  }
  .navi a[aria-current="page"] { background: var(--primaer); color: #fff; }
  .navi a[aria-current="page"] .badge { background: #fff; color: var(--primaer); }
  .badge { position: static; margin-left: auto; }
  .spalten {
    display: grid; grid-template-columns: minmax(340px, 420px) 1fr; padding: 0; min-height: 0;
  }
  .spalte-liste, .spalte-detail { overflow-y: auto; min-height: 0; }
  .spalte-liste { border-right: 1px solid var(--rahmen); padding-bottom: 24px; }
  body.mit-detail .spalte-liste, .spalte-detail { display: block; }
  body[data-tab="mehr"] .spalten { grid-template-columns: 1fr; }
  body[data-tab="mehr"] .spalte-detail { display: none; }
  body[data-tab="mehr"] .panel { max-width: 720px; }
  body:not(.mit-detail) .detail-leiste { display: none; }
  .detail-leiste { background: var(--flaeche); top: 0; }
  .detail-inhalt { padding: 0 32px 32px; }
  .kopf { position: sticky; top: 0; z-index: 2; background: var(--flaeche); padding-top: 20px; }
  .leiste { left: auto; right: 24px; bottom: 24px; width: 420px; }
  .entscheid-gruppe { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
