:root {
  --bg: #f6f8f8; --surface: #fff; --surface-2: #f1f5f4; --border: #dfe6e4;
  --text: #0f172a; --muted: #5b6b70; --primary: #0f766e; --primary-dark: #115e59;
  --accent: #ccfbf1; --danger: #dc2626; --warning: #b45309;
  --shadow: 0 1px 2px rgba(15,23,42,.08), 0 6px 18px rgba(15,23,42,.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[v-cloak] { display: none; }
#app { min-height: 100%; display: flex; flex-direction: column; }
h1 { font-size: 24px; margin: 0 0 16px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h2 small { color: var(--muted); font-weight: 600; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 12px 0 4px; }
a { color: var(--primary); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* Boutons */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { border-color: #9fb1b5; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; }
.link.danger, .danger { color: var(--danger); }

/* Compte (coin haut droit) */
.account-corner { position: fixed; top: 12px; right: 14px; z-index: 1500; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-weight: 800; font-size: 16px; cursor: pointer; box-shadow: var(--shadow); }
.menu { position: absolute; right: 0; top: 48px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); min-width: 260px; padding: 6px; display: flex; flex-direction: column; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu a, .menu button { text-align: left; padding: 9px 10px; border-radius: 9px; color: var(--text); text-decoration: none; border: 0; background: none; font: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); }

/* Accueil : carte plein écran */
.home { position: fixed; inset: 0; }
.map { width: 100%; height: 100%; min-height: 300px; }
.map.full { position: absolute; inset: 0; }
.floating { position: absolute; top: 12px; left: 12px; width: 400px; max-width: calc(100% - 80px); z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-height: calc(100% - 24px); }
.searchbox { display: flex; align-items: center; gap: 6px; background: var(--surface); border-radius: 26px; box-shadow: var(--shadow); padding: 5px 8px 5px 5px; }
.searchbox .logo img { width: 36px; height: 36px; border-radius: 50%; display: block; }
.searchbox input { flex: 1; border: 0; padding: 8px 4px; font-size: 15px; outline: none; background: transparent; }
.searchbox .clear { border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.panel { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; overflow: auto; position: relative; }
.panel .row, .incident-row { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 9px; cursor: pointer; font: inherit; color: inherit; }
.panel .row:hover, .incident-row:hover { background: var(--surface-2); }
.panel .row span { font-size: 13px; color: var(--muted); }
.store { position: absolute; left: 12px; bottom: 26px; z-index: 900; background: var(--surface); padding: 8px 12px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 700; text-decoration: none; font-size: 13.5px; }
.steps { display: flex; gap: 8px; padding: 0; list-style: none; margin: 10px 0; }
.steps li { flex: 1; text-align: center; font-size: 12.5px; padding: 6px 4px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.steps li.done { background: var(--accent); color: var(--primary-dark); font-weight: 700; }

/* En-tête des espaces */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 70px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1000; flex-wrap: wrap; min-height: 62px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.org-name { font-weight: 700; color: var(--muted); border-left: 1px solid var(--border); padding-left: 14px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { padding: 7px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.nav a.active { background: var(--accent); color: var(--primary-dark); }
.badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }

/* Pages */
.page { padding: 24px 16px 60px; max-width: 1100px; margin: 0 auto; width: 100%; }
.page.narrow { max-width: 440px; padding-top: 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; position: relative; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 12px; }
.error { color: var(--danger); font-weight: 600; }
.info { color: var(--primary-dark); font-weight: 600; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 8px; }
.chip { display: inline-block; font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.code { font-size: 22px; font-weight: 800; letter-spacing: .04em; margin: 2px 0; }
.small-code { font-size: 15px; color: var(--primary); }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 10px 0 0; font-weight: 700; }
.note { background: var(--surface-2); border-radius: 9px; padding: 8px 10px; font-size: 14px; margin: 8px 0; }
.photo { width: 100%; border-radius: 10px; margin: 8px 0; max-height: 240px; object-fit: cover; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.actions.subtle { justify-content: space-between; border-top: 1px solid var(--border); padding-top: 8px; }
.item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item.clickable { cursor: pointer; text-decoration: none; color: inherit; }
.item.clickable:hover { background: var(--surface-2); }
.block { display: block; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); z-index: 2; }
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 2000; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.error { background: var(--danger); }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 12px; }
.form.inline { flex-direction: row; flex-wrap: wrap; }
.form label, .form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 500; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; margin: 4px 14px 4px 0; font-size: 14px; }
.fieldset { border: 1px solid var(--border); border-radius: 12px; margin: 14px 0 0; padding: 10px 12px; }
.fieldset legend { font-weight: 700; font-size: 14px; padding: 0 6px; }
.village-list { max-height: 200px; overflow: auto; margin-top: 8px; }
input, select { font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
.form.inline input { flex: 1; min-width: 220px; }
.links { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* Espace d'une organisation : tableau de bord */
.org { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.board { flex: 1; display: flex; flex-direction: column; min-height: 0; height: calc(100vh - 62px); }
.kpis { display: flex; gap: 10px; padding: 12px 16px; flex-wrap: wrap; align-items: stretch; border-bottom: 1px solid var(--border); background: var(--surface); }
.kpis.inline { padding: 0; border: 0; background: none; margin-bottom: 14px; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 8px 14px; min-width: 120px; }
.kpi b { display: block; font-size: 22px; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi.alert b { color: var(--danger); }
.kpi-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.create { margin: 12px 16px; flex-shrink: 0; max-height: 46vh; overflow: auto; }
.board-body { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 340px; }
.board-list { overflow: auto; border-right: 1px solid var(--border); background: var(--surface); }
.filters { display: flex; gap: 8px; padding: 8px; align-items: center; }
.filters select { flex: 1; font-size: 13px; padding: 6px 8px; }
.tabs { display: flex; gap: 4px; }
.tabs.wide { padding: 0 0 12px; flex-wrap: wrap; }
.tabs button { flex: 1; border: 1px solid var(--border); background: var(--surface); border-radius: 9px; padding: 7px 10px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.incident-row { flex-direction: row; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); border-radius: 0; }
.incident-row.selected { background: var(--accent); }
.incident-row.fresh { animation: fresh 1.2s ease-in-out 4; }
@keyframes fresh { 50% { background: #fee2e2; } }
.incident-row .grow { display: flex; flex-direction: column; flex: 1; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.dot.big { width: 22px; height: 22px; }
.board-map-wrap { position: relative; min-height: 0; }
.detail { position: absolute; top: 12px; right: 12px; width: 380px; max-height: calc(100% - 24px); overflow: auto; z-index: 500; margin: 0; }
.detail-head { display: flex; align-items: center; gap: 10px; }
.detail-head > div { flex: 1; }
.detail-head h2 { margin: 0; }
.assign { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.assign label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13.5px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr.muted td { opacity: .6; }

/* Dessin sur la carte */
.draw-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; padding: 10px; border-radius: 10px; background: #f5f3ff; }
.drawing .leaflet-container, .drawing .leaflet-interactive { cursor: crosshair; }

/* Intégration */
.snippet { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; white-space: pre; }

/* Bilan */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 200px; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar { width: 100%; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; display: flex; justify-content: center; }
.bar span { color: #fff; font-size: 11px; font-weight: 700; padding-top: 2px; }
.bar-col small { color: var(--muted); font-size: 11.5px; }

/* Marqueurs */
.pin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pin.pulse { animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.6); } 100% { box-shadow: 0 0 0 16px rgba(220,38,38,0); } }
.bubble { background: var(--primary); color: #fff; border: 3px solid #fff; border-radius: 999px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* Téléphone */
@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  .floating { width: auto; right: 64px; max-width: none; }
  .floating .panel { max-height: 55vh; }
  .store { display: none; }
  .topbar { padding-right: 64px; }
  .org-name { border: 0; padding: 0; width: 100%; }
  .nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; }
  .nav a { white-space: nowrap; }
  .board { height: auto; }
  .kpis { display: grid; grid-template-columns: 1fr 1fr; padding: 10px 12px; }
  .kpis.inline { display: grid; }
  .kpi { min-width: 0; }
  .kpi-actions { grid-column: 1 / -1; margin-left: 0; }
  .kpi-actions .btn { flex: 1; }
  .board-body { display: flex; flex-direction: column; }
  .board-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 45vh; }
  .board-map-wrap .map { height: 60vh; }
  .detail { position: static; width: auto; max-height: none; margin: 12px; }
  .form.inline input { min-width: 0; }
  .table th:nth-child(2), .table td:nth-child(2) { display: none; }
}
