/* Espace Beauté — téléphone d'abord, puis tablette/PC à partir de 900px */
:root {
  --bg: #FAF9FC; --surface: #FFFFFF; --surface-2: #F2F0F5; --ink: #1E1A24; --muted: #6E6878;
  --faint: #9A93A5; --line: #ECE9F1; --line-2: #DCD7E3; --accent: #1E1A24; --on-accent: #FFFFFF;
  --now: #E5484D; --good: #1E7B45; --bad: #B3261E; --hatch: #E6E2EC;
  --shadow: 0 10px 30px -12px rgba(30, 20, 40, .35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --fs: 15px; --ppm: 1.1px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141218; --surface: #1B1820; --surface-2: #24202B; --ink: #ECE7F2; --muted: #A59DB1;
  --faint: #7F7889; --line: #2A2631; --line-2: #3A3542; --accent: #E8C9A0; --on-accent: #141218;
  --now: #FF7A70; --good: #6FD39A; --bad: #FF8A80; --hatch: #26222D;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
:root[data-size="large"] { --fs: 17px; --ppm: 1.45px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: var(--fs); line-height: 1.4; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono, .t { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

#app { min-height: 100%; display: flex; flex-direction: column; }

/* Barre du haut */
.appbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(8px + var(--safe-t)) max(14px, var(--safe-r)) 8px max(14px, var(--safe-l));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand img { border-radius: 9px; flex: none; }
.brand div { display: flex; flex-direction: column; min-width: 0; }
.brand b { font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-size: .75em; color: var(--muted); }
.topnav { display: none; gap: 4px; }
.topnav button { padding: 8px 14px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.topnav button[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.sync-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.sync-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.sync-dot[data-s="ok"]::after { background: #2EB872; }
.sync-dot[data-s="syncing"]::after { background: #F0B35A; animation: pulse 1s infinite alternate; }
.sync-dot[data-s="error"]::after, .sync-dot[data-s="offline"]::after { background: var(--now); }
@keyframes pulse { to { opacity: .35; } }

main { flex: 1; padding: 0 max(14px, var(--safe-r)) calc(96px + var(--safe-b)) max(14px, var(--safe-l)); outline: none; }

/* Barre d'onglets du bas (téléphone) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px max(8px, var(--safe-r)) calc(6px + var(--safe-b)) max(8px, var(--safe-l)); background: var(--surface); border-top: 1px solid var(--line); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72em; color: var(--faint); padding: 4px 0; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tabbar button[aria-current="page"] { color: var(--ink); font-weight: 700; }
.fab { position: fixed; z-index: 21; right: max(16px, calc(16px + var(--safe-r))); bottom: calc(72px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 19px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; box-shadow: var(--shadow); }
.fab:active { transform: scale(.95); }

/* Agenda : barre de date */
.daybar { display: flex; align-items: center; gap: 8px; padding: 12px 0 8px; }
.daybar h1 { flex: 1; margin: 0; font-size: 1.35em; line-height: 1.15; min-width: 0; }
.daybar h1 small { display: block; font-size: .58em; font-weight: 500; color: var(--muted); }
.datepick { position: relative; display: block; cursor: pointer; }
.datepick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.iconbtn { width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex: none; font-size: 1.2em; }
.pillbtn { padding: 8px 12px; border-radius: 12px; background: var(--surface-2); font-weight: 600; font-size: .85em; flex: none; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding-bottom: 10px; }
.week button { display: flex; flex-direction: column; align-items: center; padding: 6px 0 7px; border-radius: 12px; font-size: .68em; color: var(--muted); gap: 1px; }
.week button b { font-size: 1.55em; color: var(--ink); }
.week button.closed { opacity: .4; }
.week button.today b { color: var(--now); }
.week button[aria-current="date"] { background: var(--ink); color: var(--bg); }
.week button[aria-current="date"] b { color: var(--bg); }
.occ { display: flex; gap: 2px; width: 70%; margin-top: 3px; }
.occ i { flex: 1; height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; position: relative; }
.occ i::after { content: ""; position: absolute; inset: 0; width: var(--v); background: var(--c); }

.seg { display: flex; background: var(--surface-2); border-radius: 13px; padding: 3px; margin-bottom: 10px; overflow-x: auto; }
.seg button { flex: 1; padding: 7px 10px; border-radius: 10px; font-weight: 600; font-size: .88em; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; font-size: .8em; }
.summary span { background: var(--surface-2); border-radius: 9px; padding: 4px 9px; }

.banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: .85em; margin: 10px 0 2px; }
.banner button { font-weight: 700; text-decoration: underline; flex: none; }

/* Fil de la journée (une coiffeuse, téléphone) */
.feed { display: flex; flex-direction: column; gap: 8px; }
.item { display: grid; grid-template-columns: 50px 1fr; gap: 10px; align-items: stretch; }
.item .t { font-size: .8em; padding-top: 10px; }
.item .t small { display: block; color: var(--faint); font-size: .85em; }
.item.past { opacity: .55; }
.card { text-align: left; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: .85em; width: 100%;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: color-mix(in srgb, var(--c) 60%, var(--ink)); border-left: 4px solid var(--c); }
.card b { font-size: 1.12em; color: var(--ink); }
.card .meta { display: flex; justify-content: space-between; gap: 8px; }
.card.absent b { text-decoration: line-through; }
.card.gap { background: none; border: 1.5px dashed var(--line-2); color: var(--muted); flex-direction: row; justify-content: space-between; align-items: center; padding: 9px 12px; }
.card.gap em { font-style: normal; font-weight: 700; color: var(--ink); background: var(--surface-2); border-radius: 9px; padding: 4px 9px; }
.card.pause { background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, var(--hatch) 5px 10px); color: var(--muted); border-left-color: var(--line-2); padding: 7px 12px; }
.nowrow { display: grid; grid-template-columns: 50px 1fr; gap: 10px; align-items: center; color: var(--now); font-weight: 700; font-size: .8em; }
.nowrow i { height: 2px; background: var(--now); border-radius: 2px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty b { color: var(--ink); font-size: 1.1em; }

/* Colonnes (les deux coiffeuses) */
.agenda-wide { display: block; }
.side { display: none; }
.cols { display: grid; grid-template-columns: 34px repeat(var(--n), minmax(0, 1fr)); gap: 0 6px; }
.colhead { position: sticky; top: calc(55px + var(--safe-t)); z-index: 5; background: var(--bg); padding: 6px 0; display: flex; flex-direction: column; font-size: .85em; font-weight: 700; color: var(--c); min-width: 0; }
.colhead small { font-weight: 500; color: var(--muted); font-size: .85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hours { position: relative; font-size: .68em; color: var(--faint); }
.hours span { position: absolute; left: 0; transform: translateY(-50%); }
.lane { position: relative; border-radius: 10px; cursor: copy;
  background: repeating-linear-gradient(var(--line) 0 1px, transparent 1px calc(var(--ppm) * 30)), var(--surface);
  background-size: 100% calc(var(--ppm) * 60); }
.lane .off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, var(--hatch) 5px 10px); pointer-events: none; font-size: .65em; color: var(--faint); padding: 2px 5px; border-radius: 6px; }
.ev { position: absolute; left: 2px; right: 2px; border-radius: 8px; padding: 3px 6px; font-size: .7em; line-height: 1.25; overflow: hidden; text-align: left; cursor: pointer;
  background: color-mix(in srgb, var(--c) 18%, var(--surface)); color: color-mix(in srgb, var(--c) 55%, var(--ink)); border-left: 3px solid var(--c); }
.ev b { display: block; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.05em; }
.ev span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.absent b { text-decoration: line-through; }
.ev.done::after { content: "✓"; position: absolute; top: 2px; right: 5px; font-weight: 700; }
.ev.clash { outline: 2px solid var(--now); outline-offset: -2px; }
.ev.short { display: flex; gap: 4px; align-items: center; padding-block: 0; }
.ev.short b { font-size: .95em; }
.lane .now { position: absolute; left: -5px; right: 0; height: 2px; background: var(--now); z-index: 3; pointer-events: none; }
.lane .now::before { content: ""; position: absolute; left: -2px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--now); }

/* Feuilles (panneaux du bas / dialogues) */
#sheet-root .scrim { position: fixed; inset: 0; z-index: 40; background: rgba(20, 16, 26, .45); animation: fade .15s ease-out; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: calc(100% - 40px - var(--safe-t)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px max(18px, var(--safe-r)) calc(18px + var(--safe-b)) max(18px, var(--safe-l));
  display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); animation: up .2s ease-out; }
.sheet > * { flex-shrink: 0; }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 0 auto 2px; flex: none; }
.sheet h2 { margin: 0; font-size: 1.3em; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet h2 button { font-size: .7em; color: var(--muted); font-weight: 600; padding: 6px 4px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.lbl { font-size: .72em; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lbl span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.field { width: 100%; border: 1.5px solid var(--line-2); background: var(--surface); border-radius: 12px; padding: 10px 12px; font-size: 16px; }
.field:focus { border-color: var(--accent); outline: none; }
textarea.field { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { padding: 8px 11px; border-radius: 11px; background: var(--surface-2); font-weight: 600; font-size: .88em; white-space: nowrap; }
.chip small { font-weight: 500; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .75; }
.chip.staff[aria-pressed="true"] { background: var(--c); color: #fff; }
.chip.dot::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.chip.staff[aria-pressed="true"]::before { background: #fff; }
.chip.slot { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.chip.slot i { font-style: normal; font-family: var(--font); font-size: .78em; margin-left: 4px; opacity: .8; }
.results { display: flex; flex-direction: column; gap: 4px; }
.result { text-align: left; background: var(--surface-2); border-radius: 11px; padding: 8px 12px; display: flex; flex-direction: column; font-size: .85em; }
.result b { font-size: 1.05em; }
.result.picked { background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.btn { border-radius: 14px; padding: 13px 16px; font-weight: 700; text-align: center; background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--bad); }
.btn.danger.confirm { background: var(--bad); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.sticky-cta { position: sticky; bottom: 0; box-shadow: 0 -12px 16px -4px var(--surface); }
.sticky-cta:disabled { opacity: 1; background: var(--surface-2); color: var(--faint); }
.btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.hint { font-size: .8em; color: var(--muted); }
.warn { font-size: .85em; color: var(--bad); font-weight: 600; }
.detail { display: flex; flex-direction: column; gap: 4px; }
.detail .big { font-size: 1.5em; font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92em; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.status-pill { display: inline-block; font-size: .72em; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); }

/* Listes (clientes, réglages) */
.page-title { margin: 14px 0 10px; font-size: 1.5em; }
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list > button, .list > div { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; width: 100%; }
.list > :last-child { border-bottom: 0; }
.list .grow { display: flex; flex-direction: column; min-width: 0; }
.list .grow small { color: var(--muted); font-size: .8em; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); flex: none; }
.avatar.c { background: var(--c); color: #fff; }
.chev { color: var(--faint); }
.section { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.section h3 { margin: 0; font-size: .78em; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.section p { margin: 0; }
.letter { font-size: .72em; font-weight: 700; color: var(--faint); padding: 10px 2px 4px; }
.hourrow { display: grid; grid-template-columns: 58px 1fr; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.hourrow:last-child { border-bottom: 0; }
.hourrow label { display: flex; gap: 6px; align-items: center; font-weight: 600; font-size: .9em; }
.hourrow .times { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hourrow .times input { padding: 6px 8px; font-size: 14px; border-radius: 9px; }
.hourrow .times small { grid-column: 1 / -1; font-size: .7em; color: var(--faint); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; background: var(--c); }
.swatches button[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }

#toast { position: fixed; z-index: 60; left: 50%; bottom: calc(140px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .9em; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); display: flex; gap: 14px; align-items: center; }
#toast.on { opacity: 1; pointer-events: auto; }
#toast button { color: inherit; text-decoration: underline; font-weight: 700; }

/* Tablette et PC */
@media (min-width: 900px) {
  :root { --ppm: 1.3px; }
  :root[data-size="large"] { --ppm: 1.6px; }
  .topnav { display: flex; }
  .tabbar { display: none; }
  .fab { bottom: calc(24px + var(--safe-b)); right: max(24px, calc(24px + var(--safe-r))); }
  main { padding-bottom: 40px; }
  #toast { bottom: calc(40px + var(--safe-b)); }
  .agenda-wide { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
  .side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(70px + var(--safe-t)); padding-top: 14px; }
  .seg.phone-only, .week.phone-only { display: none; }
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100% - 48px)); max-height: calc(100% - 60px); border-radius: 22px; animation: fade .15s ease-out; }
  .sheet .grab { display: none; }
  .narrow { max-width: 720px; margin-inline: auto; }
}
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .75em; }
.month .h { color: var(--faint); font-weight: 700; padding: 2px 0; }
.month button { padding: 6px 0; border-radius: 8px; position: relative; }
.month button.out { color: var(--faint); opacity: .5; }
.month button.busy::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--muted); }
.month button.today { color: var(--now); font-weight: 700; }
.month button[aria-current="date"] { background: var(--ink); color: var(--bg); }
.monthhead { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.monthhead button { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); }
.freelist { display: flex; flex-direction: column; gap: 6px; }
.freelist button { display: flex; justify-content: space-between; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: .82em; text-align: left; }
.freelist button span:last-child { color: var(--c); font-weight: 700; }
