:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #16202b;
  --muted: #677489;
  --line: #e2e8f0;
  --brand: #0f2a43;
  --brand-2: #1b3d5c;
  --accent: #14956a;
  --accent-soft: #e6f6ef;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #a96500;
  --warn-soft: #fff4e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 30, 45, .06), 0 8px 24px rgba(16, 30, 45, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ── Marque ─────────────────────────────────────────────────────────── */
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 17px; font-weight: 700; letter-spacing: .02em;
  color: #fff; padding: 4px 6px;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(150deg, #3ecf8e, #14956a);
  color: #06251a; font-size: 18px; font-weight: 800;
}
.brand-lg { color: var(--brand); font-size: 22px; padding: 0; }
.brand-lg .brand-mark { width: 38px; height: 38px; font-size: 22px; }

/* ── Connexion ──────────────────────────────────────────────────────── */
.login {
  min-height: 100%;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(20, 149, 106, .14), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, rgba(15, 42, 67, .16), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-card .muted { margin-top: -8px; }
.login-card .small { text-align: center; margin-top: 2px; }
.login-card .sso-block { display: flex; flex-direction: column; gap: 10px; }
.login-card .sso-block .small { margin: 0; }
.login-card a.btn { text-decoration: none; }
.login-card h2 { margin: 4px 0 0; font-size: 1.05rem; text-align: center; }
.linklike { border: 0; background: none; color: var(--accent, #2563eb); cursor: pointer;
  padding: 2px; font: inherit; text-decoration: underline; align-self: center; }

/* ── Structure ──────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100%; }
.sidebar {
  background: var(--brand);
  color: #cfe0ee;
  display: flex; flex-direction: column;
  padding: 18px 12px;
  gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav button {
  appearance: none; border: 0; background: transparent;
  color: #b9cddd; text-align: left;
  padding: 10px 12px; border-radius: 8px;
  font: inherit; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.nav button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav button[aria-current="page"] {
  background: rgba(62, 207, 142, .16);
  color: #fff;
  box-shadow: inset 2px 0 0 #3ecf8e;
}
.nav .nav-icon { width: 18px; display: inline-flex; align-items: center; justify-content: center; opacity: .9; }
.sidebar-foot {
  margin-top: auto; padding: 8px 10px; color: #7794ac;
  font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; justify-content: flex-end; min-width: 0; }
.topbar-tools, .topbar-identity { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user { font-weight: 600; }
.page { padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ── Primitives ─────────────────────────────────────────────────────── */
.btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: var(--surface-2); border-color: #cfd8e3; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0f815b; border-color: #0f815b; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #a93226; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }
.btn.icon { padding: 6px 9px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; }
.field > span:first-child { color: #3b4655; }
.field input, .field select, .field textarea {
  font: inherit; font-weight: 400;
  padding: 8px 10px;
  border: 1px solid #cfd8e3; border-radius: 8px;
  background: #fff; color: var(--ink);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(20, 149, 106, .25);
  border-color: var(--accent);
}
.field .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }

/* ── Cartes / KPI ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.card-body { padding: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 3px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--line);
}
.kpi[data-tone="danger"]::after { background: var(--danger); }
.kpi[data-tone="warn"]::after { background: var(--warn); }
.kpi[data-tone="ok"]::after { background: var(--accent); }
.kpi .kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.kpi .kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }

/* ── Tableaux ───────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1 1 220px; }
.toolbar input[type="search"] {
  font: inherit; padding: 7px 10px; border: 1px solid #cfd8e3; border-radius: 8px; width: 100%; background: #fff;
}
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfe; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table .primary-cell { display: flex; flex-direction: column; gap: 1px; }
.table .primary-cell strong { font-weight: 600; }
.table td.empty, .empty {
  text-align: center; color: var(--muted); padding: 34px 16px;
}

.badges { display: flex; gap: 5px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: #eef2f6; color: #475467;
}
.badge.ok { background: var(--accent-soft); color: #0c6b4a; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: #e8f1fd; color: #1d5fb0; }
.badge.muted { background: #f1f3f5; color: #7a8797; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12px; color: #475467;
}
.pill.live .dot { width: 7px; height: 7px; border-radius: 50%; background: #98a2b3; }
.pill.live.up .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(20, 149, 106, .14); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(20, 149, 106, .35); }
  70% { box-shadow: 0 0 0 7px rgba(20, 149, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(20, 149, 106, 0); }
}

/* ── Dialogues ──────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(13, 24, 36, .45);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .12s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(560px, 100%);
  max-height: min(86vh, 900px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(10, 25, 40, .3);
  overflow: hidden;
}
.modal.wide { width: min(760px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }
.modal .message { color: #3b4655; }
.close-x { appearance: none; border: 0; background: transparent; font: inherit; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.close-x:hover { background: var(--surface-2); color: var(--ink); }

/* ── Toasts ─────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; top: 16px; right: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(10, 25, 40, .16);
  padding: 11px 13px;
  display: flex; gap: 10px; align-items: flex-start;
  animation: slide .16s ease;
}
@keyframes slide { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast .toast-body { flex: 1; font-size: 13px; }
.toast .toast-title { font-weight: 700; margin-bottom: 1px; }
.toast[data-kind="error"] { border-left-color: var(--danger); }
.toast[data-kind="warn"] { border-left-color: var(--warn); }
.toast[data-kind="alarm"] { border-left-color: var(--danger); background: #fffafa; }
.toast .close-x { font-size: 16px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #d7e0ea; border-top-color: var(--accent);
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 24px; }

.def-list { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 13.5px; }
.def-list dt { color: var(--muted); }
.def-list dd { margin: 0; font-weight: 500; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { appearance: none; border: 0; background: #fff; font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 11px; cursor: pointer; color: #475467; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: #0c6b4a; }

.reading-list { display: flex; flex-direction: column; gap: 8px; }
.reading {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  display: flex; justify-content: space-between; gap: 12px; font-size: 13px;
}
.reading .when { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    padding: 10px 12px; gap: 12px; overflow-x: auto;
  }
  .sidebar .brand span:last-child { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav button { white-space: nowrap; padding: 8px 10px; }
  .sidebar-foot { display: none; }
  .topbar { flex-direction: column; align-items: flex-start; }
  /* Les deux groupes se fondent dans l'en-tête pour un retour à la ligne
     naturel sur petit écran. */
  .topbar-tools, .topbar-identity { display: contents; }
  .page { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .def-list { grid-template-columns: 1fr; gap: 2px; }
  .def-list dd { margin-bottom: 8px; }
}

/* Mobile étroit : l'en-tête tient en deux lignes lisibles. */
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar-right { gap: 6px; row-gap: 8px; }
  .page-heading { min-width: 0; }
  .global-search { order: -1; flex: 1 1 100%; max-width: none; }
  .global-search input { font-size: 14px; }
  .topbar-right .pill.live { display: none; } /* état aussi dans le bandeau bas */
  .topbar-right #org-name { display: none; } /* l'organisation reste visible dans Mon compte */
  .user { font-size: 13px; }
  .topbar-right .btn { padding: 6px 10px; font-size: 13px; }
  .alarms-button { font-size: 13px; padding: 6px 10px; }
  .icon-btn { padding: 5px 8px; }
}

/* ── Bandeau, recherche globale, son ────────────────────────────────── */
.page-heading { min-width: 180px; }
.global-search { position: relative; flex: 0 1 220px; max-width: 220px; min-width: 120px; }
#org-name { display: inline-block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.global-search input {
  font: inherit; font-size: 13px; width: 100%;
  padding: 7px 11px; border: 1px solid #cfd8e3; border-radius: 8px; background: #fff;
}
.global-search input:focus { outline: 2px solid rgba(20, 149, 106, .25); border-color: var(--accent); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
}
.search-item {
  appearance: none; border: 0; background: transparent; font: inherit; text-align: left;
  padding: 8px 11px; display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.search-item:hover { background: var(--surface-2); }
.search-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }
.icon-btn { font-size: 16px; padding: 6px 10px; }
.alarms-button .counter {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 999px; background: #eef2f6; color: #475467;
  font-size: 11.5px; font-weight: 700;
}
.alarms-button .counter.active { background: var(--danger); color: #fff; }
.statusbar {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 24px; border-top: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 12px;
}
.statusbar .danger { color: var(--danger); font-weight: 600; }
.statusbar .ok { color: #0c6b4a; font-weight: 600; }

/* ── Carte ──────────────────────────────────────────────────────────── */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; min-height: 70vh; }
.map {
  position: relative; overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--line); background: #dfe7ef;
  box-shadow: var(--shadow); touch-action: none; cursor: grab;
  background-image:
    linear-gradient(0deg, rgba(15, 42, 67, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 42, 67, .05) 1px, transparent 1px);
  background-size: 64px 64px;
}
.map.dragging { cursor: grabbing; }
.map-pickable { cursor: crosshair; }
.map-world { position: absolute; inset: 0; }
.map-tiles { position: absolute; inset: 0; }
.map-tile-layer { position: absolute; top: 0; left: 0; width: 1px; height: 1px; }
.map-tile {
  position: absolute; width: 256px; height: 256px; user-select: none;
  -webkit-user-drag: none; pointer-events: none;
}
.map-tile.missing { background: #e8eef5; }
.map-layers { position: absolute; inset: 0; transform-origin: 0 0; pointer-events: none; }
.map-layer-svg { position: absolute; top: 0; left: 0; overflow: visible; }
.map-layer-shape { pointer-events: auto; }
.map-layers-legend { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.map-layers-legend .layer-row {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff;
}
.map-layers-legend .layer-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.map-layers-legend .layer-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-layers-legend .dot { flex: none; }
.map-markers { position: absolute; inset: 0; pointer-events: none; }
.map-marker {
  position: absolute; transform: translate(-50%, -100%);
  appearance: none; border: 0; background: transparent; padding: 0;
  pointer-events: auto; cursor: pointer; width: 22px; height: 30px;
}
.map-marker-pin {
  display: block; width: 18px; height: 18px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(10, 25, 40, .35);
  background: #7a8797;
}
.map-marker.ok .map-marker-pin { background: var(--accent); }
.map-marker.warn .map-marker-pin { background: #e2a33a; }
.map-marker.danger .map-marker-pin { background: var(--danger); }
.map-marker.muted .map-marker-pin { background: #98a2b3; }
.map-marker.site { transform: translate(-50%, -50%); width: 26px; height: 26px; }
.map-marker.site .map-marker-pin { width: 22px; height: 22px; border-radius: 7px; transform: none; background: #6b4fbb; }
.map-marker.pick { transform: translate(-50%, -100%); }
.map-marker.pick .map-marker-pin { background: #6b4fbb; }
.map-marker.pulse .map-marker-pin { animation: marker-pulse 1.6s infinite; }
@keyframes marker-pulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .45); }
  70% { box-shadow: 0 0 0 12px rgba(192, 57, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
}
.map-controls { position: absolute; right: 10px; bottom: 44px; display: flex; flex-direction: column; gap: 6px; }
.map-zoom {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-size: 18px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
}
.map-reset {
  position: absolute; left: 10px; bottom: 10px;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 5px 9px; font: inherit; font-size: 12px; cursor: pointer; box-shadow: var(--shadow);
}
.map-scale {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(255, 255, 255, .9); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 7px; font-size: 11px; color: var(--muted);
}
.map-side { display: flex; flex-direction: column; overflow: hidden; max-height: calc(100vh - 160px); }
.map-side .card-body + .card-body { border-top: 1px solid var(--line); }
.alarm-quick { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.alarm-quick-item {
  appearance: none; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 8px 10px; font: inherit; display: flex; align-items: center; gap: 8px;
  cursor: pointer; text-align: left;
}
.alarm-quick-item:hover { background: var(--danger-soft); border-color: #f2c3bd; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #98a2b3; flex: none; }
.dot.ok { background: var(--accent); }
.dot.warn { background: #e2a33a; }
.dot.danger { background: var(--danger); }
.dot.muted { background: #98a2b3; }
.dot.site { background: #6b4fbb; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }

/* ── Fiche capteur ──────────────────────────────────────────────────── */
.link-button {
  appearance: none; border: 0; background: transparent; padding: 0; font: inherit;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  cursor: pointer; color: inherit; text-align: left;
}
.link-button:hover strong { color: var(--accent); text-decoration: underline; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-head h3 { margin: 0; font-size: 18px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.detail-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.detail-block h4 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.detail-actions { display: flex; flex-direction: column; gap: 7px; align-items: stretch; }
.detail-actions .btn { justify-content: center; }
.def-list.compact { grid-template-columns: 128px 1fr; font-size: 12.5px; gap: 6px 10px; }
.chart-canvas { width: 100%; height: 190px; display: block; border-radius: 8px; background: #fbfcfe; }
.reading-list.compact { margin-top: 10px; gap: 5px; }
.reading-list.compact .reading { padding: 6px 9px; font-size: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline-item { display: flex; gap: 9px; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; margin-top: 5px; flex: none; }
.timeline-item.alarm .timeline-dot { background: var(--danger); }
.timeline-item.maintenance_start .timeline-dot,
.timeline-item.maintenance_end .timeline-dot { background: #1d5fb0; }
.timeline-body { min-width: 0; }
.timeline-title { font-size: 13px; }
.location-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.location-inputs { display: flex; gap: 6px; flex: 1 1 220px; }
.location-inputs input { min-width: 0; }
.location-picker { display: flex; flex-direction: column; gap: 10px; }
.location-readout { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.location-current { font-family: ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; }

/* ── Impression du rapport PDF ──────────────────────────────────────── */
.print-report { display: none; }
@media print {
  @page { size: A4; margin: 16mm; }
  body.printing { background: #fff; }
  body.printing > *:not(.print-report) { display: none !important; }
  body.printing .print-report { display: block; color: #111; font-size: 11pt; }
  .print-head { display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 2px solid #0f2a43; padding-bottom: 8px; margin-bottom: 14px; }
  .print-head h1 { font-size: 16pt; }
  .print-brand { font-size: 14pt; font-weight: 800; color: #14956a; }
  .print-report section { margin-bottom: 16px; }
  .print-report h2 { font-size: 12pt; margin-bottom: 6px; }
  .print-report .def-list { grid-template-columns: 130px 1fr; }
  .print-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  .print-table th, .print-table td { border: 1px solid #ccc; padding: 4px 6px; text-align: left; }
  .print-foot { margin-top: 24px; border-top: 1px solid #ccc; padding-top: 6px; font-size: 8pt; color: #555; }
}

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-side { max-height: none; }
  .map { height: 62vh !important; }
  .detail-grid { grid-template-columns: 1fr; }
  .statusbar { padding: 8px 16px; }
  .global-search { max-width: none; flex-basis: 100%; order: -1; }
}

/* Secrets et codes de secours (double authentification) */
.secret-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 8px; background: rgba(127, 127, 127, 0.12); margin: 8px 0; }
.secret-box code.secret { font-size: 0.95rem; letter-spacing: 0.06em; word-break: break-all; }
.secret-link { word-break: break-all; font-family: ui-monospace, monospace; font-size: 0.72rem; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin: 10px 0; }
.recovery-codes code { padding: 6px 8px; border-radius: 6px; background: rgba(127, 127, 127, 0.12);
  font-family: ui-monospace, monospace; text-align: center; letter-spacing: 0.08em; }

/* Clés applicatives des capteurs (fiche capteur). */
.key-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.key-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.key-meta { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.key-meta .mono { overflow-wrap: anywhere; }

/* Sélecteur de langue */
.login { position: relative; }
#lang-login { position: absolute; top: 16px; right: 20px; }
.lang-toggle { min-width: 46px; text-align: center; }

/* Synchronisation SIG : actions par couche et badge de source. */
.map-layers-legend .layer-row { flex-wrap: wrap; }
.map-layers-legend .layer-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.map-layers-legend .badge {
  flex: none; font-size: 10px; letter-spacing: .04em; padding: 1px 5px;
  border-radius: 999px; background: #e8f0fb; color: #1f5fae; border: 1px solid #c9ddf5;
}
/* Recherche spatiale par rayon autour du centre de la carte. */
.spatial-search { border-top: 1px solid var(--line); }
.spatial-search .card-head { margin-bottom: 4px; }
.spatial-controls { display: flex; align-items: end; gap: 8px; margin: 8px 0; }
.spatial-controls .field { flex: 1; margin: 0; }
