/* MFH-Verwaltung – eigenes Erscheinungsbild nach Apple Human Interface Guidelines (siehe docs/DESIGN.md).
   Mobile zuerst. Schriftgrössen in rem (skaliert mit der Systemschrift, bis 200 %). */
:root {
  /* Farben: semantische Tokens, je hell / dunkel / erhöhter Kontrast */
  --bg: #f2f2ef;            /* primärer Hintergrund (gruppiert) */
  --flaeche: #ffffff;       /* sekundär: Gruppen, Karten */
  --flaeche-2: #f7f7f4;     /* tertiär: Gruppen in Gruppen */
  --text: #1c1f1e;          /* label */
  --leise: #5b6461;         /* secondaryLabel */
  --linie: #d9d8d2;         /* separator */
  --primaer: #1f5c4a;       /* Akzent nur für Bedienbares */
  --primaer-text: #ffffff;
  --primaer-hell: #e2eee8;
  --leiste: rgba(255, 255, 255, .82);   /* Material für Kopf- und Tab-Leiste */
  --ok: #1e6b3a; --ok-bg: #e2f2e7;
  --info: #24527a; --info-bg: #e3edf6;
  --warn: #7a5300; --warn-bg: #fbf0d4;
  --alarm: #9b1c1c; --alarm-bg: #fbe3e1;
  --grau: #5b6461; --grau-bg: #ebeae5;
  --radius: 12px;
  --schatten: 0 1px 2px rgba(0, 0, 0, .05);
  /* Typografie: iOS-Textstile (Grösse / Zeilenhöhe), Systemschrift */
  --schrift: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t-title1: 1.75rem;      /* 28/34 */
  --t-title3: 1.25rem;      /* 20/25 */
  --t-headline: 1.0625rem;  /* 17/22 semibold */
  --t-body: 1.0625rem;      /* 17/22 */
  --t-subhead: .9375rem;    /* 15/20 */
  --t-footnote: .8125rem;   /* 13/18 */
  --t-caption1: .75rem;     /* 12/16 */
  --t-caption2: .6875rem;   /* 11/13 – Minimum */
  --ziel: 44px;             /* Mindestgrösse Bedienelemente */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --flaeche: #1c1c1e; --flaeche-2: #2c2c2e; --text: #f2f3f2; --leise: #a4aba8; --linie: #38383a;
    --primaer: #62c39d; --primaer-text: #06140f; --primaer-hell: #17352a; --leiste: rgba(28, 28, 30, .8);
    --ok: #7fd19d; --ok-bg: #143020; --info: #8fbde6; --info-bg: #15283a;
    --warn: #f0c565; --warn-bg: #362b10; --alarm: #ff9b94; --alarm-bg: #3d1716; --grau: #a4aba8; --grau-bg: #2c2c2e;
    --schatten: none; color-scheme: dark;
  }
}
@media (prefers-contrast: more) {
  :root { --leise: #3b4240; --linie: #9e9b92; --grau: #3b4240; --primaer: #134536; --leiste: #ffffff; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --leise: #d0d6d3; --linie: #6b6b70; --grau: #d0d6d3; --primaer: #8ee0bf; --leiste: #1c1c1e; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--schrift); font-size: var(--t-body); line-height: 1.35;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--primaer); }
h1 { font-size: var(--t-title1); line-height: 1.214; font-weight: 700; margin: .2rem 0 1rem; text-wrap: balance; }
h2 { font-size: var(--t-title3); line-height: 1.25; font-weight: 600; margin: 1.6rem 0 .6rem; text-wrap: balance; }
h3 { font-size: var(--t-headline); line-height: 1.294; font-weight: 600; margin: 1.2rem 0 .4rem; }
p { margin: .4rem 0 .8rem; line-height: 1.45; }   /* lockere Zeilenhöhe für Fliesstext */
.leise { color: var(--leise); font-size: var(--t-subhead); line-height: 1.333; }
.klein { font-size: var(--t-footnote); line-height: 1.385; }
.rechts { text-align: right; }
.betrag, td.betrag, th.betrag { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
:focus-visible { outline: 3px solid var(--primaer); outline-offset: 2px; border-radius: 4px; }

/* Kopfleiste: neutral (kein Markenfarb-Balken), Material mit Unschärfe */
.kopf {
  position: sticky; top: 0; z-index: 20; background: var(--flaeche); border-bottom: 1px solid var(--linie);
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 12px; min-height: 52px;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .kopf, .unten { background: var(--leiste); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
}
.kopf .marke { color: var(--text); text-decoration: none; font-weight: 700; font-size: var(--t-headline); display: inline-flex; align-items: center; gap: 8px; min-height: var(--ziel); }
.kopf .marke svg { width: 26px; height: 26px; color: var(--primaer); flex: 0 0 auto; }
.kopf .platz { flex: 1; }
.kopf .suche { display: none; }
.testbanner { background: #b45309; color: #fff; text-align: center; font-weight: 700; padding: 4px; font-size: var(--t-footnote); }

.rahmen { display: block; }
main { max-width: 1100px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left)); min-width: 0; }

/* Seitenleiste (nur breite Bildschirme): ersetzt die Tab-Leiste, max. zwei Ebenen */
.seitenleiste { display: none; }

/* Tab-Leiste (Handy): Tabs navigieren nur, sie lösen keine Aktionen aus */
.unten {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--flaeche);
  border-top: 1px solid var(--linie); display: flex;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.unten a {
  flex: 1; text-align: center; text-decoration: none; color: var(--leise); font-size: var(--t-caption2); font-weight: 500;
  padding: 7px 2px 5px; min-height: 52px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.unten a svg { width: 25px; height: 25px; }
.unten a[aria-current="page"] { color: var(--primaer); font-weight: 600; }

@media (min-width: 900px) {
  body { padding-bottom: 24px; font-size: 1rem; }
  .unten { display: none; }
  .kopf .suche { display: block; width: min(360px, 40vw); }
  .kopf .suche input { min-height: 36px; padding: 6px 12px; font-size: var(--t-subhead); background: var(--flaeche-2); }
  .rahmen { display: grid; grid-template-columns: 236px minmax(0, 1fr); align-items: start; }
  .seitenleiste {
    display: block; position: sticky; top: 53px; height: calc(100vh - 53px); overflow-y: auto;
    border-right: 1px solid var(--linie); background: var(--flaeche-2); padding: 12px 10px 24px max(10px, env(safe-area-inset-left));
  }
  .seitenleiste h2 { font-size: var(--t-caption1); text-transform: uppercase; letter-spacing: .5px; color: var(--leise); font-weight: 600; margin: 14px 10px 4px; }
  .seitenleiste a { display: flex; align-items: center; min-height: 34px; padding: 4px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: var(--t-subhead); }
  .seitenleiste a:hover { background: var(--grau-bg); }
  .seitenleiste a[aria-current="page"] { background: var(--primaer-hell); color: var(--primaer); font-weight: 600; }
  .seitenleiste form { margin: 14px 10px 0; }
  main { padding: 24px 28px; }
}

/* Karten, Listen (gruppierte Listen im iOS-Stil) */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; box-shadow: var(--schatten); }
.karte > h2:first-child, .karte > h3:first-child { margin-top: 0; }
.raster { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .raster.zwei { grid-template-columns: repeat(2, minmax(0, 1fr)); } .raster.drei { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.aufgabe {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  background: var(--flaeche); border: 1px solid var(--linie); border-left-width: 5px; border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; min-height: 56px;
}
.aufgabe .zahl { font-size: var(--t-title3); font-weight: 700; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.aufgabe .was { flex: 1; min-width: 0; }
.aufgabe .was small { display: block; color: var(--leise); font-size: var(--t-subhead); }
.aufgabe.alarm { border-left-color: var(--alarm); }
.aufgabe.warn { border-left-color: var(--warn); }
.aufgabe.info { border-left-color: var(--info); }
.zeile { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--linie); align-items: flex-start; min-height: var(--ziel); line-height: 1.294; }
.zeile:last-child { border-bottom: 0; }
.zeile .haupt { flex: 1; min-width: 0; }
.zeile a.haupt { text-decoration: none; color: var(--text); }
.zeile .titel { font-weight: 600; }
.zeile .leise { margin-top: 2px; }

/* Status-Marken – immer mit Text, nie nur Farbe */
.marke-status { display: inline-block; font-size: var(--t-caption1); font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ok { background: var(--ok-bg); color: var(--ok); }
.info { background: var(--info-bg); color: var(--info); }
.warn { background: var(--warn-bg); color: var(--warn); }
.alarm { background: var(--alarm-bg); color: var(--alarm); }
.grau { background: var(--grau-bg); color: var(--grau); }
.hinweis { border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; line-height: 1.4; }
.hinweis.leer { background: var(--grau-bg); color: var(--leise); }

/* Tabellen */
.tabelle-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-subhead); }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--linie); vertical-align: top; }
th { font-size: var(--t-footnote); color: var(--leise); font-weight: 600; }
tfoot td { font-weight: 700; border-top: 2px solid var(--linie); }

/* Knöpfe: Akzentfarbe nur auf der Hauptaktion */
.knopf, button.knopf, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--primaer);
  background: var(--primaer); color: var(--primaer-text); font: inherit; font-size: var(--t-body); font-weight: 600; border-radius: 12px;
  padding: 10px 18px; min-height: var(--ziel); text-decoration: none; cursor: pointer;
}
.knopf.zweit { background: transparent; color: var(--primaer); }
.knopf.gefahr { background: var(--alarm); border-color: var(--alarm); color: #fff; }
.knopf.klein { padding: 6px 12px; min-height: 36px; font-size: var(--t-subhead); }
.knopf.breit { width: 100%; }
.knopf[disabled] { opacity: .45; cursor: not-allowed; }
.aktionen { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; align-items: center; }
.aktionen form { margin: 0; }

/* Formulare */
form p, form > div { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: var(--t-subhead); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=datetime-local], input[type=search], input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: max(16px, var(--t-body)); color: var(--text); background: var(--flaeche);
  border: 1px solid var(--linie); border-radius: 10px; padding: 10px 12px; min-height: var(--ziel);
}
textarea { min-height: 80px; line-height: 1.4; }
input[type=checkbox] { width: 24px; height: 24px; vertical-align: middle; margin-right: 8px; accent-color: var(--primaer); }
input[type=file] { font: inherit; padding: 8px 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--primaer-hell); border-color: var(--primaer); }
.helptext, form .helptext { display: block; color: var(--leise); font-size: var(--t-footnote); line-height: 1.385; margin-top: 4px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0; color: var(--alarm); font-weight: 600; font-size: var(--t-subhead); }
.errorlist.nonfield { background: var(--alarm-bg); padding: 10px 12px; border-radius: 10px; }
.filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: end; }
.filter > * { flex: 1 1 140px; margin: 0; }
.filter .knopf { flex: 0 0 auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chips a { text-decoration: none; padding: 6px 14px; min-height: 36px; display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid var(--linie); color: var(--text); font-size: var(--t-subhead); background: var(--flaeche); }
.chips a.aktiv, .chips a[aria-current="page"] { background: var(--primaer); color: var(--primaer-text); border-color: var(--primaer); }

/* Segment-Umschalter (Geld: Offen · Eingänge · Rechnungen · Mahnungen) */
.segment { display: flex; background: var(--grau-bg); border-radius: 10px; padding: 3px; gap: 2px; margin: 0 0 16px; max-width: 560px; }
.segment a { flex: 1; text-align: center; text-decoration: none; color: var(--text); font-size: var(--t-subhead); font-weight: 500;
  border-radius: 8px; padding: 6px 4px; min-height: 36px; display: flex; align-items: center; justify-content: center; }
.segment a[aria-current="page"] { background: var(--flaeche); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
@media (pointer: coarse) { .segment a { min-height: var(--ziel); } }

/* Touch: alle Ziele mindestens 44 × 44 */
@media (pointer: coarse) {
  .knopf.klein, .chips a { min-height: var(--ziel); }
  .zeile > a:not(.haupt), .zeile span > a, td > a { display: inline-flex; align-items: center; min-height: var(--ziel); }
}
/* Maus: sichtbare Rückmeldung beim Überfahren */
@media (hover: hover) and (pointer: fine) {
  .knopf:hover { filter: brightness(1.08); }
  .knopf.zweit:hover { background: var(--primaer-hell); filter: none; }
  .aufgabe:hover, .zeile a.haupt:hover .titel { background: transparent; }
  .aufgabe:hover { border-color: var(--primaer); }
  .chips a:hover { border-color: var(--primaer); }
}

/* Meldungen (bleiben stehen, kein automatisches Ausblenden) */
.meldungen { list-style: none; padding: 0; margin: 0 0 14px; }
.meldungen li { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; line-height: 1.4; }
.meldungen .success { background: var(--ok-bg); color: var(--ok); }
.meldungen .error { background: var(--alarm-bg); color: var(--alarm); }
.meldungen .warning { background: var(--warn-bg); color: var(--warn); }
.meldungen .info { background: var(--info-bg); color: var(--info); }

/* Stoppuhr */
.stoppuhr { text-align: center; padding: 20px 8px; }
.stoppuhr .anzeige { font-size: 3.25rem; font-weight: 600; font-variant-numeric: tabular-nums; margin: 8px 0; line-height: 1.1; }
.taetigkeiten { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.taetigkeiten button { font-size: var(--t-title3); min-height: 72px; border-radius: 16px; }
.stopknopf { font-size: 1.375rem !important; min-height: 80px !important; width: 100%; background: var(--alarm) !important; border-color: var(--alarm) !important; color: #fff !important; border-radius: 16px !important; }
.schritte { list-style: none; padding: 0; margin: 0; }
.schritte li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--linie); }
.schritte .nr { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; background: var(--grau-bg); flex: 0 0 auto; }
.schritte .fertig .nr { background: var(--ok-bg); color: var(--ok); }
.beleg-bild { max-width: 100%; border-radius: 10px; border: 1px solid var(--linie); }
details summary { cursor: pointer; font-weight: 600; padding: 6px 0; min-height: var(--ziel); }
.versteckt { display: none !important; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
