/* Kolisa — système de design
   Tokens : primitives → sémantiques → composants. Grille 4 px. Rayons 4/8/12/16/24. */

:root {
  /* Primitives */
  --navy-900: #0F2944; --navy-800: #16365A; --navy-700: #1E4672;
  --blue-600: #245CC8; --blue-500: #2F6BDB; --blue-100: #E6EEFC; --blue-50: #F2F6FE;
  --gray-0: #FFFFFF; --gray-25: #F6F7F9; --gray-50: #EEF0F3; --gray-100: #E3E6EB; --gray-300: #C3C9D2;
  --gray-500: #5B6576; --gray-700: #343C49; --gray-900: #0F1B2D;
  --green-700: #137A3F; --green-50: #E8F5EE; --amber-700: #8A5300; --amber-50: #FDF3E1;
  --red-700: #B42318; --red-50: #FDECEA;

  /* Sémantiques */
  --bg: var(--gray-25); --surface: var(--gray-0); --surface-2: var(--gray-50); --border: var(--gray-100); --border-strong: var(--gray-300);
  --text: var(--gray-900); --text-2: var(--gray-700); --muted: var(--gray-500);
  --primary: var(--blue-600); --primary-hover: var(--blue-500); --primary-soft: var(--blue-100); --primary-text: #fff;
  --brand: var(--navy-900); --nav-bg: var(--navy-900); --nav-text: #DCE4F0; --nav-active: #fff;
  --success: var(--green-700); --success-soft: var(--green-50);
  --warning: var(--amber-700); --warning-soft: var(--amber-50);
  --danger: var(--red-700); --danger-soft: var(--red-50);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue-500);

  /* Espacement (4 px) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  /* Rayons */
  --r1: 4px; --r2: 8px; --r3: 12px; --r4: 16px; --r5: 24px;
  /* Typographie */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px;
  /* Ombres : contact + ambiante */
  --sh1: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 1px rgba(15, 27, 45, .04);
  --sh2: 0 1px 2px rgba(15, 27, 45, .08), 0 8px 24px rgba(15, 27, 45, .08);
  --sh3: 0 2px 4px rgba(15, 27, 45, .1), 0 24px 48px rgba(15, 27, 45, .18);
  /* Mouvement */
  --ease-out: cubic-bezier(.2, .8, .2, 1); --t-fast: 120ms; --t-in: 220ms; --t-out: 150ms;
  --touch: 44px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417; --surface: #1A1E23; --surface-2: #22272E; --border: #2C333C; --border-strong: #3B444F;
    --text: #E8EAED; --text-2: #C5CAD2; --muted: #9AA3AF;
    --primary: #6C9BFF; --primary-hover: #86AEFF; --primary-soft: #1E2D4A; --primary-text: #0B1220;
    --nav-bg: #0D1520; --nav-text: #B9C3D1;
    --success: #4CC38A; --success-soft: #153223; --warning: #F0B95B; --warning-soft: #3A2C12; --danger: #FF8A80; --danger-soft: #3D1B19;
    --sh1: 0 1px 2px rgba(0,0,0,.4); --sh2: 0 8px 24px rgba(0,0,0,.4); --sh3: 0 24px 48px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 var(--fs-md)/1.5 var(--font); color: var(--text); background: var(--bg); min-height: 100dvh; }
body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: var(--fs-xl); } h2 { font-size: var(--fs-lg); } h3 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: var(--primary); text-underline-offset: 2px; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r1); }
[hidden] { display: none !important; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: var(--fs-sm); } .xs { font-size: var(--fs-xs); }
.strong { font-weight: 650; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--s2); top: -60px; z-index: 100; background: var(--surface); padding: var(--s2) var(--s3); border-radius: var(--r2); }
.skip-link:focus { top: var(--s2); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Démarrage */
.boot { min-height: 100dvh; display: grid; place-items: center; align-content: center; gap: var(--s4); }
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Bannières */
.banner { padding: var(--s2) var(--s4); font-size: var(--fs-sm); text-align: center; }
.banner-warn { background: var(--warning-soft); color: var(--warning); border-bottom: 1px solid var(--border); }
.banner-danger { background: var(--danger-soft); color: var(--danger); }
.banner-info { background: var(--primary-soft); color: var(--text); }
.banner a { color: inherit; font-weight: 650; }

/* ---------------- Coquille ---------------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.sidebar { background: var(--nav-bg); color: var(--nav-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; }
.sidebar .brand { padding: var(--s5) var(--s5) var(--s4); }
.sidebar .brand img { height: 28px; width: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3); overflow-y: auto; flex: 1; }
.nav-group { margin-top: var(--s4); padding: 0 var(--s3) var(--s1); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; opacity: .6; }
.nav a { display: flex; align-items: center; gap: var(--s3); min-height: 40px; padding: 0 var(--s3); border-radius: var(--r2); color: var(--nav-text); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; transition: background var(--t-fast); }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: var(--nav-active); }
.nav a[aria-current="page"]::before { content: ""; width: 3px; height: 18px; background: #5B8DEF; border-radius: 2px; margin-left: -9px; margin-right: 6px; }
.nav .ico { width: 20px; height: 20px; flex: none; }
.sidebar-foot { padding: var(--s3); border-top: 1px solid rgba(255,255,255,.08); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s6); min-height: 60px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .spacer { flex: 1; }
.org-switch { display: flex; align-items: center; gap: var(--s2); min-height: var(--touch); padding: 0 var(--s3); border: 1px solid var(--border); border-radius: var(--r2); background: var(--surface); cursor: pointer; max-width: 280px; }
.org-switch .dot { width: 22px; height: 22px; border-radius: var(--r1); background: var(--org-color, var(--brand)); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; overflow: hidden; }
.org-switch .dot img { width: 100%; height: 100%; object-fit: cover; }
.org-switch .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: var(--fs-sm); }
.icon-btn { position: relative; width: var(--touch); height: var(--touch); display: grid; place-items: center; border: 0; background: transparent; border-radius: var(--r2); cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .badge-dot { position: absolute; top: 8px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
main { padding: var(--s6); max-width: 1240px; width: 100%; margin: 0 auto; flex: 1; }
.mobile-brand { display: none; }
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: var(--s2) var(--s4); padding-top: max(var(--s2), env(safe-area-inset-top)); }
  .mobile-brand { display: block; height: 22px; }
  .org-switch { max-width: 46vw; }
  main { padding: var(--s4); padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; font-size: 11px; color: var(--muted); text-decoration: none; font-weight: 500; }
  .bottom-nav a[aria-current="page"] { color: var(--primary); }
  .bottom-nav .ico { width: 22px; height: 22px; }
}

/* ---------------- En-tête de page ---------------- */
.page-head { display: flex; align-items: flex-start; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--s1); }
.page-head .actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: var(--s1); color: var(--muted); text-decoration: none; font-size: var(--fs-sm); min-height: 32px; margin-bottom: var(--s1); }
.back:hover { color: var(--text); }

/* ---------------- Boutons ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--touch); padding: 0 var(--s4);
  border-radius: var(--r2); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: var(--fs-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast); }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 0 var(--s3); }
.btn-block { width: 100%; }
.btn[aria-busy="true"] { pointer-events: none; opacity: .85; }
.btn[aria-busy="true"]::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 18px; height: 18px; }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 0; font-weight: 600; min-height: 32px; }

/* ---------------- Cartes et grilles ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3); box-shadow: var(--sh1); }
.card-pad { padding: var(--s5); }
.card-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { flex: 1; font-size: var(--fs-md); }
.card-body { padding: var(--s4) var(--s5); }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--s4); align-items: start; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid-3, .split { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .grid-2, .grid-4 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }

/* Indicateurs */
.stat { padding: var(--s4) var(--s5); }
.stat .label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: var(--fs-xl); font-weight: 700; margin-top: var(--s1); font-variant-numeric: tabular-nums; }
.stat .hint { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s1); }

/* Listes d'action du tableau de bord */
.action-list { list-style: none; margin: 0; padding: 0; }
.action-list li + li { border-top: 1px solid var(--border); }
.action-list a, .action-list .item { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5); min-height: 52px; color: var(--text); text-decoration: none; }
.action-list a:hover { background: var(--surface-2); }
.action-list .grow { flex: 1; min-width: 0; }
.action-list .t { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-list .s { font-size: var(--fs-xs); color: var(--muted); }

/* Pastilles de statut : couleur + libellé, jamais la couleur seule */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--success-soft); color: var(--success); }
.pill-warn { background: var(--warning-soft); color: var(--warning); }
.pill-bad { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--primary-soft); color: var(--primary); }

/* ---------------- Tableaux ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; }
table.data td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr[data-href] { cursor: pointer; }
table.data tbody tr[data-href]:hover { background: var(--surface-2); }
table.data th.num { text-align: right; }
table.data .main-cell { font-weight: 600; }
@media (max-width: 700px) {
  table.data.responsive thead { display: none; }
  table.data.responsive tr { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
  table.data.responsive td { border: 0; padding: 0; }
  table.data.responsive td.hide-sm { display: none; }
  table.data.responsive td.num { grid-column: 2; grid-row: 1; }
}

/* ---------------- Filtres ---------------- */
.toolbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s4); }
.chips { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { min-height: 36px; padding: 0 var(--s3); border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.search input { padding-left: 38px; }
.search .ico { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }

/* ---------------- Formulaires ---------------- */
.form { display: grid; gap: var(--s4); }
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field .req { color: var(--danger); }
.field .help { font-size: var(--fs-xs); color: var(--muted); }
.input, input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%; min-height: var(--touch); padding: 0 var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r2); background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast); }
textarea { padding: var(--s3); min-height: 88px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); border-radius: var(--r2); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field .error { display: none; font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.field .error::before { content: "⚠ "; }
.field.has-error .error { display: block; }
.check { display: flex; align-items: center; gap: var(--s2); min-height: var(--touch); cursor: pointer; font-size: var(--fs-sm); }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.form-actions { display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: wrap; padding-top: var(--s2); }
.form-error { padding: var(--s3); border-radius: var(--r2); background: var(--danger-soft); color: var(--danger); font-size: var(--fs-sm); font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 650; margin-bottom: var(--s3); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 88px; }
.pw-wrap button { position: absolute; right: 4px; top: 4px; bottom: 4px; }
.meter { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; background: var(--danger); transition: width var(--t-in), background var(--t-in); }

/* Lignes de document */
.lines { display: grid; gap: var(--s2); }
.line { display: grid; grid-template-columns: minmax(0, 3fr) 90px 130px 80px 80px 120px 44px; gap: var(--s2); align-items: center; }
.line-head { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; }
.line .total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: var(--fs-sm); }
@media (max-width: 800px) {
  .line-head { display: none; }
  .line { grid-template-columns: 1fr 1fr; padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r2); }
  .line .desc { grid-column: 1 / -1; }
  .line .total { grid-column: 1; text-align: left; }
}
.totals { display: grid; gap: var(--s1); justify-content: end; font-variant-numeric: tabular-nums; }
.totals .r { display: grid; grid-template-columns: 160px 140px; text-align: right; font-size: var(--fs-sm); }
.totals .r.big { font-size: var(--fs-lg); font-weight: 700; padding-top: var(--s2); border-top: 1px solid var(--border); }

/* ---------------- États vides ---------------- */
.empty { text-align: center; padding: var(--s10) var(--s5); display: grid; justify-items: center; gap: var(--s3); }
.empty .ill { width: 56px; height: 56px; border-radius: var(--r4); background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.empty .ill .ico { width: 28px; height: 28px; }
.empty p { color: var(--muted); max-width: 420px; font-size: var(--fs-sm); }
.error-state .ill { background: var(--danger-soft); color: var(--danger); }

/* Squelettes */
.sk { background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--r1); }
.sk-line { height: 14px; margin: var(--s3) 0; }
.sk-block { height: 96px; border-radius: var(--r3); }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------------- Fenêtres ---------------- */
dialog { border: 0; padding: 0; border-radius: var(--r4); background: var(--surface); color: var(--text); box-shadow: var(--sh3); width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
dialog.wide { width: min(880px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 20, 35, .45); }
dialog[open] { animation: dlg-in var(--t-in) var(--ease-out); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h2 { flex: 1; font-size: var(--fs-lg); }
.dlg-body { padding: var(--s5); }
.dlg-foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s4) var(--s5); border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
@media (max-width: 600px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r4) var(--r4) 0 0; max-height: 92dvh; }
  dialog[open] { animation: sheet-in var(--t-in) var(--ease-out); }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
}

/* Menu déroulant */
.menu { position: absolute; z-index: 50; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3); box-shadow: var(--sh2); padding: var(--s1); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s3); border: 0; background: none; border-radius: var(--r2); text-align: left; cursor: pointer; text-decoration: none; color: var(--text); font-size: var(--fs-sm); }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: var(--s1) 0; }
.menu .danger { color: var(--danger); }

/* ---------------- Toasts ---------------- */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); z-index: 200; display: grid; gap: var(--s2); width: min(380px, calc(100vw - 32px)); }
@media (max-width: 900px) { .toasts { top: calc(var(--s3) + env(safe-area-inset-top)); bottom: auto; left: 50%; right: auto; translate: -50% 0; } }
.toast { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r3); background: var(--gray-900); color: #fff; box-shadow: var(--sh3); font-size: var(--fs-sm); animation: toast-in var(--t-in) var(--ease-out); }
@media (prefers-color-scheme: dark) { .toast { background: #2A313A; } }
.toast.leaving { animation: toast-out var(--t-out) ease-in forwards; }
.toast .msg { flex: 1; padding-top: 2px; }
.toast .ico { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.toast-ok .ico { color: #6FDCA0; } .toast-bad .ico { color: #FF9C94; } .toast-warn .ico { color: #F5C26B; }
.toast button { background: none; border: 0; color: #9FC0FF; font-weight: 700; cursor: pointer; min-height: 28px; padding: 0 var(--s1); }
.toast .x { color: #BBB; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------------- Authentification ---------------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { background: var(--navy-900); color: #DCE4F0; padding: var(--s12); display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside img { height: 36px; width: auto; align-self: flex-start; }
.auth-aside h2 { color: #fff; font-size: var(--fs-2xl); max-width: 440px; margin-bottom: var(--s5); }
.auth-aside ol { padding-left: 20px; display: grid; gap: var(--s2); max-width: 440px; }
.auth-aside .tag { color: #9FB9E8; font-weight: 600; letter-spacing: .02em; }
.auth-main { display: grid; place-items: center; padding: var(--s8) var(--s5); }
.auth-card { width: min(420px, 100%); }
.auth-card h1 { margin-bottom: var(--s1); }
.auth-card .lead { color: var(--muted); margin-bottom: var(--s6); }
.auth-mobile-logo { display: none; height: 30px; margin-bottom: var(--s6); }
.steps { display: flex; gap: var(--s2); margin-bottom: var(--s5); }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.steps span.on { background: var(--primary); }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-aside { display: none; } .auth-mobile-logo { display: block; } }

/* Page publique du devis */
.public { max-width: 820px; margin: 0 auto; padding: var(--s6) var(--s4) var(--s12); }
.public-head { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s5); }
.public-head .org-logo { width: 56px; height: 56px; border-radius: var(--r3); background: var(--org-color, var(--brand)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: var(--fs-lg); }
.public .decision { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: var(--s4); margin: var(--s5) calc(var(--s4) * -1) 0; }
.powered { text-align: center; margin-top: var(--s8); font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; justify-content: center; gap: var(--s2); }
.powered img { height: 14px; }

/* Graphique barres (rapports) */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--s3); align-items: end; height: 200px; padding-top: var(--s4); border-bottom: 1px solid var(--border-strong); }
.bars .grp { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.bars .b { width: 14px; border-radius: 3px 3px 0 0; background: var(--primary); min-height: 1px; }
.bars .b.c2 { background: var(--success); } .bars .b.c3 { background: var(--warning); }
.bars-x { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--s3); font-size: var(--fs-xs); color: var(--muted); text-align: center; padding-top: var(--s1); }
.legend { display: flex; gap: var(--s4); font-size: var(--fs-xs); color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; background: var(--primary); vertical-align: -1px; }
.legend .l2::before { background: var(--success); } .legend .l3::before { background: var(--warning); }

/* Usage / quotas */
.usage-row { display: grid; gap: 6px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar.warn > span { background: var(--warning); } .bar.full > span { background: var(--danger); }

/* Offres */
.plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 1000px) { .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .plans { grid-template-columns: 1fr; } }
.plan { padding: var(--s5); border: 1px solid var(--border); border-radius: var(--r3); background: var(--surface); display: grid; gap: var(--s3); align-content: start; }
.plan.current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.plan.featured { box-shadow: var(--sh2); }
.plan .price { font-size: var(--fs-2xl); font-weight: 700; }
.plan ul { margin: 0; padding-left: 18px; font-size: var(--fs-sm); color: var(--text-2); display: grid; gap: 4px; }

/* Tableau Kanban léger (pipeline) */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: var(--s3); overflow-x: auto; padding-bottom: var(--s2); }
.kcol { background: var(--surface-2); border-radius: var(--r3); padding: var(--s2); display: grid; gap: var(--s2); align-content: start; min-height: 160px; }
.kcol h3 { font-size: var(--fs-sm); padding: var(--s2); display: flex; justify-content: space-between; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); padding: var(--s3); display: grid; gap: var(--s1); box-shadow: var(--sh1); }
.kcard .t { font-weight: 600; font-size: var(--fs-sm); }
.kcard select { min-height: 36px; font-size: var(--fs-sm); }

/* Tâches d'activation */
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.checklist li { display: flex; align-items: center; gap: var(--s3); }
.checklist .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.checklist li.done .tick { background: var(--success); border-color: var(--success); color: #fff; }
.checklist li.done a { color: var(--muted); text-decoration: line-through; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: var(--s2) var(--s4); font-size: var(--fs-sm); }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); font-size: var(--fs-sm); }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: var(--s3); }
.timeline li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 7px; }
.code-box { display: flex; gap: var(--s2); align-items: center; padding: var(--s2); border: 1px dashed var(--border-strong); border-radius: var(--r2); background: var(--surface-2); }
.code-box input { border: 0; background: transparent; min-height: 36px; font-size: var(--fs-sm); }
.ico { display: inline-block; vertical-align: middle; width: 20px; height: 20px; flex: none; }
.divider { border: 0; border-top: 1px solid var(--border); margin: var(--s2) 0; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* Utilitaires (grille 4 px) */
.mt-1 { margin-top: var(--s1); } .mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); }
.mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); } .mb-5 { margin-bottom: var(--s5); }
.grow1 { flex: 1; min-width: 0; } .w-140 { width: 140px; flex: none; } .w-160 { width: 160px; }
.narrow { max-width: 560px; margin: var(--s8) auto; }
.rot { transform: rotate(-90deg); width: 16px; height: 16px; color: var(--muted); }
@media (max-width: 520px) { .hide-xs { display: none; } }
.rot-r { transform: rotate(180deg); width: 16px; height: 16px; color: var(--muted); }
.logo-prev img { max-height: 80px; width: auto; border-radius: var(--r2); background: var(--surface-2); padding: var(--s2); }
input[type=color] { padding: 4px; height: var(--touch); }
.hint-inline { font-size: var(--fs-xs); color: var(--muted); }
a.chip { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
a.chip[aria-pressed="true"] { color: var(--surface); }
.sidebar-foot .btn { color: var(--nav-text); justify-content: flex-start; }
.sidebar-foot .btn:hover { background: rgba(255,255,255,.07); }
.action-list .t, .action-list .s { display: block; }
@media (max-width: 600px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat .value { font-size: var(--fs-lg); } }
a.link-card { color: var(--text); text-decoration: none; transition: box-shadow var(--t-fast), transform var(--t-fast); }
a.link-card:hover { box-shadow: var(--sh2); }
.note { padding: var(--s3); border-radius: var(--r2); background: var(--surface-2); }
.bars-thin { height: 120px; gap: 2px; } .bars-thin .b { width: 100%; max-width: 14px; }
/* Choix d'offre (inscription) */
.plan-pick { display: grid; gap: var(--s2); }
.plan-opt { display: grid; grid-template-columns: 24px 1fr auto; gap: var(--s3); align-items: start; padding: var(--s3) var(--s4); border: 1px solid var(--border-strong); border-radius: var(--r3); cursor: pointer; background: var(--surface); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.plan-opt:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--blue-50); }
@media (prefers-color-scheme: dark) { .plan-opt:has(input:checked) { background: var(--primary-soft); } }
.plan-opt input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); }
.plan-opt .pn { font-weight: 650; display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.plan-opt .pd { font-size: var(--fs-xs); color: var(--muted); }
.plan-opt .pp { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan-opt .pp small { display: block; font-weight: 500; color: var(--muted); font-size: var(--fs-xs); }
.seg { display: inline-grid; grid-auto-flow: column; border: 1px solid var(--border-strong); border-radius: var(--r2); overflow: hidden; }
.seg label { min-height: 40px; padding: 0 var(--s4); display: grid; place-items: center; cursor: pointer; font-size: var(--fs-sm); font-weight: 600; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--text); color: var(--surface); }
.seg label:has(input:focus-visible) { box-shadow: inset var(--focus); }
.console-tag { margin-top: var(--s2); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: #9FB9E8; font-weight: 600; }
.console-mode .topbar strong { font-size: var(--fs-sm); }
