/* SEMEP Pointage — feuille de style unique (mobile d'abord) */
:root {
  --brand: #0f766e;
  --brand-dark: #0b5f58;
  --brand-soft: #e6f4f2;
  --bg: #f1f0ee;
  --surface: #fff;
  --surface-2: #f7f6f5;
  --border: #dcd9d5;
  --text: #1f2421;
  --muted: #6b6f6c;
  --ok: #2e8b47;   --ok-soft: #e3f3e7;
  --warn: #a8650a; --warn-soft: #fdf1dc;
  --bad: #c0392b;  --bad-soft: #fbe7e4;
  --info: #1e6fb8; --info-soft: #e5f0fa;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior-y: contain; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---- Barre du haut ---- */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-top)) 10px 8px;
       background: var(--brand); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar-app { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.bar-sub { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-back, .bar-menu { background: none; border: 0; color: #fff; font-size: 28px; line-height: 1; width: 40px; height: 40px; border-radius: 50%; }
.bar-back:active, .bar-menu:active { background: rgba(255,255,255,.15); }
.pill { border: 0; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.18); color: #fff; white-space: nowrap; }
.pill.pending { background: #fbbf24; color: #3b2a00; }
.pill.offline { background: rgba(0,0,0,.25); }
.pill.error { background: var(--bad); }

/* ---- Vues ---- */
.view { padding: 12px 12px calc(96px + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }
.splash { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.logo { font-weight: 800; font-size: 34px; letter-spacing: .08em; color: var(--brand); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card h2 { margin: 0 0 8px; font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hint { background: var(--info-soft); color: #134a7a; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.error-box { background: var(--bad-soft); color: #7a1f15; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }

/* ---- Formulaires ---- */
label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 17px; }
.input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.input.code { text-transform: uppercase; letter-spacing: .12em; font-weight: 600; text-align: center; font-size: 20px; }
.btn { display: block; width: 100%; border: 0; border-radius: 10px; padding: 14px; font-weight: 600; font-size: 17px; background: var(--brand); color: #fff; margin-top: 14px; }
.btn:active { background: var(--brand-dark); }
.btn:disabled { opacity: .5; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---- Clavier du code PIN ---- */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 22px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots span.on { background: var(--brand); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 0 auto; }
.keypad button { height: 64px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); font-size: 26px; font-weight: 500; }
.keypad button:active { background: var(--brand-soft); }
.keypad button.ghost { background: none; box-shadow: none; font-size: 15px; color: var(--muted); }

/* ---- Sélecteurs mois / personne ---- */
.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.month-nav .m { flex: 1; text-align: center; font-weight: 700; font-size: 18px; text-transform: capitalize; }
.month-nav button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 22px; }
.month-nav button:disabled { opacity: .3; }
.people { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 14px; white-space: nowrap; font-size: 14px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.summary { display: flex; gap: 10px; margin-bottom: 10px; }
.summary > div { flex: 1; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); padding: 10px; text-align: center; }
.summary b { display: block; font-size: 20px; }
.summary small { color: var(--muted); font-size: 12px; }
.banner-closed { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

/* ---- Liste des jours ---- */
.days { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.day { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; min-height: 56px; }
.day:last-child { border-bottom: 0; }
.day:active { background: var(--brand-soft); }
.day .d { width: 56px; }
.day .d b { display: block; font-size: 18px; }
.day .d small { color: var(--muted); text-transform: capitalize; }
.day.we { background: var(--surface-2); }
.day.today .d b { color: var(--brand); }
.day .h { flex: 1; font-weight: 600; }
.day .h.zero { font-weight: 400; color: var(--muted); }
.day .chev { color: var(--muted); font-size: 22px; }
.dots { display: flex; gap: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.a_valider { background: var(--warn); }
.dot.valide { background: var(--ok); }
.dot.refuse { background: var(--bad); }
.dot.pending { background: #fbbf24; box-shadow: 0 0 0 2px #fff3c4; }

/* ---- Lignes d'une journée ---- */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line { display: block; width: 100%; text-align: left; background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; border-left: 5px solid var(--warn); }
.line.valide { border-left-color: var(--ok); }
.line.refuse { border-left-color: var(--bad); }
.line .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.line .num { font-weight: 700; }
.line .dur { font-weight: 700; font-size: 18px; white-space: nowrap; }
.line .lib { color: var(--muted); font-size: 14px; margin: 2px 0 6px; }
.line .motif { color: var(--bad); font-size: 13px; margin-top: 6px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 8px; margin-right: 4px; }
.badge.a_valider { background: var(--warn-soft); color: var(--warn); }
.badge.valide { background: var(--ok-soft); color: var(--ok); }
.badge.refuse { background: var(--bad-soft); color: var(--bad); }
.badge.pending { background: #fff3c4; color: #7a5a00; }
.badge.type { background: var(--surface-2); color: var(--text); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.fab { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--safe-bottom)); width: min(616px, calc(100% - 24px));
       border: 0; border-radius: 14px; padding: 16px; font-size: 17px; font-weight: 700; background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(15,118,110,.35); z-index: 5; }
.fab:active { background: var(--brand-dark); }

/* ---- Panneau du bas (édition, menu) ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--surface); border-radius: 18px 18px 0 0;
         padding: 10px 16px calc(16px + var(--safe-bottom)); max-height: 92vh; overflow-y: auto; max-width: 640px; margin: 0 auto;
         box-shadow: 0 -4px 20px rgba(0,0,0,.15); }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 10px; }
.sheet h2 { margin: 4px 0 6px; font-size: 18px; }
.att-list { max-height: 34vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; margin-top: 6px; }
.att { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: none; padding: 10px 12px; }
.att:last-child { border-bottom: 0; }
.att.on { background: var(--brand-soft); box-shadow: inset 4px 0 0 var(--brand); }
.att b { display: block; }
.att span { color: var(--muted); font-size: 14px; }
.att-sep { padding: 4px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.types { display: flex; flex-wrap: wrap; gap: 8px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 26px; }
.stepper output { flex: 1; text-align: center; font-size: 26px; font-weight: 700; }
.quick { display: flex; gap: 8px; margin-top: 8px; }
.quick button { flex: 1; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: none; padding: 15px 4px; font-size: 16px; }
.menu-item.danger { color: var(--bad); }
.menu-item:last-child { border-bottom: 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-bottom)); z-index: 30; background: #222; color: #fff;
         padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.noscript { padding: 20px; text-align: center; }

@media (min-width: 700px) { .view { padding-top: 20px; } }
