/* GPA Connect · theme.css v1 (2026-11-22) · polices système, aucune ressource externe */

/* ===== Jetons fixes ===== */
:root {
  --font: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;

  --t-xs: 12px; --t-sm: 13.5px; --t-md: 15px; --t-base: 16px; --t-lg: 18px;
  --t-xl: 20px; --t-2xl: 24px; --t-3xl: 30px; --t-4xl: 44px;
  --w-text: 400; --w-strong: 600; --w-title: 700;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;
  --pad: var(--s-4);

  --r-1: 6px; --r-2: 10px; --r-3: 14px; --r-sheet: 20px; --r-pill: 999px;

  --tap: 44px;
  --ctl: 44px;
  --nav-h: 64px;
  --side-w: 232px;
  --cut: 14px;

  --brand: #FFDD00;
  --brand-press: #EBCB00;
  --on-brand: #141414;
  --bad-solid: #B3261E;
  --on-bad: #FFFFFF;

  --we-x: #F0DCC6;
  --fer-x: #D2926F;

  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --d-1: 120ms; --d-2: 200ms; --d-3: 320ms;

  --shp-ok: circle(50%);
  --shp-warn: polygon(50% 6%, 100% 94%, 0 94%);
  --shp-bad: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
  --shp-info: inset(8% round 2px);
}

/* ===== Thème sombre (défaut) · .login reste toujours sombre ===== */
:root, .login {
  color-scheme: dark;
  --bg: #121110;
  --surface: #1B1A17;
  --raise: #25241F;
  --sunk: #0D0C0B;
  --field: #141310;
  --line: #33312C;
  --line-strong: #75726A;
  --ink: #F3F1EB;
  --muted: #ADA99F;
  --hover: rgba(243, 241, 235, .055);
  --focus: #FFDD00;

  --brand-text: #FFDD00;
  --brand-line: #FFDD00;
  --brand-tint: #34300F;
  --active-ink: #FFDD00;
  --slot-edge: transparent;
  --data: #FFDD00;

  --ok: #7AD7A4;   --ok-bg: #14301F;   --ok-line: #3FB97A;
  --warn: #FFB36B; --warn-bg: #3A2510; --warn-line: #FF9A3D;
  --bad: #FFB4B0;  --bad-bg: #4A1C1C;  --bad-line: #FF6B62;
  --info: #9CC8FF; --info-bg: #13263D; --info-line: #5AA2F5;

  --we: #37342E;  --we-ink: #E9C9A5;
  --fer: #664C3B; --fer-ink: #FFE3D2;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 6px 18px rgba(0, 0, 0, .45);
  --sh-3: 0 18px 48px rgba(0, 0, 0, .6);
  --scrim: rgba(6, 6, 5, .66);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ADA99F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ===== Thème clair ===== */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --raise: #FFFFFF;
  --sunk: #ECEAE4;
  --field: #FFFFFF;
  --line: #DCD9D0;
  --line-strong: #8A877D;
  --ink: #191815;
  --muted: #57554D;
  --hover: rgba(25, 24, 21, .045);
  --focus: #191815;

  --brand-text: #6E5700;
  --brand-line: #9C8200;
  --brand-tint: #FFF5B8;
  --active-ink: #191815;
  --slot-edge: #9C8200;
  --data: #191815;

  --ok: #1C6A41;   --ok-bg: #E1F1E7;   --ok-line: #2E8B57;
  --warn: #954600; --warn-bg: #FDEBD7; --warn-line: #E07A12;
  --bad: #A8211A;  --bad-bg: #FBE2DF;  --bad-line: #D3302A;
  --info: #1D5FA6; --info-bg: #E1ECF8; --info-line: #2F7BD0;

  --we: #F0DCC6;  --we-ink: #5C3B12;
  --fer: #D2926F; --fer-ink: #2B1407;

  --sh-1: 0 1px 2px rgba(25, 24, 21, .08);
  --sh-2: 0 6px 18px rgba(25, 24, 21, .10);
  --sh-3: 0 18px 48px rgba(25, 24, 21, .18);
  --scrim: rgba(25, 24, 21, .48);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2357554D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

@media (min-width: 760px) {
  :root { --t-base: 15px; --pad: var(--s-6); --nav-h: 0px; }
}
@media (min-width: 1100px) {
  :root { --side-w: 248px; }
}
@media (pointer: fine) {
  :root { --ctl: 38px; }
}

/* ===== Gravité : couleur + forme ===== */
.ok   { --g-tx: var(--ok);   --g-bg: var(--ok-bg);   --g-ln: var(--ok-line);   --g-shp: var(--shp-ok); }
.warn { --g-tx: var(--warn); --g-bg: var(--warn-bg); --g-ln: var(--warn-line); --g-shp: var(--shp-warn); }
.bad  { --g-tx: var(--bad);  --g-bg: var(--bad-bg);  --g-ln: var(--bad-line);  --g-shp: var(--shp-bad); }
.info { --g-tx: var(--info); --g-bg: var(--info-bg); --g-ln: var(--info-line); --g-shp: var(--shp-info); }

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: var(--w-text) var(--t-base)/1.5 var(--font);
  overflow-wrap: anywhere;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: var(--w-title); line-height: 1.25; text-wrap: balance; }
p { margin: 0; }
img, video, canvas { display: block; max-width: 100%; }
svg { flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-text); text-underline-offset: 2px; }
::selection { background: var(--brand); color: var(--on-brand); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.stack { display: grid; gap: var(--gap, var(--s-4)); align-content: start; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--s-3)); }
.cols { display: grid; gap: var(--gap, var(--s-4)); grid-template-columns: repeat(auto-fit, minmax(min(var(--min, 260px), 100%), 1fr)); }
.scroll-x { overflow-x: auto; overscroll-behavior-x: contain; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Balise de rubrique : fente + capitales jaunes + filet (seul usage des capitales espacées) */
.sec {
  display: flex; align-items: center; gap: var(--s-2);
  margin: var(--s-2) 0 0;
  font: 700 11px/1 var(--font);
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--brand-text);
}
.sec::before { content: ""; width: 3px; height: 12px; background: var(--brand); box-shadow: 0 0 0 1px var(--slot-edge); }
.sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100dvh;
}
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: 0 max(var(--pad), env(safe-area-inset-right)) calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s-6)) max(var(--pad), env(safe-area-inset-left));
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-3);
  min-height: calc(56px + env(safe-area-inset-top));
  margin-inline: calc(-1 * max(var(--pad), env(safe-area-inset-left))) calc(-1 * max(var(--pad), env(safe-area-inset-right)));
  padding: env(safe-area-inset-top) max(var(--pad), env(safe-area-inset-right)) 0 max(var(--pad), env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; min-width: 0; font-size: var(--t-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .logo { height: 22px; width: auto; }
.topbar .btn { flex: none; }

.sidebar { display: none; }

@media (min-width: 760px) {
  .app { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .topbar { min-height: 64px; }
  .topbar h1 { font-size: var(--t-xl); }
  .topbar .logo { display: none; }

  .sidebar {
    position: sticky; top: 0;
    display: flex; flex-direction: column;
    height: 100dvh;
    overflow-y: auto;
    padding-left: env(safe-area-inset-left);
    background: var(--surface);
    border-right: 1px solid var(--line);
  }
}
.sidebar .brand { display: flex; align-items: center; gap: var(--s-3); min-height: 64px; padding: var(--s-4) var(--s-5); }
.sidebar .brand img { height: 28px; width: auto; }
.sidebar nav { display: grid; gap: 2px; padding: var(--s-2) 10px var(--s-4); }
.sidebar .sec { margin: var(--s-4) 2px var(--s-1); }
.sidebar nav a,
.sidebar nav button {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 40px;
  padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-2);
  background: none;
  color: var(--muted);
  font: var(--w-strong) 14.5px/1.2 var(--font);
  text-align: start; text-decoration: none;
  cursor: pointer;
}
.sidebar nav svg { width: 20px; height: 20px; }
.sidebar nav a:hover,
.sidebar nav button:hover { background: var(--hover); color: var(--ink); }
.sidebar nav .on,
.sidebar nav [aria-current="page"] { background: var(--brand-tint); color: var(--active-ink); }
.sidebar nav .on::before,
.sidebar nav [aria-current="page"]::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand); box-shadow: 0 0 0 1px var(--slot-edge);
}
.sidebar nav .count { margin-left: auto; }
.sidebar .foot { margin-top: auto; padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: var(--t-xs); color: var(--muted); }

.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.bottomnav > a,
.bottomnav > button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: var(--tap); min-height: var(--nav-h);
  border: 0; background: none;
  color: var(--muted);
  font: var(--w-strong) 11.5px/1.1 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.bottomnav svg {
  width: 56px; height: 32px; padding: 6px 18px;
  border-radius: var(--r-pill);
  transition: background-color var(--d-1) var(--ease-out);
}
.bottomnav .on,
.bottomnav [aria-current="page"] { color: var(--ink); }
.bottomnav .on svg,
.bottomnav [aria-current="page"] svg { background: var(--brand); color: var(--on-brand); }
.bottomnav .count { position: absolute; top: 5px; left: calc(50% + 8px); }
.bottomnav > :nth-child(n + 6) { display: none; }
@media (min-width: 760px) { .bottomnav { display: none; } }

/* ===== Carte, KPI, compte à rebours ===== */
.card {
  --pad: var(--s-4);
  min-width: 0;
  padding: var(--pad);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
}
@media (min-width: 760px) { .card { --pad: var(--s-5); } }
.card-h { display: flex; align-items: center; gap: 10px; min-height: 28px; margin: 0 0 var(--s-3); }
.card-h > svg { width: 20px; height: 20px; color: var(--brand-text); }
.card-h h2,
.card-h h3 { flex: 1; min-width: 0; font-size: var(--t-md); font-weight: 650; }
.card-h > .btn,
.card-h > a { margin-left: auto; }
.card > .list,
.card > .tbl,
.card > .scroll-x { margin-inline: calc(-1 * var(--pad)); }
.card > .list:last-child { margin-bottom: calc(-1 * var(--s-2)); }

.kpi {
  position: relative;
  display: grid; gap: var(--s-1); align-content: start;
  min-width: 0;
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  overflow: hidden;
}
.kpi .lbl { font-size: var(--t-sm); font-weight: var(--w-strong); color: var(--muted); }
.kpi .val { font: 650 var(--t-3xl)/1.1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi .val small { margin-left: 3px; font-size: var(--t-md); font-weight: 500; color: var(--muted); }
.kpi .sub { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi.ok::before, .kpi.warn::before, .kpi.bad::before, .kpi.info::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--g-ln);
}
.kpi.warn .val, .kpi.bad .val { color: var(--g-tx); }

/* Jauge d'heures : piste = 120 % du contrat, repère au contrat (--p = % du contrat, sans unité) */
.meter {
  position: relative;
  height: 8px; margin-top: var(--s-2);
  border-radius: var(--r-pill);
  background: var(--sunk);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.meter > i { display: block; height: 100%; width: calc(min(var(--p, 0), 100) / 1.2 * 1%); background: var(--data); }
.meter::after {
  content: ""; position: absolute; top: 0; bottom: 0;
  left: calc(100% / 1.2);
  width: calc(min(max(var(--p, 0) - 100, 0), 20) / 1.2 * 1%);
  background: var(--warn-line);
}
.meter.bad::after { background: var(--bad-line); }
.meter::before { content: ""; position: absolute; z-index: 1; top: 0; bottom: 0; left: calc(100% / 1.2); width: 2px; margin-left: -1px; background: var(--ink); }

/* Plaque « prochain service » : noire, cadre jaune, coin coupé (étiquette du logo) */
.countdown {
  position: relative;
  display: grid; gap: var(--s-2);
  padding: var(--s-5) var(--s-5) var(--s-4) calc(var(--s-5) + 4px);
  background: #0B0A09;
  color: #F3F1EB;
  border: 1.5px solid var(--brand);
  border-radius: var(--r-2) 0 var(--r-2) var(--r-2);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
}
.countdown::after {
  content: ""; position: absolute; top: -1.5px; right: -1.5px;
  width: var(--cut); height: var(--cut);
  background: linear-gradient(to top right, transparent calc(50% - 2px), var(--brand) calc(50% - 2px) 50%, transparent 50%);
}
.countdown::before { content: ""; position: absolute; left: 0; top: var(--s-5); bottom: var(--s-4); width: 4px; background: var(--brand); }
.countdown .lbl { font: 700 var(--t-sm)/1.2 var(--font); color: #FFDD00; }
.countdown .time {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 6px;
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.countdown .time b { font-size: var(--t-4xl); font-weight: 700; letter-spacing: -.01em; }
.countdown .time small { margin-right: 10px; font-size: var(--t-md); font-weight: 600; color: #ADA99F; }
.countdown .meta { font-size: var(--t-sm); color: #ADA99F; font-variant-numeric: tabular-nums; }
.countdown .meta b { color: #F3F1EB; font-weight: 600; }
.countdown.soon .time b { color: #FFDD00; }
.countdown.live { border-color: #3FB97A; }
.countdown.live::before { background: #3FB97A; }
.countdown.live::after { background: linear-gradient(to top right, transparent calc(50% - 2px), #3FB97A calc(50% - 2px) 50%, transparent 50%); }
.countdown.live .lbl { color: #7AD7A4; }
@media (min-width: 760px) { .countdown .time b { font-size: 56px; } }

/* ===== Boutons ===== */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--ctl);
  padding: 0 var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background-color: var(--raise);
  color: var(--ink);
  font: var(--w-strong) var(--t-md)/1.2 var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background-color var(--d-1) var(--ease-out), border-color var(--d-1) var(--ease-out), transform var(--d-1) var(--ease-out);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background-image: linear-gradient(var(--hover), var(--hover)); }
.btn:active { transform: translateY(1px); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.pri:hover { background: var(--brand-press); border-color: var(--brand-press); }
.btn.ghost { background-color: transparent; border-color: transparent; }
.btn.bad { background-color: transparent; border-color: var(--bad-line); color: var(--bad); }
.btn.bad:hover { background: var(--bad-bg); }
.btn.sm { min-height: 32px; padding: 0 var(--s-3); border-radius: var(--r-1); font-size: var(--t-sm); }
.btn.sm svg { width: 16px; height: 16px; }
.btn.lg { min-height: 52px; padding: 0 var(--s-6); font-size: var(--t-base); }
.btn.icon { width: var(--ctl); padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled,
.btn[aria-disabled="true"] { background: var(--sunk); border-color: var(--line); color: var(--muted); cursor: not-allowed; transform: none; background-image: none; }
@media (pointer: coarse) {
  .btn.sm::after { content: ""; position: absolute; inset: -6px; }
}

/* ===== Badges, compteurs ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: var(--r-1);
  background: var(--sunk);
  color: var(--muted);
  font: var(--w-strong) var(--t-xs)/1 var(--font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  vertical-align: middle;
}
.badge.ok, .badge.warn, .badge.bad, .badge.info { background: var(--g-bg); color: var(--g-tx); }
.badge.ok::before, .badge.warn::before, .badge.bad::before, .badge.info::before {
  content: ""; width: 9px; height: 9px; flex: none;
  background: var(--g-ln);
  clip-path: var(--g-shp);
}
.badge.gold { background: var(--brand); color: var(--on-brand); }

.count {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--bad-solid); color: var(--on-bad);
  font: 700 11.5px/1 var(--font);
  font-variant-numeric: tabular-nums;
}

/* ===== Tableau ===== */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.tbl th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px var(--s-3);
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-weight: var(--w-strong);
  text-align: start;
  white-space: nowrap;
}
.tbl td { padding: 10px var(--s-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr > :first-child { padding-inline-start: var(--pad); }
.tbl tr > :last-child { padding-inline-end: var(--pad); }
.tbl .num { text-align: end; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tr.on > td { background: var(--brand-tint); }
.tbl tr.on > td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
@media (pointer: coarse) { .tbl td { height: 48px; } }

/* ===== Liste ===== */
.list { display: grid; margin: 0; padding: 0; list-style: none; }
.item {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 56px;
  padding: 10px var(--pad);
  border: 0; border-top: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit; text-align: start; text-decoration: none;
}
.list > .item:first-child,
.list > li:first-child > .item { border-top: 0; }
.item > svg { width: 22px; height: 22px; color: var(--muted); }
.item .txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.item .ttl { font-weight: var(--w-strong); font-size: var(--t-md); line-height: 1.3; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: var(--t-sm); line-height: 1.35; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .end { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); flex: none; }
a.item, button.item, .item[tabindex] { cursor: pointer; }
a.item:hover, button.item:hover, .item[tabindex]:hover { background: var(--hover); }
.item.new::before,
.item.on::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); box-shadow: 0 0 0 1px var(--slot-edge); }
.item.new .ttl { font-weight: 700; }
.item.on { background: var(--brand-tint); }

/* ===== Avatar (lg = photo d'identité 4:5) ===== */
.avatar {
  --av: 40px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--av); height: var(--av);
  border-radius: 50%;
  overflow: hidden;
  background: var(--sunk);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  font: 650 calc(var(--av) * .38)/1 var(--font);
  text-transform: uppercase;
  object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { --av: 28px; }
.avatar.md { --av: 40px; }
.avatar.lg { --av: 96px; height: 120px; border-radius: var(--r-2); box-shadow: inset 0 0 0 1px var(--line-strong); font-size: 34px; }
@media (min-width: 760px) { .avatar.lg { --av: 112px; height: 140px; font-size: 40px; } }

/* ===== Formulaires ===== */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label,
.field > .lbl { font-size: var(--t-sm); font-weight: var(--w-strong); color: var(--ink); }
.field .hint { font-size: var(--t-xs); color: var(--muted); }
.field .err { display: flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: var(--w-strong); color: var(--bad); }
.field .err::before { content: ""; width: 10px; height: 10px; flex: none; background: var(--bad-line); clip-path: var(--shp-bad); }

input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"]),
select,
textarea {
  width: 100%;
  min-height: var(--ctl);
  padding: 0 var(--s-3);
  background-color: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  color: var(--ink);
  font-size: 16px;
  transition: border-color var(--d-1) var(--ease-out);
}
@media (pointer: fine) {
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"]),
  select, textarea { font-size: var(--t-md); }
}
textarea { min-height: 96px; padding: 10px var(--s-3); line-height: 1.45; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none;
  padding-inline-end: 38px;
  background-image: var(--chev);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
input[readonly], textarea[readonly] { background-color: var(--sunk); }
.field.invalid input, .field.invalid select, .field.invalid textarea,
[aria-invalid="true"] { border-color: var(--bad-line); box-shadow: inset 3px 0 0 var(--bad-line); }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); cursor: pointer; }
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }

/* ===== Contrôle segmenté, onglets ===== */
.seg {
  display: inline-flex; gap: 2px;
  padding: 3px;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg > * {
  position: relative;
  flex: 1 0 auto;
  min-height: calc(var(--ctl) - 8px);
  padding: 0 var(--s-3);
  border: 0; border-radius: 7px;
  background: none;
  color: var(--muted);
  font: var(--w-strong) var(--t-sm)/1 var(--font);
  white-space: nowrap;
  cursor: pointer;
}
@media (pointer: coarse) { .seg > * { min-height: var(--tap); } }
.seg > *:hover { color: var(--ink); }
.seg > .on,
.seg > [aria-pressed="true"],
.seg > [aria-selected="true"],
.seg > [aria-checked="true"] { background: var(--raise); color: var(--ink); box-shadow: var(--sh-1), inset 0 0 0 1px var(--line); }
.seg > .on::after,
.seg > [aria-pressed="true"]::after,
.seg > [aria-selected="true"]::after,
.seg > [aria-checked="true"]::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: 3px; height: 2px; border-radius: 2px; background: var(--brand); box-shadow: 0 0 0 .5px var(--slot-edge); }

.tabs {
  display: flex; gap: var(--s-1);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs > * {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-3);
  border: 0; background: none;
  color: var(--muted);
  font: var(--w-strong) var(--t-md)/1 var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.tabs > *:hover { color: var(--ink); }
.tabs > .on,
.tabs > [aria-selected="true"],
.tabs > [aria-current="page"] { color: var(--ink); }
.tabs > .on::after,
.tabs > [aria-selected="true"]::after,
.tabs > [aria-current="page"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); box-shadow: 0 0 0 1px var(--slot-edge); }

/* ===== Modale (<dialog>) et feuille du bas ===== */
.modal {
  width: min(560px, calc(100% - 2 * var(--s-4)));
  max-width: none;
  max-height: min(88dvh, 820px);
  margin: auto;
  padding: 0;
  background: var(--raise);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; animation: m-in var(--d-2) var(--ease-out); }
.modal::backdrop { background: var(--scrim); }
.modal[open]::backdrop { animation: fade var(--d-2) var(--ease-out); }
.modal > header { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); flex: none; }
.modal > header h2 { flex: 1; min-width: 0; font-size: var(--t-lg); }
.modal > :not(header, footer) { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-5); }
.modal > footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex: none; }
.modal.wide { width: min(1040px, calc(100% - 2 * var(--s-4))); }

@media (max-width: 759.98px) {
  .modal.sheet {
    width: 100%;
    max-height: 92dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    transform: translateY(var(--drag, 0px));
  }
  .modal.sheet[open] { animation: sheet-in var(--d-3) var(--ease-out); }
  .modal.sheet::before { content: ""; flex: none; width: 36px; height: 4px; margin: var(--s-2) auto 0; border-radius: 2px; background: var(--line-strong); }
  .modal.sheet > header { border-bottom: 0; min-height: 48px; }
  .modal.sheet > footer { flex-direction: column-reverse; align-items: stretch; }
  .modal.sheet > footer .btn { width: 100%; min-height: 52px; }
  .modal.sheet > :last-child:not(footer) { padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom)); }
}

/* ===== Toast ===== */
.toast {
  position: fixed; z-index: 60;
  left: 50%; translate: -50% 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s-3));
  display: flex; align-items: center; gap: var(--s-3);
  width: max-content; max-width: calc(100% - 2 * var(--s-4));
  min-height: 48px;
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  background: var(--raise);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  box-shadow: var(--sh-2), inset 4px 0 0 var(--g-ln, var(--brand));
  font-weight: 500;
  animation: rise var(--d-2) var(--ease-out);
}
.toast.ok::before, .toast.warn::before, .toast.bad::before, .toast.info::before { content: ""; width: 12px; height: 12px; flex: none; background: var(--g-ln); clip-path: var(--g-shp); }
.toast .btn { margin-left: var(--s-2); }
@media (min-width: 760px) { .toast { left: auto; right: var(--s-6); translate: none; bottom: var(--s-6); max-width: 420px; } }

/* ===== État vide ===== */
.empty { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-8) var(--s-4); text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; margin-bottom: var(--s-2); color: var(--line-strong); }
.empty h3, .empty b { font-size: var(--t-base); font-weight: 650; color: var(--ink); }
.empty .btn { margin-top: var(--s-3); }

/* ===== Signature (papier blanc dans les deux thèmes) ===== */
.sigbox {
  --surface: #FFFFFF; --raise: #FFFFFF; --sunk: #ECEAE4; --line: #DCD9D0; --line-strong: #8A877D;
  --ink: #191815; --muted: #57554D; --hover: rgba(25, 24, 21, .05); --focus: #191815;
  --bad: #A8211A; --bad-bg: #FBE2DF; --bad-line: #D3302A;
  position: relative;
  height: 200px;
  background: #FFFFFF;
  color: #191815;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  overflow: hidden;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  color-scheme: light;
}
.sigbox canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sigbox::before { content: ""; position: absolute; left: var(--s-6); right: var(--s-6); bottom: 28%; border-bottom: 1.5px solid #8A877D; pointer-events: none; }
.sigbox::after { content: "\00D7"; position: absolute; left: var(--s-6); bottom: calc(28% + 6px); font: 600 20px/1 var(--font); color: #57554D; pointer-events: none; }
.sigbox .bar { position: absolute; z-index: 1; top: var(--s-2); right: var(--s-2); display: flex; gap: var(--s-2); }
.sigbox:focus-within, .sigbox.active { border-color: #9C8200; box-shadow: 0 0 0 1px #9C8200; }
.sigbox.signed { border-color: #2E8B57; }
.sigbox.full {
  position: fixed; inset: 0; z-index: 80;
  height: auto;
  border: 0; border-radius: 0; box-shadow: none;
}
.sigbox.full::before { left: max(var(--s-7), env(safe-area-inset-left)); right: max(var(--s-7), env(safe-area-inset-right)); bottom: 30%; }
.sigbox.full::after { left: max(var(--s-7), env(safe-area-inset-left)); bottom: calc(30% + 8px); font-size: 26px; }
.sigbox.full .bar {
  top: auto; left: 0; right: 0; bottom: 0;
  justify-content: space-between;
  padding: var(--s-3) max(var(--s-4), env(safe-area-inset-right)) calc(var(--s-3) + env(safe-area-inset-bottom)) max(var(--s-4), env(safe-area-inset-left));
  background: #F6F5F1;
  border-top: 1px solid #DCD9D0;
}
.sigbox.full .bar .btn { min-height: 52px; flex: 1; }

/* ===== Planificateur ===== */
.grid-plan {
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
  max-height: calc(100dvh - 140px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}
.grid-plan table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.grid-plan th,
.grid-plan td {
  min-width: 40px; height: 44px;
  padding: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  background-clip: padding-box;
}
@media (pointer: fine) {
  .grid-plan th, .grid-plan td { min-width: 36px; height: 32px; }
}
.grid-plan thead th {
  position: sticky; top: 0; z-index: 2;
  height: auto; padding: 6px 2px;
  background: var(--raise);
  border-bottom-color: var(--line-strong);
  color: var(--muted);
  font-weight: var(--w-strong);
  line-height: 1.15;
}
.grid-plan thead th b { display: block; font-size: var(--t-sm); font-weight: 700; color: var(--ink); }
.grid-plan thead th small { display: block; font-size: 10.5px; }
.grid-plan tr > :first-child {
  position: sticky; left: 0; z-index: 1;
  min-width: 128px; max-width: 128px;
  padding: 0 var(--s-2) 0 var(--s-3);
  background: var(--surface);
  border-right: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: var(--t-sm); font-weight: var(--w-strong);
  text-align: start;
  white-space: nowrap; overflow: clip; text-overflow: ellipsis;
}
@media (min-width: 760px) { .grid-plan tr > :first-child { min-width: 200px; max-width: 200px; } }
.grid-plan thead tr > :first-child { z-index: 3; background: var(--raise); }
.grid-plan .tot { min-width: 56px; padding: 0 var(--s-2); border-left: 2px solid var(--line-strong); font-weight: 700; text-align: end; color: var(--ink); }
@media (min-width: 760px) {
  .grid-plan .tot { position: sticky; right: 0; z-index: 1; background: var(--surface); }
  .grid-plan thead .tot { z-index: 3; background: var(--raise); }
}

.grid-plan .we { background: var(--we); }
.grid-plan .fer { background: var(--fer); }
.grid-plan thead .we, .grid-plan thead .we b { color: var(--we-ink); }
.grid-plan thead .fer, .grid-plan thead .fer b { color: var(--fer-ink); }
.grid-plan td.today { box-shadow: inset 2px 0 0 var(--brand-line), inset -2px 0 0 var(--brand-line); }
.grid-plan thead th.today,
.grid-plan thead th.today b { background: var(--brand); color: var(--on-brand); }
.grid-plan td.sel { outline: 2px solid var(--focus); outline-offset: -2px; }

.grid-plan .code {
  display: grid; place-items: center;
  min-height: 26px;
  margin: 2px;
  border-radius: 4px;
  background: #E6E3DB;
  color: #141414;
  font: 650 11.5px/1 var(--mono);
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.grid-plan .code.inv { color: #FFFFFF; }
.grid-plan.fill .code { margin: 0; min-height: 100%; height: 100%; border-radius: 0; box-shadow: none; }
.grid-plan.compact th, .grid-plan.compact td { min-width: 30px; height: 26px; }
.grid-plan.compact .code { min-height: 20px; font-size: 10.5px; }
@media (hover: hover) {
  .grid-plan tbody tr:hover > td:not(:first-child, .we, .fer, .tot) { background: var(--hover); }
}

/* ===== Connexion ===== */
.login {
  position: relative;
  isolation: isolate;
  display: grid; place-items: center;
  min-height: 100dvh;
  padding: max(var(--s-6), env(safe-area-inset-top)) max(var(--s-4), env(safe-area-inset-right)) max(var(--s-6), env(safe-area-inset-bottom)) max(var(--s-4), env(safe-area-inset-left));
  background: #0B0A09;
  color: var(--ink);
  overflow: hidden;
}
.login::before {
  content: ""; position: absolute; z-index: -1;
  top: 10%; bottom: 10%; left: 92%; width: 2px;
  background: linear-gradient(transparent, #FFDD00 28% 72%, transparent);
}
@media (min-width: 760px) { .login::before { left: 74%; width: 3px; } }
.login .panel { display: grid; gap: var(--s-4); width: min(400px, 100%); }
.login .logo { justify-self: start; height: 40px; width: auto; margin-bottom: var(--s-4); }
.login h1 { font-size: var(--t-2xl); }
.login .or { display: flex; align-items: center; gap: var(--s-3); color: var(--muted); font-size: var(--t-sm); }
.login .or::before, .login .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login .bio {
  display: grid; justify-items: center; gap: var(--s-2);
  justify-self: center;
  padding: var(--s-2);
  border: 0; border-radius: var(--r-3);
  background: none;
  color: var(--ink);
  font: var(--w-strong) var(--t-sm)/1.2 var(--font);
  cursor: pointer;
}
.login .bio svg {
  width: 88px; height: 88px; padding: 20px;
  border: 2px solid var(--brand); border-radius: 50%;
  color: var(--brand);
  transition: background-color var(--d-1) var(--ease-out), transform var(--d-1) var(--ease-out);
}
.login .bio:hover svg { background: var(--brand-tint); }
.login .bio:active svg { transform: scale(.96); }
.login .bio[aria-busy="true"] svg { background: var(--brand); color: var(--on-brand); }

/* ===== Mouvement ===== */
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes m-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }

:root[data-fx="0"] *,
:root[data-fx="0"] *::before,
:root[data-fx="0"] *::after,
:root[data-fx="0"] ::backdrop { animation: none !important; transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .modal[open], .modal.sheet[open], .toast { animation: fade var(--d-1) linear; }
  .btn:active, .login .bio:active svg { transform: none; }
  *, *::before, *::after { transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .badge::before, .toast::before, .field .err::before { background: CanvasText; }
  .sidebar nav .on, .bottomnav .on svg, .seg > .on, .tabs > .on { outline: 2px solid Highlight; }
}
