/* =====================================================================
   Freed CRM — charte et composants
   Une seule couleur d'accent (cyan Freed), fond blanc / gris clair,
   vert-orange-rouge réservés aux statuts. Tablette d'abord (cibles 44 px).
   ===================================================================== */

:root {
  --brand-50: #ecfeff;  --brand-100: #cffafe; --brand-200: #a5f3fc;
  --brand-400: #22d3ee; --brand-500: #06b6d4; --brand-600: #0891b2;
  --brand-700: #0e7490; --brand-800: #155e75;
  --logo: #6cdfd0;

  --ink: #0f172a; --ink-2: #334155; --muted: #64748b;
  --line: #e2e8f0; --line-2: #f1f5f9; --line-strong: #cbd5e1;
  --bg: #f4f7fa; --surface: #fff;

  --ok: #047857;   --ok-bg: #ecfdf5;   --ok-line: #a7f3d0;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-line: #fde68a;
  --bad: #dc2626;  --bad-bg: #fef2f2;  --bad-line: #fecaca;

  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
  --touch: 44px;
  --sidebar: 232px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============ Structure ============ */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: var(--ink); text-decoration: none !important; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--logo); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.logo-txt { font-weight: 700; letter-spacing: .18em; font-size: 18px; line-height: 1.1; }
.logo-txt small { display: block; font-size: 10px; letter-spacing: .4em; color: var(--muted); font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: var(--touch); padding: 0 12px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; text-decoration: none; }
.nav a i { width: 18px; text-align: center; color: var(--muted); }
.nav a:hover { background: var(--line-2); }
.nav a.on { background: var(--brand-50); color: var(--brand-700); }
.nav a.on i { color: var(--brand-600); }
.nav-sep { height: 1px; background: var(--line); margin: 12px 6px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 12px; }
.user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 4px 0 6px; border-top: 1px solid var(--line); }
.user-txt { font-size: 13px; line-height: 1.3; min-width: 0; flex: 1; }
.user-txt b { display: block; overflow: hidden; text-overflow: ellipsis; }
.user-txt span { color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }
.avatar-xl { width: 96px; height: 96px; font-size: 30px; border-radius: 20px; }

.main { min-width: 0; padding: 24px 32px 120px; }
.topbar { display: none; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }

/* ============ En-tête de page ============ */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.crumbs a { color: var(--muted); }
.crumbs i { font-size: 10px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .who { display: flex; gap: 14px; align-items: center; min-width: 0; }
h1 { font-size: 24px; font-weight: 700; }
.sub { color: var(--muted); margin-top: 4px; display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 14px; }
.sub i { margin-right: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ============ Boutons ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--touch); padding: 0 18px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; color: var(--ink-2); white-space: nowrap; text-decoration: none !important; line-height: 1.2; }
.btn:hover { background: var(--line-2); }
.btn:focus-visible { outline: 3px solid var(--brand-200); outline-offset: 1px; }
.btn-primary { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-800); }
.btn-soft { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-icon { width: var(--touch); padding: 0; flex: none; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #065f46; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

/* ============ Cartes ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-head h2 { font-size: 16px; display: flex; align-items: center; gap: 10px; }
.card-title { font-size: 12.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack > * + * { margin-top: 20px; }

/* ============ Badges ============ */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.b-brand { background: var(--brand-50); color: var(--brand-700); }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-gray { background: var(--line-2); color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--line-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-bad { color: var(--bad); } .text-ok { color: var(--ok); } .text-warn { color: var(--warn); }

/* ============ Alertes et messages ============ */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); border: 1px solid; font-size: 14px; }
.alert > i { margin-top: 3px; }
.alert + .alert { margin-top: 10px; }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-line); color: #064e3b; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: #78350f; }
.alert-bad { background: var(--bad-bg); border-color: var(--bad-line); color: #7f1d1d; }
.alert-info { background: var(--brand-50); border-color: var(--brand-100); color: #164e63; }
.flashes { margin-bottom: 20px; }
.flash-txt { flex: 1; }
.flash-close { border: 0; background: transparent; cursor: pointer; color: inherit; opacity: .6; width: 28px; height: 28px; border-radius: 6px; margin: -4px -6px -4px 0; }
.flash-close:hover { opacity: 1; background: rgba(0,0,0,.05); }
.mb { margin-bottom: 20px; }

/* ============ Chiffres clés et carte en cours ============ */
.summary { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.kpi .k { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 2px; line-height: 1.2; }
.kpi .v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.carte-card { border-color: var(--brand-100); background: linear-gradient(180deg, var(--brand-50), #fff 70%); }
.carte-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.carte-name { font-weight: 600; color: var(--brand-700); }
.progress { height: 10px; border-radius: 999px; background: var(--brand-100); overflow: hidden; margin: 12px 0 8px; }
.progress span { display: block; height: 100%; background: var(--brand-500); border-radius: 999px; }
.carte-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }

/* ============ Onglets ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 8px; min-height: var(--touch); padding: 0 16px; border: 0; background: none; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab .n { background: var(--line-2); color: var(--ink-2); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.tab.on { color: var(--brand-700); border-bottom-color: var(--brand-600); }
.tab.on .n { background: var(--brand-100); color: var(--brand-700); }
.tab-panel { display: none; }
.tab-panel.on { display: block; }

/* ============ Listes (séances, éléments) ============ */
.row-item { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.row-item:last-child { border-bottom: 0; }
.row-item.accent { box-shadow: inset 4px 0 0 var(--warn-line); background: #fffdf5; }
.r-date { font-weight: 700; }
.r-date small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; }
.r-main { min-width: 0; }
.r-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.r-strong { font-weight: 700; font-size: 16px; }
.r-zones { margin-top: 8px; }
.r-meta { color: var(--muted); font-size: 13px; margin-top: 8px; display: flex; gap: 4px 14px; flex-wrap: wrap; }
.r-meta i { margin-right: 5px; }
.r-note { margin-top: 8px; font-size: 13px; color: #92400e; background: var(--warn-bg); border-radius: var(--r-sm); padding: 6px 10px; display: inline-block; }
.r-right { display: flex; align-items: center; gap: 16px; }
.r-solde { text-align: right; min-width: 92px; }
.r-solde b { display: block; font-size: 16px; }
.r-solde span { font-size: 12px; color: var(--muted); }
.r-actions { display: flex; gap: 2px; }
.r-actions form { margin: 0; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty i { font-size: 28px; color: var(--brand-400); display: block; margin-bottom: 10px; }

/* ============ Tableaux ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--brand-50); }
.table .num { text-align: right; }
.table .act { text-align: right; white-space: nowrap; }

/* ============ Détails repliables ============ */
details.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; font-weight: 600; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .fa-chevron-down { transition: transform .15s; color: var(--muted); }
details.fold[open] > summary .fa-chevron-down { transform: rotate(180deg); }
details.fold[open] > summary { border-bottom: 1px solid var(--line-2); }

/* ============ Fiche (clé / valeur) ============ */
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.kv .k { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kv .v { margin-top: 2px; white-space: pre-line; word-break: break-word; }
.kv.full { grid-column: 1 / -1; }

/* ============ Formulaires ============ */
.section { margin-bottom: 20px; }
.section > h2, .section-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 0 0 16px; font-weight: 700; }
.num-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); display: grid; place-items: center; font-size: 13px; flex: none; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.req { color: var(--bad); }
.input, .field input[type=text], .field input[type=email], .field input[type=tel], .field input[type=number], .field input[type=date],
.field input[type=password], .field input[type=search], .field select, .field textarea {
  width: 100%; min-height: var(--touch); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 12px; background: #fff; }
.field textarea, textarea.input { padding: 10px 12px; min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid var(--brand-100); border-color: var(--brand-600); }
.field input:disabled, .field select:disabled { background: var(--line-2); color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.input-suffix { position: relative; }
.input-suffix > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > .input, .input-icon > input { padding-left: 40px; }

/* Choix segmentés */
.segmented { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 6px; background: var(--line-2); padding: 5px; border-radius: var(--r); }
.segmented button, .segmented label { min-height: var(--touch); border: 0; border-radius: var(--r-sm); background: transparent; font-weight: 600; color: var(--muted); cursor: pointer; display: flex; gap: 8px; align-items: center; justify-content: center; }
.segmented button.on, .segmented input:checked + label { background: #fff; color: var(--brand-700); box-shadow: var(--shadow); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }

/* Interrupteurs (nouveau .switch et anciens .toggle / .toggle-input / .toggle-ui) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--touch); padding: 6px 0; }
.switch-row + .switch-row { border-top: 1px solid var(--line-2); }
.switch-row .t { font-weight: 600; }
.switch-row .d { font-size: 13px; color: var(--muted); }
.switch, .toggle { position: relative; width: 52px; height: 30px; flex: none; display: inline-block; }
.switch input, .toggle .toggle-input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span, .toggle .toggle-ui { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: .2s; cursor: pointer; font-size: 0; }
.switch span::after, .toggle .toggle-ui::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.toggle .toggle-knob { display: none; }
.switch input:checked + span, .toggle .toggle-input:checked + .toggle-ui { background: var(--brand-600); }
.switch input:checked + span::after, .toggle .toggle-input:checked + .toggle-ui::after { transform: translateX(22px); }
.switch input:focus-visible + span, .toggle .toggle-input:focus-visible + .toggle-ui { outline: 3px solid var(--brand-200); }

/* Cases et boutons radio en ligne */
.check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--touch); cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--brand-700); margin: 0; flex: none; }
.checks { display: flex; gap: 4px 20px; flex-wrap: wrap; }

/* Tuiles (choix de carte) */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.tile { position: relative; border: 1.5px solid var(--line); border-radius: var(--r); padding: 12px 8px; text-align: center; cursor: pointer; background: #fff; min-height: 72px; display: flex; flex-direction: column; justify-content: center; }
.tile b { display: block; font-size: 17px; }
.tile span { font-size: 12px; color: var(--muted); }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile.on, .tile:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-100); }
.tile.on b, .tile:has(input:checked) b { color: var(--brand-700); }

/* Choix (bandeau de dépassement) */
.choice { display: flex; gap: 12px; align-items: center; min-height: var(--touch); padding: 10px 14px; border: 1.5px solid var(--bad-line); background: #fff; border-radius: var(--r-sm); margin-top: 8px; cursor: pointer; font-weight: 600; color: var(--ink) !important; }
.choice input { width: 20px; height: 20px; accent-color: var(--brand-700); flex: none; margin: 0; }

/* Pastilles de sélection */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill.on, .pill:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); color: var(--brand-700); }

/* Fichiers */
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: #fff; }
.drop:hover { border-color: var(--brand-400); background: var(--brand-50); }
.drop i { font-size: 22px; color: var(--brand-600); }
.drop input[type=file] { display: none; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.photo-chip, .photo-tile { position: relative; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); background: var(--line-2); aspect-ratio: 1 / 1; }
.photo-chip img, .photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo-chip button, .photo-tile .del { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(15,23,42,.7); color: #fff; cursor: pointer; display: grid; place-items: center; }
.photo-tile.to-delete { opacity: .35; outline: 3px solid var(--bad); }

/* Zones (lignes dynamiques des formulaires de séance) */
.zone-row { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)) var(--touch); gap: 10px; align-items: end; padding: 14px 0; border-top: 1px solid var(--line-2); }
.zone-row.apl { grid-template-columns: minmax(0, 1.5fr) repeat(5, minmax(0, 1fr)) var(--touch); }
.zone-row:first-child { border-top: 0; padding-top: 0; }

/* Barre d'enregistrement fixe */
.savebar { position: fixed; left: var(--sidebar); right: 0; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 12px 32px; display: flex; justify-content: flex-end; gap: 10px; z-index: 30; }
.savebar .left { margin-right: auto; display: flex; align-items: center; gap: 10px; }

/* Récapitulatif latéral */
.side-sticky { position: sticky; top: 24px; }
.recap-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.recap-row:last-child { border-bottom: 0; }
.recap-row span { color: var(--muted); }
.recap-row b { text-align: right; }
.recap-big { font-size: 30px; font-weight: 700; color: var(--brand-700); line-height: 1.1; }

/* Choices.js (liste de zones avec recherche) */
.choices { margin-bottom: 0; }
.choices__inner { min-height: var(--touch); border: 1px solid var(--line-strong); border-radius: var(--r-sm) !important; background: #fff; padding: 6px 8px 2px; font-size: 15px; }
.is-focused .choices__inner, .is-open .choices__inner { border-color: var(--brand-600); }
.choices__list--dropdown, .choices__list[aria-expanded] { border-radius: var(--r-sm); border-color: var(--line-strong); box-shadow: var(--shadow-lg); z-index: 50; }
.choices__list--dropdown .choices__item--selectable.is-highlighted { background: var(--brand-50); }
.choices[data-type*=select-one]::after { border-color: var(--muted) transparent transparent; }

/* ============ Visionneuse ============ */
.lightbox { position: fixed; inset: 0; background: rgba(15,23,42,.92); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 60px 70px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); box-shadow: var(--shadow-lg); }
.lb-btn { position: absolute; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 18px; cursor: pointer; display: grid; place-items: center; }
.lb-btn:hover { background: rgba(255,255,255,.22); }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: #cbd5e1; font-size: 14px; }

/* ============ Page de connexion ============ */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg, var(--brand-50), var(--bg) 60%); }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.auth-logo img { width: 220px; border-radius: var(--r); }

/* ============ Tablette ============ */
@media (max-width: 1100px) {
  :root { --sidebar: 76px; }
  .sidebar { padding: 16px 10px; align-items: center; }
  .logo { padding: 4px 0 16px; }
  .logo-txt, .nav a .lbl, .nav-label, .user-txt { display: none; }
  .nav a { justify-content: center; padding: 0; width: 52px; }
  .nav-sep { width: 40px; }
  .user { flex-direction: column; border: 0; padding: 0; gap: 6px; }
  .main { padding: 20px 20px 110px; }
  .grid-side { grid-template-columns: 1fr; }
  .side-sticky { position: static; }
  .savebar { padding: 12px 20px; }
  .summary { grid-template-columns: 1fr 1fr; }
  .summary .carte-card { grid-column: 1 / -1; }
  .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .zone-row.apl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .zone-row.apl > :first-child { grid-column: 1 / -1; }
}

/* ============ Téléphone ============ */
@media (max-width: 700px) {
  :root { --sidebar: 0px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; align-items: stretch; padding: 20px 14px; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar .logo-txt, .sidebar .nav a .lbl, .sidebar .nav-label, .sidebar .user-txt { display: initial; }
  .sidebar .logo-txt small { display: block; }
  .sidebar .nav a { justify-content: flex-start; padding: 0 12px; width: auto; }
  .sidebar .user { flex-direction: row; border-top: 1px solid var(--line); padding-top: 12px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; margin: -16px -16px 16px; padding: 6px 8px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .topbar-brand { font-weight: 700; letter-spacing: .18em; color: var(--ink); text-decoration: none !important; }
  .main { padding: 16px 16px 110px; }
  h1 { font-size: 20px; }
  .grid-2, .grid-3, .fields, .fields-3, .kv-grid { grid-template-columns: 1fr; }
  .row-item { grid-template-columns: 1fr; gap: 10px; padding: 14px 16px; }
  .r-right { justify-content: space-between; }
  .r-solde { text-align: left; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .zone-row, .zone-row.apl { grid-template-columns: 1fr 1fr; }
  .zone-row > :first-child { grid-column: 1 / -1; }
  .savebar { left: 0; padding: 10px 16px; }
  .savebar .btn { flex: 1; }
  .savebar .left { display: none; }
  .summary { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi .v { font-size: 22px; }
  .card-pad { padding: 16px; }
  .lightbox { padding: 60px 8px; }
  .hide-phone { display: none !important; }
  /* Tableaux en cartes empilées */
  .table.stack-phone thead { display: none; }
  .table.stack-phone tr { display: block; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
  .table.stack-phone td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .table.stack-phone td::before { content: attr(data-label); color: var(--muted); font-weight: 600; font-size: 13px; text-align: left; }
  .table.stack-phone td.act { justify-content: flex-end; }
  .table.stack-phone td.act::before { content: none; }
}

/* Liste des clientes (accueil) : répétée des milliers de fois, donc styles ici et non dans le HTML */
.cl { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none !important; }
.cl-carte { color: var(--brand-600); margin-left: 4px; }
@media (max-width: 1300px) { .hide-tablet { display: none !important; } }
@media (max-width: 1100px) {
  .recent-aside { order: -1; }
  .recent-aside .card > a:nth-of-type(n+6) { display: none !important; }
}

/* Bouton « Surligner » (séance mise en avant) */
#accent_toggle[aria-pressed="true"] { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }

/* Suggestions d'adresse */
.autocomplete { position: relative; }
.autocomplete-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; z-index: 60; }
.autocomplete-item { padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.autocomplete-item:last-child { border-bottom: 0; }
.autocomplete-item:hover, .autocomplete-item[aria-selected="true"] { background: var(--brand-50); }

/* Document (texte du consentement) */
.doc { font-size: 15.5px; line-height: 1.65; color: var(--ink-2); }
.doc h1, .doc h2, .doc h3 { color: var(--ink); margin: 18px 0 8px; font-size: 18px; }
.doc h1:first-child, .doc h2:first-child, .doc h3:first-child, .doc p:first-child { margin-top: 0; }
.doc p { margin: 0 0 12px; }
.doc ul, .doc ol { padding-left: 22px; margin: 0 0 12px; }
.doc li { margin-bottom: 4px; }

/* Signature */
.sig-box { position: relative; height: 240px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: #fafbfc; }
.sig-box canvas { width: 100%; height: 100%; display: block; touch-action: none; position: relative; z-index: 1; }
.sig-line { position: absolute; left: 24px; right: 24px; bottom: 44px; border-top: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; padding-top: 6px; pointer-events: none; }

/* Éditeur de texte (consentement) */
.editor-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 5; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.tool-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.editor-surface { min-height: 420px; padding: 24px; outline: none; }
.editor-surface:focus { box-shadow: inset 0 0 0 3px var(--brand-100); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* Galerie photos */
.gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 0; }
.photo-tile { margin: 0; }
.photo-cap { position: absolute; left: 6px; bottom: 6px; background: rgba(15,23,42,.7); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; pointer-events: none; }

/* Raccourcis et catalogue de zones */
.code-tag { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-weight: 700; background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-100); padding: 2px 10px; border-radius: 6px; }
.chip-x { border: 0; background: transparent; cursor: pointer; color: var(--muted); width: 22px; height: 22px; border-radius: 50%; margin-right: -6px; }
.chip-x:hover { background: var(--line); color: var(--bad); }
.zone-cat { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.zone-item { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); min-width: 0; }
.zone-item form { margin: 0; }
.zone-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav[aria-pressed="true"] { color: #e11d48; }

/* Liens dans un sélecteur segmenté */
.seg-link { min-height: var(--touch); border-radius: var(--r-sm); font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: center; padding: 0 14px; text-decoration: none !important; }
.seg-link.on { background: #fff; color: var(--brand-700); box-shadow: var(--shadow); }

/* Barres horizontales (statistiques) : une série, une couleur, valeurs écrites */
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 120px; gap: 12px; align-items: center; min-height: 36px; border-radius: var(--r-sm); padding: 0 6px; }
.bar-row:hover { background: var(--line-2); }
.bar-label { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { height: 18px; }
.bar-fill { display: block; height: 100%; min-width: 4px; background: var(--brand-500); border-radius: 0 4px 4px 0; }
.bar-fill.bar-other { background: var(--line-strong); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
@media (max-width: 700px) { .bar-row { grid-template-columns: 64px minmax(0, 1fr) 92px; gap: 8px; } }

/* Historique d une seance */
.audit-val { word-break: break-word; font-size: 13.5px; }
.audit-pre { white-space: pre-wrap; word-break: break-word; margin: 8px 0 0; background: var(--line-2); border-radius: var(--r-sm); padding: 12px; font-size: 12.5px; max-height: 360px; overflow: auto; }

/* ---- Prix des cartes ---- */
.tile-carte .prix { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin: 2px 0 1px; }
.tile-carte.on .prix { color: var(--brand-700); }

/* ---- Fenêtre de confirmation ---- */
.confirm-dlg { border: none; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(15, 23, 42, .25); color: var(--ink); }
.confirm-dlg::backdrop { background: rgba(15, 23, 42, .45); }
.confirm-dlg .cd-body { padding: 24px 24px 8px; }
.confirm-dlg .cd-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-50); color: var(--brand-700); display: grid; place-items: center; font-size: 20px; margin-bottom: 14px; }
.confirm-dlg h3 { font-size: 18px; margin: 0 0 6px; }
.confirm-dlg .cd-msg { color: var(--muted); font-size: 14px; line-height: 1.5; }
.confirm-dlg .cd-big { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--brand-50); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.confirm-dlg .cd-big b { font-size: 22px; color: var(--brand-700); }
.confirm-dlg .cd-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 20px; }

/* ---- Filaments ---- */
.fil-stock { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.fil-stock .card + .card { margin-top: 0; }
.fil-nom { font-weight: 700; color: var(--brand-700); }
.fil-card .kpi { margin: 10px 0 4px; }
.fil-alerte { border-color: #fecaca; background: linear-gradient(180deg, #fef2f2, #fff 70%); }
.fil-alerte .kpi .v { color: var(--bad); }
.fil-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.fil-meta i { color: var(--muted); margin-right: 5px; }
.fil-seuil { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.fil-seuil .input { width: 90px; min-height: 36px; }
.fil-seuil label { margin-right: auto; }
.fil-form { display: grid; grid-template-columns: 160px 120px 140px minmax(0, 1fr) 160px; gap: 14px; }
.fil-tables .card + .card { margin-top: 0; }
.fil-tables tfoot td { border-top: 1px solid var(--line); background: #fafbfc; }
.fil-futur td { color: var(--muted); opacity: .6; }
@media (max-width: 1100px) { .fil-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } .fil-tables { grid-template-columns: 1fr; } }

/* ---- Avant / après ---- */
.aa-layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 20px; align-items: start; }
.aa-side { position: sticky; top: 20px; }
.aa-slots { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.aa-slot { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1.5px solid var(--line); border-radius: var(--r); background: #fff; cursor: pointer; text-align: left; min-width: 0; }
.aa-slot b { display: block; font-size: 15px; }
.aa-slot small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aa-slot.on { border-color: var(--brand-600); background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-100); }
.aa-slot-img { width: 52px; height: 52px; flex: none; border-radius: 10px; background: var(--line-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.aa-slot-img img { width: 100%; height: 100%; object-fit: cover; }
.aa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.aa-photo { position: relative; padding: 0; border: 2px solid transparent; border-radius: var(--r); overflow: hidden; aspect-ratio: 3 / 4; background: var(--line-2); cursor: pointer; }
.aa-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aa-photo:hover { border-color: var(--brand-200); }
.aa-photo.used { border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-100); }
.aa-tag { position: absolute; left: 6px; top: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; background: var(--brand-600); color: #fff; padding: 2px 8px; border-radius: 999px; }
.aa-tag:empty { display: none; }
.aa-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.aa-opts .segmented button { font-size: 13px; padding: 0 6px; }
.aa-preview { background: repeating-conic-gradient(#f1f5f9 0 25%, #fff 0 50%) 0 0 / 20px 20px; border-radius: var(--r); padding: 10px; display: grid; place-items: center; }
.aa-preview canvas { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto; border-radius: 6px; box-shadow: var(--shadow); touch-action: none; cursor: grab; }
.aa-zooms { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.aa-zooms label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.aa-zooms input { width: 100%; accent-color: var(--brand-600); }
.aa-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; }
.aa-export { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin: 16px 0 8px; }
.aa-export .btn-primary { flex: 1; }
@media (max-width: 1100px) {
  .aa-layout { grid-template-columns: 1fr; }
  .aa-side { position: static; order: -1; }
  .aa-preview canvas { max-height: 55vh; }
}
@media (max-width: 700px) { .aa-opts, .aa-zooms { grid-template-columns: 1fr; } }
.aa-day + .aa-day { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-2); }
