/* ===========================================================================
   Zuschnitt Universal - 2px Solid High-Contrast Studio Edition
   =========================================================================== */

:root {
  --farbe-akzent:      var(--c-black-900);
  --farbe-text:        var(--c-black-900);
  --farbe-rand:        var(--c-border-strong);
  --farbe-hintergrund: var(--c-stage-bg);
}

/* --- Anmeldeseite --------------------------------------------------------- */
.login-mitte { max-width: 420px; margin: 10vh auto; padding: 0 16px; }
.login-titel {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--c-black-900);
}

/* --- Zeichenfläche des Zuschnittplans (Canvas) --------------------------- */
.canvas-wrapper {
  background: #ffffff;
  border: 2px solid var(--c-border-strong);
  border-radius: 10px;
  padding: 16px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: border-color var(--dur-hover) var(--ease-smooth);
}
.canvas-wrapper:hover {
  border-color: var(--c-black-900);
}
#zuschnitt-canvas { 
  display: block; 
  width: 100% !important;
  max-height: 65vh !important;
  object-fit: contain !important;
  touch-action: none;
  border-radius: 6px;
}

/* --- Canvas Werkzeugleiste ----------------------------------------------- */
.canvas-werkzeuge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.canvas-werkzeuge .btn-sekundaer {
  padding: 8px 14px;
  font-size: 13px;
}

/* --- Spezialformen Aufklapper -------------------------------------------- */
.spezialformen-aufklapper {
  border: 2px solid var(--c-border-strong);
  border-radius: 10px;
  padding: 14px 18px;
  background: var(--c-surface-subtle);
  margin-bottom: 24px;
  transition: all var(--dur-hover) var(--ease-smooth);
}
.spezialformen-aufklapper:hover {
  border-color: var(--c-black-900);
  background: #ffffff;
}
.spezialformen-aufklapper summary {
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  color: var(--c-black-900);
  outline: none;
  user-select: none;
}
.spezialformen-aufklapper .knopfreihe {
  margin-top: 14px;
}

/* --- Polygon-Zeichner (Spezialformen & Scan) ---------------------------- */
.polygon-layout { display: flex; gap: 20px; flex-wrap: wrap; }
.polygon-canvas-wrapper { flex: 0 0 auto; }
.polygon-seite {
  flex: 1 1 240px;
  min-width: 220px;
  max-height: 540px;
  overflow-y: auto;
}
#polygon-canvas, #scan-canvas {
  border: 2px solid var(--c-border-strong);
  border-radius: 8px;
  background: #111111;
  cursor: crosshair;
  touch-action: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.punkteliste {
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-text-muted);
  padding-left: 18px;
  max-height: 140px;
  overflow-y: auto;
  margin: 8px 0;
  border-left: 2px solid var(--c-border-strong);
}

/* --- Zuschnitt-Tabelle (100% Passgenau ohne horizontalen Scrollbalken) --- */
.tabelle-wrapper {
  border: 2px solid var(--c-border-strong);
  border-radius: 10px;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  max-height: 480px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  width: 100% !important;
  box-sizing: border-box !important;
}

#tabelle-zuschnitte {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
  font-size: 11.5px !important;
}

#tabelle-zuschnitte th,
#tabelle-zuschnitte td {
  padding: 7px 4px !important;
  border-bottom: 1px solid var(--c-border-subtle) !important;
  color: var(--c-black-900) !important;
  font-weight: 500 !important;
  vertical-align: middle !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  letter-spacing: normal !important;
}

#tabelle-zuschnitte th {
  background: var(--c-surface-subtle) !important;
  border-bottom: 2px solid var(--c-border-strong) !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  font-size: 10px !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 2 !important;
}

/* Exakte, harmonische Spaltenverteilung */
#tabelle-zuschnitte th:nth-child(1),
#tabelle-zuschnitte td:nth-child(1) { width: 28px !important; text-align: center !important; }

#tabelle-zuschnitte th:nth-child(2),
#tabelle-zuschnitte td:nth-child(2) { width: auto !important; text-align: left !important; }

#tabelle-zuschnitte th:nth-child(3),
#tabelle-zuschnitte td:nth-child(3) { width: 68px !important; text-align: left !important; }

#tabelle-zuschnitte th:nth-child(4),
#tabelle-zuschnitte td:nth-child(4) { width: 78px !important; text-align: center !important; font-variant-numeric: tabular-nums !important; }

#tabelle-zuschnitte th:nth-child(5),
#tabelle-zuschnitte td:nth-child(5) { width: 38px !important; text-align: center !important; font-weight: 700 !important; }

#tabelle-zuschnitte th:nth-child(6),
#tabelle-zuschnitte td:nth-child(6) { width: 48px !important; text-align: center !important; }

#tabelle-zuschnitte th:nth-child(7),
#tabelle-zuschnitte td:nth-child(7) { width: 36px !important; text-align: center !important; }

#tabelle-zuschnitte th:nth-child(8),
#tabelle-zuschnitte td:nth-child(8) { width: 76px !important; text-align: right !important; }

#tabelle-zuschnitte tr:last-child td {
  border-bottom: none !important;
}

.zeile-aktionen {
  white-space: nowrap !important;
  text-align: right !important;
  padding: 3px 2px !important;
}

.zeile-aktionen button {
  background: #ffffff !important;
  border: 1px solid var(--c-border-strong) !important;
  border-radius: 5px !important;
  cursor: pointer !important;
  font-size: 11px !important;
  padding: 3px 3px !important;
  margin: 0 1px !important;
  line-height: 1 !important;
  transition: all 0.2s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.zeile-aktionen button:hover {
  background: var(--c-black-900) !important;
  color: #ffffff !important;
  border-color: var(--c-black-900) !important;
  transform: scale(1.15) !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15) !important;
}
/* --- Knöpfe & Kontraste --- */
.btn-primary, 
#btn-zuschnitt-add, 
#btn-berechnen,
button.btn-primary,
button.btn-primary *,
.btn-primary * {
  background: var(--c-black-900) !important;
  color: #ffffff !important;
  fill: #ffffff !important;
  text-shadow: none !important;
}

.btn-primary:hover, 
#btn-zuschnitt-add:hover, 
#btn-berechnen:hover {
  background: #222222 !important;
  color: #ffffff !important;
}

/* --- Responsive Canvas & Controls (< 768px) --- */
@media (max-width: 768px) {
  .canvas-werkzeuge {
    justify-content: center;
  }
  .canvas-werkzeuge .btn-sekundaer {
    flex: 1 1 calc(50% - 10px);
    text-align: center;
    padding: 8px 10px;
    font-size: 12px;
  }
  #polygon-canvas, #scan-canvas {
    max-width: 100%;
    height: auto;
  }
  .polygon-layout {
    flex-direction: column;
  }
  .polygon-seite {
    max-height: 320px;
  }
}

/* ==========================================================================
   MODERNES DESIGN: GESPEICHERTE PROJEKTE MODAL (Hans 01.09.2026)
   ========================================================================== */
#modal-projekte .modal {
  max-width: 680px !important;
  width: 92vw !important;
  max-height: 85vh !important;
  display: flex !important;
  flex-direction: column !important;
  border-radius: 14px !important;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.22) !important;
  padding: 24px 28px !important;
}

.projekte-liste {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  max-height: 52vh !important;
  overflow-y: auto !important;
  padding-right: 6px !important;
  margin: 16px 0 20px 0 !important;
}

.projekt-card {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 12px 16px !important;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 10px !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

.projekt-card:hover {
  border-color: #141414 !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08) !important;
  transform: translateY(-1px) !important;
}

.projekt-card-main {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
  padding-right: 16px !important;
}

.projekt-card-header {
  display: flex !important;
  align-items: center !important;
  gap: 9px !important;
}

.projekt-title {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #141414 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Modus-Badges */
.projekt-badge {
  display: inline-flex !important;
  align-items: center !important;
  padding: 3px 8px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.3px !important;
  flex-shrink: 0 !important;
}

.projekt-badge.badge-leder {
  background: rgba(184, 115, 51, 0.15) !important;
  color: #8a5a36 !important;
  border: 1px solid rgba(184, 115, 51, 0.35) !important;
}

.projekt-badge.badge-ohne_rapport {
  background: rgba(20, 20, 20, 0.08) !important;
  color: #141414 !important;
}

.projekt-badge.badge-mit_rapport {
  background: rgba(59, 130, 246, 0.12) !important;
  color: #1d4ed8 !important;
  border: 1px solid rgba(59, 130, 246, 0.25) !important;
}

.projekt-badge.badge-holz {
  background: rgba(160, 100, 40, 0.12) !important;
  color: #78350f !important;
  border: 1px solid rgba(160, 100, 40, 0.25) !important;
}

.projekt-badge.badge-schaum {
  background: rgba(14, 165, 233, 0.12) !important;
  color: #0369a1 !important;
  border: 1px solid rgba(14, 165, 233, 0.25) !important;
}

/* Metadaten (Teile, Datum) */
.projekt-meta {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-size: 12px !important;
  color: #64748b !important;
}

.projekt-meta span {
  display: inline-flex !important;
  align-items: center !important;
}

.projekt-dot {
  color: #cbd5e1 !important;
  font-weight: 900 !important;
}

/* Aktionen (Öffnen, Löschen) */
.projekt-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
}

.btn-projekt-open {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 7px 14px !important;
  background: #141414 !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 7px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
}

.btn-projekt-open:hover {
  background: #2a2a2a !important;
  transform: scale(1.03) !important;
  color: #ffffff !important;
}

.btn-projekt-delete {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  height: 32px !important;
  background: #ffffff !important;
  color: #94a3b8 !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 7px !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
}

.btn-projekt-delete:hover {
  background: #fee2e2 !important;
  color: #dc2626 !important;
  border-color: #fca5a5 !important;
  transform: scale(1.06) !important;
}

/* Wartefenster fuer lange Berechnungen (Hans, 04.09.2026) */
.warte-hintergrund { position: fixed; inset: 0; background: rgba(20,24,30,.45);
  display: none; align-items: center; justify-content: center; z-index: 9000; }
.warte-hintergrund.auf { display: flex; }
.warte-kasten { background: #fff; border-radius: 12px; padding: 26px 30px; min-width: 320px;
  max-width: 90vw; box-shadow: 0 18px 50px rgba(0,0,0,.28); text-align: center; }
.warte-titel { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.warte-dauer { font-size: 14px; color: #333; margin-bottom: 10px; }
.warte-zeit { font-size: 34px; font-weight: 700; line-height: 1.1; }
.warte-schaetzung { color: #555; font-size: 13px; margin-top: 6px; }
.warte-schaetzung.warte-warnung { color: #b00020; }
.warte-balken { height: 6px; background: #ececec; border-radius: 3px; margin: 16px 0 10px; overflow: hidden; }
.warte-balken-fuellung { height: 100%; width: 0; background: #141414; border-radius: 3px;
  transition: width .25s linear; }
.warte-balken-fuellung.warte-ueberzogen { background: #b00020; }
.warte-balken-fuellung.warte-unbekannt { background: linear-gradient(90deg,#ddd,#141414,#ddd);
  background-size: 200% 100%; animation: warte-lauf 1.2s linear infinite; }
@keyframes warte-lauf { from { background-position: 200% 0; } to { background-position: 0 0; } }
.warte-hinweis { color: #777; font-size: 12px; }


/* ==========================================================================
   FENSTER: SCHLIESSEN UND SCROLLEN (Hans, 04.09.2026)
   ========================================================================== */
/* Das X sitzt oben rechts im Fenster. Der Abbrechen-Knopf steht ganz unten -
   bei einem 700 px hohen Bildschirm sieht man ihn im Polygon-Fenster nicht. */
.modal { position: relative; }

.modal-x {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--c-border, #d8d8d8);
  border-radius: 8px;
  background: var(--c-card-bg, #ffffff);
  color: var(--c-text, #1a1a1a);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
}
.modal-x:hover { background: var(--c-hover-bg, #f0f0f0); }

/* Die Zeichenfläche des Polygon-Fensters wird nur ANGETIPPT (Punkt setzen),
   nicht gezogen - deshalb darf senkrechtes Wischen dort scrollen. Beim
   Foto-Scan bleibt "none": dort wird gezogen und mit zwei Fingern gezoomt. */
#polygon-canvas { touch-action: pan-y !important; }

/* Der Knopf zum Einscannen einer Schablone sitzt jetzt oben im Fenster, damit
   er ohne Scrollen zu sehen ist. */
.modal-kopfzeile {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: -4px 0 14px;
}

/* ==========================================================================
   PUNKT A & C: TABELLENEINGABE & GEGENPROBE (Hans 07.09.2026)
   ========================================================================== */
.modal-tabelle-dialog {
  max-width: 980px !important;
  width: 96vw !important;
  max-height: 88vh !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 24px 28px !important;
  border-radius: 14px !important;
}

.modal-tabelle-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 56vh;
  border: 1px solid var(--c-border, #e2e8f0);
  border-radius: 8px;
  background: #ffffff;
}

.tabelle-eingabe {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.tabelle-eingabe th {
  position: sticky;
  top: 0;
  background: var(--c-bg-subtle, #f8fafc);
  color: var(--c-text-gedaempft, #475569);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 2px solid var(--c-border, #cbd5e1);
  z-index: 2;
  white-space: nowrap;
}

.tabelle-eingabe td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--c-border-light, #f1f5f9);
  vertical-align: top;
}

.tabelle-eingabe tr:nth-child(even) td {
  background: rgba(248, 250, 252, 0.5);
}

.tabelle-eingabe tr:hover td {
  background: rgba(241, 245, 249, 0.8);
}

.tabelle-eingabe input[type="text"],
.tabelle-eingabe select {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--c-border, #cbd5e1);
  border-radius: 6px;
  background: #ffffff;
  color: var(--c-text, #0f172a);
  transition: border-color 0.15s, background-color 0.15s;
}

.tabelle-eingabe input[type="text"]:focus,
.tabelle-eingabe select:focus {
  border-color: #000000;
  outline: none;
}

.tabelle-eingabe .mass-zu-gross {
  border: 2px solid #B00020 !important;
  background: #fff5f5 !important;
  color: #B00020 !important;
}

.tabelle-zeile-warnung {
  display: block;
  color: #B00020;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  margin-top: 4px;
}

.btn-zeile-loeschen {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.btn-zeile-loeschen:hover {
  color: #B00020;
  background: #fee2e2;
}

/* Punkt C: Gegenprobe mm/cm unter jedem Maßfeld */
.gegenprobe-hinweis {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--c-text-gedaempft, #64748b);
  margin-top: 3px;
  letter-spacing: 0.15px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Sparvorschlag (Hans, 14.09.2026) */
.spar-panel { border: 1px solid #d99a00; border-left: 4px solid #d99a00; background: #fff8e6; border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; font-size: 14px; }
.spar-panel.spar-ok { border-color: #2e9e4f; background: #e6f6ea; }
.spar-panel.spar-fehler { border-color: #B00020; background: #FDE7EA; color: #B00020; }
.spar-panel.spar-hilfe { border-color: #1d4fa3; background: #eef3fc; }
.spar-panel table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.spar-panel th, .spar-panel td { padding: 5px 6px; border-bottom: 1px solid #eee; text-align: left; vertical-align: middle; }
.spar-panel td.zahl, .spar-panel th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.spar-panel button { min-height: 32px; font-size: 13px; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.spar-panel .spar-warnung { color: #B00020; font-weight: 600; margin-top: 6px; }
.spar-panel .spar-hinweis { font-size: 12px; color: #664; margin-top: 4px; }
.spar-panel .spar-nachbestellen { color: #B00020; margin-top: 6px; }
