@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage.woff2') format('woff2'); font-weight: 500 800; font-display: swap; }
:root {
  color-scheme: dark light;
  --bg: #04191D; --bg2: #0A2429; --card: #0C2A2E; --line: #18353B; --line2: #234850;
  --ink: #F6E2CB; --ink2: #C7C0AE; --ink3: #9aa8a2;
  --dl: #E65C52; --dl-ink: #2a0805; --cm: #5FB98A; --cm-ink: #062a17; --gold: #ffd88a; --gold-ink: #2a1b00;
  --ok: #5FB98A; --warn: #f0a65c; --bad: #ff8f8f; --wa: #25d366; --wa-ink: #06240f;
  --ff: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ffd: 'Bricolage', var(--ff);
  --r: 16px; --tap: 48px;
}
:root[data-theme="light"] {
  --bg: #F7F3EA; --bg2: #FFFFFF; --card: #FFFFFF; --line: #DDD6C6; --line2: #C9C1AE;
  --ink: #14262A; --ink2: #4C5B58; --ink3: #6b7a76; --gold: #8a5a00; --gold-ink: #fff; --ok: #1f7a4b; --warn: #b35c00; --bad: #b3261e;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F7F3EA; --bg2: #FFFFFF; --card: #FFFFFF; --line: #DDD6C6; --line2: #C9C1AE;
    --ink: #14262A; --ink2: #4C5B58; --ink3: #6b7a76; --gold: #8a5a00; --gold-ink: #fff; --ok: #1f7a4b; --warn: #b35c00; --bad: #b3261e;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ff); font-size: 16px; }
body { min-height: 100dvh; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
body.sheet-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-family: var(--ffd); font-weight: 800; letter-spacing: -0.02em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---- en-tête ---- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: calc(8px + env(safe-area-inset-top)) 14px 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 44px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--ink2); font-weight: 700; font-size: 14px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button.dl[aria-pressed="true"] { background: var(--dl); color: var(--dl-ink); }
.seg button.cm[aria-pressed="true"] { background: var(--cm); color: var(--cm-ink); }
.icon-btn { min-width: var(--tap); min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); background: var(--bg2); border-radius: 14px; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.day-pager { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.day-title { flex: 1; text-align: center; line-height: 1.1; background: none; border: 0; padding: 4px; color: inherit; min-height: 44px; }
.day-title .num { font-size: 21px; display: block; }
.day-title small { color: var(--ink2); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.day-title.today .num { color: var(--gold); }
.pill { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; }
.pill.dl { background: var(--dl); color: var(--dl-ink); } .pill.cm { background: var(--cm); color: var(--cm-ink); }
.banner { margin: 10px 14px 0; padding: 10px 12px; border-radius: 12px; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.banner.err { background: color-mix(in srgb, var(--bad) 18%, var(--card)); color: var(--bad); border: 1px solid var(--bad); }
.banner.off { background: color-mix(in srgb, var(--warn) 22%, var(--card)); color: var(--warn); }
.banner button { margin-left: auto; min-height: 40px; border-radius: 10px; border: 1px solid currentColor; background: transparent; color: inherit; padding: 0 12px; font-weight: 800; }

/* ---- résumé ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 12px 14px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 8px; text-align: center; }
.stat .num { font-size: 24px; line-height: 1; }
.stat small { display: block; color: var(--ink2); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }
.stat.warn .num { color: var(--warn); } .stat.ok .num { color: var(--ok); }

/* ---- liste ---- */
main { padding: 12px 14px 24px; max-width: 640px; margin: 0 auto; }
main[aria-busy="true"] .card { opacity: .5; }
.empty { text-align: center; color: var(--ink3); padding: 44px 16px; line-height: 1.5; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }
.skel { height: 84px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); margin-bottom: 10px; opacity: .6; }
.card { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line2); border-radius: var(--r); padding: 10px 10px 10px 12px; margin-bottom: 10px; display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 10px; align-items: start; transition: background .25s; }
.card.DL { border-left-color: var(--dl); } .card.CM { border-left-color: var(--cm); }
.card.done { background: var(--bg); }
.card.done .heure .num, .card.done .nom { color: var(--ink2); }
.card.annule .nom, .card.no_show .nom { text-decoration: line-through; }
.card.retard { border-color: var(--warn); }
.card.flash { background: color-mix(in srgb, var(--ok) 22%, var(--card)); }
.heure { text-align: center; background: none; border: 0; padding: 0; color: inherit; }
.heure .num { font-size: 22px; line-height: 1; display: block; }
.heure small { color: var(--ink3); font-size: 12px; }
.body { min-width: 0; text-align: left; background: none; border: 0; padding: 0; color: inherit; width: 100%; }
.nom { font-weight: 800; font-size: 17px; line-height: 1.2; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.nom .tel4 { color: var(--ink3); font-weight: 600; font-size: 13px; }
.homonyme { color: var(--warn); font-size: 12px; font-weight: 800; }
.meta { color: var(--ink2); font-size: 14px; margin-top: 3px; line-height: 1.4; overflow-wrap: anywhere; }
.note { color: var(--gold); font-size: 13px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); color: var(--ink2); }
.chip.arrive { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); border-color: transparent; }
.chip.retard { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); border-color: transparent; }
.chip.no_show, .chip.annule { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); border-color: transparent; }
.actions { display: flex; flex-direction: column; gap: 6px; }
.btn { min-height: var(--tap); min-width: var(--tap); padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg2); color: var(--ink); font-weight: 800; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; transition: transform .08s; }
.btn:active { transform: scale(.96); filter: brightness(1.15); }
.btn.primary { background: var(--ok); color: var(--cm-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.wa { background: var(--wa); color: var(--wa-ink); border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 12px; }
.btn.lock { pointer-events: none; opacity: .6; }
.arrived-mark { color: var(--ok); font-weight: 800; font-size: 14px; text-align: center; min-width: 64px; }

/* ---- porte ---- */
.search { width: 100%; min-height: var(--tap); border-radius: 14px; border: 1px solid var(--line); background: var(--bg2); padding: 0 14px; font-size: 17px; }
.porte .card { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 10px 10px 10px 12px; }
.porte .nom { font-size: 19px; }
.porte .btn.primary { min-width: 96px; min-height: 58px; font-size: 18px; }

/* ---- calendrier ---- */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--ink3); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin: 6px 0 4px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cell { aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 5px 4px; display: flex; flex-direction: column; justify-content: space-between; align-items: stretch; color: var(--ink); min-height: 48px; }
.cell.off { opacity: .28; } .cell.today { border-color: var(--gold); } .cell.sel { background: var(--ink); color: var(--bg); }
.cell .d { font-family: var(--ffd); font-weight: 800; font-size: 14px; }
.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dot { font-size: 11px; font-weight: 800; padding: 1px 5px; border-radius: 6px; line-height: 1.2; }
.dot.dl { background: var(--dl); color: var(--dl-ink); } .dot.cm { background: var(--cm); color: var(--cm-ink); }

/* ---- barre du bas ---- */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 96%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); display: flex; gap: 4px; }
.bottom button { flex: 1; min-height: 54px; border: 0; border-radius: 14px; background: transparent; color: var(--ink2); font-size: 12px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0 2px; }
.bottom button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottom button[aria-current="page"] { background: var(--bg2); color: var(--ink); }
.bottom button.add { color: var(--gold); }

/* ---- feuille ---- */
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto; background: var(--bg2); border-radius: 22px 22px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line2); }
.sheet h2 { margin: 6px 0 12px; font-family: var(--ffd); font-size: 22px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.sheet h2:focus { outline: none; }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 12px; color: var(--ink2); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 10px 12px; font-size: 17px; }
.field input:disabled { opacity: .6; }
.field textarea { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet .btn { width: 100%; margin-top: 8px; }
.sheet .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet .grid2 .btn { margin-top: 0; }
.brand-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.brand-pick .btn { margin: 0; border: 2px solid transparent; }
.brand-pick .btn[aria-pressed="true"].dl { background: var(--dl); color: var(--dl-ink); }
.brand-pick .btn[aria-pressed="true"].cm { background: var(--cm); color: var(--cm-ink); }
.detail-lines { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.hist { color: var(--ink3); font-size: 12px; margin-top: 8px; }
.err-msg { color: var(--bad); font-weight: 700; min-height: 22px; margin-top: 8px; }

/* ---- login ---- */
.gate { max-width: 380px; margin: 48px auto 0; padding: 0 22px; text-align: center; }
.gate h1 { font-family: var(--ffd); font-size: 34px; margin: 0 0 6px; }
.gate p { color: var(--ink2); margin: 0 0 18px; line-height: 1.5; }
.gate input { width: 100%; font-size: 26px; letter-spacing: .2em; text-align: center; min-height: 58px; border-radius: 16px; border: 1px solid var(--line2); background: var(--card); }
.gate .btn { width: 100%; margin-top: 12px; min-height: 56px; font-size: 17px; }
.gate .btn.enter { background: var(--ink); color: var(--bg); border: 0; }
.gate .brand { min-height: 62px; font-size: 19px; border: 0; }
.gate .brand.dl { background: var(--dl); color: var(--dl-ink); } .gate .brand.cm { background: var(--cm); color: var(--cm-ink); }
.gate .msg { min-height: 22px; margin-top: 12px; color: var(--bad); font-weight: 700; }

/* ---- toast ---- */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 30; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 16px; font-weight: 700; font-size: 15px; opacity: 0; transform: translateY(10px); transition: opacity .18s, transform .18s; pointer-events: none; display: flex; gap: 10px; align-items: center; max-width: 640px; margin: 0 auto; }
.toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast.err { background: var(--bad); color: #fff; }
.toast span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast button { border: 0; background: var(--bg); color: var(--ink); border-radius: 12px; min-height: 44px; padding: 0 16px; font-weight: 800; white-space: nowrap; }
.toast.err button { background: #fff; color: var(--bad); }

/* ---- étiquettes ---- */
.labels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.label { border: 2px dashed var(--line2); border-radius: 12px; padding: 12px; text-align: center; min-height: 110px; display: flex; flex-direction: column; justify-content: center; overflow-wrap: anywhere; }
.label .n { font-family: var(--ffd); font-weight: 800; font-size: 20px; line-height: 1.1; }
.label .p { font-size: 14px; color: var(--ink2); margin-top: 4px; }
@media print {
  body { background: #fff; color: #000; padding: 0; }
  .top, .bottom, .stats, .toast, .banner, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .labels { gap: 0; }
  .label { border: 1px solid #999; border-radius: 0; min-height: 5.5cm; page-break-inside: avoid; color: #000; }
  .label .p { color: #333; }
}
@media (prefers-reduced-motion: reduce) { .toast, .btn, .card { transition: none; } }
