:root {
  --bg: #0f1923;
  --bg2: #1a2636;
  --bg3: #243347;
  --accent: #e8ff47;
  --accent2: #47c4ff;
  --text: #e8edf5;
  --text-muted: #7a8fa6;
  --border: #2d4057;
  --danger: #ff4757;
  --success: #2ed573;
  --radius: 12px;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100dvh;
  overflow: hidden;
}

#app { width: 100%; height: 100dvh; position: relative; overflow: hidden; }

/* ── SCREENS ── */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transform: translateX(30px);
  transition: opacity .25s, transform .25s;
  background: var(--bg);
}
.screen.active {
  opacity: 1; pointer-events: all;
  transform: translateX(0);
}
.screen.slide-left { transform: translateX(-30px); }

/* ── LOGIN ── */
#screen-login { justify-content: flex-end; }
.login-bg {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, #0a1520 0%, #1a2e47 50%, #0f1923 100%);
}
.grid-overlay {
  position: absolute; inset: 0;
  background-image: 
    linear-gradient(rgba(72,196,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(72,196,255,.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent);
}
.login-content {
  position: relative; z-index: 1;
  padding: 40px 24px 48px;
  background: linear-gradient(to top, var(--bg) 80%, transparent);
}
.logo-mark {
  width: 48px; height: 48px;
  color: var(--accent);
  margin-bottom: 16px;
}
.logo-mark svg { width: 100%; height: 100%; }
h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 6px;
}
h1 span { color: var(--accent); }
.tagline { color: var(--text-muted); font-size: .78rem; margin-bottom: 32px; letter-spacing: .05em; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: .72rem; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }
input[type=text], input[type=password], input[type=search], input[type=date],
input[type=number], textarea, select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .9rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s;
  width: 100%;
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8fa6' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea { resize: vertical; min-height: 80px; }
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem;
  padding: 14px;
  cursor: pointer;
  letter-spacing: .03em;
  transition: transform .15s, filter .15s;
}
.btn-primary:active { transform: scale(.97); filter: brightness(.9); }
.error-msg { color: var(--danger); font-size: .8rem; text-align: center; }
.hidden { display: none !important; }

/* ── TOP BAR ── */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
}
.top-bar-left { display: flex; align-items: center; gap: 10px; }
.logo-small {
  width: 32px; height: 32px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .8rem;
  flex-shrink: 0;
}
.top-bar-right { display: flex; gap: 8px; }
.screen-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }
.icon-btn {
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:active { background: var(--bg3); }
.btn-save {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .85rem;
  padding: 8px 16px;
  cursor: pointer;
}
.btn-small {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .78rem;
  padding: 5px 10px;
  cursor: pointer;
}

/* ── DASHBOARD ── */
.dash-content {
  flex: 1; overflow-y: auto;
  padding: 20px 16px 100px;
  display: flex; flex-direction: column; gap: 20px;
}
.dash-greeting { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.dash-greeting strong { color: var(--accent); }
.dash-date { font-size: .75rem; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s;
}
.stat-card:active { border-color: var(--accent2); }
.stat-card.accent { border-color: var(--accent); }
.stat-num { font-family: var(--font-display); font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat-card.accent .stat-num { color: var(--accent); }
.stat-label { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted);
}
.inspection-list { display: flex; flex-direction: column; gap: 10px; }
.inspection-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .2s;
  display: flex; align-items: center; gap: 12px;
}
.inspection-card:active { border-color: var(--accent2); }
.insp-icon {
  width: 40px; height: 40px;
  background: var(--bg3);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--accent2);
}
.insp-icon svg { width: 20px; height: 20px; }
.insp-info { flex: 1; min-width: 0; }
.insp-room { font-weight: 500; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insp-type { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.insp-status {
  font-size: .68rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-weight: 600;
  flex-shrink: 0;
}
.status-open { background: rgba(255,71,87,.15); color: var(--danger); }
.status-done { background: rgba(46,213,115,.15); color: var(--success); }
.status-progress { background: rgba(72,196,255,.15); color: var(--accent2); }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .8rem;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color .2s, background .2s;
}
.quick-btn svg { width: 24px; height: 24px; color: var(--accent2); }
.quick-btn:active { border-color: var(--accent2); background: var(--bg3); }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 4px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: var(--font-mono);
  font-size: .6rem;
  transition: color .2s;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn.active, .nav-btn:active { color: var(--accent); }

/* ── FORM CONTENT ── */
.form-content { flex: 1; overflow-y: auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.form-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.form-section-header {
  padding: 12px 16px;
  background: var(--bg3);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .85rem;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
}
.form-section-header svg { width: 16px; height: 16px; color: var(--accent); }
.form-section-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.full { grid-template-columns: 1fr; }

/* ── CHECKLIST ── */
.checklist { display: flex; flex-direction: column; gap: 2px; }
.check-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}
.check-item:active { background: var(--bg3); }
.check-box {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.check-item.checked .check-box {
  background: var(--success);
  border-color: var(--success);
}
.check-item.checked .check-box::after {
  content: '✓';
  color: #000;
  font-size: .85rem;
  font-weight: bold;
}
.check-item.required .check-box { border-color: var(--danger); }
.check-label { font-size: .88rem; flex: 1; }
.check-badge {
  font-size: .65rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.badge-tts { background: rgba(255,71,87,.2); color: var(--danger); }
.badge-ok { background: rgba(46,213,115,.2); color: var(--success); }

/* Radio toggle for TTS/mangelfrei */
.toggle-group { display: flex; gap: 8px; }
.toggle-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .78rem;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.toggle-btn.active-tts { background: rgba(255,71,87,.15); border-color: var(--danger); color: var(--danger); }
.toggle-btn.active-ok { background: rgba(46,213,115,.15); border-color: var(--success); color: var(--success); }

/* ── ANLAGE CARD ── */
.anlage-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.anlage-header {
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.anlage-num {
  width: 28px; height: 28px;
  background: var(--bg3);
  border-radius: 50%;
  font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent2);
  flex-shrink: 0;
  font-weight: 500;
}
.anlage-name { flex: 1; font-size: .85rem; font-weight: 500; }
.anlage-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.anlage-status-dot.ok { background: var(--success); }
.anlage-status-dot.tts { background: var(--danger); }
.anlage-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.anlage-detail { font-size: .72rem; color: var(--text-muted); }
.anlage-book-row {
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem;
}
.anlage-book-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text-muted); }
.anlage-book-row input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }

/* ── PHOTO ── */
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.photo-thumb {
  width: 72px; height: 72px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
  cursor: pointer;
}
.photo-add-btn {
  width: 72px; height: 72px;
  border-radius: 8px;
  border: 2px dashed var(--border);
  background: var(--bg3);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: .62rem;
  gap: 4px;
  flex-shrink: 0;
  transition: border-color .2s;
}
.photo-add-btn svg { width: 20px; height: 20px; }
.photo-add-btn:active { border-color: var(--accent); }

/* ── MODALS ── */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: flex-end;
}
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-box {
  position: relative; z-index: 1;
  width: 100%;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border);
  overflow: hidden;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } }
.modal-header {
  padding: 16px 20px 12px;
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.modal-header button { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }

/* ── CAMERA ── */
.camera-modal { max-height: 90dvh; display: flex; flex-direction: column; }
.camera-preview { flex: 1; background: #000; max-height: 50dvh; overflow: hidden; }
#camera-video { width: 100%; height: 100%; object-fit: cover; }
.camera-controls { padding: 16px; display: flex; justify-content: center; }
.btn-capture {
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.btn-capture:active { transform: scale(.9); }
.capture-inner {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform .15s;
}
.btn-capture:active .capture-inner { transform: scale(.85); }
.photo-preview-list { display: flex; gap: 8px; padding: 0 16px 12px; overflow-x: auto; }
.photo-preview-list .photo-thumb { position: relative; }

/* ── NFC ── */
.nfc-modal { padding: 20px; text-align: center; }
.nfc-animation { position: relative; width: 120px; height: 120px; margin: 16px auto; display: flex; align-items: center; justify-content: center; }
.nfc-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent2);
  animation: nfcPulse 2s ease-in-out infinite;
}
.ring1 { width: 60px; height: 60px; animation-delay: 0s; }
.ring2 { width: 90px; height: 90px; animation-delay: .4s; }
.ring3 { width: 120px; height: 120px; animation-delay: .8s; }
@keyframes nfcPulse {
  0%, 100% { opacity: .8; transform: scale(1); }
  50% { opacity: .2; transform: scale(1.05); }
}
.nfc-icon { width: 36px; height: 36px; color: var(--accent2); }
#nfc-status { font-size: .85rem; color: var(--text-muted); margin: 12px 0; }
.nfc-result {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  text-align: left;
  font-size: .82rem;
  margin-top: 12px;
}

/* ── ROOM LIST ── */
.search-bar { padding: 4px 0; }
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  display: flex; align-items: center; gap: 12px;
}
.room-badge {
  background: var(--bg3);
  color: var(--accent2);
  font-size: .7rem;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 500;
}
.room-info { flex: 1; }
.room-name { font-size: .9rem; font-weight: 500; }
.room-anlagen { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: .82rem;
  z-index: 200;
  white-space: nowrap;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ── LOADING ── */
.loading-spinner {
  width: 30px; height: 30px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── OFFLINE BADGE ── */
.offline-badge {
  position: fixed; top: 60px; left: 0; right: 0;
  background: var(--danger);
  color: white;
  text-align: center;
  font-size: .72rem;
  padding: 6px;
  z-index: 50;
  display: none;
}
.offline-badge.show { display: block; }

/* ── WARTUNGS DATE ── */
.wartung-date { display: flex; align-items: center; gap: 8px; }
.wartung-date label { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
