:root {
  --navy: #122437;
  --bg: #F4F6F9;
  --muted: #5B6573;
  --muted2: #4A5462;
  --text2: #3F4A58;
  --line: #EEF1F4;
  --border: #D9DEE5;
  --soft: #F3F6FA;
  --orange: #E2711D;
  --shadow: 0 1px 2px rgba(18,36,55,.06), 0 6px 20px rgba(18,36,55,.06);
  --shadow-sm: 0 1px 2px rgba(18,36,55,.08), inset 0 0 0 1px #E1E5EB;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-family: 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--navy); font-size: 16px; line-height: 1.45; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid #6B8FBF; outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* En-tête */
.topbar { background: #fff; border-bottom: 1px solid #E6E9EE; }
.topbar-in { max-width: 920px; margin: 0 auto; padding: 14px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--navy); display: flex; align-items: center; justify-content: center; }
.seg { display: flex; gap: 4px; padding: 4px; background: #EEF1F5; border-radius: 14px; }
.seg button { min-height: 40px; padding: 0 18px; border-radius: 10px; border: 0; background: transparent; color: var(--muted2); font-size: 15px; font-weight: 700; }
.seg button.on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(18,36,55,.14); }
.seg.sm button { min-height: 36px; padding: 0 16px; font-size: 14px; }
.seg.grey { background: #E6EAF0; }

main { max-width: 920px; margin: 0 auto; padding: 32px 20px 96px; }
.stack { display: flex; flex-direction: column; gap: 28px; }
.stack-sm { display: flex; flex-direction: column; gap: 16px; }
.eyebrow { margin: 0; font-size: 15px; font-weight: 600; color: var(--muted); }
h1.title { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -.03em; }
.section-label { margin: 0; font-size: 15px; font-weight: 700; color: var(--muted); }
.hint { margin: 0; font-size: 15px; color: var(--muted); }

/* Chiffres du mois */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { min-width: 0; background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text2); }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.v-done { color: #1E6B45; } .v-miss { color: #A12626; } .v-cancel { color: #4B5563; }
.stat-sub { font-size: 14px; color: var(--muted); }

/* Barre semaine / mois */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar-part { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: #fff; box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center; color: var(--navy); }
.icon-btn:disabled { color: #C3C9D2; }
.period { margin-left: 6px; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; background: #fff; box-shadow: var(--shadow-sm); font-size: 14px; font-weight: 700; color: var(--navy); }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--navy); color: #fff; font-size: 15px; font-weight: 700; box-shadow: 0 6px 16px rgba(18,36,55,.20); }
.btn-primary.lg { min-height: 48px; padding: 0 20px; box-shadow: none; }
.btn-primary:disabled { background: #E3E7ED; color: #6B7482; box-shadow: none; }
.btn-outline { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border); background: #fff; font-size: 15px; font-weight: 700; color: var(--navy); }

.days { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 2px 20px 6px; }
.days::-webkit-scrollbar { display: none; }
.day { flex: 1 0 96px; min-height: 100px; padding: 12px 10px; border-radius: 18px; border: 0; background: #fff; box-shadow: 0 1px 2px rgba(18,36,55,.06), 0 4px 14px rgba(18,36,55,.05); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--navy); }
.day-top { font-size: 13px; font-weight: 700; color: var(--muted); }
.day-num { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.day-sub { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.day.on { background: var(--navy); color: #fff; box-shadow: 0 8px 22px rgba(18,36,55,.22); }
.day.on .day-top, .day.on .day-sub { color: #D3DCE8; }
.odot { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }

.month { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.month-dow, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.month-dow { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 0; }
.mcell { min-height: 80px; min-width: 0; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 4px; text-align: left; overflow: hidden; color: var(--navy); }
.mcell.has { background: var(--soft); }
.mcell.past { color: #6B7482; }
.mcell.today { border: 2px solid var(--navy); }
.mcell.on { border: 0; background: var(--navy); color: #fff; box-shadow: 0 6px 16px rgba(18,36,55,.22); }
.mcell-num { font-size: 15px; font-weight: 800; }
.mcell-sub { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--muted2); }
.mcell.on .mcell-sub { color: #D3DCE8; }
.mcell-blank { visibility: hidden; }
.legend { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }

/* Liste des RDV */
.list { display: flex; flex-direction: column; gap: 14px; }
.list-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.list-title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.list-sum { margin: 4px 0 0; font-size: 16px; color: var(--muted2); }
.group { display: flex; flex-direction: column; gap: 12px; }
.group-h { margin: 10px 0 0; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 16px; font-weight: 800; }
.group-h span:last-child { font-size: 14px; font-weight: 600; color: var(--muted); }

.card { background: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.appt { padding: 16px 18px 16px 20px; display: flex; flex-direction: column; gap: 14px; transition: box-shadow .15s ease; }
.appt:hover { box-shadow: 0 1px 2px rgba(18,36,55,.06), 0 12px 28px rgba(18,36,55,.10); }
.appt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; }
.appt-main { flex: 1 1 280px; min-width: 0; min-height: 52px; display: flex; align-items: center; gap: 16px; padding: 0; border: 0; background: transparent; text-align: left; color: var(--navy); }
.time { flex: 0 0 64px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.time.cancelled { color: #9AA3AF; text-decoration: line-through; }
.appt-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.name { font-size: 18px; font-weight: 700; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); }
.dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; }
.prev { font-size: 14px; color: #5B45C6; }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.badge.paid { background: #E8F0FA; color: var(--navy); }
.badge.unpaid { background: #FFF1E6; color: #9A4100; }
.status-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px 0 14px; border-radius: 12px; border: 1px solid var(--border); background: #fff; font-size: 14px; font-weight: 700; white-space: nowrap; color: var(--navy); }
.status-btn.open { border-color: var(--navy); }
.sdot { width: 9px; height: 9px; border-radius: 50%; }

.panel { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.panel-label { font-size: 14px; font-weight: 700; color: var(--muted); }
.panel-title { font-size: 16px; font-weight: 800; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: inline-flex; align-items: center; gap: 9px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border); background: #fff; font-size: 15px; font-weight: 700; color: var(--navy); }
.choice.current { border: 2px solid var(--navy); background: var(--soft); }
.choice.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.choice.zone { min-width: 104px; justify-content: center; }

.picker { display: flex; flex-wrap: wrap; gap: 24px 32px; }
.minical { flex: 1 1 290px; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.mc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-label { font-size: 16px; font-weight: 800; }
.mc-dow, .mc-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mc-dow { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.mc { min-height: 42px; border-radius: 12px; border: 1px solid transparent; background: var(--soft); font-size: 15px; font-weight: 700; color: var(--navy); }
.mc.today { border: 2px solid var(--navy); }
.mc.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.mc:disabled { background: transparent; color: #B4BBC5; border-color: transparent; }
.slots-col { flex: 1 1 240px; display: flex; flex-direction: column; gap: 10px; }
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { min-width: 78px; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border); background: #fff; font-size: 15px; font-weight: 700; color: var(--navy); }
.slot.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.slot.busy { border-style: dashed; background: transparent; color: #B4BBC5; text-decoration: line-through; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.empty { background: #fff; border-radius: 20px; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; box-shadow: 0 1px 2px rgba(18,36,55,.06); color: #9AA3AF; }
.empty .t { margin: 0; font-size: 17px; font-weight: 600; color: var(--navy); }
.empty .s { margin: 0; font-size: 15px; color: var(--muted); }
.note { background: #fff; border-radius: 20px; padding: 22px 24px; font-size: 16px; color: var(--muted); box-shadow: 0 1px 2px rgba(18,36,55,.06); }

/* Patients */
.search { position: relative; }
.search svg { position: absolute; left: 18px; top: 18px; color: #7A8494; }
.search input { width: 100%; height: 56px; padding: 0 18px 0 50px; border: 0; border-radius: 16px; background: #fff; box-shadow: var(--shadow); font-size: 17px; }
.rows { display: flex; flex-direction: column; gap: 10px; }
.prow { display: flex; align-items: center; gap: 16px; width: 100%; padding: 16px 20px; background: #fff; border: 0; border-radius: 18px; box-shadow: var(--shadow); text-align: left; color: var(--navy); }
.avatar { flex: 0 0 48px; height: 48px; border-radius: 50%; background: #E8EDF4; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: var(--navy); }
.avatar.dark { background: var(--navy); color: #fff; }
.avatar.lg { flex-basis: 64px; height: 64px; font-size: 22px; }
.avatar.md { flex-basis: 44px; height: 44px; font-size: 15px; }
.avatar.xs { flex-basis: 38px; height: 38px; font-size: 14px; }
.prow-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.prow-name { font-size: 17px; font-weight: 700; }
.prow-sub { font-size: 15px; color: var(--muted); }
.chev { color: #9AA3AF; display: flex; }
.more { align-self: center; }

/* Fiche */
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px 0 10px; border: 0; border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgba(18,36,55,.08); font-size: 15px; font-weight: 700; color: var(--navy); }
.fiche-card { padding: 26px; display: flex; flex-direction: column; gap: 24px; border-radius: 24px; }
.fiche-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; }
.fiche-name { display: flex; align-items: center; gap: 16px; min-width: 0; }
.fiche-name h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.contact-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.cbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; font-size: 16px; font-weight: 700; text-decoration: none; }
.cbtn.dark { background: var(--navy); color: #fff; }
.cbtn.light { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 1px var(--border); }
dl.info { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px 24px; padding-top: 22px; border-top: 1px solid var(--line); }
dl.info div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
dl.info dt { font-size: 13px; font-weight: 700; color: var(--muted); }
dl.info dd { margin: 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.sec { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.sec-title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.up { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.up-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.datebox { flex: 0 0 64px; border-radius: 14px; background: var(--navy); color: #fff; padding: 9px 0; display: flex; flex-direction: column; align-items: center; }
.datebox .a { font-size: 12px; font-weight: 700; text-transform: uppercase; color: #D3DCE8; }
.datebox .b { font-size: 24px; font-weight: 800; line-height: 1.1; }
.datebox .c { font-size: 12px; color: #D3DCE8; }
.up-text { flex: 1 1 220px; display: flex; flex-direction: column; gap: 3px; }
.up-when { font-size: 17px; font-weight: 700; }
.up-what { font-size: 15px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; padding: 7px 13px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.st-plan { background: #EEF1F5; color: var(--text2); }
.st-done { background: #E3F3EA; color: #1E6B45; }
.st-miss { background: #FDECEC; color: #A12626; }
.st-cancel { background: #F0F1F3; color: #4B5563; }
.st-moved { background: #EFEBFC; color: #5B45C6; }
.past-list { overflow: hidden; }
.past-row { display: flex; flex-direction: column; gap: 14px; padding: 16px 20px; border-top: 1px solid var(--line); }
.past-row .up-row { gap: 10px 16px; }
.past-row:first-child { border-top: 0; }
.rebook { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: #fff; font-size: 14px; font-weight: 700; white-space: nowrap; color: var(--navy); }

/* Fenêtre de réservation */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(18,36,55,.45); display: flex; align-items: flex-start; justify-content: center; padding: 28px 12px; overflow-y: auto; }
.modal { width: 100%; max-width: 760px; background: #fff; border-radius: 24px; box-shadow: 0 24px 60px rgba(18,36,55,.35); padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.modal-head p { margin: 4px 0 0; font-size: 15px; color: var(--muted); }
.close { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 12px; border: 0; background: #F0F3F7; display: flex; align-items: center; justify-content: center; color: var(--navy); }
.step { display: flex; flex-direction: column; gap: 10px; }
.step-label { font-size: 14px; font-weight: 700; color: var(--muted); }
.picked { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--soft); }
.zones { padding: 16px; border-radius: 16px; background: var(--soft); display: flex; flex-direction: column; gap: 10px; }
.zones .step-label { color: var(--text2); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 700; color: var(--text2); }
.field label span { font-weight: 500; color: var(--muted); }
.input { height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; font-size: 16px; background: #fff; width: 100%; }
.match { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; border-radius: 14px; border: 1px solid var(--line); background: #fff; text-align: left; color: var(--navy); }
.match .n { flex: 1 1 auto; min-width: 0; font-size: 16px; font-weight: 700; }
.match .p { font-size: 14px; color: var(--muted); }
.modal-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.recap { font-size: 16px; font-weight: 600; color: var(--text2); }

.toast { position: fixed; z-index: 60; left: 20px; right: 20px; top: 20px; margin: 0 auto; width: fit-content; max-width: 640px; display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: 16px; background: var(--navy); color: #fff; box-shadow: 0 14px 34px rgba(18,36,55,.30); font-size: 15px; font-weight: 600; }
.toast .ic { flex: 0 0 26px; height: 26px; border-radius: 50%; background: #2F9E66; display: flex; align-items: center; justify-content: center; }
.toast.error .ic { background: #D64545; }

.boot, .fatal { max-width: 520px; margin: 80px auto; padding: 0 20px; text-align: center; color: var(--muted); }
.fatal h1 { font-size: 22px; color: var(--navy); }

@media (max-width: 560px) {
  h1.title { font-size: 28px; }
  .mcell { min-height: 60px; padding: 6px; }
  .mcell-sub .lbl { display: none; }
  .modal { padding: 18px; }
}

/* Connexion directe (téléphone) */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 28px 22px; display: flex; flex-direction: column; gap: 16px; }
.auth-brand { justify-content: center; }
.auth-card h1 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.02em; text-align: center; }
.auth-help { margin: 0; font-size: 14px; color: var(--muted); text-align: center; }
.auth-error { margin: 0; padding: 10px 12px; border-radius: 12px; background: #FDECEC; color: #A12C2C; font-size: 14px; font-weight: 600; }
.auth-card .btn-primary { width: 100%; }
.logout { border: 0; background: none; padding: 8px 4px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.topbar-in .logout { margin-left: auto; }
@media (max-width: 600px) {
  .topbar-in .brand { order: 1; flex: 1 1 auto; }
  .topbar-in .logout { order: 2; }
  .topbar-in .seg { order: 3; }
}

/* Commentaires (fiche patient) */
.comments-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.cform { display: flex; flex-direction: column; gap: 10px; }
.textarea { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.45; resize: vertical; font-family: inherit; color: var(--navy); }
.cform-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.cform-foot .hint { flex: 1 1 220px; margin: 0; font-size: 13px; }
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.comment { display: flex; flex-direction: column; gap: 4px; padding: 14px 0; border-top: 1px solid var(--line); }
.comment-meta { font-size: 13px; font-weight: 700; color: var(--muted); }
.comment-text { margin: 0; font-size: 16px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
