:root {
  --bg: #05060a;
  --surface: #0e1016;
  --surface-2: #161922;
  --surface-3: #1e2230;
  --border: #242836;
  --text: #e8eaf0;
  --muted: #8a90a2;
  --silver: #c9ccd5;
  --accent: #a8dcfb;
  --accent-strong: #7cc8f6;
  --accent-ink: #04121c;
  --todo: #c9ccd5;
  --wait: #f5b84a;
  --ok: #4ade80;
  --ko: #f87171;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 14px; outline: none; font-size: 16px; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
::placeholder { color: #5d6375; }
.hidden { display: none !important; }

/* Démarrage */
.boot { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 24px; }
.boot img { width: 88px; height: 88px; border-radius: 22px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Structure */
.shell { max-width: 680px; margin: 0 auto; min-height: 100vh; padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 96px); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 6px 2px 18px; }
.topbar img { width: 38px; height: 38px; border-radius: 10px; }
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: .3px; font-weight: 700; }
.topbar h1 span { color: var(--accent); }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .grow { flex: 1; }
.demo-badge { font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent); padding: 4px 8px; border-radius: 99px; letter-spacing: .4px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 26px 2px 10px; font-weight: 600; }

/* Barre du bas */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(8, 9, 14, .92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border); padding: 8px 8px calc(var(--safe-b) + 8px);
}
.tabbar-inner { max-width: 680px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); padding: 4px 0; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.tab-add { justify-self: center; width: 54px; height: 54px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 6px 24px rgba(168, 220, 251, .25); margin-top: -18px; }
.tab-add svg { width: 28px; height: 28px; }

/* Cartes stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: left; position: relative; overflow: hidden; }
.stat .n { font-size: 30px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.stat:active { transform: scale(.98); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.st-todo .dot, .dot.st-todo { background: var(--todo); }
.st-wait .dot, .dot.st-wait { background: var(--wait); }
.st-ok .dot, .dot.st-ok { background: var(--ok); }
.st-ko .dot, .dot.st-ko { background: var(--ko); }
.stat.st-ok .n { color: var(--ok); }
.stat.st-wait .n { color: var(--wait); }
.stat.st-ko .n { color: var(--ko); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.rate-row { display: flex; justify-content: space-between; align-items: baseline; }
.rate-row b { font-size: 22px; color: var(--accent); }
.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 10px; display: flex; }
.bar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.today { display: flex; gap: 18px; color: var(--muted); font-size: 14px; margin-top: 12px; }
.today b { color: var(--text); }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 18px; border-radius: 14px; font-weight: 650; background: var(--surface-2); border: 1px solid var(--border); transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-block { width: 100%; }
.btn-big { padding: 18px; font-size: 17px; border-radius: 16px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { color: var(--ko); }
.btn-small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack { display: grid; gap: 10px; }

/* Actions de contact */
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.act svg { width: 26px; height: 26px; }
.act.call { color: var(--accent); }
.act.sms { color: #7ee0a5; }
.act.wa { color: #4ade80; }
.act:active { transform: scale(.96); }

.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.res { padding: 16px 6px; border-radius: 16px; font-weight: 700; border: 1.5px solid var(--border); background: var(--surface); }
.res.st-wait { color: var(--wait); }
.res.st-ok { color: var(--ok); }
.res.st-ko { color: var(--ko); }
.res.on.st-wait { background: rgba(245, 184, 74, .14); border-color: var(--wait); }
.res.on.st-ok { background: rgba(74, 222, 128, .14); border-color: var(--ok); }
.res.on.st-ko { background: rgba(248, 113, 113, .14); border-color: var(--ko); }
.res:active { transform: scale(.96); }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; border: 1px solid var(--border); }
.seg button { padding: 10px 2px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface-3); color: var(--text); }
.seg button.on.st-wait { color: var(--wait); }
.seg button.on.st-ok { color: var(--ok); }
.seg button.on.st-ko { color: var(--ko); }

/* Liste */
.searchbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(var(--safe-t) + 4px) 0 10px; margin-top: calc(-1 * var(--safe-t) - 4px); }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search input { padding-left: 40px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.chip b { color: var(--text); font-weight: 650; }
.chip.on { background: var(--surface-3); border-color: var(--silver); color: var(--text); }
.list-tools { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; padding: 8px 2px; }
.list-tools select { width: auto; padding: 6px 10px; font-size: 13px; border-radius: 10px; background: var(--surface); }
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 12px 12px 14px; text-align: left; width: 100%; }
.item .main { flex: 1; min-width: 0; }
.item .num { font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: .2px; }
.item .meta { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .quick { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--accent); flex: none; }
.item .quick svg { width: 20px; height: 20px; }
.pill { font-size: 12px; font-weight: 650; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); display: inline-flex; align-items: center; gap: 5px; }
.pill.st-wait { color: var(--wait); }
.pill.st-ok { color: var(--ok); }
.pill.st-ko { color: var(--ko); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty b { color: var(--text); display: block; font-size: 17px; margin-bottom: 6px; }

/* Feuilles (fenêtres du bas) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 40; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-top-left-radius: 22px; border-top-right-radius: 22px; border: 1px solid var(--border);
  padding: 10px 18px calc(var(--safe-b) + 20px); animation: up .22s cubic-bezier(.2, .8, .2, 1);
  max-width: 680px; margin: 0 auto;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 19px; flex: 1; }
.close { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.close svg { width: 18px; height: 18px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 14px 2px 6px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 2px 0; }
.check { font-size: 14px; margin: 8px 2px 0; min-height: 20px; }
.check.ok { color: var(--ok); }
.check.ko { color: var(--ko); }
.check.warn { color: var(--wait); }
.big-num { font-size: 28px; font-weight: 750; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.copy { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.copy svg { width: 15px; height: 15px; }
.infos { display: grid; gap: 8px; font-size: 14px; }
.infos div { display: flex; justify-content: space-between; gap: 12px; }
.infos span:first-child { color: var(--muted); }
.history { display: grid; gap: 8px; font-size: 14px; }
.history div { display: flex; gap: 10px; color: var(--muted); }
.history b { color: var(--text); font-weight: 600; }
.report { display: grid; gap: 6px; background: var(--surface-2); border-radius: 14px; padding: 14px; font-size: 15px; margin-top: 12px; }
.report div { display: flex; justify-content: space-between; }
.tpl-pick { display: grid; gap: 10px; }
.tpl-pick button { text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.tpl-pick button b { display: block; margin-bottom: 4px; }
.tpl-pick button span { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tabs2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 6px; }
.tabs2 button { padding: 10px; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 15px; }
.tabs2 button.on { background: var(--surface-3); color: var(--text); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.input-row .btn { flex: none; }
.preview { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; color: var(--silver); font-size: 15px; white-space: pre-wrap; }

/* Session */
.session-card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 22px 18px; text-align: center; animation: up .2s ease; }
.session-card .big-num { font-size: 32px; margin: 6px 0 2px; }
.session-card .name { color: var(--silver); font-size: 17px; min-height: 24px; }
.session-card .note { color: var(--muted); font-size: 14px; margin-top: 8px; }
.progress { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin: 4px 2px 12px; }
.progress b { color: var(--text); }
.queue-pick { display: grid; gap: 10px; }
.queue-pick button { display: flex; align-items: center; justify-content: space-between; padding: 18px; border-radius: 16px; background: var(--surface); border: 1.5px solid var(--border); font-weight: 650; font-size: 17px; }
.queue-pick button.on { border-color: var(--accent); }
.queue-pick button span { color: var(--muted); font-weight: 500; }
.done-ico { font-size: 54px; margin: 10px 0; }

/* Réglages */
.menu { display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.menu > * { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left; width: 100%; }
.menu > *:last-child { border-bottom: 0; }
.menu .grow { flex: 1; min-width: 0; }
.menu .grow small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu select { width: auto; padding: 8px 10px; font-size: 14px; }
.menu svg.chev { width: 18px; height: 18px; color: var(--muted); }

/* Connexion */
.auth { max-width: 400px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 22px calc(var(--safe-b) + 24px); }
.auth .logo { width: 96px; height: 96px; border-radius: 24px; margin: 0 auto 14px; display: block; }
.auth h1 { text-align: center; margin: 0 0 4px; font-size: 26px; }
.auth h1 span { color: var(--accent); }
.auth p.sub { text-align: center; color: var(--muted); margin: 0 0 26px; }
.auth .links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 14px; }
.auth .links button { color: var(--accent); }
.err { color: var(--ko); font-size: 14px; margin-top: 10px; min-height: 18px; text-align: center; }

/* Toast */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 92px); z-index: 60; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--surface-3); border: 1px solid var(--border); color: var(--text); padding: 11px 16px; border-radius: 14px; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: up .2s ease; max-width: 460px; }
.toast.ok { border-color: rgba(74, 222, 128, .5); }
.toast.err { border-color: rgba(248, 113, 113, .6); }
.toast.out { opacity: 0; transition: opacity .3s; }

/* Modale de confirmation */
.confirm { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, .6); animation: fade .15s; }
.confirm .box { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 20px; width: 100%; max-width: 360px; }
.confirm h4 { margin: 0 0 6px; font-size: 18px; }
.confirm p { color: var(--muted); margin: 0 0 18px; font-size: 15px; }

@media (min-width: 760px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 22px; animation: fade .18s; max-height: 86vh; }
  .sheet .grab { display: none; }
}

/* Mot de passe : bouton œil */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 50px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); border-radius: 10px; }
.pw-eye svg { width: 20px; height: 20px; }
.pw-eye:active { color: var(--accent); }
