/* GMAO Datacenter — Design System (refonte UX §68). Documentation : docs/ux/design-system.md
   1. jetons  2. base  3. structure (menu, barre supérieure, navigation mobile)  4. composants
   5. modules (messagerie, carte, terrain, technicien, planning)  6. responsive  7. impression */

/* =============================================================== 1. JETONS */
:root {
  /* couleurs institutionnelles GUCE.CI Datacenter (logo) : vert GUCE, orange, ardoise */
  --brand-green: #1c9a3e;   --brand-orange: #f07b14;  --brand-slate: #1f2a36;
  --primary: #178a37;       --primary-600: #116b2b;   --primary-50: #e9f6ed;   --primary-100: #cbe9d4;
  --navy: #16212c;          --navy-2: #1f2d3b;        --navy-3: #29394a;       --navy-text: #c5d0db;
  --bg: #f2f4f7;            --surface: #ffffff;       --surface-2: #f7f9fb;    --surface-3: #eef2f6;
  --border: #e0e5eb;        --border-strong: #c9d2dc;
  --text: #142032;          --text-2: #556377;        --text-3: #8592a3;
  /* états (toujours accompagnés d'un symbole et d'un libellé) */
  --ok: #157347;            --ok-bg: #e2f5ea;
  --warn: #8f5d00;          --warn-bg: #fff3d1;       --warn-strong: #e0a100;
  --major: #b4470c;         --major-bg: #ffe8d8;
  --danger: #c0262d;        --danger-bg: #fde5e6;
  --info: #1d5fb8;          --info-bg: #e3eefc;
  --muted: #5e6b7a;         --muted-bg: #edf0f4;
  /* compatibilité avec les noms existants */
  --accent: var(--primary); --accent-2: var(--primary-600);
  --side: var(--navy);      --side-2: var(--navy-2);  --side-text: var(--navy-text);
  /* typographie, espacements, formes */
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-md: .875rem; --fs-lg: 1rem; --fs-xl: 1.25rem; --fs-2xl: 1.6rem;
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px; --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --focus: 0 0 0 3px rgba(23, 138, 55, .28);
  --sidebar-w: 256px; --topbar-h: 56px;
}

/* ================================================================= 2. BASE */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: var(--fs-md); line-height: 1.5; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 var(--sp-2); line-height: 1.25; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--primary); color: #fff; padding: .5rem 1rem; }
.skip-link:focus { left: 0; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round;
  stroke-linejoin: round; vertical-align: -3px; }

/* ===================================================== 3. STRUCTURE GÉNÉRALE */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { padding: var(--sp-6); max-width: 1560px; width: 100%; }

/* menu latéral */
.sidebar { background: var(--navy); color: var(--navy-text); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow: hidden; }
.brand { display: block; padding: .85rem .8rem .8rem; border-bottom: 1px solid #243444;
  background: linear-gradient(180deg, rgba(28, 154, 62, .16), transparent); }
.brand:hover { text-decoration: none; }
.brand-plate { display: block; background: #fff; border-radius: 12px; padding: .45rem .6rem .35rem; position: relative; overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28), inset 0 -3px 0 var(--brand-orange); transition: transform .15s; }
.brand:hover .brand-plate { transform: translateY(-1px); }
.brand-plate img { display: block; width: 100%; height: auto; }
.brand-name .dot, .topbar-brand .dot, .app-foot .dot { color: var(--brand-orange); }
.brand-name .ci, .topbar-brand .ci, .app-foot .ci { color: var(--brand-green); }
.nav { flex: 1; overflow-y: auto; padding: .6rem .55rem 1rem; scrollbar-width: thin; scrollbar-color: #2a4166 transparent; }
.nav-link { display: flex; align-items: center; gap: .65rem; padding: .48rem .65rem; color: var(--navy-text); border-radius: 8px;
  font-size: var(--fs-md); position: relative; }
.nav-link:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--navy-3); color: #fff; font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: -.55rem; top: .35rem; bottom: .35rem; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand-orange); }
.nav-link .i { opacity: .8; width: 17px; height: 17px; }
.nav-section { margin-top: .25rem; }
.nav-section > summary { display: flex; align-items: center; gap: .65rem; padding: .48rem .65rem; border-radius: 8px; cursor: pointer;
  color: #b4c1cf; font-size: var(--fs-sm); font-weight: 600; letter-spacing: .01em; user-select: none; list-style: none; }
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary .i { width: 17px; height: 17px; opacity: .8; }
.nav-section[open] > summary { color: #fff; }
.nav-section > summary:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.nav-section > summary .caret { margin-left: auto; width: 14px; height: 14px; transition: transform .15s; }
.nav-section[open] > summary .caret { transform: rotate(180deg); }
.nav-items { padding: .1rem 0 .3rem 1.1rem; margin-left: .55rem; border-left: 1px solid #263646; }
.nav-items .nav-link { font-size: var(--fs-sm); padding: .4rem .6rem; }
.nav-items .nav-link .i { width: 15px; height: 15px; }
.nav-count { margin-left: auto; background: #e5484d; color: #fff; border-radius: var(--radius-pill); font-size: .68rem;
  font-weight: 700; padding: 0 .4rem; line-height: 1.35rem; min-width: 1.35rem; text-align: center; }
.sidebar-foot { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1.1rem; font-size: var(--fs-xs);
  color: #7d8ea6; border-top: 1px solid #1a2f4d; }
.env-chip { padding: .05rem .5rem; border-radius: var(--radius-pill); background: #173a2b; color: #6fd3a1; font-weight: 700; }
.credit b { color: #fff; } .credit b span { color: var(--brand-orange); }
.env-chip.demo { background: #3d300c; color: #f5c451; }
.backdrop { display: none; }

/* barre supérieure */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  background: linear-gradient(90deg, var(--brand-green) 0 70%, var(--brand-orange) 70% 100%) top / 100% 3px no-repeat, rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-6); }
.topbar .spacer { flex: 1; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn .i { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: 3px; right: 2px; background: #e5484d; color: #fff; font-size: .62rem; font-weight: 700;
  border-radius: var(--radius-pill); min-width: 16px; padding: 0 .3rem; line-height: 16px; text-align: center; border: 2px solid #fff; }
.menu-toggle { display: none; }
.topbar-brand { display: none; align-items: center; gap: .4rem; font-weight: 800; letter-spacing: .03em; color: var(--brand-slate); font-size: .95rem; }
.topbar-brand:hover { text-decoration: none; }
.topbar-brand img { width: 34px; height: 34px; }
.site-select { position: relative; display: flex; align-items: center; }
.site-select .site-icon { position: absolute; left: .6rem; color: var(--text-3); pointer-events: none; }
.site-select select { min-width: 230px; padding-left: 2.1rem; background-color: var(--surface-2); border-color: var(--border); }
.top-search { position: relative; display: flex; align-items: center; width: min(340px, 30vw); }
.top-search > span { position: absolute; left: .7rem; color: var(--text-3); display: flex; }
.top-search input, .top-search input[type=search] { padding-left: 2.3rem; border-radius: var(--radius-pill); background: var(--surface-2); border-color: var(--border); }
.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: .55rem; padding: .25rem .45rem; border-radius: 10px; cursor: pointer; }
.user-chip:hover { background: var(--surface-3); }
.user-chip .caret { width: 14px; height: 14px; color: var(--text-3); }
.user-id { display: flex; flex-direction: column; line-height: 1.15; }
.user-id .name { font-weight: 600; font-size: var(--fs-sm); }
.user-id .role { font-size: var(--fs-xs); color: var(--text-2); }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--brand-green), #0f6b2a); flex: none; }
img.avatar-sm { object-fit: cover; padding: 0; background: var(--muted-bg); }
.avatar-lg { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; flex: none; object-fit: cover;
  font-size: 1.6rem; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--brand-green), #0f6b2a); }
.profile-id { display: flex; gap: 1.1rem; align-items: flex-start; flex-wrap: wrap; }
.profile-id .props { flex: 1; min-width: 220px; margin: 0; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .35rem; z-index: 40; }
.menu-pop a, .menu-pop button { display: flex; gap: .6rem; align-items: center; width: 100%; padding: .5rem .65rem; border-radius: 8px;
  color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-3); text-decoration: none; }
.bottom-nav { display: none; }

/* en-tête de page */
.page-head { display: flex; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head h1 { margin-bottom: .2rem; }
.page-head .muted { max-width: 80ch; }
.page-head .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: var(--fs-xs); color: var(--text-2); margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .05em; }
.breadcrumb a { color: var(--text-2); }

/* =========================================================== 4. COMPOSANTS */
/* cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-4); }
.card-head { display: flex; align-items: center; gap: var(--sp-3); padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; font-size: .98rem; }
.card-head > .i { color: var(--primary); background: var(--primary-50); border-radius: 7px; padding: 4px; width: 24px; height: 24px; }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: 0; }
.card-foot { padding: .7rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: var(--sp-4); }
.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(300px, 1fr); gap: var(--sp-4); align-items: start; }

/* indicateurs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--border); }
.kpi.tone-ok::before { background: var(--ok); } .kpi.tone-warn::before { background: var(--warn-strong); }
.kpi.tone-danger::before { background: var(--danger); } .kpi.tone-info::before { background: var(--info); }
.kpi.tone-major::before { background: var(--major); }
.kpi .label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600; }
.kpi .value { font-size: var(--fs-2xl); font-weight: 750; margin-top: .1rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .hint { font-size: var(--fs-xs); color: var(--text-2); }
.kpi a.cover { position: absolute; inset: 0; }
.kpi:has(a.cover):hover { border-color: var(--primary-100); box-shadow: var(--shadow); }
.kpi.tone-ok, .kpi.tone-warn, .kpi.tone-danger, .kpi.tone-info, .kpi.tone-major, .kpi.tone-muted { background: var(--surface); color: var(--text); }
.section-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--text-2);
  margin: var(--sp-5) 0 var(--sp-2); font-weight: 700; }

/* cartes de statistique (tableaux de bord) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm); display: flex; gap: .9rem; align-items: center; color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--primary-100); box-shadow: var(--shadow); transform: translateY(-1px); }
.stat .stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--primary-50); color: var(--primary); }
.stat .stat-icon .i { width: 20px; height: 20px; }
.stat.tone-danger .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat.tone-warn .stat-icon { background: var(--warn-bg); color: var(--warn); }
.stat.tone-ok .stat-icon { background: var(--ok-bg); color: var(--ok); }
.stat.tone-major .stat-icon { background: var(--major-bg); color: var(--major); }
.stat.tone-ok, .stat.tone-warn, .stat.tone-danger, .stat.tone-info, .stat.tone-major { background: var(--surface); }
.stat .stat-value, .stat .stat-label, .stat .stat-sub { display: block; }
.stat .stat-value { font-size: 1.85rem; font-weight: 760; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .stat-label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; }
.stat .stat-sub { font-size: var(--fs-xs); color: var(--text-3); }

/* badges d'état : symbole + texte + couleur */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .14rem .55rem; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 650; white-space: nowrap; border: 1px solid transparent; line-height: 1.35; }
.badge .sym { font-size: .62rem; line-height: 1; }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-danger { background: var(--danger-bg); color: var(--danger); }
.tone-major { background: var(--major-bg); color: var(--major); }
.tone-info { background: var(--info-bg); color: var(--info); }
.tone-muted { background: var(--muted-bg); color: var(--muted); }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); margin-right: .35rem; }
.status-dot.on { background: #22a35a; box-shadow: 0 0 0 3px rgba(34, 163, 90, .18); }
.status-dot.warn { background: var(--warn-strong); } .status-dot.off { background: #b0b9c5; } .status-dot.danger { background: var(--danger); }

/* tableaux */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); background: var(--surface-2);
  font-weight: 700; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table th a { color: var(--text-2); }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: #f5f8fd; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table td a:first-child { font-weight: 600; }
.empty { padding: var(--sp-8); text-align: center; color: var(--text-2); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-2); }
.empty-state .i { width: 40px; height: 40px; color: var(--text-3); margin-bottom: .5rem; }
dl.props { display: grid; grid-template-columns: minmax(120px, 36%) minmax(0, 1fr); margin: 0; }
dl.props dt { color: var(--text-2); padding: .45rem 0; border-bottom: 1px solid var(--surface-3); font-size: var(--fs-sm); }
dl.props dd { margin: 0; padding: .45rem 0 .45rem .6rem; border-bottom: 1px solid var(--surface-3); word-break: break-word; }

/* formulaires */
label { font-weight: 600; font-size: var(--fs-sm); display: block; margin-bottom: .3rem; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=datetime-local], input[type=search], input[type=url], input[type=tel], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff;
  font: inherit; color: inherit; transition: border-color .12s, box-shadow .12s; min-height: 38px; }
input:hover, select:hover, textarea:hover { border-color: #aab6c4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
select[multiple] { min-height: 7rem; }
textarea { min-height: 4.5rem; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem 1.1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.field { min-width: 0; }
.field .help { font-size: var(--fs-xs); color: var(--text-2); margin-top: .25rem; }
.field .errors, .errorlist { color: var(--danger); font-size: var(--fs-xs); margin: .25rem 0 0; padding: 0; list-style: none; font-weight: 600; }
.field:has(.errors) input, .field:has(.errors) select, .field:has(.errors) textarea { border-color: var(--danger); background: #fffafa; }
.field.required > label::after { content: " *"; color: var(--danger); }
.field.checkbox label { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.field.checkbox input { width: auto; min-height: 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.1rem 1.1rem; margin: 0 0 var(--sp-4); background: var(--surface); }
legend { font-weight: 700; padding: 0 .45rem; color: var(--primary-600); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em; }
.form-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; flex-wrap: wrap; padding-top: var(--sp-3); }
.inline-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1; min-width: 160px; }
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: flex-end; padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.filters .field { min-width: 150px; flex: 1; max-width: 240px; }
.filters .field.search { max-width: 360px; flex: 2; }
.filters label { font-size: .68rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }

/* boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .95rem; min-height: 38px;
  border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--primary); color: #fff; line-height: 1.2; white-space: nowrap; transition: background .12s, box-shadow .12s, transform .05s; }
.btn:hover { background: var(--primary-600); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: var(--surface-3); color: var(--text); }
.btn.success { background: var(--ok); } .btn.success:hover { background: #105c38; }
.btn.danger { background: var(--danger); } .btn.danger:hover { background: #9b1c22; }
.btn.ghost { background: transparent; color: var(--primary); border-color: transparent; padding-inline: .55rem; box-shadow: none; }
.btn.ghost:hover { background: var(--primary-50); color: var(--primary-600); }
.btn.small { padding: .28rem .65rem; font-size: var(--fs-sm); min-height: 30px; border-radius: 7px; }
.btn.large { padding: .8rem 1.2rem; font-size: 1rem; min-height: 48px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn .i { width: 16px; height: 16px; }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details { position: relative; }

/* alertes et messages */
.messages { list-style: none; margin: 0 0 var(--sp-4); padding: 0; }
.messages li { padding: .7rem 1rem .7rem 2.4rem; border-radius: var(--radius); margin-bottom: var(--sp-2); border: 1px solid; position: relative; font-weight: 500; }
.messages li::before { position: absolute; left: .9rem; font-weight: 800; }
.messages .success { background: var(--ok-bg); color: var(--ok); border-color: #b6e3cb; } .messages .success::before { content: "✓"; }
.messages .error { background: var(--danger-bg); color: var(--danger); border-color: #f5b9bc; } .messages .error::before { content: "✕"; }
.messages .warning { background: var(--warn-bg); color: var(--warn); border-color: #f2d48a; } .messages .warning::before { content: "!"; }
.messages .info { background: var(--info-bg); color: var(--info); border-color: #b9d3f6; } .messages .info::before { content: "i"; }
.callout { padding: .8rem 1rem; border-radius: var(--radius); border-left: 4px solid var(--info); background: var(--info-bg); margin-bottom: var(--sp-4); }
.callout.warn { border-color: var(--warn-strong); background: var(--warn-bg); }
.callout.danger { border-color: var(--danger); background: var(--danger-bg); }
.callout.ok { border-color: var(--ok); background: var(--ok-bg); }

/* onglets */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: .6rem .95rem; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { padding: .3rem .75rem; border-radius: 7px; color: var(--text-2); font-weight: 600; font-size: var(--fs-sm);
  border: 0; background: none; cursor: pointer; }
.seg a.active, .seg button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.seg a:hover { text-decoration: none; color: var(--text); }

/* chronologie, workflow, barres, arbre, pagination */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.5rem; border-left: 2px solid var(--border); margin-left: .45rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .25rem; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary); }
.timeline li.tone-danger::before { border-color: var(--danger); } .timeline li.tone-ok::before { border-color: var(--ok); }
.timeline li.tone-ok, .timeline li.tone-danger, .timeline li.tone-warn, .timeline li.tone-info { background: none; color: inherit; }
.timeline .when { font-size: var(--fs-xs); color: var(--text-2); }
.workflow { display: flex; flex-wrap: wrap; gap: .3rem; margin: .25rem 0 var(--sp-4); }
.workflow .step { flex: 1; min-width: 90px; text-align: center; font-size: .72rem; padding: .45rem .3rem; background: var(--muted-bg);
  color: var(--muted); border-radius: 6px; font-weight: 650; }
.workflow .step.done { background: var(--ok-bg); color: var(--ok); }
.workflow .step.done::before { content: "✓ "; }
.workflow .step.current { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(23, 138, 55, .3); }
.workflow .step.cancelled { background: var(--danger-bg); color: var(--danger); }
.bar { height: 8px; border-radius: 4px; background: var(--muted-bg); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar.ok > span { background: var(--ok); } .bar.warn > span { background: var(--warn-strong); } .bar.danger > span { background: var(--danger); }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 30%) minmax(0, 1fr) auto; gap: .6rem; align-items: center; padding: .3rem 0; font-size: var(--fs-sm); }
.tree { list-style: none; padding-left: 1.1rem; margin: .2rem 0; border-left: 1px dashed var(--border-strong); }
.tree > li { padding: .2rem 0; }
.tree-root { padding-left: 0; border: 0; }
.pagination { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; padding: .75rem 1.1rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.pagination a:hover { text-decoration: none; background: var(--surface-3); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* connexion : panneau de marque + formulaire */
body.login-body { background: var(--navy); }
.login-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem;
  background: radial-gradient(900px 520px at 88% -5%, rgba(240, 123, 20, .22) 0, transparent 60%),
              radial-gradient(1100px 640px at 0% 105%, rgba(28, 154, 62, .32) 0, transparent 60%),
              repeating-linear-gradient(135deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 22px), var(--navy); }
.login-wrap { width: 100%; max-width: 960px; }
.login-shell { display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; border-radius: 22px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.login-brand { position: relative; padding: 2.4rem 2.2rem 2rem; background: linear-gradient(160deg, #ffffff 0%, #f3faf5 55%, #fff4ea 100%);
  border-right: 1px solid var(--border); overflow: hidden; }
.login-brand::after { content: ""; position: absolute; right: -90px; bottom: -90px; width: 260px; height: 260px; border-radius: 50%;
  border: 26px solid rgba(240, 123, 20, .12); }
.login-brand::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: linear-gradient(90deg, var(--brand-green) 0 62%, var(--brand-orange) 62% 100%); }
.login-logo { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 0 1.4rem; }
.login-brand h2 { font-size: 1.15rem; color: var(--brand-slate); margin-bottom: 1rem; }
.login-pillars { list-style: none; margin: 0; padding: 0; display: grid; gap: .85rem; position: relative; z-index: 1; }
.login-pillars li { display: flex; gap: .8rem; align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); }
.login-pillars b { display: block; color: var(--text); font-size: var(--fs-md); }
.pill-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; }
.pill-ico.green { background: var(--brand-green); } .pill-ico.orange { background: var(--brand-orange); } .pill-ico.slate { background: var(--brand-slate); }
.login-card { padding: 2.2rem 2.2rem 1.8rem; display: flex; flex-direction: column; justify-content: center; background: #fff; }
.login-card .field { margin-bottom: .95rem; }
.login-card h1 { font-size: 1.45rem; margin: .5rem 0 .15rem; }
.login-emblem { width: 56px; height: 56px; border-radius: 16px; box-shadow: 0 6px 18px rgba(23, 138, 55, .22); }
.login-lead { margin: 0 0 1.2rem; }
.login-note { display: flex; align-items: center; gap: .4rem; margin: 1rem 0 0; }
.login-note .i { width: 15px; height: 15px; color: var(--primary); }
.login-credit { color: #9aabbc; font-size: var(--fs-xs); text-align: center; margin-top: 1.1rem; letter-spacing: .02em; }
.login-credit strong { color: #fff; } .login-credit strong span { color: var(--brand-orange); }
@media (max-width: 767px) {
  .login-shell { grid-template-columns: 1fr; max-width: 460px; margin: 0 auto; }
  .login-brand { padding: 1.6rem 1.5rem .4rem; border-right: 0; background: #fff; }
  .login-brand h2, .login-pillars, .login-brand::after { display: none; }
  .login-logo { margin: 0 auto; }
  .login-card { padding: .6rem 1.5rem 1.6rem; }
  .login-emblem { display: none; }
}

/* bandeau d'accueil (tableau de bord) */
.hero { position: relative; overflow: hidden; display: flex; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap;
  margin-bottom: var(--sp-5); padding: 1.4rem 1.6rem 1.5rem; border-radius: var(--radius-lg); color: #fff;
  background: radial-gradient(600px 260px at 100% 0%, rgba(240, 123, 20, .35), transparent 65%),
              linear-gradient(120deg, var(--brand-slate) 0%, #173b2a 55%, var(--primary-600) 100%);
  box-shadow: 0 10px 28px rgba(22, 33, 44, .22); }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand-green) 0 70%, var(--brand-orange) 70% 100%); }
.hero-emblem { position: absolute; right: -28px; top: 50%; width: 210px; height: 210px; transform: translateY(-50%);
  opacity: .16; pointer-events: none; }
.hero-text { flex: 1; min-width: 240px; position: relative; }
.hero-kicker { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: #ffd2a8; margin-bottom: .3rem; }
.hero h1 { color: #fff; font-size: 1.65rem; margin: 0 0 .25rem; }
.hero p { margin: 0; color: #c9d7e2; font-size: var(--fs-sm); }
.hero-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; position: relative; }
.hero .seg { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); }
.hero .seg a { color: #dce6ee; }
.hero .seg a.active { background: #fff; color: var(--primary-600); }
.hero .btn { background: var(--brand-orange); box-shadow: 0 4px 14px rgba(240, 123, 20, .4); }
.hero .btn:hover { background: #d96a0a; }

/* pages d'erreur */
.error-page { max-width: 520px; margin: 3rem auto; text-align: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.2rem 1.8rem; box-shadow: var(--shadow); border-top: 4px solid var(--brand-green); }
.error-page img { width: 96px; height: 96px; }
.error-code { display: block; font-size: 3rem; font-weight: 800; line-height: 1; margin: .6rem 0 .3rem; letter-spacing: -.03em;
  background: linear-gradient(90deg, var(--brand-green), var(--brand-orange)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* pied de page */
.app-foot { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin-top: auto; padding: .9rem var(--sp-6);
  border-top: 1px solid var(--border); color: var(--text-3); font-size: var(--fs-xs); background: var(--surface); }
.app-foot img { width: 22px; height: 22px; }
.app-foot b { color: var(--text-2); }
.app-foot .spacer { flex: 1; }
.app-foot .tr { color: var(--brand-slate); } .app-foot .tr span { color: var(--brand-orange); }
body:has(.chat-app) .app-foot, body:has(.map-shell) .app-foot { display: none; }

/* ================================================================ 5. MODULES */
/* tableau de bord */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
/* pilotage : à traiter, objectifs, charge, délais, évolution */
.text-danger { color: var(--danger); }
.pilot-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-4); align-items: stretch; }
.pilot-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pilot-grid > .card { margin: 0; display: flex; flex-direction: column; }
.attention { list-style: none; margin: 0; padding: .35rem; }
.attention a { display: flex; align-items: center; gap: .75rem; padding: .55rem .65rem; border-radius: 10px; color: var(--text);
  border-left: 4px solid var(--tone, var(--border)); margin-bottom: .3rem; background: var(--surface-2); }
.attention a:hover { text-decoration: none; background: var(--surface-3); }
.attention li.att-danger { --tone: var(--danger); --tone-bg: var(--danger-bg); }
.attention li.att-major { --tone: var(--major); --tone-bg: var(--major-bg); }
.attention li.att-warn { --tone: var(--warn-strong); --tone-bg: var(--warn-bg); }
.attention li.att-info { --tone: var(--info); --tone-bg: var(--info-bg); }
.attention .grow, .load .grow { flex: 1; min-width: 0; }
.att-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--tone-bg); color: var(--tone); }
.att-label { display: block; font-weight: 650; font-size: var(--fs-md); line-height: 1.25; }
.att-hint { display: block; font-size: var(--fs-xs); color: var(--text-2); }
.att-n { font-size: 1.35rem; font-weight: 760; color: var(--tone); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.att-go { color: var(--text-3); width: 16px; height: 16px; }
.empty-state.ok .i { color: var(--ok); }
.objectives { display: grid; gap: 1rem; }
.objective .obj-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.obj-label { font-weight: 600; font-size: var(--fs-sm); }
.obj-value { font-size: 1.2rem; font-weight: 760; font-variant-numeric: tabular-nums; }
.obj-bar { height: 8px; border-radius: 4px; background: var(--muted-bg); overflow: hidden; margin: .3rem 0 .2rem; }
.obj-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--state, var(--muted)); }
.obj-foot { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-2); }
.obj-state { font-weight: 700; color: var(--state, var(--muted)); }
.objective.state-ok { --state: var(--ok); } .objective.state-warn { --state: var(--warn-strong); }
.objective.state-danger { --state: var(--danger); } .objective.state-muted { --state: var(--muted); }
.objective.state-warn .obj-state { color: var(--warn); }
.load { list-style: none; margin: 0; padding: .35rem; flex: 1; }
.load a { display: flex; align-items: center; gap: .7rem; padding: .5rem .55rem; border-radius: 10px; color: var(--text); }
.load a:hover { background: var(--surface-2); text-decoration: none; }
.load .avatar-sm { background: var(--primary-50); color: var(--primary-600); }
.load-name { display: block; font-weight: 600; font-size: var(--fs-sm); }
.load-bar { display: block; height: 6px; border-radius: 3px; background: var(--muted-bg); overflow: hidden; margin: .2rem 0; }
.load-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-green), var(--primary-600)); border-radius: 3px; }
.load-meta { display: block; font-size: var(--fs-xs); color: var(--text-2); }
.load-n { font-size: 1.15rem; font-weight: 760; font-variant-numeric: tabular-nums; }
.card-foot { display: flex; align-items: center; gap: .5rem; padding: .65rem 1.1rem; border-top: 1px solid var(--border); font-size: var(--fs-sm);
  font-weight: 600; margin-top: auto; }
.card-foot.warn { background: var(--warn-bg); color: var(--warn); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-foot:hover { text-decoration: none; filter: brightness(.98); }
.sla { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.sla .ring { width: 118px; height: 118px; flex: none; }
.sla-txt { font-size: var(--fs-sm); line-height: 1.7; }
.ok-txt { color: var(--ok); }
.subhead { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: .2rem 0 .3rem; }
.hbar-row.age { grid-template-columns: 110px minmax(0, 1fr) 36px; }
.bar.tone-ok > span { background: var(--ok); } .bar.tone-warn > span { background: var(--warn-strong); } .bar.tone-danger > span { background: var(--danger); }
.evo { list-style: none; margin: 0; padding: .3rem 1.1rem .8rem; }
.evo li { display: flex; align-items: center; gap: .6rem; padding: .62rem 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.evo li:last-child { border-bottom: 0; }
.evo b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.delta { font-size: var(--fs-xs); font-weight: 700; padding: .1rem .45rem; border-radius: var(--radius-pill); background: var(--muted-bg);
  color: var(--muted); min-width: 64px; text-align: center; }
.delta.good { background: var(--ok-bg); color: var(--ok); } .delta.bad { background: var(--danger-bg); color: var(--danger); }
.delta.up:not(.good):not(.bad), .delta.down:not(.good):not(.bad) { background: var(--info-bg); color: var(--info); }
.chart { width: 100%; height: 200px; display: block; }
.chart .bar-a { fill: var(--primary); } .chart .bar-b { fill: #9cc2f5; } .chart .axis { stroke: var(--border); }
.chart text { font-size: 10px; fill: var(--text-3); font-family: var(--font); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.donut-wrap { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; flex: none; }
.donut-legend { flex: 1; min-width: 160px; }
.donut-legend .row { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--surface-3); font-size: var(--fs-sm); }
.donut-legend .row b { font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: .75rem; align-items: center; padding: .65rem 1.1rem; border-bottom: 1px solid var(--surface-3); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { font-size: var(--fs-xs); color: var(--text-2); }
.prio { width: 4px; align-self: stretch; border-radius: 3px; background: var(--border); flex: none; }
.prio.P1 { background: var(--danger); } .prio.P2 { background: var(--major); } .prio.P3 { background: var(--info); } .prio.P4 { background: var(--text-3); }

/* espace technicien */
.tech { max-width: 760px; margin: 0 auto; }
.tech .tile { display: flex; align-items: center; gap: .9rem; padding: 1rem; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: .6rem; color: var(--text); box-shadow: var(--shadow-sm); }
.tech .tile:hover { text-decoration: none; border-color: var(--primary); }
.tech .tile .big { font-size: 1.6rem; width: 2.2rem; text-align: center; }
.tech .tile .t { font-weight: 700; }
.tech .btn { padding: .85rem 1rem; font-size: 1rem; min-height: 52px; }
.tech-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; margin: .8rem 0; }
.check-item { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; margin-bottom: .6rem; background: #fff; }
.check-item.nc { border-color: var(--danger); background: #fff8f8; }
.check-item.ok { border-color: #9fd8bb; }
.check-item .q { font-weight: 650; margin-bottom: .35rem; }
.choice-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.choice-row label { flex: 1; min-width: 110px; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: .7rem;
  text-align: center; cursor: pointer; font-weight: 600; margin: 0; }
.choice-row input { display: none; }
.choice-row input:checked + span { color: var(--primary); }
.choice-row label:has(input:checked) { border-color: var(--primary); background: var(--info-bg); }
#qr-video { width: 100%; border-radius: var(--radius-lg); background: #000; max-height: 60vh; }
.signature-pad { border: 1px dashed #9aa8b8; border-radius: var(--radius); background: #fff; width: 100%; height: 180px; touch-action: none; }

/* planning */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; }
.cal .day { background: #fff; min-height: 110px; padding: .4rem; font-size: .78rem; }
.cal .day.other { background: var(--surface-2); color: var(--text-2); }
.cal .day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal .dname { background: var(--surface-2); padding: .4rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--text-2); }
.cal .ev { display: block; margin-top: .2rem; padding: .15rem .35rem; border-radius: 4px; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; color: var(--text); background: var(--info-bg); }
.cal .ev.tone-danger { background: var(--danger-bg); } .cal .ev.tone-ok { background: var(--ok-bg); }
.cal .ev.tone-warn { background: var(--warn-bg); } .cal .ev.tone-major { background: var(--major-bg); }
.year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }

/* étiquettes QR */
.qr-label { display: flex; gap: 1rem; align-items: center; border: 1px dashed var(--border-strong); padding: .8rem; max-width: 520px; background: #fff; border-radius: var(--radius); }
.qr-label img { width: 160px; height: 160px; }
.qr-label svg { width: 120px; height: 120px; }
.qr-label .code { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; }
.qr-label-title { font-weight: 700; font-size: 1.05rem; }

/* messagerie instantanée */
.chat-app { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 3rem); min-height: 520px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.chat-side { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; min-width: 0; background: var(--surface); }
.chat-side-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1rem .6rem; gap: .5rem; }
.chat-side-head h1 { font-size: 1.2rem; margin: 0; }
.chat-side-actions { display: flex; gap: .3rem; }
.chat-search { padding: 0 1rem .6rem; position: relative; }
.chat-search input { border-radius: var(--radius-pill); background: var(--surface-2); padding-left: 2.1rem; }
.chat-search .i { position: absolute; left: 1.7rem; top: .65rem; color: var(--text-3); }
.chat-filters { display: flex; gap: .35rem; padding: 0 1rem .7rem; flex-wrap: wrap; }
.chat-filters a { padding: .22rem .7rem; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 650; }
.chat-filters a:hover { text-decoration: none; color: var(--text); }
.chat-filters a.active { background: #d9f2e3; color: #0b6b3a; }
.chat-list { overflow-y: auto; flex: 1; min-height: 0; border-top: 1px solid var(--border); }
.chat-item { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; color: var(--text); cursor: pointer; text-decoration: none; position: relative; }
.chat-item + .chat-item::before { content: ""; position: absolute; top: 0; left: 4.6rem; right: 0; border-top: 1px solid var(--surface-3); }
.chat-item:hover { background: var(--surface-2); text-decoration: none; }
.chat-item.active { background: var(--primary-50); }
.chat-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.chat-item-top, .chat-item-bottom { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.chat-item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-time { font-size: .72rem; color: var(--text-3); flex-shrink: 0; }
.chat-item.unread .chat-item-time { color: #128c4b; font-weight: 700; }
.chat-item.unread .chat-item-title { font-weight: 750; }
.chat-item-preview { font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-preview .badge { padding: 0 .4rem; font-size: .65rem; }
.ctx { display: inline-flex; align-items: center; gap: .2rem; font-size: .68rem; font-weight: 700; color: var(--primary-600);
  background: var(--primary-50); border-radius: 5px; padding: 0 .35rem; margin-right: .25rem; }
.chat-unread { background: #25d366; color: #fff; border-radius: var(--radius-pill); min-width: 20px; height: 20px; font-size: .72rem;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; font-weight: 700; flex-shrink: 0; }
.chat-public { padding: .7rem 0 0; border-top: 1px solid var(--border); }
.chat-public > .small { padding: 0 1rem .3rem; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, #5f8fd3, #3b6fbf); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: .92rem; }
.avatar.group { background: linear-gradient(135deg, #3fae84, #23866a); }
.avatar.ot { background: linear-gradient(135deg, #f0a43b, #d9772a); border-radius: 12px; }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative;
  background-color: #efeae2; background-image: radial-gradient(rgba(0, 0, 0, .035) 1px, transparent 1px); background-size: 18px 18px; }
.chat-head { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 64px; }
.chat-head .avatar { width: 40px; height: 40px; }
.chat-head-title { flex: 1; min-width: 0; }
.chat-head-title strong { display: block; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-back { display: none; color: var(--text); padding: .3rem; border-radius: 8px; }
.chat-back:hover { background: var(--surface-3); text-decoration: none; }
.chat-menu { position: relative; }
.chat-menu summary, .chat-attach summary { list-style: none; }
.chat-menu-body { position: absolute; right: 0; top: 2.6rem; z-index: 25; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .5rem; width: 300px; max-height: 70vh; overflow: auto; }
.chat-members ul { padding-left: 1rem; margin: .3rem 0; }
.chat-join, .chat-closed { padding: .7rem; text-align: center; background: var(--surface); border-top: 1px solid var(--border); }
.chat-thread { flex: 1; overflow-y: auto; padding: 1.1rem 7%; display: flex; flex-direction: column; gap: .2rem; min-height: 0; }
.chat-thread.compact { max-height: 45vh; padding: .8rem; background-color: #efeae2; }
.chat-empty { text-align: center; color: var(--text-2); margin: auto; background: rgba(255, 255, 255, .85); padding: .5rem .9rem; border-radius: 10px; }
.chat-day { text-align: center; margin: .7rem 0 .35rem; }
.chat-day span { background: #fff; color: var(--text-2); font-size: .72rem; font-weight: 600; padding: .25rem .75rem; border-radius: 8px; box-shadow: var(--shadow-sm); }
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble-row.system { justify-content: center; }
.bubble-system { background: #fff6d1; color: #5f4b00; font-size: .76rem; padding: .3rem .75rem; border-radius: 8px; max-width: 85%; text-align: center; }
.bubble { position: relative; max-width: min(72%, 600px); background: #fff; border-radius: 12px; border-top-left-radius: 4px;
  padding: .4rem .65rem .3rem; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); overflow-wrap: anywhere; }
.bubble-row.mine .bubble { background: #d9fdd3; border-top-left-radius: 12px; border-top-right-radius: 4px; }
.bubble.important { box-shadow: inset 3px 0 0 var(--danger), 0 1px .5px rgba(11, 20, 26, .13); }
.bubble-sender { font-size: .76rem; font-weight: 700; color: #1f7aa8; margin-bottom: .1rem; }
.bubble-body { line-height: 1.4; font-size: .92rem; }
.bubble-deleted { font-style: italic; color: var(--text-2); }
.bubble-meta { display: flex; justify-content: flex-end; align-items: center; gap: .25rem; font-size: .68rem; color: #667781; margin-top: .1rem; }
.ticks { color: #8696a0; letter-spacing: -2px; font-weight: 700; }
.ticks.read { color: #34b7f1; }
.bubble-del { display: none; }
.bubble:hover .bubble-del { display: inline; }
.link-btn { background: none; border: 0; padding: 0 .1rem; cursor: pointer; font-size: .8rem; }
.bubble-att { margin: .15rem 0 .25rem; }
.bubble-att img, .bubble-att video { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; }
.bubble-file, .bubble-ref { display: flex; gap: .6rem; align-items: center; background: rgba(0, 0, 0, .045); border-radius: 8px;
  padding: .5rem .65rem; color: var(--text); text-decoration: none; margin: .15rem 0; }
.bubble-file:hover, .bubble-ref:hover { background: rgba(0, 0, 0, .08); text-decoration: none; }
.bubble-file-ico { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: #fff; color: var(--primary); flex: none; }
.chat-compose { display: flex; align-items: flex-end; gap: .45rem; padding: .55rem .75rem; background: #f0f2f5; position: relative; border-top: 1px solid var(--border); }
.chat-attach { position: relative; }
.chat-attach-menu { position: absolute; bottom: 3rem; left: 0; z-index: 25; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .4rem; width: 250px; }
.chat-attach-menu label.btn input[type=file] { display: none; }
.chat-attach-menu .btn { justify-content: flex-start; color: var(--text); }
.chat-input { flex: 1; display: flex; flex-direction: column; }
.chat-input textarea { width: 100%; border-radius: 22px; padding: .6rem 1rem; resize: none; max-height: 140px; min-height: 44px;
  border: 1px solid transparent; background: #fff; }
.chat-send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center; box-shadow: var(--shadow); }
.chat-send:hover { background: var(--primary-600); }
.chat-send:disabled { opacity: .5; }
.chat-docs { position: absolute; inset: 0; background: rgba(15, 23, 42, .35); display: flex; align-items: center; justify-content: center; z-index: 30; }
.chat-docs[hidden] { display: none; }
.chat-docs-box { background: var(--surface); border-radius: var(--radius-lg); padding: 1rem; width: min(540px, 92%); max-height: 80%; display: flex;
  flex-direction: column; gap: .55rem; box-shadow: var(--shadow-lg); }
.chat-docs-head { display: flex; justify-content: space-between; align-items: center; }
.chat-docs-list { overflow-y: auto; }
.chat-docs-list button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--border); padding: .6rem; cursor: pointer; border-radius: 6px; }
.chat-docs-list button:hover { background: var(--surface-2); }
.chat-welcome { margin: auto; text-align: center; max-width: 440px; padding: 2rem; }
.chat-welcome-icon { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 1rem; background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.chat-welcome-icon .i { width: 40px; height: 40px; }
.chat-welcome-icon img { width: 60px; height: 60px; }
.chat-list.people .chat-item { cursor: default; }
.msg-compose { border-top: 1px solid var(--border); padding: .8rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
.msg-compose textarea { width: 100%; }
.msg-compose label.btn input[type=file] { display: none; }

/* carte et supervision terrain */
.field-map { width: 100%; height: 100%; min-height: 420px; background: #dfe7ef; position: relative; overflow: hidden; cursor: grab; touch-action: none; }
.field-map.dragging { cursor: grabbing; }
.field-map .tiles img { position: absolute; width: 256px; height: 256px; user-select: none; -webkit-user-drag: none; }
.map-shell { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - var(--topbar-h) - 9rem); min-height: 520px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.map-side { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.map-side .head { padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.map-side .people { overflow-y: auto; flex: 1; }
.person { display: flex; gap: .7rem; align-items: center; padding: .65rem 1rem; border-bottom: 1px solid var(--surface-3); cursor: pointer; }
.person:hover, .person.active { background: var(--primary-50); }
.person .avatar { width: 38px; height: 38px; font-size: .8rem; }
.map-zoom { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
.map-zoom button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 1.1rem; box-shadow: var(--shadow); }
.map-attrib { position: absolute; right: 6px; bottom: 4px; font-size: .68rem; background: rgba(255, 255, 255, .85); padding: 0 .4rem; border-radius: 4px; z-index: 5; }
.map-pin { position: absolute; transform: translate(-50%, -100%); z-index: 4; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.map-pin .head { background: var(--primary); color: #fff; font-size: .7rem; font-weight: 700; padding: .15rem .45rem; border-radius: 8px;
  white-space: nowrap; box-shadow: var(--shadow); border: 2px solid #fff; }
.map-pin .tail { width: 2px; height: 8px; background: var(--primary); }
.map-pin.off .head { background: #7b8794; } .map-pin.off .tail { background: #7b8794; }
.map-pin.busy .head { background: var(--major); } .map-pin.busy .tail { background: var(--major); }
.map-pin.site .head { background: var(--navy); } .map-pin.site .tail { background: var(--navy); }
.map-pin.selected .head { outline: 3px solid rgba(240, 123, 20, .45); }
.map-card { position: absolute; left: 12px; bottom: 12px; width: min(340px, calc(100% - 24px)); background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 1rem; z-index: 6; }
.map-card dl.props { grid-template-columns: 42% 1fr; }
.map-stats { display: flex; gap: 1rem; flex-wrap: wrap; padding: .6rem 1rem; border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); }
.map-stats b { font-variant-numeric: tabular-nums; }

/* ============================================================ 6. RESPONSIVE */
@media (max-width: 1280px) {
  :root { --sidebar-w: 236px; }
  .content { padding: var(--sp-5); }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pilot-grid, .pilot-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pilot-grid.three > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .top-search { width: min(280px, 26vw); }
}
/* ordinateur portable compact (écran mis à l'échelle 125 à 150 %) : le menu latéral reste visible */
@media (max-width: 1100px) and (min-width: 768px) {
  :root { --sidebar-w: 216px; }
  .content { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
  .user-id { display: none; }
  .brand { padding: .7rem .65rem; }
  .chat-app { grid-template-columns: 270px minmax(0, 1fr); }
  .chat-side-head .btn .lbl { display: none; }
  .chat-side-head .btn { padding-inline: .55rem; }
  .chat-side-head h1 { font-size: 1.05rem; }
  .map-shell { grid-template-columns: 270px minmax(0, 1fr); }
  .hero-emblem { width: 160px; height: 160px; }
}
@media (max-width: 960px) {
  .top-search { display: none; }
}
@media (min-width: 960px) and (max-width: 1100px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
  .stat { padding: .8rem .85rem; gap: .65rem; }
  .stat .stat-icon { width: 38px; height: 38px; }
  .stat .stat-value { font-size: 1.5rem; }
  .stat .stat-sub { display: none; }
}
@media (min-width: 768px) and (max-width: 1100px) {
  .sidebar-foot .credit { display: none; }
}
@media (max-width: 767px) {
  :root { --topbar-h: 54px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 286px; transform: translateX(-100%); transition: transform .2s ease; z-index: 60; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  body.nav-open .backdrop { display: block; }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(5, 12, 24, .45); z-index: 55; }
  .menu-toggle.icon-btn { display: inline-grid; }
  .pilot-grid, .pilot-grid.three { grid-template-columns: minmax(0, 1fr); }
  .pilot-grid.three > :last-child { grid-column: auto; }
  .topbar-brand { display: inline-flex; }
  .app-foot { padding: .8rem var(--sp-3) 5.5rem; }
  .app-foot .spacer { display: none; }
  .hero { padding: 1.1rem 1.1rem 1.2rem; }
  .hero h1 { font-size: 1.35rem; }
  .hero-emblem { width: 150px; height: 150px; right: -30px; top: 30%; }
  .topbar { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .user-id, .user-chip .caret { display: none; }
  .site-select select { min-width: 0; max-width: 46vw; }
  .content { padding: var(--sp-3) var(--sp-3) var(--sp-4); }
  body:has(.chat-app) .content, body:has(.map-shell) .content { padding-bottom: 5.5rem; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .cal .day { min-height: 70px; }
  .year-grid { grid-template-columns: repeat(2, 1fr); }
  dl.props { grid-template-columns: minmax(0, 1fr); }
  dl.props dt { border-bottom: 0; padding-bottom: 0; }
  /* navigation basse (accès rapide au pouce) */
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: #fff; border-top: 1px solid var(--border); padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(16, 24, 40, .06); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .3rem 0; color: var(--text-2);
    font-size: .68rem; font-weight: 600; background: none; border: 0; font-family: inherit; cursor: pointer; border-radius: 10px; }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav .i { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a.scan .i { background: var(--primary); color: #fff; border-radius: 50%; padding: 7px; width: 40px; height: 40px; margin-top: -1.1rem;
    box-shadow: 0 6px 16px rgba(23, 138, 55, .4); border: 3px solid #fff; }
  /* tableaux → cartes (les en-têtes deviennent les libellés de chaque ligne) */
  .table-wrap { overflow: visible; }
  table.table.cards thead { display: none; }
  table.table.cards, table.table.cards tbody, table.table.cards tr, table.table.cards td { display: block; width: 100%; }
  table.table.cards tr { border: 1px solid var(--border); border-radius: var(--radius); margin: .6rem .6rem 0; width: auto; padding: .35rem 0; background: #fff; }
  table.table.cards tbody tr:last-child { margin-bottom: .6rem; }
  table.table.cards td { border: 0; padding: .3rem .8rem; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
  table.table.cards td::before { content: attr(data-label); color: var(--text-2); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase;
    letter-spacing: .04em; text-align: left; flex: none; max-width: 45%; }
  table.table.cards td:first-child { font-size: 1rem; }
  table.table.cards td[data-label=""]::before { content: none; }
  table.table.cards td.num { justify-content: space-between; }
  .filters .field { max-width: none; min-width: 45%; }
  /* messagerie et carte plein écran */
  .chat-app { grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 5.5rem); border-radius: var(--radius); min-height: 0; }
  .chat-app.has-active .chat-side { display: none; }
  .chat-app:not(.has-active) .chat-main { display: none; }
  .chat-back { display: inline-flex; }
  .chat-thread { padding: .7rem; }
  .bubble { max-width: 86%; }
  .map-shell { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .map-side { order: 2; border-right: 0; border-top: 1px solid var(--border); max-height: 50vh; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .stat { flex-direction: column; align-items: flex-start; gap: .4rem; padding: .8rem; }
  .stat .stat-icon { width: 36px; height: 36px; }
  .stat .stat-value { font-size: 1.5rem; }
  .page-head .actions { width: 100%; }
  .site-select { display: none; }
  h1 { font-size: 1.25rem; }
}

/* ============================================================= 7. IMPRESSION */
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .filters, .pagination, .page-head .actions { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  .content { padding: 0; max-width: none; }
}
.chat-back .i { transform: rotate(180deg); }

@media (max-width: 560px) {
  .topbar-brand span { display: none; }
  .site-select select { max-width: 34vw; font-size: var(--fs-sm); }
  .topbar .icon-btn { width: 34px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; justify-content: center; }
  .card-head { padding: .75rem .85rem; }
  .card-head .muted.small { display: none; }
  .card-body { padding: .85rem; }
  .att-hint { display: none; }
  .sla .ring { width: 96px; height: 96px; }
  .hbar-row { grid-template-columns: minmax(80px, 34%) minmax(0, 1fr) auto; }
  .page-head h1 { font-size: 1.3rem; }
}
/* longs libellés : retour à la ligne plutôt que débordement */
.list .title, .list .sub, .attention .att-label, .load-name { overflow-wrap: anywhere; }
.card { min-width: 0; }
