/* ORGA SOUFIANE — interface v2 (clair / sombre selon le téléphone) */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f1eee8;
  --surface-3: #e8e4dc;
  --line: #e4dfd6;
  --text: #17150f;
  --text-2: #5d584e;
  --text-3: #8e887c;
  --accent: #2f9e7e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 158, 126, .12);
  --shadow: 0 1px 2px rgba(23, 21, 15, .05), 0 4px 16px rgba(23, 21, 15, .06);
  --shadow-lg: 0 10px 40px rgba(23, 21, 15, .18);

  --c-travail: #6b6f78;
  --c-entrainement: #b08d55;
  --c-coaching: #2f9e7e;
  --c-camera: #3f78c0;
  --c-pc: #cf6a3e;
  --c-chaines: #b4667b;
  --c-autre: #7d786d;
  --c-google: #8e887c;
  --ok: #2f9e7e;
  --warn: #b98a3e;
  --danger: #c4524b;

  --r: 14px;
  --r-sm: 10px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0c;
    --surface: #171714;
    --surface-2: #1f1f1b;
    --surface-3: #292924;
    --line: #2a2a25;
    --text: #f2eee6;
    --text-2: #b8b2a5;
    --text-3: #7f796e;
    --accent: #3fb592;
    --accent-ink: #04130e;
    --accent-soft: rgba(63, 181, 146, .14);
    --shadow: 0 1px 0 rgba(255, 255, 255, .02);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
    --c-travail: #8a8f98;
    --c-camera: #5b93db;
    --c-pc: #e0804f;
    --c-chaines: #cf7f95;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 600; }
h3 { font-size: 18px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.stack > * + * { margin-top: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.brand { font-weight: 700; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.brand b { color: var(--accent); font-weight: 700; }
.badges { display: flex; gap: 6px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); display: inline-block; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--danger); }

main { padding: 4px 16px 24px; max-width: 1100px; margin: 0 auto; }
section.view { display: none; }
section.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 8px; color: var(--text-3); font-size: 11px; font-weight: 500;
}
.nav a svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.active { color: var(--accent); }
.nav a.active svg { stroke-width: 2.2; }

.fab {
  position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 25;
  width: 58px; height: 58px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); border: 0;
  font-size: 30px; font-weight: 300; line-height: 1; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(.95); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card, .card + .kpis, .kpis + .card, .block + .block { margin-top: 12px; }
.card.pad0 { padding: 0; overflow: hidden; }
.card h2 { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.card-head h2 { margin: 0; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 2px 10px; }

/* ---------------------------------------------------------------- KPI */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 12px 11px; box-shadow: var(--shadow); min-width: 0; }
.kpi .v { font-family: var(--mono); font-size: clamp(17px, 5vw, 24px); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .l { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.25; }
.kpi.ok .v { color: var(--ok); }
.kpi.warn .v { color: var(--warn); }
.kpi.danger .v { color: var(--danger); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px;
  white-space: nowrap; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.xs { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.icon { width: 40px; height: 40px; padding: 0; border-radius: 12px; font-size: 18px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.actions .btn { padding: 10px 6px; font-size: 13px; }

/* ---------------------------------------------------------------- forms */
label.f { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.in, select.in, textarea.in {
  width: 100%; min-width: 0; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); outline: none; transition: border-color .15s, background .15s;
}
.in:focus { border-color: var(--accent); background: var(--surface); }
textarea.in { min-height: 70px; resize: vertical; }
.in.sm { padding: 7px 9px; font-size: 13.5px; border-radius: 9px; }
.in.mono { font-family: var(--mono); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13.5px; font-weight: 500;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.slot { font-family: var(--mono); font-size: 12.5px; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg .chip { border: 0; background: transparent; flex: 1; white-space: nowrap; border-radius: 9px; }
.seg .chip.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- quick input */
.ask {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 6px 6px 6px 14px;
  box-shadow: var(--shadow);
}
.ask textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none; resize: none;
  min-height: 24px; max-height: 120px; padding: 9px 0; line-height: 1.35;
}
.ask .btn { border-radius: 13px; padding: 10px 14px; }
.ask-hint { font-size: 12px; color: var(--text-3); margin: 6px 4px 0; }

/* ---------------------------------------------------------------- hero (jour) */
.hero { margin: 6px 2px 16px; }
.hero .date { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.hero .sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.pill.btnlike { border: 0; }

.alert {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-radius: var(--r); margin-bottom: 12px;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font-size: 13.5px; font-weight: 500;
}

/* ---------------------------------------------------------------- timeline */
.timeline { position: relative; padding: 4px 0; }
.tl-row { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: stretch; }
.tl-time { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); text-align: right; padding-top: 12px; }
.tl-time b { display: block; color: var(--text); font-weight: 500; font-size: 13.5px; }
.tl-ev {
  position: relative; margin: 4px 0; padding: 11px 12px 11px 16px; border-radius: 12px;
  background: color-mix(in srgb, var(--cat) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--cat) 22%, transparent);
  cursor: pointer; min-width: 0;
}
.tl-ev::before { content: ""; position: absolute; left: 6px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: var(--cat); }
.tl-ev .t { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-ev .s { font-size: 12.5px; color: var(--text-2); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tl-ev .s .prix { font-family: var(--mono); color: var(--text); font-weight: 500; }
.tl-ev.passe { opacity: .55; }
.tl-ev.muted-ev { background: var(--surface-2); border-color: var(--line); }
.tl-ev.google { background: transparent; border-style: dashed; }
.tl-free { margin: 2px 0; padding: 8px 12px; border-radius: 12px; border: 1px dashed var(--line); color: var(--text-3); font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.tl-free:hover { border-color: var(--accent); color: var(--accent); }
.tl-now { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: center; margin: 2px 0; }
.tl-now span { font-family: var(--mono); font-size: 11.5px; color: var(--danger); text-align: right; font-weight: 600; }
.tl-now hr { border: 0; height: 2px; background: var(--danger); margin: 0; border-radius: 2px; position: relative; }
.tl-now hr::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* ---------------------------------------------------------------- next RDV */
.next { border-left: 5px solid var(--cat); }
.next .when { font-size: 13px; color: var(--text-2); font-weight: 500; }
.next .who { font-size: 19px; font-weight: 700; margin-top: 4px; letter-spacing: -0.01em; }
.next .what { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.next .big-prix { font-family: var(--mono); font-size: 22px; font-weight: 500; }

/* ---------------------------------------------------------------- lists */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-top: 1px solid var(--line); cursor: pointer; min-width: 0;
}
.item:first-child { border-top: 0; }
.item:hover { background: var(--surface-2); }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.item .prix { font-family: var(--mono); font-size: 15px; font-weight: 500; white-space: nowrap; }
.item .right { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ico {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--cat) 15%, transparent); color: var(--cat);
}
.ico svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; background: var(--surface-3); color: var(--text-2); }
.status { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.status.paye { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.status.attente { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.status.annule { color: var(--text-3); background: var(--surface-2); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.tag.poste { background: var(--surface-3); color: var(--text); }
.tag.paye { color: var(--ok); }
.tag.attente { color: var(--warn); }

.cat-travail { --cat: var(--c-travail); }
.cat-entrainement { --cat: var(--c-entrainement); }
.cat-coaching { --cat: var(--c-coaching); }
.cat-camera { --cat: var(--c-camera); }
.cat-pc { --cat: var(--c-pc); }
.cat-chaines { --cat: var(--c-chaines); }
.cat-autre { --cat: var(--c-autre); }
.cat-google { --cat: var(--c-google); }

/* ---------------------------------------------------------------- semaine */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.week-nav .mid { text-align: center; min-width: 0; }
.week-nav h1 { font-size: 19px; }
.daystrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin-bottom: 14px; }
.daystrip button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 7px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0;
}
.daystrip .dn { font-size: 11px; color: var(--text-3); text-transform: uppercase; font-weight: 600; letter-spacing: .04em; }
.daystrip .dd { font-size: 17px; font-weight: 700; }
.daystrip .dots { display: flex; gap: 2px; height: 6px; margin-top: 2px; }
.daystrip .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--cat); }
.daystrip button.today .dd { color: var(--accent); }
.daystrip button.on { background: var(--text); border-color: var(--text); }
.daystrip button.on .dn, .daystrip button.on .dd { color: var(--bg); }
.week { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 960px) {
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .daystrip { display: none; }
}
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; min-width: 0; box-shadow: var(--shadow); }
.day.today { border-color: var(--accent); }
.day .dh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.day .dh b { font-size: 14px; font-weight: 700; }
.day.today .dh b { color: var(--accent); }
.ev {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px 8px 12px; border-radius: 10px; margin-top: 6px;
  font-size: 13.5px; background: color-mix(in srgb, var(--cat) 10%, var(--surface)); cursor: pointer; position: relative; min-width: 0;
}
.ev::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--cat); }
.ev .h { font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; min-width: 76px; padding-left: 4px; }
.ev > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ev.annule { opacity: .45; text-decoration: line-through; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-3); margin: 14px 2px 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--cat); }

/* ---------------------------------------------------------------- argent */
.bar { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; background: var(--cat); }
.bar i.att { opacity: .35; }
.cat-row { padding: 10px 0; border-top: 1px solid var(--line); }
.cat-row:first-of-type { border-top: 0; }

/* ---------------------------------------------------------------- sheet / modal */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(10, 10, 8, .5); z-index: 40; display: none; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px);
}
.sheet-bg.open { display: flex; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  animation: up .22s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg);
}
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 5px; background: var(--surface-3); margin: 0 auto 14px; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } .sheet::before { display: none; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h3 { margin-bottom: 14px; }
.lignes { display: flex; flex-direction: column; gap: 6px; }
.ligne { display: grid; grid-template-columns: minmax(0, 1fr) 56px 72px 32px; gap: 6px; align-items: center; }
.total-box { background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px; }
.total-box .tl { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 3px 0; }
.total-box .tl.big { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
.total-box .tl.big .mono { color: var(--accent); }

/* ---------------------------------------------------------------- tables */
table.tb { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tb th { text-align: left; font-size: 11.5px; color: var(--text-3); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tb td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tb-wrap { overflow-x: auto; margin: 0 -4px; }

/* ---------------------------------------------------------------- login */
.login { min-height: 78dvh; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center; }
section.view.login.active { display: flex; }
.login .logo { width: 72px; height: 72px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.pin input { width: 230px; text-align: center; letter-spacing: 14px; font-family: var(--mono); font-size: 28px; padding: 14px; border-radius: 16px; }

/* ---------------------------------------------------------------- misc */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(8px);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 500; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); color: #fff; }
.empty { padding: 26px 16px; text-align: center; color: var(--text-3); font-size: 14px; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }
.status-line { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 3px 7px; border-radius: 6px; word-break: break-all; }
