/* ============================================================
   CSC Prüf-App — Stylesheet
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a3a5c;
  --primary-light: #2a5a8c;
  --accent: #e8a020;
  --success: #2e7d32;
  --danger: #c62828;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #222;
  --text-muted: #666;
  --border: #dde3ea;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
}

/* ===== SCREENS ===== */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ===== HEADER ===== */
.header {
  background: #ffffff;
  color: var(--primary);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  border-bottom: 2px solid #e8a020;
}
.header-logo {
  height: 36px;
  width: auto;
  margin-left: auto;
  border-radius: 4px;
  padding: 2px 6px;
}

.header-title {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
}
.btn-back {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  line-height: 1;
}

/* ===== CONTENT ===== */
.content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

/* ===== HOME ===== */
.welcome-text {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-align: center;
}
.divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 16px 0;
}

/* ===== STANDORT KARTE ===== */
.standort-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.standort-header {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.standort-header:active { opacity: 0.85; }

/* ===== BEREICH LISTE ===== */
.bereich-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.bereich-item:last-child { border-bottom: none; }
.bereich-item:active { background: #eef2f7; }
.bereich-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-right: 12px;
  flex-shrink: 0;
}
.icon-aufzug       { background: #e3f2fd; }
.icon-brandschutz  { background: #fce4ec; }
.icon-notbel       { background: #fff8e1; }
.icon-leiter       { background: #e8f5e9; }
.icon-default      { background: #f3e5f5; }
.icon-gruppe       { background: #e8eaf6; font-size: 1.4rem; }
.bereich-info { flex: 1; }
.bereich-name { font-weight: 600; font-size: 15px; }
.bereich-liste-name { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.bereich-arrow { color: var(--text-muted); font-size: 20px; }

/* ===== CHECKLISTE ===== */
.meta-box {
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.meta-box .meta-standort { font-size: 13px; opacity: 0.8; }
.meta-box .meta-bereich  { font-size: 17px; font-weight: 700; margin: 4px 0; }
.meta-box .meta-datum    { font-size: 13px; opacity: 0.8; }
.meta-box .meta-kw       { font-size: 13px; opacity: 0.8; }

.abschnitt {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.abschnitt-titel {
  background: #eef2f7;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pruef-item {
  display: flex;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.pruef-item:last-child { border-bottom: none; }
.pruef-item.checked   { background: #f1f8f1; }
.pruef-item.nok       { background: #fff5f5; }

.pruef-text { flex: 1; font-size: 14px; line-height: 1.5; }

.toggle-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.toggle-btn {
  width: 40px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-weight: 700;
}
.toggle-btn.ok-btn.active  { background: var(--success); border-color: var(--success); color: white; }
.toggle-btn.nok-btn.active { background: var(--danger);  border-color: var(--danger);  color: white; }
.toggle-btn:active { transform: scale(0.93); }

/* ===== FOTO-BUTTON ===== */
.foto-bereich {
  margin-top: 10px;
}
.btn-foto {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}
.btn-foto:active { opacity: 0.85; }
.foto-vorschau {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.foto-vorschau-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
}
.foto-vorschau-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.foto-loeschen {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(198,40,40,0.85);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 13px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}

/* ===== BEMERKUNG & UNTERSCHRIFT ===== */
.aufzug-nr-box, .bemerkung-box, .unterschrift-box, .pruefer-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.aufzug-nr-box label, .bemerkung-box label, .unterschrift-box label, .pruefer-box label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--primary);
}
.pruefer-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.btn-pruefer {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
}
.btn-pruefer.active {
  background: #1a5276;
  box-shadow: 0 0 0 3px #aed6f1;
}
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
}
input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}

/* ===== SIGNATURE PAD ===== */
#sig-container {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#sig-canvas {
  width: 100%;
  height: 140px;
  display: block;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}
.btn-sig-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 4px 10px;
  font-size: 12px;
}

/* ===== BUTTONS ===== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: background 0.15s;
}
.btn-primary:active { background: var(--primary-light); }
.btn-secondary {
  padding: 6px 14px;
  background: #e8ecf0;
  color: var(--text);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.btn-qr { font-size: 17px; padding: 18px; margin-bottom: 4px; background: #fff !important; color: #1a3a5c !important; border: 2px solid #1a3a5c !important; }
.btn-submit { background: var(--success); margin-top: 8px; }
.btn-submit:active { background: #1b5e20; }

/* ===== DASHBOARD ===== */
.dashboard-box {
  background: #f0f4f8;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.dashboard-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  color: #1a3a5c;
}
.dashboard-row strong { font-size: 15px; }

/* ===== QR ===== */
.qr-content { background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.qr-hint { color: white; margin-top: 16px; font-size: 14px; text-align: center; }

/* ===== RESULT ===== */
.result-content { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding-top: 60px; }
.result-icon { font-size: 72px; }
.result-text { font-size: 22px; font-weight: 700; }
.result-sub  { font-size: 14px; color: var(--text-muted); text-align: center; }

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 999;
  gap: 16px;
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 48px; height: 48px;
  border: 5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: white; font-size: 16px; font-weight: 600; }

.icon { font-style: normal; }

/* ===== GFB MITARBEITERLISTE ===== */
.gfb-ma-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.gfb-ma-header label { font-weight: 600; font-size: 14px; color: var(--text-main); }
.btn-ma-add { font-size: 13px; padding: 6px 12px; }
.gfb-ma-eintrag { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.gfb-ma-eintrag input[type="text"] { width: 100%; box-sizing: border-box; margin-bottom: 8px; }
.gfb-ma-sig-wrap { position: relative; }
.gfb-ma-sig-wrap canvas { width: 100%; height: 80px; border: 1px dashed var(--border); border-radius: 6px; touch-action: none; user-select: none; display: block; }
.gfb-ma-sig-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.gfb-ma-loeschen { position: absolute; top: 4px; right: 4px; font-size: 11px; padding: 3px 7px; }
.btn-ma-sig-clear { font-size: 11px; padding: 3px 8px; margin-top: 4px; }

/* ===== AMPEL-BADGES ===== */
.ampel-badge {
  min-width: 28px; text-align: center;
  font-size: 18px; flex-shrink: 0;
}
.ampel-unbekannt { opacity: 0.4; }
.ampel-rot  {}
.ampel-gelb {}
.ampel-gruen {}

/* ===== MÄNGEL-BUTTON (Home) ===== */
.btn-maengel {
  width: 100%; padding: 14px 16px;
  background: #fff3cd; border: 2px solid #e6b800;
  border-radius: 12px; font-size: 15px; font-weight: 600;
  color: #7a5c00; cursor: pointer; margin-bottom: 12px;
  text-align: left;
}

/* ===== MÄNGEL-SCREEN ===== */
.mangel-card {
  background: #fff8f0; border: 1px solid #f5c6a0;
  border-radius: 12px; padding: 14px; margin-bottom: 12px;
}
.mangel-header {
  display: flex; justify-content: space-between;
  margin-bottom: 6px;
}
.mangel-bereich { font-weight: 700; color: #1a3a5c; font-size: 14px; }
.mangel-datum   { font-size: 12px; color: #888; }
.mangel-text    { font-size: 14px; color: #333; margin-bottom: 6px; line-height: 1.4; }
.mangel-meta    { font-size: 12px; color: #888; margin-bottom: 10px; }
.btn-erledigt {
  background: #e8f5e9; border: 1px solid #81c784;
  border-radius: 8px; padding: 8px 14px;
  font-size: 13px; color: #2e7d32; cursor: pointer;
}

/* ===== LEITERN FRISTENLISTE ===== */
.leitern-fristenliste {
  margin: 8px 0 16px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dde4ed;
  background: #f8fafc;
}
.leiter-frist-row {
  display: flex;
  align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid #e8edf4;
  gap: 10px;
}
.leiter-frist-row:last-child { border-bottom: none; }
.leiter-frist-ampel {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}
.leiter-frist-nr {
  font-weight: 700;
  color: #1a3a5c;
  font-size: 14px;
  min-width: 80px;
  flex-shrink: 0;
  margin-top: 2px;
}
.leiter-frist-info {
  font-size: 12px;
  color: #555;
  line-height: 1.6;
}
.frist-ueberfaellig {
  color: #c00;
  font-weight: 700;
}
.frist-bald {
  color: #b85c00;
  font-weight: 600;
}
.frist-ok {
  color: #2a7a2a;
}
