:root {
  --bg: #08111f;
  --panel: rgba(255, 255, 255, .09);
  --text: #f8fafc;
  --muted: #a8b3c7;
  --line: rgba(255,255,255,.16);
  --accent: #2dd4bf;
  --accent-2: #f97316;
  --success: #22c55e;
  --danger: #fb7185;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 10% 0%, rgba(45,212,191,.22), transparent 28%), radial-gradient(circle at 88% 8%, rgba(249,115,22,.18), transparent 30%), linear-gradient(135deg, #050816 0%, var(--bg) 48%, #10172a 100%);
  color: var(--text);
  min-height: 100vh;
}
.app-shell { width: min(1480px, 96vw); margin: 0 auto; padding: 24px 0 34px; }
.topbar, .panel-card, .preview-area, .tab-panel, .mode-switch {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255,255,255,.11), rgba(255,255,255,.055));
  box-shadow: 0 20px 70px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.10);
  backdrop-filter: blur(18px);
}
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 22px; padding: 18px 20px; border-radius: 30px; }
.brand { display: flex; align-items: center; gap: 18px; }
.brand-logo { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 18px 26px rgba(0,0,0,.30)); }
.eyebrow { display: inline-block; color: #99f6e4; font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 2px 0 2px; font-size: clamp(30px, 4vw, 48px); line-height: .95; letter-spacing: -.055em; font-weight: 950; }
h1 span { background: linear-gradient(135deg, #2dd4bf, #60a5fa 50%, #f97316); -webkit-background-clip: text; background-clip: text; color: transparent; }
p { margin: 0; color: var(--muted); }
.tabs { display: flex; gap: 8px; padding: 7px; border-radius: 18px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); }
.tab, button, select { border-radius: 16px; border: 1px solid var(--line); color: var(--text); background: rgba(15,23,42,.74); padding: 13px 15px; font-weight: 850; outline: none; }
button { width: 100%; cursor: pointer; transition: transform .15s, opacity .15s, box-shadow .15s; }
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(0,0,0,.20); }
button:disabled { opacity: .45; cursor: not-allowed; }
.tab { border: 0; background: transparent; padding: 11px 20px; }
.tab.active, .mode-switch button.active { background: linear-gradient(135deg, rgba(45,212,191,.28), rgba(249,115,22,.20)); }
.tab-panel { display: none; margin-top: 16px; border-radius: 22px; padding: 14px 18px; color: var(--muted); }
.tab-panel.active { display: block; }
.tab-panel strong { color: var(--text); margin-right: 8px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(460px, 100%); margin-top: 16px; padding: 8px; border-radius: 22px; }
.workspace { display: grid; grid-template-columns: 380px 1fr; gap: 20px; margin-top: 20px; }
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.panel-card { border-radius: 26px; padding: 19px; }
.panel-card h2 { margin: 0 0 15px; font-size: 17px; letter-spacing: -.02em; }
.field-label { display: block; color: var(--muted); margin-bottom: 8px; font-weight: 850; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.field-spaced { margin-top: 14px; }
select { width: 100%; }
.primary { background: linear-gradient(135deg, #0ea5e9, #6366f1); border: 0; }
.success { background: linear-gradient(135deg, #14b8a6, #22c55e); border: 0; color: #022c22; }
.danger { background: rgba(251, 113, 133, .14); border-color: rgba(251, 113, 133, .38); color: #ffe4e6; }
.upload-box { margin-top: 16px; min-height: 126px; border: 1px dashed rgba(255,255,255,.30); border-radius: 22px; display: grid; place-content: center; text-align: center; cursor: pointer; background: linear-gradient(135deg, rgba(45,212,191,.10), rgba(249,115,22,.08)); }
.upload-box input { display: none; }
.upload-box span { font-weight: 900; }
.upload-box small { margin-top: 6px; color: var(--muted); }
video { width: 100%; aspect-ratio: 4/3; background: #020617; border-radius: 20px; object-fit: cover; border: 1px solid var(--line); }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.status { margin-top: 10px; font-size: 14px; }
.small { font-size: 12px; }
#photoPreview { width: 100%; border-radius: 18px; border: 1px solid var(--line); margin-bottom: 12px; }
.preview-area { border-radius: 30px; padding: 20px; min-width: 0; }
.preview-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.preview-header h2 { margin: 0 0 5px; font-size: 24px; letter-spacing: -.03em; }
#paperBadge { display: inline-flex; padding: 10px 13px; border: 1px solid var(--line); border-radius: 999px; color: #99f6e4; background: rgba(45,212,191,.10); font-weight: 900; white-space: nowrap; }
.progress-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.progress-steps span { text-align: center; padding: 10px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-weight: 900; }
.progress-steps span.active { color: #022c22; background: var(--accent); }
.progress-steps span.done { color: #dcfce7; background: rgba(34,197,94,.22); }
.canvas-wrap { position: relative; display: grid; place-items: center; min-height: 620px; border-radius: 24px; background: rgba(2, 6, 23, .48); overflow: auto; border: 1px solid rgba(255,255,255,.10); padding: 24px; }
canvas { width: min(100%, 520px); height: auto; background: white; border-radius: 18px; box-shadow: 0 25px 90px rgba(0,0,0,.40); touch-action: none; }
.empty-state { position: absolute; text-align: center; padding: 24px; max-width: 420px; }
.empty-state h3 { margin: 0 0 8px; }
.retake-grid { display: grid; gap: 8px; margin-bottom: 12px; }
#finalActionsPanel button, #qrPanel button, #qrPanel a { margin-top: 8px; }
.download-link { display: block; text-align: center; text-decoration: none; border-radius: 16px; border: 1px solid var(--line); color: var(--text); background: rgba(15,23,42,.74); padding: 13px 15px; font-weight: 850; }
#qrCode { display: grid; place-items: center; min-height: 220px; background: white; border-radius: 20px; padding: 16px; }
.hidden { display: none !important; }
.countdown-overlay, .print-overlay, .modal, .flash-overlay { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; }
.countdown-overlay { background: rgba(2,6,23,.78); backdrop-filter: blur(16px); text-align: center; }
#countdownNumber { font-size: clamp(90px, 18vw, 220px); line-height: .8; font-weight: 950; color: white; text-shadow: 0 20px 70px rgba(45,212,191,.55); }
#countdownLabel { margin-top: 28px; font-size: 28px; color: #99f6e4; font-weight: 950; }
.flash-overlay { background: white; animation: flash .32s ease-out forwards; }
@keyframes flash { from { opacity: .95; } to { opacity: 0; } }
.modal, .print-overlay { background: rgba(2, 6, 23, .74); backdrop-filter: blur(18px); }
.modal-card, .print-loader-card { width: min(440px, 88vw); padding: 32px 28px; text-align: center; border-radius: 30px; border: 1px solid rgba(255,255,255,.18); background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.08)); box-shadow: 0 30px 90px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.16); }
.spinner { width: 72px; height: 72px; margin: 0 auto; border-radius: 999px; border: 6px solid rgba(255,255,255,.16); border-top-color: var(--accent); border-right-color: var(--accent-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.viewer-mode .operator-only, body.viewer-mode .tabs, body.viewer-mode #paperBadge { display: none !important; }
body.viewer-mode .workspace { grid-template-columns: minmax(320px, 440px) 1fr; }
body.viewer-mode .preview-header p { display: none; }
@media (max-width: 980px) {
  .workspace, body.viewer-mode .workspace { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .brand-logo { width: 86px; height: 86px; }
  .tabs { justify-content: center; }
}
@media print {
  body * { visibility: hidden; }
  #boothCanvas { visibility: visible; position: fixed; inset: 0; width: 100vw !important; max-width: none; border-radius: 0; box-shadow: none; }
}

/* Role selection landing screen */
.role-select {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 10%, rgba(45,212,191,.22), transparent 28%), radial-gradient(circle at 80% 0%, rgba(249,115,22,.18), transparent 30%), linear-gradient(135deg, #050816 0%, var(--bg) 48%, #10172a 100%);
}
.role-card {
  width: min(540px, 94vw);
  padding: 34px;
  border-radius: 34px;
  text-align: center;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255,255,255,.13), rgba(255,255,255,.06));
  box-shadow: 0 30px 90px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.14);
  backdrop-filter: blur(18px);
}
.role-logo { width: 150px; height: 150px; object-fit: contain; margin-bottom: 14px; filter: drop-shadow(0 20px 34px rgba(0,0,0,.32)); }
.role-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }

/* Clean viewer kiosk screen */
body.viewer-mode .topbar,
body.viewer-mode .tab-panel,
body.viewer-mode .preview-header,
body.viewer-mode .progress-steps,
body.viewer-mode .operator-only,
body.viewer-mode .operator-action { display: none !important; }
body.viewer-mode .app-shell { width: min(640px, 96vw); padding-top: 18px; }
body.viewer-mode .workspace { display: block; margin-top: 0; }
body.viewer-mode .sidebar { gap: 14px; }
body.viewer-mode .sidebar .panel-card:not(:has(#cameraFeed)):not(#finalActionsPanel):not(#qrPanel) { display: none !important; }
body.viewer-mode .panel-card { border-radius: 30px; padding: 24px; }
body.viewer-mode video { aspect-ratio: 4/3; border-radius: 24px; }
body.viewer-mode .button-row { grid-template-columns: 1fr; }
body.viewer-mode #startCameraBtn { display: none; }
body.viewer-mode .preview-area.viewer-final-only { display: none; }
body.viewer-mode .preview-area:not(.viewer-final-only) { display: block; margin-top: 16px; padding: 14px; }
body.viewer-mode .canvas-wrap { min-height: 0; padding: 12px; border-radius: 24px; }
body.viewer-mode canvas { width: min(100%, 440px); }
body.viewer-mode #finalActionsPanel { margin-top: 14px; }
body.viewer-mode #finalActionsPanel h2::after { content: ' — choose a photo to retake or tap Done'; color: var(--muted); font-size: 12px; font-weight: 700; display: block; margin-top: 4px; }
body.viewer-mode #qrPanel { margin-top: 14px; }

@media (max-width: 620px) {
  .role-buttons { grid-template-columns: 1fr; }
  .role-card { padding: 26px 20px; }
  .role-logo { width: 120px; height: 120px; }
}
.live-status-list { display: grid; gap: 8px; margin-top: 12px; }
.live-status-list span { display: block; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(15,23,42,.48); color: var(--muted); font-weight: 850; }
body.viewer-mode #operatorLivePanel { display: none !important; }
