:root {
  --sand: #F5F0E7;
  --sand-deep: #ECE4D6;
  --paper: #FFFDF9;
  --ink: #16211F;
  --ink-soft: #46514E;
  --muted: #6E7672;
  --ocean: #0E4F6B;
  --ocean-dark: #0A3A4F;
  --sea: #2F7D74;
  --sea-soft: #E3EFEC;
  --line: #DED5C5;
  --danger: #A1402F;
  --radius: 18px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --tabs-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--sand); color: var(--ink);
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 500; letter-spacing: -0.015em; line-height: 1.15; }
p { margin: 0; }
a { color: var(--ocean); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; border-radius: 6px; }

/* Barre du haut */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(245, 240, 231, 0.94); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar__brand { font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.bar__tag { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--sea); white-space: nowrap; }
.bar__out { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 14px; cursor: pointer; padding: 6px 0; }

.view { width: 100%; max-width: 720px; margin: 0 auto; padding: 20px 16px calc(var(--tabs-h) + 40px + env(safe-area-inset-bottom)); }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* Onglets du bas */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--tabs-h); text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a[aria-current="page"] { color: var(--ocean); }

/* Typo */
.kicker { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sea); margin-bottom: 8px; }
.h1 { font-size: clamp(28px, 7vw, 38px); margin-bottom: 8px; }
.sub { color: var(--ink-soft); }
.muted { color: var(--muted); font-size: 14px; }
.stack > * + * { margin-top: 14px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--ocean); color: #fff; border: 0; border-radius: 999px; cursor: pointer;
  font-weight: 600; padding: 14px 22px; text-decoration: none; transition: background .2s;
}
.btn:hover { background: var(--ocean-dark); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--block { width: 100%; }
.btn--big { padding: 18px 22px; font-size: 17px; }
.btn--ghost { background: transparent; color: var(--ocean); border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--paper); }
.btn--small { padding: 9px 14px; font-size: 14px; }
.btn--danger { background: transparent; color: var(--danger); border: 1px solid #E5C9C2; }
.btn svg { width: 22px; height: 22px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ocean); cursor: pointer; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }

/* Formulaires */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--sea); box-shadow: 0 0 0 3px var(--sea-soft); }
.hint { font-size: 13px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; }

.switch { display: grid; grid-template-columns: 1fr 1fr; background: var(--sand-deep); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.switch button { border: 0; background: none; border-radius: 999px; padding: 10px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.switch button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.auth { max-width: 440px; margin: 8px auto 0; }
.auth__intro { margin-bottom: 22px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 500; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ocean); color: #fff; border-color: var(--ocean); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: var(--ocean); color: #fff; font-size: 13px; font-weight: 600; }
.badge--soft { background: var(--sea-soft); color: var(--sea); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #F3E3C9; color: #7A5418; }

/* Journal */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 0 16px; }
.daynav button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 18px; }
.daynav button:disabled { opacity: .35; cursor: default; }
.daynav__label { text-align: center; }
.daynav__label strong { display: block; font-family: var(--serif); font-size: 20px; font-weight: 500; }
.daynav__label span { font-size: 13px; color: var(--muted); }

.meals { display: grid; gap: 16px; margin-top: 20px; }
.meal { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.meal__photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--sand-deep); cursor: zoom-in; }
.meal__body { padding: 14px 16px 16px; }
.meal__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.meal__type { font-family: var(--serif); font-size: 19px; }
.meal__time { font-size: 14px; color: var(--muted); }
.meal__note { margin-top: 6px; color: var(--ink-soft); white-space: pre-wrap; }
.meal__actions { margin-top: 10px; display: flex; gap: 14px; }
.coachnote { margin-top: 12px; padding: 12px 14px; background: var(--sea-soft); border-radius: 12px; }
.coachnote__who { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sea); margin-bottom: 4px; }
.coachnote p { white-space: pre-wrap; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Feuille d'ajout */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(22, 33, 31, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--sand);
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 22px; } }
.sheet__preview { width: 100%; max-height: 42vh; object-fit: cover; border-radius: 14px; margin-bottom: 16px; }

/* Coach */
.clients { display: grid; gap: 12px; margin-top: 18px; }
.client { display: block; text-decoration: none; color: inherit; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.client:hover { border-color: var(--sea); }
.client__top { display: flex; align-items: center; gap: 12px; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--ocean); color: #fff; display: grid; place-items: center; font-family: var(--serif); font-size: 19px; }
.client__name { font-weight: 600; font-size: 17px; }
.client__meta { font-size: 13px; color: var(--muted); }
.client__right { margin-left: auto; text-align: right; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; }
.week__d { text-align: center; font-size: 11px; color: var(--muted); }
.week__dot { margin: 4px auto 0; width: 28px; height: 28px; border-radius: 50%; background: var(--sand-deep); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.week__dot.is-on { background: var(--sea); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat strong { display: block; font-family: var(--serif); font-size: 26px; font-weight: 500; }
.stat span { font-size: 12px; color: var(--muted); }

.back { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-soft); text-decoration: none; font-size: 14px; margin-bottom: 12px; }
.dayblock + .dayblock { margin-top: 26px; }
.dayblock__title { font-family: var(--serif); font-size: 20px; margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; }
.dayblock__title span { font-family: var(--sans); font-size: 13px; color: var(--muted); }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.commentbox { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.commentbox textarea { width: 100%; min-height: 70px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; resize: vertical; }

/* Ressources */
.res-cat { margin-top: 26px; }
.res-cat__title { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sea); margin-bottom: 10px; }
.res { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.res + .res { margin-top: 10px; }
.res summary { list-style: none; cursor: pointer; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-family: var(--serif); font-size: 19px; }
.res summary::-webkit-details-marker { display: none; }
.res summary::after { content: "+"; font-family: var(--sans); font-size: 22px; color: var(--sea); }
.res[open] summary::after { content: "–"; }
.res__body { padding: 0 18px 18px; color: var(--ink-soft); }
.res__body p + p, .res__body p + ul, .res__body ul + p { margin-top: 10px; }
.res__body ul { margin: 8px 0 0; padding-left: 20px; }
.res__body li + li { margin-top: 6px; }
.res__body strong { color: var(--ink); }
.res__edit { margin-top: 14px; display: flex; gap: 10px; }
.disclaimer { margin-top: 28px; font-size: 13px; color: var(--muted); text-align: center; }

/* Toast + lightbox */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; max-width: calc(100% - 32px); }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.9); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* ===== Console : menu latéral (ordinateur) ===== */
.side {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: 248px; display: none; flex-direction: column;
  background: var(--ink); color: #E8EEEC; padding: 24px 16px 18px;
}
.side__brand { font-family: var(--serif); font-size: 22px; font-weight: 600; color: #fff; text-decoration: none; padding: 0 10px; }
.side__tag { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #8CC7BE; padding: 4px 10px 0; }
.side__nav { display: flex; flex-direction: column; gap: 4px; margin-top: 30px; }
.side__nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
  color: #C9D3D0; text-decoration: none; font-weight: 500; font-size: 15px;
}
.side__nav a svg { width: 20px; height: 20px; flex: none; }
.side__nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side__nav a[aria-current="page"] { background: rgba(140,199,190,.16); color: #fff; }
.side__count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #E9A75B; color: var(--ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.side__foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 16px 10px 0; }
.side__me { font-size: 14px; color: #fff; font-weight: 600; }
.side__me span { display: block; font-weight: 400; color: #9AA7A3; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.side__out { margin-top: 10px; background: none; border: 0; padding: 0; color: #9AA7A3; cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

@media (min-width: 900px) {
  body.is-auth { padding-left: 248px; }
  body.is-auth .side { display: flex; }
  body.is-auth .bar, body.is-auth .tabs { display: none !important; }
  body.is-auth .view { padding: 40px 40px 60px; }
  .toast { bottom: 28px; }
}
.view--wide { max-width: 1160px; }

/* ===== En-tête de page ===== */
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; margin-bottom: 24px; }
.pagehead .h1 { margin-bottom: 4px; }
.pagehead__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ===== KPI ===== */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--sea); }
.kpi__label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi__value { font-family: var(--serif); font-size: 32px; line-height: 1.1; margin-top: 6px; }
.kpi__hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi--accent { background: var(--ocean); border-color: var(--ocean); color: #fff; }
.kpi--accent .kpi__label, .kpi--accent .kpi__hint { color: #BFD6DF; }
.kpi--warn .kpi__value { color: #A9611B; }

/* ===== Panneaux ===== */
.panels { display: grid; gap: 16px; margin-top: 20px; }
@media (min-width: 1000px) { .panels { grid-template-columns: 1.6fr 1fr; align-items: start; } }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel + .panel { margin-top: 0; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel__head h2 { font-size: 20px; }
.panel__head a { font-size: 14px; white-space: nowrap; }
.panel__empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.col { display: grid; gap: 16px; }

.feed { display: grid; gap: 4px; }
.feed__item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; text-decoration: none; color: inherit; }
.feed__item:hover { background: var(--sand); }
.feed__thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--sand-deep); flex: none; }
.feed__main { min-width: 0; flex: 1; }
.feed__title { font-weight: 600; font-size: 15px; }
.feed__meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__side { font-size: 13px; color: var(--muted); text-align: right; flex: none; }

.rowlist { display: grid; }
.rowlist__item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.rowlist__item:last-child { border-bottom: 0; }
.rowlist__item a { color: inherit; text-decoration: none; font-weight: 600; }
.rowlist__item .muted { margin-left: auto; }

/* ===== Tableaux ===== */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search { flex: 1; min-width: 200px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.table-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.is-link { cursor: pointer; }
.table tbody tr.is-link:hover { background: var(--sand); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.who { display: flex; align-items: center; gap: 10px; }
.who .avatar { width: 34px; height: 34px; font-size: 15px; }
.who__name { font-weight: 600; }
.who__sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.mini-week { display: flex; gap: 3px; }
.mini-week span { width: 10px; height: 10px; border-radius: 3px; background: var(--sand-deep); }
.mini-week span.is-on { background: var(--sea); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status--active { background: #E1F0EC; color: #23695F; }
.status--paused { background: #F6EBD8; color: #91601B; }
.status--done { background: #ECECEA; color: #6E7672; }
.status--invited { background: #E3ECF3; color: #2D5F80; }
.status--paid { background: #E1F0EC; color: #23695F; }
.status--pending { background: #FBE7D6; color: #A1531B; }
button.status { border: 0; cursor: pointer; }

/* Liste en cartes sur mobile */
@media (max-width: 760px) {
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table--cards td { border: 0; padding: 3px 0; }
  .table--cards td[data-label]::before { content: attr(data-label) " : "; color: var(--muted); font-size: 13px; }
  .table--cards .num { text-align: left; }
  .hide-mobile { display: none !important; }
}

/* ===== Fiche coaché ===== */
.subtabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 22px 0 18px; overflow-x: auto; }
.subtabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ocean); }
.ficheinfo { display: grid; gap: 10px 24px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-top: 16px; }
.ficheinfo div { font-size: 14px; }
.ficheinfo strong { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.invite { margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: #E3ECF3; color: #1F4A66; font-size: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.invite code { background: #fff; padding: 4px 8px; border-radius: 8px; font-size: 13px; word-break: break-all; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.modal-title { margin-bottom: 4px; }
