/* AVA Aufmaß – Tablet. Farben wie im Plan: grau offen, grün ok/montiert, orange teilweise, rot fehlt/Mangel.
   Bedienelemente mindestens 48 px hoch (Finger, auch mit Handschuh). */
:root {
  --papier: #eef1f4; --flaeche: #fff; --tinte: #1c2630; --tinte-2: #56626e; --linie: #cfd6de; --linie-2: #e3e8ed;
  --blau: #1f5fad; --blau-hell: #e3ecf7; --gruen: #2e7d4f; --gruen-hell: #e2f1e8; --orange: #d97a00; --orange-hell: #fbeedb;
  --rot: #c62828; --rot-hell: #fbe7e5; --grau: #7d8792; --grau-hell: #eceff2;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 8px; --kopf: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --papier: #161c22; --flaeche: #1e252d; --tinte: #e4e9ee; --tinte-2: #9aa6b2; --linie: #34404b; --linie-2: #29323b;
    --blau: #6aa3e8; --blau-hell: #1c2f45; --gruen: #6cc08f; --gruen-hell: #1b3326; --orange: #f0a64a; --orange-hell: #3a2a14;
    --rot: #f08a82; --rot-hell: #3b1e1c; --grau: #8e99a4; --grau-hell: #262e36;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--papier); color: var(--tinte); font: 17px/1.4 var(--text); min-height: 100vh; overscroll-behavior-y: contain; }
a { color: var(--blau); }
h2 { font-size: 1.05rem; margin: 22px 16px 8px; color: var(--tinte-2); font-weight: 600; }
h2 small { font-weight: 400; }
button, .knopf, select, input, textarea { font: inherit; color: inherit; }
button, .knopf {
  min-height: 48px; padding: 0 16px; border: 1px solid var(--linie); border-radius: var(--r); background: var(--flaeche);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; touch-action: manipulation;
}
button:active, .knopf:active { filter: brightness(0.92); }
button.haupt, .knopf.haupt { background: #1f5fad; border-color: #1f5fad; color: #fff; font-weight: 600; }
button.gefahr { color: var(--rot); border-color: var(--rot); }
input[type=text], input[type=search], input:not([type]), textarea, select {
  min-height: 48px; border: 1px solid var(--linie); border-radius: var(--r); background: var(--flaeche); padding: 8px 12px; width: 100%;
}
textarea { min-height: 120px; resize: vertical; }
code { font-size: 0.9em; }
.klein, small { font-size: 0.85rem; color: var(--tinte-2); }

/* Kopf */
.kopf {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: var(--kopf);
  padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  padding-top: max(6px, env(safe-area-inset-top)); background: #1f5fad; color: #fff;
}
.kopf-titel { flex: 1; min-width: 0; }
.kopf h1 { margin: 0; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#untertitel { font-size: 0.85rem; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-knopf { background: transparent; color: #fff; border-color: rgba(255,255,255,0.5); padding: 0 12px; }
.kopf-knopf.aktiv { background: #fff; color: #1f5fad; }
.kopf-knopf.zurueck { font-size: 2rem; line-height: 1; padding: 0 14px 4px; border: 0; }
.kopf-aktionen { display: flex; gap: 6px; flex-wrap: nowrap; }

main { padding-bottom: 96px; max-width: 1100px; margin: 0 auto; }
main.voll { max-width: none; padding: 0; }
.block { margin: 16px; }
.leer-hinweis { margin: 32px 16px; color: var(--tinte-2); text-align: center; list-style: none; }
.hinweis { margin-top: 10px; padding: 10px 12px; background: var(--blau-hell); border-radius: var(--r); }
.gross-knopf { display: flex; min-height: 64px; font-size: 1.1rem; width: 100%; border-radius: var(--r); align-items: center; justify-content: center; cursor: pointer; }
.gross-knopf.haupt { background: #1f5fad; color: #fff; font-weight: 600; }
.einstellungen p { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Karten */
.karten { list-style: none; margin: 0 16px; padding: 0; display: grid; gap: 10px; }
.karte { display: block; background: var(--flaeche); border: 1px solid var(--linie-2); border-radius: var(--r); color: inherit; text-decoration: none; }
.projekt .karte-haupt { display: grid; gap: 4px; padding: 14px 16px; color: inherit; text-decoration: none; }
.projekt strong { font-size: 1.15rem; }
.karte-knoepfe { display: flex; gap: 8px; padding: 0 16px 14px; flex-wrap: wrap; }
.fortschritt { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--tinte-2); }
.balken { display: inline-block; width: 120px; height: 10px; border-radius: 5px; background: var(--grau-hell); overflow: hidden; flex: none; }
.balken i { display: block; height: 100%; background: var(--grau); }
.balken.teil i { background: var(--orange); } .balken.fertig i { background: var(--gruen); } .balken.problem i { background: var(--rot); }

.plan-knoepfe { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 16px 0; }
.plan-knoepfe .knopf { background: var(--blau-hell); border-color: var(--blau); color: var(--blau); font-weight: 600; }
.filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 16px; align-items: center; }
.filter input[type=search] { flex: 1 1 260px; }
.filter select { width: auto; flex: 0 0 auto; }
.schalter { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 12px; border: 1px solid var(--linie); border-radius: var(--r); background: var(--flaeche); }
.schalter input { width: 22px; height: 22px; }
.raeume { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.karte.raum { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 12px 14px; min-height: 72px; border-left: 6px solid var(--grau); }
.karte.raum.teil { border-left-color: var(--orange); } .karte.raum.fertig { border-left-color: var(--gruen); } .karte.raum.problem { border-left-color: var(--rot); }
.raum-nr { font-weight: 700; font-size: 1.1rem; grid-row: span 2; align-self: center; min-width: 74px; }
.raum-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Raum */
.raum-kopf { margin: 14px 16px 0; display: grid; gap: 10px; }
.raum-kopf .balken { width: 100%; height: 12px; }
.knopfreihe { display: flex; gap: 8px; flex-wrap: wrap; }
.zeile { padding: 12px 14px; display: grid; gap: 10px; border-left: 6px solid var(--grau); }
.st-rand-ok { border-left-color: var(--gruen) !important; } .st-rand-teilweise { border-left-color: var(--orange) !important; }
.st-rand-fehlt, .st-rand-mangel { border-left-color: var(--rot) !important; }
.zeile-kopf { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; cursor: pointer; }
.oz { font-variant-numeric: tabular-nums; color: var(--tinte-2); font-size: 0.9rem; white-space: nowrap; }
.kurz { font-weight: 600; }
.einheit { color: var(--tinte-2); }
.langtext { white-space: pre-wrap; font-size: 0.9rem; color: var(--tinte-2); background: var(--grau-hell); padding: 8px 10px; border-radius: var(--r); }
.mengen, .tab-mengen { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.diff.minus b { color: var(--rot); } .diff.plus b { color: var(--orange); }
.verweis { min-height: 40px; background: var(--blau-hell); border-color: transparent; color: var(--blau); }
.ist-zeile { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rund { width: 56px; min-height: 56px; font-size: 1.6rem; padding: 0; font-weight: 600; }
input.ist { width: 96px; min-height: 56px; text-align: center; font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tab-mengen input.ist { min-height: 48px; font-size: 1.1rem; }
.tab-mengen select { width: auto; }
button.hat { border-color: var(--blau); color: var(--blau); font-weight: 600; }
.status-wahl { display: flex; flex-wrap: wrap; gap: 6px; }
.status-wahl button { flex: 1 1 auto; min-width: 84px; }
.status-wahl .gewaehlt { color: #fff; font-weight: 600; }
.status-wahl .st-offen.gewaehlt { background: var(--grau); border-color: var(--grau); }
.status-wahl .st-ok.gewaehlt { background: var(--gruen); border-color: var(--gruen); }
.status-wahl .st-teilweise.gewaehlt { background: var(--orange); border-color: var(--orange); }
.status-wahl .st-fehlt.gewaehlt, .status-wahl .st-mangel.gewaehlt { background: var(--rot); border-color: var(--rot); }
.notiz { margin: 0; padding: 8px 10px; background: var(--orange-hell); border-radius: var(--r); white-space: pre-wrap; }
.tabelle { margin: 0 16px; display: grid; gap: 8px; }
.tabzeile { background: var(--flaeche); border: 1px solid var(--linie-2); border-left: 6px solid var(--grau); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 8px; }
.tab-text { cursor: pointer; }
.tab-mengen label { display: inline-flex; align-items: center; gap: 6px; }
.fotos { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 16px; }
.zeile .fotos, .tabzeile .fotos { margin: 0; }
.foto { padding: 0; width: 76px; height: 76px; overflow: hidden; }
.foto img { width: 100%; height: 100%; object-fit: cover; }
.foto-gross { max-width: 100%; max-height: 60vh; display: block; margin: 0 auto; }

/* Plan */
.auswahl-suche { width: 100%; margin: 0 0 10px; }
.auswahl button[hidden] { display: none; }
.plan-bereich { position: fixed; inset: var(--kopf) 0 0 0; display: grid; grid-template-rows: 1fr auto; }
#plan { position: relative; overflow: hidden; background: #fff; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.plan-ebene { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.plan-grund, .plan-kacheln { position: absolute; inset: 0; }
.plan-ebene img { position: absolute; max-width: none; pointer-events: none; image-rendering: auto; }
.plan-ebene img:not(.da), .plan-ebene img.leer { visibility: hidden; }
.plan-marken { position: absolute; left: 0; top: 0; pointer-events: none; }
.plan-leiste { background: var(--flaeche); border-top: 1px solid var(--linie); padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 4px; min-height: 64px; }
.plan-info { font-size: 0.95rem; }
.legende { font-size: 0.8rem; color: var(--tinte-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.legende i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-left: 8px; }
.legende .st-offen { background: #7d8792; } .legende .st-montiert { background: #2e7d4f; } .legende .st-fehlt { background: #c62828; }

/* Dialoge, Meldungen */
.dialog-huelle { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.dialog { background: var(--flaeche); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 24px); overflow: auto; padding: 16px 18px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
@media (min-width: 700px) { .dialog-huelle { align-items: center; } }
.dialog h2 { margin: 0 0 10px; color: var(--tinte); font-size: 1.15rem; }
.dialog-inhalt p { margin: 0 0 10px; }
.dialog-knoepfe { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.dialog-knoepfe button { flex: 1 1 auto; }
.auswahl { display: grid; gap: 8px; }
.auswahl button, .auswahl .knopf { justify-content: flex-start; text-align: left; min-height: 52px; display: flex; flex-direction: column; align-items: flex-start; padding: 8px 14px; }
.auswahl .knopf.haupt { align-items: center; justify-content: center; }
.auswahl small { font-size: 0.8rem; }
.auswahl .st-montiert { border-left: 6px solid var(--gruen); } .auswahl .st-fehlt, .auswahl .st-mangel { border-left: 6px solid var(--rot); }
.auswahl .haupt small { color: #e6eefa; }
.meldung {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; max-width: calc(100% - 24px);
  background: #24303c; color: #fff; padding: 10px 14px; border-radius: var(--r); display: flex; gap: 12px; align-items: center; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.meldung[hidden] { display: none; }
.meldung.fehler { background: var(--rot); }
.meldung button { min-height: 40px; background: transparent; color: #fff; border-color: rgba(255,255,255,0.6); }
.update { position: fixed; top: calc(var(--kopf) + 8px); left: 50%; transform: translateX(-50%); z-index: 40; background: var(--gruen); color: #fff; padding: 8px 12px; border-radius: var(--r); display: flex; gap: 10px; align-items: center; }
.update[hidden] { display: none; }
.update button { min-height: 40px; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .kopf-knopf { padding: 0 9px; }
  .raeume { grid-template-columns: 1fr; }
  .status-wahl button { min-width: 0; padding: 0 8px; }
}
/* Plan mit mehreren Blättern: vier Knöpfe im Kopf, der Titel soll auf dem Telefon lesbar bleiben */
@media (max-width: 420px) {
  .kopf { gap: 4px; }
  .kopf-aktionen { gap: 4px; }
  .kopf-knopf { padding: 0 7px; }
  .kopf-knopf.zurueck { padding: 0 6px 4px; }
}
