/* Serova CRM. Farben und Schrift wie serova.ch: Navy, Rot, Spinnaker für Überschriften. Zuerst fürs Handy gebaut. */
@font-face {
  font-family: Spinnaker;
  src: url("schrift/spinnaker.woff2") format("woff2");
  font-display: swap;
}

:root {
  --navy: #1a2b6d;
  --navy-dunkel: #121e4e;
  --rot: #d41317;
  --grund: #f4f5f9;
  --karte: #ffffff;
  --text: #1c2233;
  --leise: #5b6170;
  --linie: #dde0e8;
  --gut: #1f7a4c;
  --gut-grund: #e3f3ea;
  --warn: #8a5a00;
  --warn-grund: #fff2d6;
  --schlecht: #b0141a;
  --schlecht-grund: #fde4e4;
  --info: #1a4f9c;
  --info-grund: #e3ecfa;
  --radius: 12px;
  --schatten: 0 1px 2px rgba(20, 30, 70, .06), 0 4px 16px rgba(20, 30, 70, .06);
  --nav-hoehe: 64px;
  --rand: #7b8194;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; scroll-padding-bottom: calc(var(--nav-hoehe) + 80px); }
body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
h1, h2, h3 { font-family: Spinnaker, system-ui, sans-serif; color: var(--navy); font-weight: 400; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1rem; }
a { color: var(--navy); }
p { margin: 0 0 .75rem; }
small { color: var(--leise); }
.block { display: block; }
code { background: var(--grund); padding: .1rem .35rem; border-radius: 4px; word-break: break-all; }
.laedt { padding: 3rem 1rem; text-align: center; color: var(--leise); }
.sprung { position: absolute; left: -9999px; }
.sprung:focus { left: 1rem; top: 1rem; z-index: 50; background: #fff; padding: .5rem 1rem; }
:focus-visible { outline: 3px solid var(--rot); outline-offset: 2px; }
.kopf :focus-visible { outline-color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Gerüst ---------- */
.kopf {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  padding: .6rem max(1rem, env(safe-area-inset-right)) .6rem max(1rem, env(safe-area-inset-left)); padding-top: max(.6rem, env(safe-area-inset-top));
  background: var(--navy); color: #fff;
}
.marke { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-family: Spinnaker, sans-serif; letter-spacing: .08em; }
.marke img { height: 28px; width: auto; border-radius: 4px; }
.kopf .knopf.leise { color: #fff; border-color: rgba(255, 255, 255, .35); background: transparent; }

.kopf-rechts { display: flex; align-items: center; gap: .4rem; }
.kopf-einstellungen { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: #fff; border-radius: 8px; }
.kopf-einstellungen .symbol { width: 24px; height: 24px; }
.navigation .nav-link[data-ziel="einstellungen"] { display: none; }
.navigation {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: #fff; border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-hoehe); padding: .3rem .1rem;
  color: var(--leise); text-decoration: none; font-size: .72rem; text-align: center; overflow-wrap: anywhere;
}
.nav-link[aria-current="page"] { color: var(--navy); font-weight: 600; }
.nav-link[aria-current="page"] .symbol { stroke: var(--rot); }
.symbol { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.inhalt { max-width: 1100px; margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-right)) calc(var(--nav-hoehe) + 2rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
.inhalt h1:focus { outline: none; }
.inhalt:focus { outline: none; }

@media (min-width: 900px) {
  .navigation {
    top: 56px; bottom: 0; right: auto; width: 210px;
    display: flex; flex-direction: column; gap: .2rem; padding: 1rem .6rem;
    border-top: 0; border-right: 1px solid var(--linie);
  }
  .nav-link { flex-direction: row; justify-content: flex-start; gap: .7rem; min-height: 44px; padding: .5rem .8rem; border-radius: 8px; font-size: .95rem; }
  .navigation .nav-link[data-ziel="einstellungen"] { display: flex; }
  .kopf-einstellungen { display: none; }
  .nav-link:hover { background: var(--grund); }
  .nav-link[aria-current="page"] { background: var(--info-grund); }
  .inhalt { margin-left: 210px; padding: 1.5rem 2rem 3rem; }
  @supports (margin-left: max(0px, 1px)) {
    .inhalt { margin-left: max(210px, calc((100vw - 1100px) / 2 + 105px)); }
  }
}

/* ---------- Seiten ---------- */
.seitenkopf { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1rem; }
.seitenkopf h1 { margin: 0; }
.unter { color: var(--leise); margin: .25rem 0 0; }
.brotkrumen { margin: 0 0 .2rem; font-size: .9rem; }
.brotkrumen a { color: var(--leise); }

.karte { background: var(--karte); border-radius: var(--radius); box-shadow: var(--schatten); padding: 1rem; margin-bottom: 1rem; min-width: 0; }
.warnkarte { border-left: 4px solid var(--rot); }
.raster { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.raster > .karte { margin: 0; }
@media (min-width: 700px) { .raster { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.kennzahlen { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
@media (min-width: 900px) { .kennzahlen { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }
.kennzahl { background: var(--karte); border-radius: var(--radius); box-shadow: var(--schatten); padding: .8rem 1rem; min-width: 0; }
.kz-titel { display: block; font-size: .8rem; color: var(--leise); }
.kz-wert { display: block; font-size: 1.15rem; color: var(--navy); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.minus { color: var(--schlecht); }
.plus { color: var(--gut); }

.werkzeugleiste { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.werkzeugleiste input[type="search"] { flex: 1 1 220px; }

/* ---------- Listen ---------- */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li + li { border-top: 1px solid var(--linie); }
.listenzeile { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .2rem; color: inherit; text-decoration: none; min-width: 0; }
a.listenzeile:hover { background: var(--grund); }
.haupttext { display: flex; flex-direction: column; min-width: 0; flex: 1 1 12rem; }
.haupttext strong { overflow-wrap: anywhere; }
.rechts { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .4rem; text-align: right; flex-shrink: 0; margin-left: auto; }
.leer { color: var(--leise); margin: .5rem 0; }
.punkte { margin: 0; padding-left: 1.2rem; }
.betrag { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; background: var(--grund); color: var(--leise); white-space: nowrap; }
.pill.gut { background: var(--gut-grund); color: var(--gut); }
.pill.warn { background: var(--warn-grund); color: var(--warn); }
.pill.schlecht { background: var(--schlecht-grund); color: var(--schlecht); }
.pill.info { background: var(--info-grund); color: var(--info); }
.pill.grau { background: #eceef3; color: var(--leise); }

/* ---------- Tabellen ---------- */
.tabelle-rahmen { overflow-x: auto; margin: .5rem 0 1rem; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tabelle th { text-align: left; font-weight: 600; color: var(--leise); font-size: .8rem; padding: .4rem .5rem; border-bottom: 2px solid var(--navy); }
.tabelle td { padding: .5rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
.tabelle .rechts, .tabelle th.rechts { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabelle tr.summe td { font-weight: 700; border-top: 2px solid var(--navy); }
.tabelle.kompakt td { padding: .35rem .4rem; }
.berechnung { margin: 1rem 0; padding: 1rem; background: var(--grund); border-radius: var(--radius); }
.berechnung:empty { display: none; }

/* ---------- Formulare ---------- */
.formular { display: flex; flex-direction: column; gap: .9rem; }
.felder { display: grid; gap: .8rem 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .felder { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.feld { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.feld.breit { grid-column: 1 / -1; }
.feld label, .feld .label { font-size: .85rem; font-weight: 600; color: var(--text); }
.feld-haken { flex-direction: row; align-items: flex-start; gap: .6rem; }
.feld-haken label { font-weight: 400; font-size: .95rem; flex: 1 1 0; min-width: 0; }
.feld-haken .hinweis { flex-basis: 100%; }
.feld-haken { flex-wrap: wrap; }
.hinweis { color: var(--leise); font-size: .85rem; }
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  min-height: 44px; padding: .55rem .7rem;
  border: 1px solid var(--rand); border-radius: 8px; background: #fff;
}
::placeholder { color: #6b7180; opacity: 1; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--navy); flex-shrink: 0; }
input[readonly] { background: var(--grund); }
input.ungueltig, input[aria-invalid="true"] { border-color: var(--schlecht); border-width: 2px; }
.gruppe { border: 1px solid var(--linie); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0; min-width: 0; }
.gruppe legend { font-family: Spinnaker, sans-serif; color: var(--navy); padding: 0 .4rem; }
.hakenliste { display: grid; gap: .45rem; grid-template-columns: minmax(0, 1fr); margin: .4rem 0; }
@media (min-width: 640px) { .hakenliste { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hakenliste.aus { opacity: .4; pointer-events: none; }
.haken { display: flex; align-items: flex-start; gap: .6rem; padding: .4rem 0; cursor: pointer; }
.haken.gesperrt { opacity: .55; cursor: not-allowed; }
.segmente { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.segmente label { position: relative; }
.segmente input { position: absolute; opacity: 0; }
.segmente span { display: inline-block; padding: .55rem .9rem; min-height: 44px; border: 1px solid var(--rand); border-radius: 999px; background: #fff; cursor: pointer; }
.segmente input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.segmente input:focus-visible + span { outline: 3px solid var(--rot); outline-offset: 2px; }
.segmente input:disabled + span { opacity: .45; cursor: not-allowed; }
.formfehler { color: var(--schlecht); margin: 0; min-height: 0; }
.formfehler:empty { display: none; }
.hinweisbox { background: var(--info-grund); border-radius: 8px; padding: .8rem 1rem; font-size: .92rem; }
.hinweisbox p:last-child { margin: 0; }

.positionen { display: flex; flex-direction: column; gap: .6rem; }
.position { display: grid; gap: .4rem; grid-template-columns: minmax(0, 1fr) auto; padding: .6rem; background: var(--grund); border-radius: 8px; }
.position input:nth-child(1), .position input:nth-child(2) { grid-column: 1 / -1; }
.position .betrag-eingabe { text-align: right; font-variant-numeric: tabular-nums; }
@media (min-width: 760px) {
  .position { grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 130px auto; background: none; padding: 0; }
  .position input:nth-child(1), .position input:nth-child(2) { grid-column: auto; }
}
.summe-zeile { font-weight: 700; color: var(--navy); text-align: right; font-size: 1.1rem; }

/* ---------- Knöpfe ---------- */
.knopfreihe { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.knopfreihe > select, .knopfreihe > input { width: auto; flex: 1 1 140px; }
.knopfreihe.klebend { position: sticky; bottom: calc(var(--nav-hoehe) + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .95); padding: .7rem 0; border-top: 1px solid var(--linie); z-index: 5; }
@media (min-width: 900px) { .knopfreihe.klebend { bottom: 0; } }
/* Auf dem Handy die Knöpfe der festen Leiste in zwei Spalten, damit sie nicht ein Viertel des Bildschirms belegt */
@media (max-width: 599px) {
  .knopfreihe.klebend { gap: .4rem; padding: .5rem 0; }
  .knopfreihe.klebend > .knopf { flex: 1 1 40%; padding: .4rem .6rem; font-size: .92rem; }
}
/* Bei wenig Höhe (Handy quer, Tastatur offen) würde die Leiste die Felder verdecken */
@media (max-height: 520px) { .knopfreihe.klebend { position: static; } }
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .5rem 1rem; border-radius: 8px;
  border: 1px solid var(--rand); background: #fff; color: var(--navy);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.knopf:hover { border-color: var(--navy); }
.knopf.haupt { background: var(--navy); border-color: var(--navy); color: #fff; }
.knopf.haupt:hover { background: var(--navy-dunkel); }
.knopf.gefahr { color: var(--schlecht); border-color: #e6b3b5; }
.knopf.haupt.gefahr { background: var(--schlecht); border-color: var(--schlecht); color: #fff; }
.knopf.klein { min-height: 36px; padding: .3rem .8rem; font-size: .9rem; }
.knopf.breit { width: 100%; }
.knopf:disabled, .knopf[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.knopf[aria-busy="true"] { opacity: .6; cursor: progress; }
.mini-knopf { background: none; border: 1px solid var(--linie); border-radius: 6px; padding: .2rem .55rem; min-height: 32px; min-width: 32px; cursor: pointer; color: var(--leise); font: inherit; font-size: .85rem; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; margin-left: .25rem; }
.mini-knopf:hover { color: var(--schlecht); border-color: var(--schlecht); }
@media (pointer: coarse) { .mini-knopf { min-height: 44px; min-width: 44px; } }
.mini { font-size: .85rem; color: var(--leise); }

/* ---------- Verlauf ---------- */
.verlauf-neu { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.verlauf { list-style: none; margin: 0; padding: 0; }
.verlauf li { padding: .6rem 0; border-top: 1px solid var(--linie); }
.verlauf-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .9rem; }
.verlauf-kopf span { color: var(--leise); }
.mehrzeilig { white-space: pre-wrap; margin: .3rem 0 0; overflow-wrap: anywhere; }

/* ---------- Balken ---------- */
.balken { height: 12px; background: var(--grund); border-radius: 999px; overflow: hidden; margin: .5rem 0; }
.balken span { display: block; height: 100%; background: var(--navy); border-radius: 999px; }
.balken span.hoch { background: var(--rot); }

/* ---------- Anmeldung ---------- */
.anmelde-seite { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1.5rem 1rem; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dunkel) 100%); }
.anmelde-karte { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 1.6rem 1.4rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.anmelde-logo { display: block; height: auto; max-width: 200px; margin-bottom: 1.2rem; border-radius: 6px; }

/* ---------- Dialog und Meldungen ---------- */
.dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dialog::backdrop { background: rgba(18, 30, 78, .45); }
.dialog-form { padding: 1.3rem; display: flex; flex-direction: column; gap: .9rem; }
.dialog-form .knopfreihe { justify-content: flex-end; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-hoehe) + 1rem + env(safe-area-inset-bottom)); transform: translate(-50%, 2rem);
  max-width: min(92vw, 520px); padding: .75rem 1.1rem; border-radius: 10px; z-index: 100;
  background: var(--navy); color: #fff; box-shadow: var(--schatten); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.sichtbar { opacity: 1; transform: translate(-50%, 0); }
.toast-fehler { background: var(--schlecht); }
.toast-warn { background: #7a4e00; }
@media (min-width: 900px) { .toast { bottom: 1.5rem; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

.anleitung { margin: .8rem 0; }
.anleitung summary { cursor: pointer; font-weight: 600; color: var(--navy); min-height: 44px; display: flex; align-items: center; }
.anleitung ol { padding-left: 1.2rem; }
.anleitung li { margin-bottom: .4rem; }

/* Seite für Meldungen ohne App (onedrive.php) */
.einfach { max-width: 40rem; margin: 0 auto; padding: 2rem 1rem; }

/* Windows mit hohem Kontrast: Rahmen und Auswahl bleiben sichtbar */
@media (forced-colors: active) {
  .knopf, .pill, .mini-knopf, .segmente span, .karte, .kennzahl, .dialog { border: 1px solid ButtonText; }
  .nav-link[aria-current="page"], .kopf-einstellungen[aria-current="page"] { outline: 2px solid Highlight; }
  .segmente input:checked + span { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .balken span { background: Highlight; }
}
.kopf-einstellungen[aria-current="page"] { background: rgba(255, 255, 255, .18); }
