:root {
  --ink: #15171C;
  --ink-2: #23262D;
  --ink-3: #33363E;
  --ground: #F3F1EC;
  --surface: #FFFFFF;
  --line: #E2DFD8;
  --muted: #5B5F68;
  --muted-dark: #A9ADB6;
  --accent: #E9A13B;
  --accent-soft: #F9E2BC;
  --late-bg: #FBE7D3;
  --late-ink: #9A4A0B;
  --info-bg: #E8EEF8;
  --info-ink: #1F4E94;
  --ok-ink: #1F4E94;
  --danger: #B3261E;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--ink);
  font-family: Manrope, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { cursor: pointer; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--ground);
  position: relative;
  overflow: hidden;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
}
.screen.dark { background: var(--ink); color: var(--ground); }
.screen.center { align-items: center; justify-content: center; }

.brand {
  font-family: Archivo, sans-serif;
  font-weight: 800;
  font-size: 40px;
  letter-spacing: 10px;
  padding-left: 10px;
}
.display { font-family: Archivo, sans-serif; font-weight: 700; }
.muted { color: var(--muted); }
.caps { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }

/* ---------- PIN ---------- */
.login { padding: 56px 28px calc(28px + var(--safe-b)); align-items: center; }
.login .sub { font-size: 13px; color: var(--muted-dark); letter-spacing: 1.5px; text-transform: uppercase; margin-top: 6px; }
.login h1 { font-size: 20px; font-weight: 600; margin: 56px 0 0; }
.dots { display: flex; gap: 18px; margin-top: 22px; height: 16px; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #5B5F68; }
.dot.on { background: var(--accent); border-color: var(--accent); }
.pin-error { min-height: 22px; margin-top: 16px; color: #F4BE6C; font-weight: 600; font-size: 15px; text-align: center; }
.keypad { margin-top: 18px; display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 28px; }
.key {
  width: 76px; height: 76px; border-radius: 50%; border: 0;
  background: var(--ink-2); color: var(--ground);
  font-family: Archivo, sans-serif; font-size: 28px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
}
.key:active { background: var(--ink-3); }
.key.ghost { background: transparent; color: var(--muted-dark); }
.key.empty { visibility: hidden; }
.login .foot { margin-top: auto; padding-top: 24px; font-size: 14px; color: var(--muted-dark); text-align: center; }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-8px) } 75% { transform: translateX(8px) } }

/* ---------- En-tête ---------- */
.top { padding: 24px 24px 0; display: flex; justify-content: space-between; align-items: center; }
.top .date { font-size: 14px; color: var(--muted); }
.top h1 { margin: 2px 0 0; font-family: Archivo, sans-serif; font-size: 24px; font-weight: 700; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: var(--ground);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0;
}

.content { flex: 1; display: flex; flex-direction: column; padding-bottom: calc(84px + var(--safe-b)); }

/* ---------- Accueil (hors service) ---------- */
.clock-block { padding: 32px 24px 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.big-clock { font-family: Archivo, sans-serif; font-size: 64px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600;
}
.hero { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.scan-btn {
  width: 232px; height: 232px; border-radius: 50%; border: 10px solid var(--accent-soft);
  background: var(--accent); color: var(--ink); box-sizing: content-box;
  font-family: Archivo, sans-serif; font-size: 22px; font-weight: 700; line-height: 1.2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
}
.scan-btn:active { transform: scale(.97); }
.card {
  margin: 0 16px 16px; background: var(--surface); border-radius: 18px; padding: 16px 18px;
}
.shift-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.shift-card .time { font-family: Archivo, sans-serif; font-size: 20px; font-weight: 700; margin-top: 4px; }
.tag { background: var(--info-bg); color: var(--info-ink); font-size: 14px; font-weight: 700; padding: 8px 12px; border-radius: 10px; white-space: nowrap; }
.warn { margin: 16px 16px 0; background: var(--late-bg); color: #7A3A08; border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 600; line-height: 1.4; }

/* ---------- En service ---------- */
.status {
  margin: 20px 16px 0; background: var(--ink); color: var(--ground); border-radius: 26px;
  padding: 22px 22px 24px; display: flex; flex-direction: column; gap: 16px;
}
.status-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.status-head .live { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 2s infinite; }
.pulse.pause { background: #7DA7E8; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(233,161,59,.6) } 70% { box-shadow: 0 0 0 10px rgba(233,161,59,0) } 100% { box-shadow: 0 0 0 0 rgba(233,161,59,0) } }
.timer { font-family: Archivo, sans-serif; font-size: 56px; font-weight: 700; letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.status .sub { font-size: 15px; color: #C9CCD2; margin-top: 6px; }
.bar { height: 8px; border-radius: 999px; background: var(--ink-3); overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; background: var(--accent); }
.bar-legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted-dark); margin-top: 8px; }

.today { padding: 24px 24px 0; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .ico { width: 36px; height: 36px; border-radius: 10px; background: var(--surface); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.row .grow { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row .lbl { font-size: 16px; font-weight: 600; }
.row .val { font-family: Archivo, sans-serif; font-size: 16px; font-weight: 700; }
.late { align-self: flex-start; font-size: 12px; font-weight: 700; color: var(--late-ink); background: var(--late-bg); border-radius: 6px; padding: 2px 7px; }

.actions { margin-top: auto; padding: 20px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.btn {
  height: 58px; border-radius: 16px; border: 2px solid var(--ink); background: var(--surface); color: var(--ink);
  font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); font-weight: 800; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.btn.light-on-dark { background: transparent; border-color: #5B5F68; color: var(--ground); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; }

/* ---------- Barre d'onglets ---------- */
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 8px calc(10px + var(--safe-b)); z-index: 5;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; border: 0; background: none;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.tab[aria-current="page"] { color: var(--ink); font-weight: 800; }

/* ---------- Mes heures ---------- */
.page-title { padding: 24px 24px 0; font-family: Archivo, sans-serif; font-size: 26px; font-weight: 700; margin: 0; }
.week-nav { margin: 14px 24px 0; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-radius: 14px; padding: 4px; }
.week-nav button { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.week-nav button[disabled] { opacity: .3; }
.week-nav .lbl { font-size: 15px; font-weight: 700; text-align: center; }
.summary { margin: 16px 16px 0; background: var(--surface); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.summary .total { font-family: Archivo, sans-serif; font-size: 40px; font-weight: 700; line-height: 1.1; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 110px; }
.bars .col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bars .b { width: 100%; border-radius: 8px; background: var(--accent); min-height: 6px; }
.bars .b.zero { background: var(--line); }
.bars .d { font-size: 12px; font-weight: 700; color: var(--muted); }
.list { padding: 10px 24px 0; }
.day-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.day-row .day { width: 86px; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.day-row .det { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); min-width: 0; }
.day-row .tot { font-family: Archivo, sans-serif; font-size: 16px; font-weight: 700; }
.empty-state { padding: 32px 24px; text-align: center; color: var(--muted); font-size: 15px; }

/* ---------- Planning / profil ---------- */
.shift-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: 16px; padding: 14px 16px; margin: 0 16px 10px; }
.shift-row .d { flex: 1; }
.shift-row .d b { display: block; font-size: 16px; text-transform: capitalize; }
.shift-row .d span { font-size: 14px; color: var(--muted); }
.shift-row .h { font-family: Archivo, sans-serif; font-weight: 700; font-size: 17px; }
.profile { margin: 20px 16px 0; background: var(--surface); border-radius: 20px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.profile .avatar { width: 72px; height: 72px; font-size: 24px; }
.profile h2 { margin: 6px 0 0; font-family: Archivo, sans-serif; font-size: 22px; }
.help { margin: 16px 16px 0; font-size: 14px; color: var(--muted); line-height: 1.5; padding: 0 8px; }

/* ---------- Scanner ---------- */
.scanner { position: fixed; inset: 0; z-index: 20; background: #2A2D33; color: var(--ground); display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .bar-top { position: relative; z-index: 2; padding: calc(16px + var(--safe-t)) 16px 0; display: flex; justify-content: space-between; align-items: center; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(21,23,28,.85); color: var(--ground); display: flex; align-items: center; justify-content: center; }
.round[hidden] { display: none; }
.scanner .title { font-size: 16px; font-weight: 700; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.viewfinder { position: relative; z-index: 2; flex: 1; display: flex; align-items: center; justify-content: center; }
.frame { width: 260px; height: 260px; position: relative; box-shadow: 0 0 0 9999px rgba(21,23,28,.45); border-radius: 18px; }
.frame i { position: absolute; width: 44px; height: 44px; border: 5px solid var(--accent); }
.frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 18px; }
.frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 18px; }
.frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 18px; }
.frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 18px; }
.frame .line { position: absolute; left: 22px; right: 22px; height: 3px; border-radius: 3px; background: var(--accent); top: 20px; animation: scanline 2.2s ease-in-out infinite alternate; }
@keyframes scanline { to { top: 236px; } }
.sheet { position: relative; z-index: 2; background: var(--surface); color: var(--ink); border-radius: 26px 26px 0 0; padding: 24px 24px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.sheet h2 { margin: 0; font-family: Archivo, sans-serif; font-size: 22px; }
.sheet p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-3); }
.info { display: flex; gap: 10px; align-items: flex-start; background: var(--info-bg); color: var(--info-ink); border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.info svg { flex-shrink: 0; margin-top: 1px; }
.error-box { background: var(--late-bg); color: #7A3A08; border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 600; line-height: 1.4; }

/* ---------- Résultat ---------- */
.result { position: fixed; inset: 0; z-index: 30; max-width: 480px; margin: 0 auto; background: var(--ink); color: var(--ground); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; gap: 14px; }
.result .check { width: 96px; height: 96px; border-radius: 50%; background: var(--accent); color: var(--ink); display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.result h2 { margin: 0; font-family: Archivo, sans-serif; font-size: 28px; }
.result .when { font-family: Archivo, sans-serif; font-size: 56px; font-weight: 700; }
.result .late-big { background: var(--late-bg); color: #7A3A08; font-weight: 700; border-radius: 12px; padding: 10px 14px; font-size: 15px; }
.result .btn { max-width: 320px; margin-top: 18px; }

/* ---------- Choix d'action ---------- */
.choice { position: fixed; inset: 0; z-index: 25; max-width: 480px; margin: 0 auto; background: rgba(21,23,28,.6); display: flex; align-items: flex-end; }
.choice .sheet { width: 100%; }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--ground); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 40; max-width: 90%; text-align: center; }

.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--ink-3); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 481px) {
  .app { box-shadow: 0 0 0 1px rgba(255,255,255,.05); }
}
