:root {
  --brand: #16386e;        /* Freudenberg dark blue */
  --brand-dark: #0d2650;
  --blue: #16386e;         /* alias: brand (name kept for reuse) */
  --blue-dark: #0d2650;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --border: #e5e7eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card-bg: #131b2e;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #26324a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--blue);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-size: 16px; }
.logout-form { margin: 0; }
.topbar-logout { color: white; text-decoration: none; opacity: 0.9; font-size: 14px; background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; }

.wizard-main {
  flex: 1;
  padding: 20px 16px 40px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.messages { max-width: 480px; margin: 12px auto 0; padding: 0 16px; }
.message {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 14px;
}
.message-error { background: #fee2e2; color: #991b1b; }
.message-warning { background: #fef3c7; color: #92400e; }
.message-success { background: #dcfce7; color: #166534; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
.step-subtitle { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  border: none;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 12px;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:active { background: var(--blue-dark); }
.btn-secondary { background: transparent; color: var(--blue); border: 2px solid var(--blue); }
.btn-link { background: none; color: var(--muted); text-decoration: underline; padding: 8px; font-weight: 400; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=password], select {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
}

/* ── Camera / scanner ─────────────────────────────────────────── */
#camera-wrap { position: relative; margin-bottom: 10px; }
#reader { width: 100%; border-radius: 14px; overflow: hidden; background: #000; min-height: 240px; }
#reader video { width: 100% !important; display: block; border-radius: 14px; }

/* Overlay sits on top of the video; only interactive bits catch taps. */
#scan-overlay { position: absolute; inset: 0; pointer-events: none; }

.scan-frame {
  position: absolute;
  top: 50%; left: 50%;
  width: 72%; max-width: 300px; aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.35);   /* dim everything outside the frame */
  border-radius: 12px;
}
.scan-frame .c {
  position: absolute; width: 28px; height: 28px;
  border: 4px solid var(--blue); border-radius: 3px;
}
.scan-frame .tl { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.scan-frame .tr { top: -2px; right: -2px; border-left: none; border-bottom: none; }
.scan-frame .bl { bottom: -2px; left: -2px; border-right: none; border-top: none; }
.scan-frame .br { bottom: -2px; right: -2px; border-left: none; border-top: none; }
.scan-line {
  position: absolute; left: 6%; right: 6%; height: 3px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  border-radius: 3px;
  animation: scanmove 2s ease-in-out infinite;
}
@keyframes scanmove { 0% { top: 8%; } 50% { top: 90%; } 100% { top: 8%; } }

.torch-fab {
  position: absolute; top: 12px; right: 12px;
  width: 48px; height: 48px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.55); color: #fff;
  font-size: 22px; line-height: 48px; text-align: center;
  cursor: pointer; pointer-events: auto;
}
.torch-fab.on { background: #f59e0b; }

.focus-ring {
  position: absolute; width: 66px; height: 66px; margin: -33px 0 0 -33px;
  border: 2px solid #fff; border-radius: 50%; pointer-events: none;
  animation: focuspulse 0.6s ease-out forwards;
}
@keyframes focuspulse {
  0% { transform: scale(1.4); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.scan-tip { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 12px; }

.confirm-head {
  font-size: 20px; font-weight: 700; color: var(--success);
  margin-bottom: 4px;
}

.checklist { list-style: none; padding: 0; margin: 0 0 20px; }
.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.checklist li:last-child { border-bottom: none; }
.status-icon { font-size: 18px; width: 22px; text-align: center; }
.status-done { color: var(--success); }
.status-pending { color: var(--muted); }
.status-active { color: var(--blue); }
.status-error { color: var(--danger); }

.summary-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.summary-row:last-child { border-bottom: none; }
.summary-row .label { color: var(--muted); }

details.troubleshoot { margin-top: 20px; }
details.troubleshoot summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
details.troubleshoot ul { padding-left: 20px; color: var(--muted); font-size: 14px; }

.job-list { list-style: none; padding: 0; }
.job-list li { padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.job-list a { color: var(--blue); text-decoration: none; }

/* ── Sensor list ──────────────────────────────────────────────── */
.sensor-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.sensor-main { flex: 1; min-width: 0; }
.sensor-name { font-weight: 600; }
.sensor-meta { font-size: 13px; color: var(--muted); word-break: break-all; }
.sensor-actions { display: flex; gap: 6px; }
.sensor-actions form { margin: 0; }
.btn-icon { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; width: 40px; height: 40px; font-size: 17px; cursor: pointer; color: var(--text); }
.btn-icon.danger { color: var(--danger); }
.sensor-edit { display: none; gap: 8px; padding: 10px 0; }
.sensor-edit.open { display: flex; }
.sensor-edit input { flex: 1; }
.sensor-edit .btn { width: auto; padding: 12px 16px; margin: 0; }

/* ── Freudenberg brand ────────────────────────────────────────── */
.topbar { background: var(--brand); }
.brand-freudenberg { display: flex; flex-direction: column; line-height: 1.05; }
.brand-freudenberg .wordmark { font-size: 19px; font-weight: 800; letter-spacing: 0.2px; color: #fff; }
.brand-freudenberg .sub { font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.85); letter-spacing: 0.4px; text-transform: uppercase; }

.appfoot { text-align: center; padding: 14px; font-size: 12px; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
