/* Dachaufmaß: Farben, Grundformen, Zustände. Layout kommt aus Tailwind-Klassen im HTML.
   Drei Ebenen: Papier (Hintergrund), Fläche (Panels), Überlagerung (Menüs, Ladeanzeige).
   Eine Signalfarbe (Moos) nur für Bedienbares: Knöpfe, Links, aktive Zustände, Fokus. */
:root {
  --papier: #f3f3f0;
  --flaeche: #ffffff;
  --tinte: #1c1e21;
  --tinte-leise: #575c63;
  --linie: #d9dad6;
  --signal: #456b00;
  --signal-dunkel: #344f00;
  --signal-hell: #eef3e3;
  --fehler: #a8200d;
  --fehler-grund: #fdecea;
  --warnung-grund: #fff2b8;
  --warnung-rand: #c99a00;
  --schatten: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .12);
}

html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--tinte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
.zahl { font-variant-numeric: tabular-nums; }
.leise { color: var(--tinte-leise); }
.gross { font-size: 44px; line-height: 1.1; font-weight: 700; letter-spacing: -.01em; }
.panel { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px; }

/* Links: unterstrichen, damit Bedienbarkeit nicht nur an der Farbe hängt */
.link { color: var(--signal); text-decoration: underline; text-underline-offset: 3px; }
.link:hover, a:hover > .link { color: var(--signal-dunkel); }

/* Knöpfe: gefüllt (Hauptaktion) oder umrandet */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 8px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--signal); color: #fff; border: 2px solid var(--signal);
}
.knopf:not(:disabled):hover { background: var(--signal-dunkel); border-color: var(--signal-dunkel); }
.knopf.umrandet { background: var(--flaeche); color: var(--signal); }
.knopf.umrandet:not(:disabled):hover { background: var(--signal-hell); color: var(--signal-dunkel); }
.knopf.klein { min-height: 36px; padding: 0 12px; font-size: 14px; }
.knopf:disabled, .knopf[aria-disabled="true"] {
  cursor: not-allowed; background: #e6e7e3; border-color: #c9cac5; color: #6b7076;
}

:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.feld {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid #8d9197; background: var(--flaeche); color: var(--tinte); font: inherit;
}
.feld:focus-visible { outline-offset: 0; border-color: var(--signal); }
.feld:disabled { background: #eeefeb; color: #6b7076; }

.meldung-fehler {
  background: var(--fehler-grund); color: var(--fehler); border-left: 4px solid var(--fehler);
  padding: 10px 14px; border-radius: 6px;
}
.hinweis {
  background: var(--warnung-grund); border: 1px solid var(--warnung-rand); border-left-width: 6px;
  padding: 12px 14px; border-radius: 8px;
}

/* Ladeanzeige */
.kreisel {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 3px solid currentColor; border-right-color: transparent;
  animation: drehen .8s linear infinite;
}
@keyframes drehen { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .kreisel { animation: none; border-right-color: currentColor; opacity: .6; }
}

/* Tabellen */
table.liste { width: 100%; border-collapse: collapse; }
table.liste th { text-align: left; font-weight: 600; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--linie); }
table.liste td { padding: 6px 8px 6px 0; border-bottom: 1px solid #ecece8; vertical-align: middle; }
table.liste .r { text-align: right; white-space: nowrap; }
table.liste .r .leise { white-space: normal; }
table.liste tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--tinte); }
table.liste tr.aus td { color: var(--tinte-leise); }
.farbe { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 8px; }

/* 3D-Ansicht */
.viewer { position: relative; overflow: hidden; background: #e9eae6; touch-action: none; }
.viewer canvas { display: block; }
/* eigene Stapelebene: die z-index-Werte der Beschriftungen bleiben unter Hilfe, Legende und Kantenmenü */
.etiketten { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.kante-etikett {
  pointer-events: auto; cursor: pointer;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums;
  color: var(--tinte); background: rgba(255, 255, 255, .94);
  border: 1px solid #b9bbb6; border-left-width: 5px; border-radius: 4px; padding: 4px 6px; white-space: nowrap;
}
.kante-etikett:hover { background: #fff; border-color: var(--tinte); }
.viewer.beschaeftigt .kante-etikett { pointer-events: none; opacity: .6; }
.kante-etikett.manuell { border-style: dashed; border-left-style: solid; }
.flaeche-nr {
  pointer-events: none; font: 700 14px/1 system-ui, sans-serif; color: var(--tinte);
  background: #fff; border: 2px solid var(--tinte); border-radius: 50%;
  min-width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
}
/* Zähler der von Hand ergänzten Aufbauten unter der Flächennummer (nur Anzeige, keine Signalfarbe).
   margin-top passt zu AUFBAU_VERSATZ in viewer.js. */
.aufbau-etikett {
  pointer-events: none; margin-top: 30px;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums;
  color: var(--tinte); background: rgba(255, 255, 255, .94);
  border: 1px dashed var(--tinte-leise); border-radius: 4px; padding: 4px 6px; white-space: nowrap;
}
.ueberlagerung { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px; box-shadow: var(--schatten); }
.typ-knopf {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 0 10px;
  border-radius: 6px; border: 1px solid var(--linie); background: var(--flaeche); color: var(--tinte);
  font: inherit; cursor: pointer; text-align: left;
}
.typ-knopf:hover { border-color: var(--tinte); }
.typ-knopf[aria-pressed="true"] { border: 2px solid var(--signal); background: var(--signal-hell); font-weight: 600; }

/* Reiter 3D | Karte über der Ansicht */
.reiter { display: flex; gap: 4px; padding: 6px 8px 0; background: var(--flaeche); border-bottom: 1px solid var(--linie); }
.reiter-knopf {
  min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0;
  background: transparent; color: var(--tinte-leise); font: inherit; font-weight: 600; cursor: pointer;
}
.reiter-knopf[aria-selected="true"] { background: #e9eae6; color: var(--tinte); border-color: var(--linie); }
.reiter-knopf:focus-visible { outline: 2px solid var(--tinte); outline-offset: -2px; }
.karte { position: relative; z-index: 0; background: #e9eae6; }
.karte[hidden], .viewer[hidden] { display: none; }
