/* =====================================================================
   Z-Planning — design system
   Contrastes WCAG AA, différenciation nette travail / absences / trajets.
   ===================================================================== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #1a2230;
  --muted: #586274;
  --border: #e1e5eb;
  --border-strong: #c9d0da;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-weak: #e8efff;
  --focus: #2563eb;

  --work-bg: #dbe7ff;
  --work-text: #173a8a;
  --travel: #c2410c;
  --weekend: #eef0f4;
  --holiday: #e4e6ec;

  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #a15c07;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --cell-w: 30px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.45rem; font-weight: 700; }
code, .mono { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.warn-text { color: var(--warn); }
.icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.boot { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }
.boot-error { color: var(--danger); }

/* ------------------------------------------------------------- Layout */
.debug-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 6px 20px;
  background: #fff7d6; border-bottom: 1px solid #f0d77a; font-size: 12.5px; color: #5c4400;
}
.debug-bar select { max-width: 340px; padding: 3px 6px; font-size: 12.5px; }
.debug-switch { display: inline-flex; align-items: center; gap: 6px; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px;
  padding: 0 20px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff; font-weight: 800;
}
.brand-lg { font-size: 1.5rem; }
.brand-lg .brand-mark { width: 40px; height: 40px; font-size: 1.2rem; }
.main-nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
.main-nav a {
  padding: 8px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; white-space: nowrap;
}
.main-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.main-nav a.active { background: var(--primary-weak); color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }

.main { padding: 22px 24px 60px; max-width: 1680px; margin: 0 auto; outline: none; }

.save-indicator { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .3s; }
.save-indicator.is-saving, .save-indicator.is-saved, .save-indicator.is-error { opacity: 1; }
.save-indicator.is-saved { color: var(--ok); }
.save-indicator.is-error { color: var(--danger); font-weight: 600; }

/* ----------------------------------------------------------- En-têtes */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-title p { margin: 4px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; margin-bottom: 4px; color: var(--muted); }

.period-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.period-label { min-width: 132px; text-align: center; font-weight: 600; }

/* ------------------------------------------------------------ Boutons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-small { padding: 4px 9px; font-size: 12.5px; }
.btn-icon {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented button { border: 0; background: transparent; padding: 7px 13px; font: inherit; font-weight: 500; cursor: pointer; color: var(--muted); }
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button.active { background: var(--primary); color: #fff; }

/* -------------------------------------------------------------- Cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-title { font-size: 1.05rem; font-weight: 650; margin-bottom: 12px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.cards-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.cards-2 > .card { margin-bottom: 0; }
.cards-2 + * { margin-top: 16px; }
.error-card { border-color: var(--danger); }
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius); background: var(--primary-weak); color: #1e3a8a; }
.banner > span { flex: 1; }
.banner-locked { background: #eef0f4; color: var(--text); border: 1px solid var(--border-strong); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge + .badge { margin-left: 4px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-under { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-over { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-itin { background: #ffedd5; color: #9a3412; border-color: transparent; }
.badge-debug { background: #fff4c2; color: #6b4e00; border-color: #f0d77a; }
.mini-badge { display: inline-block; margin-left: 6px; font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot-ok { background: var(--ok); } .dot-under { background: #d97706; } .dot-over { background: var(--danger); }

/* -------------------------------------------------------------- Jauges */
.gauge { display: grid; gap: 8px; }
.gauge-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; }
.gauge-label { color: var(--muted); }
.gauge-value { font-size: 1.15rem; }
.gauge-track { position: relative; height: 10px; border-radius: 999px; background: #e9edf3; overflow: visible; }
.gauge-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.gauge-target { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); border-radius: 2px; }
.gauge.is-ok .gauge-fill { background: #22a355; }
.gauge.is-under .gauge-fill { background: #e8a00f; }
.gauge.is-over .gauge-fill { background: #dc2626; }
.gauge-compact { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.gauge-compact .gauge-track { flex: 1; height: 7px; }
.gauge-pct { font-size: 12px; font-weight: 600; min-width: 44px; text-align: right; }
.gauge-compact.is-ok .gauge-pct { color: var(--ok); }
.gauge-compact.is-under .gauge-pct { color: var(--warn); }
.gauge-compact.is-over .gauge-pct { color: var(--danger); }

/* ---------------------------------------------------------- Dashboard */
.dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; align-items: start; }
.dashboard > .card { margin: 0; }
.service-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.service-card-head .card-title { display: inline; margin-right: 8px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
.service-card-head .quick-actions { margin-top: 0; }
.agent-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; }
.agent-list li { display: grid; grid-template-columns: 1fr 200px; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); }
.agent-list li:hover { background: var(--surface-2); }
.admin-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.tile { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 600; color: var(--text); }
.tile:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.kpi { display: grid; gap: 4px; }
.kpi-label { color: var(--muted); }
.kpi-value { font-size: 1.6rem; }

/* ----------------------------------------------- Grille mensuelle (équipe) */
.grid-wrap {
  overflow: auto; max-height: calc(100vh - 230px); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); outline: none;
}
.grid { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.grid th, .grid td { padding: 0; border-bottom: 1px solid var(--border); text-align: center; }
.grid thead th { position: sticky; background: var(--surface); z-index: 3; font-weight: 600; }
.grid thead tr:first-child th { top: 0; height: 36px; }
.grid thead tr:nth-child(2) th { top: 36px; height: 20px; font-size: 10.5px; color: var(--muted); font-weight: 500; }
.grid .day { border-left: 1px solid var(--border); min-width: calc(var(--cell-w) * 2); line-height: 1.1; }
.grid .dow { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; }
.grid .dnum { font-size: 12.5px; }
.grid th.we, .grid td.we { background: var(--weekend); }
.grid th.hol, .grid td.hol {
  background: repeating-linear-gradient(135deg, var(--holiday) 0 4px, #f3f4f7 4px 8px);
}
.grid th.today { color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); }
.grid td.today { box-shadow: inset 0 0 0 9999px rgba(37, 99, 235, .05); }
.grid .half { border-left: 1px solid var(--border); }
.grid .half.pm, .grid td.pm { border-left: 1px dotted var(--border); }
.grid td:not(.pm):not(.total-col):not(:first-child) { border-left: 1px solid var(--border); }
.sticky-col {
  position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left !important;
  min-width: 190px; max-width: 220px; padding: 0 10px !important; border-right: 1px solid var(--border-strong);
}
.grid thead .sticky-col { z-index: 5; }
.grid th.agent { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 34px; }
.grid th.agent a { color: var(--text); }
.total-col { position: sticky; right: 0; z-index: 2; background: var(--surface-2) !important; min-width: 74px; padding: 0 8px !important; font-weight: 600; border-left: 1px solid var(--border-strong) !important; white-space: nowrap; }
.grid thead .total-col { z-index: 5; }

.cell {
  position: relative; display: block; width: var(--cell-w); height: 32px; padding: 0; border: 0; margin: 0;
  background: transparent; font: inherit; font-size: 11.5px; font-weight: 600; color: var(--text); cursor: pointer;
}
.cell:hover { box-shadow: inset 0 0 0 2px var(--primary); }
.cell:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; z-index: 1; }
.cell.work { background: var(--work-bg); color: var(--work-text); }
.cell.typed { font-size: 10px; letter-spacing: .02em; }
.cell.zero { color: var(--muted); font-weight: 400; }
.cell.prefilled { font-style: italic; font-weight: 500; opacity: .78; }
.cell.prefilled.work { background: repeating-linear-gradient(135deg, var(--work-bg) 0 5px, #e7eeff 5px 10px); }
.cell.ro { cursor: default; }
.cell.ro:hover { box-shadow: none; }
.cell.off { cursor: not-allowed; }
.travel-dot {
  position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--travel); box-shadow: 0 0 0 1.5px #fff;
}
.travel-dot.static { position: static; display: inline-block; box-shadow: none; }

.staff-row th, .staff-row td { position: sticky; bottom: 0; z-index: 2; background: var(--surface-2); height: 26px; font-size: 11px; border-top: 1px solid var(--border-strong); }
.staff-row .sticky-col { z-index: 4; font-weight: 600; }
.staff-row td.low { background: var(--warn-bg) !important; color: var(--warn); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 14px 2px; font-size: 12.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .08); }
.sw-work { background: var(--work-bg); }
.sw-we { background: var(--weekend); }
.sw-hol { background: repeating-linear-gradient(135deg, var(--holiday) 0 3px, #f3f4f7 3px 6px); }
.sw-pre { background: repeating-linear-gradient(135deg, var(--work-bg) 0 3px, #e7eeff 3px 6px); }
.panels > .card:first-of-type { margin-top: 4px; }
.rights { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }

/* -------------------------------------------------- Éditeur de cellule */
.cell-editor {
  position: absolute; z-index: 60; width: 380px; max-width: calc(100vw - 24px); padding: 12px; display: grid; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.cell-editor-head { display: flex; align-items: center; gap: 8px; }
.cell-editor-head strong { flex: 1; font-size: 13px; }
.cell-input { font-size: 1.1rem; font-family: var(--mono); padding: 8px 10px; }
.cell-preview { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.cell-preview.is-error { color: var(--danger); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  --chip: var(--work-text);
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font: inherit; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; color: var(--text);
}
.chip.active { border-color: var(--chip); box-shadow: inset 0 0 0 1px var(--chip); background: color-mix(in srgb, var(--chip) 12%, white); }
.type-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--chip); }
.type-chip { --chip: #999; display: inline-flex; align-items: center; gap: 5px; }
.travels { display: grid; gap: 6px; }
.travels:empty { display: none; }
.travel-row { display: grid; grid-template-columns: 1fr auto 1fr auto auto; gap: 6px; align-items: center; }
.travel-row select { min-width: 0; padding: 4px 6px; }
.travel-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cell-editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kbd-hint { font-size: 11px; color: var(--muted); }
.form-error { color: var(--danger); font-size: 12.5px; font-weight: 600; }
.form-error:empty { display: none; }

/* ------------------------------------------------------------- Tableaux */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card .table-wrap { border: 0; }
.table-scroll { max-height: 520px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: 12px; position: sticky; top: 0; z-index: 1; }
.table tfoot th, .table tfoot td { font-weight: 700; background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * + * { margin-left: 4px; }
.table input[type=text], .table input[type=number] { padding: 4px 6px; }
.table .details { font-family: var(--mono); font-size: 11px; color: var(--muted); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-invalid td { background: var(--danger-bg); }
.row-muted td { color: var(--muted); }
.w-code { width: 70px; } .w-num { width: 90px; }

.year-table .sticky-col { min-width: 200px; }
.year-table th.today, .year-table td.today { background: var(--primary-weak); }
.month-cell a { display: grid; color: var(--text); }
.month-cell a:hover { text-decoration: none; color: var(--primary); }
.plan-v { font-weight: 600; }
.real-v { font-size: 11px; color: var(--ok); }
.real-v::before { content: "réel "; color: var(--muted); }
.gauge-cell { min-width: 190px; }
.lock-mark { display: inline-block; margin-left: 4px; color: var(--muted); vertical-align: -2px; }

.agent-year { font-size: 11px; }
.agent-year th, .agent-year td { padding: 0; text-align: center; }
.agent-year .sticky-col { padding: 6px 10px !important; min-width: 130px; }
.agent-year .dcol { width: 30px; padding: 4px 0; }
.agent-year td.num { padding: 0 10px; min-width: 80px; }
.yd { position: relative; height: 30px; border-left: 1px solid var(--border); }
.yd a { display: grid; place-items: center; width: 100%; height: 100%; color: inherit; font-weight: 600; }
.yd a:hover { text-decoration: none; box-shadow: inset 0 0 0 2px var(--primary); }
.yd.we { background: var(--weekend); }
.yd.hol { background: repeating-linear-gradient(135deg, var(--holiday) 0 4px, #f3f4f7 4px 8px); }
.yd.work { background: var(--work-bg); color: var(--work-text); }
.yd.void { background: repeating-linear-gradient(45deg, #fafbfc 0 3px, #f1f3f6 3px 6px); }
.yd.today { box-shadow: inset 0 0 0 2px var(--primary); }

/* ------------------------------------------------------------ Formulaires */
input[type=text], input[type=email], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px; min-width: 0;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
input[type=color] { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.field { display: grid; gap: 4px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.field-hint { font-size: 11.5px; color: var(--muted); }
.form { display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.pick-list { max-height: 260px; overflow-y: auto; display: grid; gap: 2px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.example { background: var(--surface-2); border: 1px solid var(--border); padding: 8px 10px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12px; }
.compact-list { margin: 6px 0; padding-left: 18px; }
.add-route input[type=text] { width: 200px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* --------------------------------------------------------- Assistant */
.wizard { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
.wizard .card { margin: 0; height: 100%; }
.wizard + .card { margin-top: 16px; }
.wizard-foot { display: flex; align-items: center; gap: 14px; }
.wizard-summary { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.wizard-summary p { margin: 0; font-weight: 600; }
.month-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.month-btn { padding: 9px 4px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font: inherit; font-weight: 500; cursor: pointer; }
.month-btn:hover:not(:disabled) { border-color: var(--primary); }
.month-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.month-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ------------------------------------------------------- Modale / toasts */
.modal { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); color: var(--text); }
.modal-wide { width: min(860px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1.05rem; }
.modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { padding: 10px 14px; border-radius: var(--radius-sm); background: #1f2937; color: #fff; box-shadow: var(--shadow-lg); max-width: 420px; transition: opacity .3s, transform .3s; }
.toast-success { background: #14532d; }
.toast-error { background: #7f1d1d; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------------------------------------------------------------- Login */
.login { min-height: 100vh; display: grid; place-items: start center; padding: 48px 16px; }
.login-card .badge { justify-self: start; }
.login-card { width: min(880px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; display: grid; gap: 14px; }
.login-group h2 { font-size: .95rem; color: var(--muted); margin: 8px 0; text-transform: uppercase; letter-spacing: .04em; }
.login-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.login-user { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font: inherit; text-align: left; cursor: pointer; }
.login-user:hover { border-color: var(--primary); background: var(--primary-weak); }
.login-user-text { display: grid; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary-weak); color: var(--primary); font-weight: 700; font-size: 13px; flex: none; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .main { padding: 16px 12px 40px; }
  .dashboard, .cards-2 { grid-template-columns: 1fr; }
  .agent-list li { grid-template-columns: 1fr; }
  .sticky-col { min-width: 130px; }
  .user-chip { display: none; }
}

@media print {
  .topbar, .debug-bar, .page-actions, .panels .rights, .banner button { display: none !important; }
  .grid-wrap { max-height: none; overflow: visible; box-shadow: none; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Synchronisation SSO */
.sync-block { margin: 10px 0; }
.sync-title { font-size: .95rem; margin-bottom: 4px; }
.sync-new { color: var(--ok); }
.sync-attach { color: var(--primary); }
.sync-off { color: var(--danger); }