/* SIDAP — système de design : premium, sobre, clair/sombre, responsive Windows ↔ mobile */
:root {
  color-scheme: light;
  --bg: #f4f6fa; --bg-2: #eef1f6; --surface: #ffffff; --surface-2: #f8f9fc; --surface-3: #f1f4f9;
  --border: #e3e7ee; --border-strong: #cfd6e1;
  --text: #141a24; --text-2: #5b6576; --text-3: #8a93a3;
  --accent: #2563eb; --accent-2: #1d4ed8; --accent-soft: #e8efff; --accent-ink: #ffffff;
  --good: #0f9d2e; --good-soft: #e6f6ea; --warn: #b7791f; --warn-soft: #fff5e0;
  --serious: #d4622b; --serious-soft: #fdeee6; --crit: #dc3c3d; --crit-soft: #fdecec; --info-soft: #eaf2fe;
  /* palette de données (référence validée) */
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600; --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --grid: #e7e7e7; --axis: #c2c2c2; --chart-ink: #191919; --chart-ink-2: #666666; --chart-surface: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05); --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .14);
  --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, .35);
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --sidebar: 248px; --topbar: 60px; --statusbar: 28px;
  --font: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0e15; --bg-2: #0e131c; --surface: #121823; --surface-2: #161d2a; --surface-3: #1b2331;
    --border: #232c3b; --border-strong: #2f3a4d;
    --text: #e8ecf3; --text-2: #a3adbd; --text-3: #6f7a8c;
    --accent: #4b8df8; --accent-2: #6aa0fa; --accent-soft: #15233d; --accent-ink: #ffffff;
    --good: #2fbf4d; --good-soft: #10261a; --warn: #f2b33d; --warn-soft: #2a2110; --serious: #f18a59; --serious-soft: #2b1a12;
    --crit: #eb6263; --crit-soft: #2c1415; --info-soft: #132036;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05; --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
    --grid: #263041; --axis: #3a4558; --chart-ink: #efefef; --chart-ink-2: #9c9c9c; --chart-surface: #121823;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -14px rgba(0, 0, 0, .6); --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e15; --bg-2: #0e131c; --surface: #121823; --surface-2: #161d2a; --surface-3: #1b2331;
  --border: #232c3b; --border-strong: #2f3a4d;
  --text: #e8ecf3; --text-2: #a3adbd; --text-3: #6f7a8c;
  --accent: #4b8df8; --accent-2: #6aa0fa; --accent-soft: #15233d; --accent-ink: #ffffff;
  --good: #2fbf4d; --good-soft: #10261a; --warn: #f2b33d; --warn-soft: #2a2110; --serious: #f18a59; --serious-soft: #2b1a12;
  --crit: #eb6263; --crit-soft: #2c1415; --info-soft: #132036;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05; --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
  --grid: #263041; --axis: #3a4558; --chart-ink: #efefef; --chart-ink-2: #9c9c9c; --chart-surface: #121823;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -14px rgba(0, 0, 0, .6); --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 8px; }
.between { justify-content: space-between; } .end { justify-content: flex-end; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- Layout */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; grid-template-rows: var(--topbar) 1fr var(--statusbar); height: 100vh; height: 100dvh; }
.app.collapsed { --sidebar: 72px; }
.sidebar { grid-row: 1 / 4; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; z-index: 30; }
.brand { height: var(--topbar); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: #030818; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .5px; box-shadow: 0 6px 16px -6px rgba(37,99,235,.7); flex-shrink: 0; object-fit: cover; }
.login-logo { width: min(400px, 100%); display: block; margin: 0 0 22px -12px; position: relative; z-index: 1; filter: drop-shadow(0 18px 40px rgba(37,99,235,.45)); }
.ai-logo { background: linear-gradient(135deg, #2563eb, #f59e0b); }
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: .3px; } .brand-sub { font-size: 10.5px; color: var(--text-3); line-height: 1.1; }
.collapsed .brand-text, .collapsed .nav-label, .collapsed .nav-section { display: none; }
.nav { overflow-y: auto; padding: 10px; flex: 1; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px; color: var(--text-3); padding: 14px 10px 6px; font-weight: 650; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); font-weight: 520; margin: 1px 0; position: relative; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.router-link-active, .nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.router-link-active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav .count { margin-left: auto; font-size: 11px; background: var(--crit); color: #fff; border-radius: 999px; padding: 0 6px; font-weight: 650; }
.collapsed .nav a { justify-content: center; } .collapsed .nav .count { position: absolute; top: 2px; right: 6px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px; }

.topbar { grid-column: 2; display: flex; align-items: center; gap: 10px; padding: 0 18px; background: var(--surface); background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); z-index: 20; }
.search { flex: 1; max-width: 560px; position: relative; }
.search input { width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); padding: 0 12px 0 38px; outline: none; transition: .15s; }
.search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .search-ico { position: absolute; left: 11px; top: 0; bottom: 0; display: flex; align-items: center; color: var(--text-3); pointer-events: none; }
.search kbd { position: absolute; right: 10px; top: 9px; font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--surface); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; padding: 6px; z-index: 50; }
.search-results .item { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.search-results .item:hover { background: var(--surface-3); }
.main { grid-column: 2; overflow: auto; min-height: 0; position: relative; }
.page { padding: 22px 26px 40px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 720; letter-spacing: -.2px; margin: 0; }
.page-sub { color: var(--text-2); margin-top: 2px; }
.statusbar { grid-column: 2; display: flex; align-items: center; gap: 16px; padding: 0 16px; font-size: 11.5px; color: var(--text-2); background: var(--surface); border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.statusbar .sep { flex: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); flex-shrink: 0; }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); } .dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.crit { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); } .dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------------------------------------------------------------- Mobile */
.bottomnav { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 56px 1fr auto; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .app.collapsed { --sidebar: 248px; }
  .collapsed .brand-text, .collapsed .nav-label, .collapsed .nav-section { display: initial; }
  .topbar, .main { grid-column: 1; } .topbar { padding: 0 12px; }
  .statusbar { display: none; }
  .page { padding: 16px 14px 96px; }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); grid-column: 1; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 25; }
  .bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 10.5px; color: var(--text-2); background: none; border: 0; font-weight: 560; }
  .bottomnav .router-link-active { color: var(--accent); }
  .hide-mobile { display: none !important; }
  .page-title { font-size: 19px; }
  .search kbd { display: none; }
}
@media (min-width: 901px) { .show-mobile { display: none !important; } }
.scrim { position: fixed; inset: 0; background: rgba(8, 12, 20, .45); z-index: 29; backdrop-filter: blur(2px); }

/* ---------------------------------------------------------------- Composants */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.card-title { font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 14px 16px 16px; } .card-body.flush { padding: 0; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .g4 .kpi-value { font-size: 21px; } .g4 .kpi { padding: 12px; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 580; cursor: pointer; transition: .12s; white-space: nowrap; user-select: none; }
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px -8px var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--crit); } .btn.danger.solid { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; } .btn.lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 11px; }
.btn.icon { width: 36px; padding: 0; } .btn.sm.icon { width: 30px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.btn-group button { border: 0; background: none; padding: 0 12px; height: 34px; cursor: pointer; color: var(--text-2); font-weight: 560; display: inline-flex; align-items: center; gap: 6px; }
.btn-group button.on { background: var(--accent-soft); color: var(--accent); }
.icon-btn { position: relative; }
.icon-btn .badge-count { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--crit); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }

.input, select.input, textarea.input { width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); padding: 0 11px; outline: none; transition: .12s; }
textarea.input { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--crit); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; } }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 22px; background: var(--border-strong); transition: .15s; flex-shrink: 0; cursor: pointer; border: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on { background: var(--accent); } .switch.on::after { left: 19px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 620; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.serious { background: var(--serious-soft); color: var(--serious); } .badge.crit { background: var(--crit-soft); color: var(--crit); }
.badge.info { background: var(--info-soft); color: var(--accent); } .badge.violet { background: rgba(106,76,226,.14); background: color-mix(in srgb, var(--s7) 14%, transparent); color: var(--s7); }
.badge svg { width: 12px; height: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; cursor: pointer; color: var(--text-2); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--text); } .tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .n { font-size: 11px; background: var(--surface-3); border-radius: 999px; padding: 0 7px; color: var(--text-2); }

/* Tables */
.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-2); font-weight: 620; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1; cursor: default; }
.tbl th.sortable { cursor: pointer; } .tbl th.sortable:hover { color: var(--text); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl tbody tr { transition: background .1s; } .tbl tbody tr.clickable { cursor: pointer; } .tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 12.5px; gap: 10px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .input { height: 34px; }
.mobile-list { display: none; }
@media (max-width: 700px) {
  .tbl.responsive { display: none; } .mobile-list { display: block; }
  .mobile-list .mi { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
  .mobile-list .mi:active { background: var(--surface-2); }
}
.progress { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; min-width: 60px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #0ea5e9); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex-shrink: 0; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }

/* KPI */
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-size: 12.5px; font-weight: 580; }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi-icon.good { background: var(--good-soft); color: var(--good); } .kpi-icon.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-icon.crit { background: var(--crit-soft); color: var(--crit); } .kpi-icon.violet { background: rgba(106,76,226,.14); background: color-mix(in srgb, var(--s7) 14%, transparent); color: var(--s7); }
.kpi-value { font-size: 26px; font-weight: 740; letter-spacing: -.5px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--text-2); margin-left: 3px; letter-spacing: 0; }
.kpi-foot { font-size: 12px; color: var(--text-2); }
.kpi.link { cursor: pointer; } .kpi.link:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }

/* Dashboard widgets */
.widgets { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; grid-auto-flow: dense; }
.w { grid-column: span var(--span, 3); min-width: 0; transition: transform .15s, opacity .15s; }
.w > div, .w .card.kpi { height: 100%; }
.w.dragging { opacity: .4; } .w.drop-target { outline: 2px dashed var(--accent); outline-offset: 3px; border-radius: var(--r); }
.edit-mode .w { cursor: grab; } .edit-mode .w .card { border-style: dashed; }
.w-tools { display: none; gap: 4px; } .edit-mode .w-tools { display: flex; }
@media (max-width: 1200px) { .w { grid-column: span min(var(--span, 3) * 2, 12); } }
@media (max-width: 700px) { .w { grid-column: span 12 !important; } }
.chart { width: 100%; height: 260px; } .chart.tall { height: 320px; } .chart.short { height: 200px; }

/* Lists & timeline */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); }
.li:first-child { border-top: 0; } .li.clickable { cursor: pointer; } .li.clickable:hover { background: var(--surface-2); }
.timeline { position: relative; padding-left: 18px; } .timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 14px; } .tl-item::before { content: ""; position: absolute; left: -17px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.empty { padding: 40px 20px; text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .icon-wrap { width: 48px; height: 48px; border-radius: 14px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }

/* Drawer & modal */
.drawer-scrim { position: fixed; inset: 0; background: rgba(8, 12, 20, .42); z-index: 60; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--surface); z-index: 61; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease; padding-top: env(safe-area-inset-top, 0px); }
.drawer.wide { width: min(1040px, 100vw); }
@media (max-width: 600px) { .drawer-head { flex-wrap: wrap; padding: 12px 14px; } .drawer-head > .grow { flex: 1 0 calc(100% - 52px); order: 0; } .drawer-head > .btn.ghost.icon:last-child { order: 1; } .drawer-head > :not(.grow):not(:last-child) { order: 2; } .drawer-body { padding: 14px; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow: auto; padding: 20px; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.modal { position: fixed; z-index: 70; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(8, 12, 20, .45); animation: fade .15s; }
.modal-box { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: min(520px, 100%); max-height: 90vh; overflow: auto; border: 1px solid var(--border); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } } @keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; right: 18px; bottom: 40px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 11px 14px; display: flex; gap: 10px; align-items: flex-start; animation: slide .2s; }
.toast.good { border-left-color: var(--good); } .toast.crit { border-left-color: var(--crit); } .toast.warn { border-left-color: var(--warn); }
@media (max-width: 900px) { .toasts { bottom: 84px; right: 12px; left: 12px; max-width: none; } }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); min-width: 260px; z-index: 50; overflow: hidden; }
.dropdown .di { padding: 9px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text); }
.dropdown .di:hover { background: var(--surface-3); }
.notif-panel { width: min(400px, calc(100vw - 24px)); max-height: 70vh; display: flex; flex-direction: column; }
.notif { padding: 11px 14px; border-top: 1px solid var(--border); display: flex; gap: 10px; cursor: pointer; }
.notif.unread { background: var(--accent-soft); background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.notif:hover { background: var(--surface-3); }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); display: flex; flex-direction: column; min-height: 200px; max-height: calc(100vh - 260px); }
.kcol-head { padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13px; border-bottom: 1px solid var(--border); }
.kcol-body { padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow-sm); }
.kcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.prio-urgente { border-left: 3px solid var(--crit); } .prio-haute { border-left: 3px solid var(--serious); }

/* Calendrier */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.cal-h { padding: 8px; font-size: 11px; font-weight: 650; text-transform: uppercase; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-d { min-height: 104px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.cal-d:nth-child(7n) { border-right: 0; } .cal-d.out { background: var(--surface-2); color: var(--text-3); } .cal-d.today .cal-n { background: var(--accent); color: #fff; }
.cal-n { font-size: 12px; font-weight: 650; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.cal-ev { font-size: 11px; padding: 2px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) { .cal-d { min-height: 64px; } .cal-ev { font-size: 0; height: 6px; padding: 0; } }

/* Carte */
.map { width: 100%; height: 100%; min-height: 300px; border-radius: var(--r); z-index: 0; background: var(--surface-3); }
.map-layout { display: grid; grid-template-columns: 360px 1fr; gap: 14px; height: calc(100vh - var(--topbar) - var(--statusbar) - 120px); min-height: 520px; }
@media (max-width: 900px) { .map-layout { grid-template-columns: 1fr; height: auto; } .map-layout .map { height: 56vh; } }
.leaflet-container { font: inherit; background: var(--surface-3); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content { margin: 12px 14px; }
:root[data-theme="dark"] .leaflet-tile, .dark-tiles .leaflet-tile { filter: brightness(.72) invert(1) contrast(.9) hue-rotate(200deg) saturate(.35) brightness(.85); }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,.35); }
.pin > span { transform: rotate(45deg); color: #fff; font-weight: 750; font-size: 11px; }
.tech-pin { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 750; font-size: 12px; border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.35); position: relative; }
.tech-pin.live::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 2px solid currentColor; opacity: .5; animation: ring 1.8s infinite; }
.tech-pin.stale { opacity: .55; filter: grayscale(.6); border-style: dashed; }
@keyframes ring { from { transform: scale(.8); opacity: .7; } to { transform: scale(1.5); opacity: 0; } }

/* Chat IA */
.chat { display: grid; grid-template-columns: 260px 1fr; gap: 14px; height: calc(100vh - var(--topbar) - var(--statusbar) - 110px); min-height: 520px; }
@media (max-width: 900px) { .chat { grid-template-columns: 1fr; height: calc(100dvh - 210px); } .chat .conv-list { display: none; } }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 860px; display: flex; gap: 10px; } .msg.user { align-self: flex-end; flex-direction: row-reverse; }
.bubble { padding: 11px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); line-height: 1.55; min-width: 0; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: #fff; border-color: var(--accent); border-bottom-right-radius: 4px; }
.msg.bot .bubble { border-bottom-left-radius: 4px; }
.bubble table { font-size: 12px; margin-top: 8px; }
.composer { border-top: 1px solid var(--border); padding: 12px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.action-box { margin-top: 10px; border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 10px; padding: 10px 12px; }

/* Divers */
.stat-line { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); gap: 12px; }
.stat-line:last-child { border-bottom: 0; } .stat-line > span:first-child { color: var(--text-2); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 13px; } .kv > dt { color: var(--text-2); } .kv > dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv > dd { margin-bottom: 8px; } }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo { aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: var(--surface-3); position: relative; border: 1px solid var(--border); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .tag { position: absolute; left: 6px; top: 6px; }
.sigpad { width: 100%; height: 200px; border: 1px dashed var(--border-strong); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.plan { position: relative; aspect-ratio: 16/9; border-radius: var(--r); border: 1px solid var(--border); overflow: hidden;
  background-color: var(--surface-2); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 32px 32px; }
.plan .cam { position: absolute; transform: translate(-50%, -50%); cursor: pointer; }
.plan .cone { position: absolute; transform-origin: 0 50%; height: 0; border-top: 34px solid transparent; border-bottom: 34px solid transparent; opacity: .16; top: -34px; left: 0; }
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: radial-gradient(1200px 600px at 10% 10%, #1d4ed8 0, #0b1630 55%, #050a17 100%); color: #e8eefc; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, transparent, #000 40%, transparent); }
.login-form { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.login-box { width: min(400px, 100%); }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login-hero { display: none; } }
.feature { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; position: relative; z-index: 1; }
.feature .fi { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.1); display: grid; place-items: center; flex-shrink: 0; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.offline-banner { background: var(--warn-soft); color: var(--warn); padding: 7px 16px; font-size: 12.5px; font-weight: 600; display: flex; gap: 8px; align-items: center; justify-content: center; }
.hero-mission { background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%); color: #fff; border: 0; }
.hero-mission .muted { color: rgba(255,255,255,.8); }
.code-box { font-family: var(--mono); font-size: 12px; background: var(--surface-3); border-radius: 8px; padding: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.md p { margin: 0 0 8px; } .md p:last-child { margin: 0; } .md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; } .md strong { font-weight: 680; }
@media (forced-colors: active) { .badge, .btn, .card { border: 1px solid CanvasText; } }
@media print { .sidebar, .topbar, .statusbar, .bottomnav, .no-print { display: none !important; } .app { display: block; } .main { overflow: visible; } }

/* Propositions de saisie sous les zones de texte (rapports terrain) */
.input.sg-add { margin-top: 6px; height: 30px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2, var(--surface)); border-style: dashed; cursor: pointer; }
.input.sg-add:hover { color: var(--accent); border-color: var(--accent); }

/* Connexion par matricule : fiche reconnue */
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary, #1d4ed8); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.id-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--good, #16a34a); border-radius: 12px; background: var(--surface); animation: fade .2s; }
.id-card.off { border-left-color: var(--crit, #dc2626); opacity: .9; }
.id-card .avatar { flex: none; }
.id-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin-top: 8px; font-size: 12.5px; }
.id-grid span { color: var(--faint, #64748b); }
.id-grid b { font-weight: 600; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- Messagerie interne */
.chat { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 210px); min-height: 460px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-items { flex: 1; overflow: auto; }
.chat-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.chat-item:hover { background: var(--surface-3); } .chat-item.on { background: var(--accent-soft); }
.chat-item .avatar, .chat-head .avatar { position: relative; flex: none; }
.avatar.grp { background: var(--accent); color: var(--accent-ink); }
.avatar .online { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--good); border: 2px solid var(--surface); }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-empty { align-items: center; justify-content: center; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.chat-back { display: none; }
.chat-body { flex: 1; overflow: auto; padding: 14px; background: var(--surface-2, var(--bg)); display: flex; flex-direction: column; gap: 4px; }
.chat-day { text-align: center; margin: 10px 0 4px; } .chat-day span { font-size: 11.5px; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); padding: 2px 10px; border-radius: 999px; text-transform: capitalize; }
.chat-sys { text-align: center; font-size: 12px; color: var(--text-3); margin: 4px 0; }
.bubble-row { display: flex; align-items: flex-end; gap: 4px; max-width: 78%; }
.bubble-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; padding: 8px 10px 4px; min-width: 90px; box-shadow: var(--shadow-sm); }
.bubble-row.mine .bubble { background: var(--accent-soft); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.bubble.urgent { border: 1.5px solid var(--crit); } .bubble.deleted { opacity: .6; font-style: italic; }
.bubble-from { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.bubble-urgent { display: flex; gap: 4px; align-items: center; font-size: 11px; font-weight: 700; color: var(--crit); text-transform: uppercase; margin-bottom: 3px; }
.bubble-reply { font-size: 12px; color: var(--text-2); border-left: 3px solid var(--accent); padding: 2px 8px; margin-bottom: 4px; background: var(--surface-3); border-radius: 4px; }
.bubble-text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.45; }
.bubble-img { max-width: 260px; max-height: 260px; border-radius: 10px; display: block; margin: 2px 0; }
.bubble-file { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 9px; background: var(--surface-3); color: inherit; text-decoration: none; min-width: 200px; font-size: 13px; }
.bubble-meta { display: flex; justify-content: flex-end; gap: 4px; align-items: center; font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.tick { display: inline-flex; color: var(--text-3); } .tick.read { color: #1e88e5; } .tick.fail { color: var(--crit); cursor: pointer; }
.bubble-actions { display: flex; flex-direction: column; opacity: 0; transition: opacity .15s; } .bubble-row:hover .bubble-actions { opacity: 1; }
.voice { display: flex; align-items: center; gap: 8px; min-width: 240px; }
.voice-bar { flex: 1; height: 6px; background: var(--surface-3); border-radius: 999px; cursor: pointer; overflow: hidden; min-width: 80px; }
.voice-fill { height: 100%; background: var(--accent); }
.chat-compose { border-top: 1px solid var(--border); padding: 10px; background: var(--surface); }
.compose-reply { font-size: 12.5px; color: var(--text-2); background: var(--surface-3); border-radius: 8px; padding: 4px 8px; margin-bottom: 6px; }
.rec-bar { gap: 10px; padding: 4px 2px; }
.count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; min-width: 18px; text-align: center; }
@media (max-width: 900px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - 190px); }
  .chat-list.hidden { display: none; } .chat-back { display: inline-flex; }
  .chat-main.chat-empty { display: none; } .bubble-row { max-width: 92%; }
}
/* ---------------------------------------------------------------- Messagerie clients / devis / GEO */
.mail-grid { display: grid; grid-template-columns: 280px 340px 1fr; height: calc(100vh - 250px); min-height: 460px; overflow: hidden; }
.mail-col { border-right: 1px solid var(--border); overflow: auto; min-width: 0; }
.mail-col:last-child { border-right: 0; }
.mail-msg { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.mail-msg.in { border-left: 4px solid var(--accent); } .mail-msg.out { border-left: 4px solid var(--good); }
.mail-body { white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; margin-top: 8px; }
@media (max-width: 1100px) { .mail-grid { grid-template-columns: 1fr; height: auto; } .mail-col { border-right: 0; border-bottom: 1px solid var(--border); max-height: 60vh; } }
.q-lines td { vertical-align: top; } .q-lines .input { height: 32px; font-size: 13px; padding: 0 8px; }
.q-totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; font-size: 13.5px; }
.q-totals .big { font-size: 17px; font-weight: 750; } .q-totals span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.catalog-pop { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 320px; overflow: auto; }
.catalog-pop .item { padding: 8px 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); font-size: 13px; }
.catalog-pop .item:hover { background: var(--surface-3); }
.layer-switch { position: absolute; z-index: 500; top: 10px; right: 10px; }
.geo-fiche .stat-line b { text-align: right; }
.arrow-pin { width: 0; height: 0; }
tr.link { cursor: pointer; } tr.link:hover td { background: var(--surface-3); }
/* Icône du sélecteur de fonds de carte (routière / satellite / hybride), embarquée hors ligne */
.leaflet-control-layers-toggle, .leaflet-retina .leaflet-control-layers-toggle { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='m12 3 9 5-9 5-9-5z'/%3E%3Cpath d='m3 13 9 5 9-5'/%3E%3C/svg%3E") !important; background-size: 24px 24px !important; }
.leaflet-control-layers-expanded { font-size: 13px; padding: 8px 10px; }
