/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #334155;
  --border:    rgba(148, 163, 184, 0.12);
  --text:      #f8fafc;
  --muted:     #94a3b8;
  --green:     #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red:       #ef4444;
  --red-dim:   rgba(239, 68, 68, 0.12);
  --amber:     #f59e0b;
  --primary:   #6366f1;
  --radius:    16px;
  /* logo-color-bg.png / logo-white.png — ratio intrinsèque */
  --cp-logo-aspect: 3163 / 1093;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── Views ────────────────────────────────────────────────────────────────── */
.view { display: none; min-height: 100dvh; }
.view.active { display: flex; flex-direction: column; }

/* ── Loading ──────────────────────────────────────────────────────────────── */
#view-loading {
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.loading-logo {
  display: block;
  width: min(200px, 88vw);
  height: auto;
  max-height: 72px;
  aspect-ratio: var(--cp-logo-aspect);
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
  margin: 0 auto 0.5rem;
}
.loader {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ────────────────────────────────────────────────────────────────── */
#view-login {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
}
.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}
.brand-icon {
  width: min(200px, 100%);
  height: auto;
  max-height: 64px;
  aspect-ratio: var(--cp-logo-aspect);
  background: transparent;
  border-radius: 14px;
  display: inline-block;
  object-fit: contain;
  object-position: center;
  margin-bottom: 0.35rem;
}
.login-brand h1 { font-size: 1.4rem; font-weight: 700; }
.login-brand p  { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

/* ── Pointage ─────────────────────────────────────────────────────────────── */
#view-pointage {
  padding: 0;
}
.pointage-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.header-logo {
  width: auto;
  max-width: min(132px, 38vw);
  height: auto;
  max-height: 36px;
  aspect-ratio: var(--cp-logo-aspect);
  object-fit: contain;
  object-position: left center;
  border-radius: 8px;
  flex-shrink: 0;
}
.restaurant-name {
  font-weight: 700;
  font-size: 0.95rem;
}
.logout-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.logout-btn:hover { color: var(--red); border-color: var(--red-dim); }

.header-actions-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid var(--primary);
  color: var(--primary);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.download-btn:hover, .download-btn:active {
  background: var(--primary);
  color: #fff;
}

.pointage-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.5rem;
  gap: 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.clock-display {
  text-align: center;
}
.clock-time {
  font-size: clamp(3.5rem, 15vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clock-date {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.4rem;
  text-transform: capitalize;
}

.employee-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.employee-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.employee-info { flex: 1; }
.employee-name { font-weight: 700; font-size: 1rem; }
.employee-role { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.status-label { color: var(--muted); font-size: 0.8rem; margin-bottom: 0.5rem; }
.status-value { font-size: 1.1rem; font-weight: 700; }
.status-duration {
  display: inline-block;
  background: var(--green-dim);
  color: var(--green);
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.4rem;
}
.status-times {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 0.75rem;
}
.status-times div { text-align: center; }
.status-times span { display: block; font-size: 0.72rem; color: var(--muted); }
.status-times strong { font-size: 1rem; }

.action-area {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.btn-action {
  width: 100%;
  padding: 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.15s;
  letter-spacing: -0.01em;
}
.btn-action:active { transform: scale(0.97); }
.btn-action:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-action.btn-in {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.35);
}
.btn-action.btn-out {
  background: var(--red);
  color: #fff;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
}
.btn-action.btn-pause {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}
.btn-action.btn-resume {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.35);
}
.btn-icon-lg { font-size: 1.4rem; }

/* Pulse indicator */
.pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: pulse-anim 1.5s ease infinite;
  margin-right: 0.4rem;
}
@keyframes pulse-anim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ── Success ──────────────────────────────────────────────────────────────── */
#view-success {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}
.success-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 1.5rem;
  animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.success-icon.in  { background: var(--green-dim); }
.success-icon.out { background: var(--red-dim); }
@keyframes pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.success-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.5rem; }
.success-msg   { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.5rem; }
.success-time  { font-size: 2rem; font-weight: 700; margin: 0.75rem 0; }
.btn-back {
  margin-top: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 2rem;
  border-radius: 12px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500;
}

/* ── Error ────────────────────────────────────────────────────────────────── */
#view-error {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  flex-direction: column;
  gap: 1rem;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.field input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.field input::placeholder { color: var(--surface2); }

.btn-submit {
  width: 100%;
  padding: 0.9rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: opacity 0.15s;
  font-family: inherit;
}
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-submit:not(:disabled):hover { opacity: 0.9; }

.alert-error {
  background: var(--red-dim);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.alert-error:not(:empty) { display: block; }
.alert-error.show { display: block; }

/* ── Login extras ─────────────────────────────────────────────────────────── */
.brand-subtitle { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }

.brochure-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 8px;
  transition: color 0.15s;
}
.brochure-link:hover { color: var(--primary); }
.login-hint { color: var(--primary); font-size: 0.82rem; text-align: center; margin-bottom: 0.75rem; min-height: 1.2em; }
.brand-icon.small {
  width: auto;
  max-width: min(148px, 42vw);
  height: auto;
  max-height: 44px;
  aspect-ratio: var(--cp-logo-aspect);
  object-fit: contain;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ── Sélecteur restaurant ─────────────────────────────────────────────────── */
#view-pick-restaurant {
  padding: 2rem 1.5rem;
  flex-direction: column;
  gap: 1.5rem;
}
.pick-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.pick-welcome { font-size: 0.85rem; color: var(--muted); }
.pick-welcome strong { color: var(--text); }
.pick-subtitle { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

.restaurant-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}
.restaurant-pick-btn {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.restaurant-pick-btn:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
}
.pick-icon { font-size: 1.4rem; flex-shrink: 0; }
.pick-name { font-weight: 700; display: block; font-size: 1rem; }
.pick-address { font-size: 0.78rem; color: var(--muted); display: block; margin-top: 0.15rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0.5rem;
  margin-top: auto;
  align-self: center;
}
.btn-link:hover { color: var(--red); }

/* ── Header restaurant + changer ─────────────────────────────────────────── */
.header-restaurant {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.change-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  transition: color 0.15s, border-color 0.15s;
}
.change-btn:hover { color: var(--primary); border-color: var(--primary); }

/* ── btn-done (journée complète) ──────────────────────────────────────────── */
.btn-action.btn-done {
  background: var(--surface2);
  color: var(--muted);
  box-shadow: none;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-size: 0.88rem;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.toast-error { border-color: var(--red-dim); color: #fca5a5; }
.toast.toast-success { border-color: rgba(34,197,94,.3); color: var(--green); }

/* ── Bottom navigation ────────────────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--primary); }
.nav-btn:not(.active):hover { color: var(--text); }
.nav-icon { font-size: 1.3rem; line-height: 1; }

/* ── Vue planning ─────────────────────────────────────────────────────────── */
#view-planning {
  display: flex;
  flex-direction: column;
}
.plan-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  -webkit-overflow-scrolling: touch;
}

/* Navigation semaine */
.week-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.week-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  width: 34px; height: 34px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.week-nav-btn:hover { background: var(--surface2); }
.week-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.week-nav-center { flex: 1; text-align: center; }
.week-label { font-weight: 700; font-size: 0.85rem; }
.week-sub   { color: var(--muted); font-size: 0.72rem; margin-top: 1px; }

/* Résumé semaine */
.week-summary {
  display: flex;
  gap: 0.75rem;
}
.summary-chip {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.sum-num   { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.sum-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Jours */
.plan-days { display: flex; flex-direction: column; gap: 0.75rem; }

.plan-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem;
}
.loader-sm {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.plan-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.plan-day-today {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.plan-day-off { opacity: 0.55; }

.plan-day-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}
.plan-day-off .plan-day-header { border-bottom: none; }

.day-name { font-weight: 700; font-size: 0.85rem; min-width: 70px; }
.day-date { color: var(--muted); font-size: 0.78rem; }
.today-badge {
  margin-left: auto;
  background: rgba(99,102,241,.15);
  color: var(--primary);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  border: 1px solid rgba(99,102,241,.25);
}
.plan-day-off-label {
  padding: 0.55rem 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

/* Shift card */
.shift-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--border);
}
.shift-card-left  { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.shift-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; flex-shrink: 0; }

.shift-name-lg { font-weight: 700; font-size: 0.88rem; }
.shift-time-lg { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.shift-note    { color: var(--amber); font-size: 0.72rem; }
.shift-duration {
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(99,102,241,.1);
  color: var(--primary);
  padding: 0.15rem 0.55rem;
  border-radius: 8px;
}

.shift-status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
}
.shift-scheduled { border-left: 3px solid var(--muted); }
.shift-scheduled .shift-status-badge { background: rgba(148,163,184,.12); color: var(--muted); }
.shift-confirmed { border-left: 3px solid var(--green); }
.shift-confirmed .shift-status-badge { background: var(--green-dim); color: var(--green); }
.shift-absent    { border-left: 3px solid var(--red); }
.shift-absent    .shift-status-badge { background: var(--red-dim); color: var(--red); }

/* Empty state */
.plan-empty {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.plan-empty-icon { font-size: 2.5rem; }
.plan-empty-sub  { font-size: 0.75rem; color: var(--muted); opacity: 0.7; }

/* ── Succès view centré ───────────────────────────────────────────────────── */
#view-success {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  gap: 0;
}

/* ── Bannière install PWA ────────────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  z-index: 900;
  transform: translateY(110%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
}
.install-banner.show { transform: translateY(0); }

/* Affiche uniquement le bloc correspondant à la plateforme */
.install-banner .install-content               { display: none; }
.install-banner[data-platform="android"] .install-content[data-show="android"] { display: flex; align-items: center; gap: .75rem; }
.install-banner[data-platform="ios"]    .install-content[data-show="ios"]     { display: flex; align-items: center; gap: .75rem; }

.install-icon { font-size: 1.8rem; flex-shrink: 0; }
.install-text { flex: 1; }
.install-text strong { display: block; font-size: .88rem; font-weight: 700; }
.install-text span   { display: block; font-size: .75rem; color: var(--muted); margin-top: .15rem; line-height: 1.4; }

.install-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: .5rem 1rem;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.install-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: .25rem .5rem;
  flex-shrink: 0;
}

/* ── QR Scanner overlay ───────────────────────────────────────────────────── */
.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.qr-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.qr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-top));
  padding-top: calc(1rem + env(safe-area-inset-top));
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.qr-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}
.qr-cancel-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 99px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.qr-cancel-btn:hover { background: rgba(255,255,255,0.2); }

.qr-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#qr-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#qr-canvas {
  display: none;
}

/* Scan frame */
.qr-frame {
  position: relative;
  z-index: 2;
  width: min(72vw, 280px);
  height: min(72vw, 280px);
}
.qr-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: #fff;
  border-style: solid;
}
.qr-corner.tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 6px 0 0 0; }
.qr-corner.tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 6px 0 0; }
.qr-corner.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 6px; }
.qr-corner.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 6px 0; }

/* Vignette outside the frame */
.qr-viewport::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(
      ellipse min(72vw, 280px) min(72vw, 280px) at center,
      transparent 49%,
      rgba(0,0,0,0.65) 50%
    );
  pointer-events: none;
}

/* Scan line animation */
.qr-scan-line {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  box-shadow: 0 0 8px var(--green);
  animation: scan 2s linear infinite;
  border-radius: 99px;
}
@keyframes scan {
  0%   { top: 10%; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { top: 90%; opacity: 0; }
}

.qr-footer {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 1.5rem 2rem calc(1.5rem + env(safe-area-inset-bottom));
  text-align: center;
  flex-shrink: 0;
}
.qr-hint {
  color: rgba(255,255,255,0.75);
  font-size: 0.85rem;
  line-height: 1.5;
}
.qr-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 1.2em;
  color: var(--amber);
  transition: color 0.2s;
}
.qr-status.success { color: var(--green); }
.qr-status.error   { color: var(--red); }

/* ── Historique semaine ───────────────────────────────────────────────────── */
.history-section {
  width: 100%;
  max-width: 360px;
}
.history-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.6rem;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.history-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  font-size: 0.8rem;
}
.history-day   { font-weight: 600; }
.history-times { color: var(--muted); font-variant-numeric: tabular-nums; }
.history-status { font-weight: 600; font-size: 0.72rem; white-space: nowrap; }
