:root {
  /* Identité GéoDetect — accent orange #E8722C (charbon #23272B pour les titres).
     Le vert reste uniquement la couleur sémantique "faible risque / sûr"
     (--bg-success / --text-success), jamais l'accent d'interface. */
  --surface-0: #ffffff;
  --surface-1: #f7f6f4;
  --surface-2: #f2f1ee;
  --border: #e5e3df;
  --border-strong: #d8d6d2;
  --text-primary: #23272b;
  --text-secondary: #6b7075;
  --text-muted: #9a9ea3;
  --bg-accent: #f9e3d3;
  --text-accent: #e8722c;
  --border-accent: #e8722c;
  --fill-accent: #e8722c;
  --on-accent: #ffffff;
  --bg-danger: #f7e3e1;
  --text-danger: #c4453a;
  --bg-warning: #fbf0dc;
  --text-warning: #b57a1e;
  --bg-success: #e3efe7;
  --text-success: #3e7c4f;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-badge: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-0: #1c1e1d;
    --surface-1: #17181a;
    --surface-2: #232525;
    --border: rgba(229, 227, 223, 0.14);
    --border-strong: rgba(229, 227, 223, 0.24);
    --text-primary: #edecea;
    --text-secondary: #b3b7ba;
    --text-muted: #797d80;
    --bg-accent: #332218;
    --text-accent: #f2a467;
    --border-accent: #e8722c;
    --fill-accent: #e8722c;
    --on-accent: #ffffff;
    --bg-danger: #3a1d1a;
    --text-danger: #f2a29c;
    --bg-warning: #3a2c12;
    --text-warning: #f0c674;
    --bg-success: #1a2e20;
    --text-success: #8fd6a3;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--surface-1);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app { display: flex; height: 100vh; background: var(--surface-1); }

/* Sidebar */
.sidebar { width: 250px; min-width: 250px; background: var(--surface-0); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.logo { padding: 20px; border-bottom: 1px solid var(--border); }
.logo-text { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.logo-icon { width: 18px; height: 18px; flex-shrink: 0; }
.logo-sub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.nav-section { font-size: 10px; font-weight: 600; color: var(--text-muted); padding: 16px 20px 6px; letter-spacing: 0.05em; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 38px; margin: 0 8px; padding: 0 12px;
  font-size: 14px; color: var(--text-secondary); cursor: pointer; text-decoration: none; border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--bg-accent); color: var(--text-accent); font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-user {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}
.nav-user-nom { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.nav-user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.nav-logout {
  display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--radius-sm); color: var(--text-secondary); transition: background 0.15s, color 0.15s;
}
.nav-logout:hover { background: var(--bg-danger); color: var(--text-danger); }
.nav-logout svg { width: 16px; height: 16px; }

/* Login page */
.page-login {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--surface-1); font-family: var(--font-sans); color: var(--text-primary); margin: 0;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface-0); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px;
}
.login-logo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.login-logo .logo-icon { width: 22px; height: 22px; flex-shrink: 0; }
.login-sub { font-size: 13px; color: var(--text-secondary); margin: 6px 0 22px; }
.login-submit { width: 100%; justify-content: center; margin-top: 6px; }

/* Main / topbar
   Normal vertical scroll by default (importer, paramètres, rapport,
   historique can all be taller than the viewport). Vue chantier's map
   page opts back into a fixed, non-scrolling layout via .contenu-fixe
   on .content, since its map must fill the screen exactly. */
.main { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.topbar { height: 56px; background: var(--surface-0); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; flex-shrink: 0; }
.breadcrumb { font-size: 14px; color: var(--text-secondary); }
.breadcrumb span { color: var(--text-primary); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius); font-size: 13px;
  cursor: pointer; border: 1px solid var(--border-strong); background: var(--surface-0); color: var(--text-primary);
  font-weight: 500; text-decoration: none; transition: background 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--fill-accent); color: var(--on-accent); border-color: transparent; }
.btn-primary:hover { background: var(--fill-accent); opacity: 0.92; }
.btn svg { width: 14px; height: 14px; }
.btn-desactive { pointer-events: none; opacity: 0.6; cursor: default; }

.content { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.map-area { flex: 1; position: relative; overflow: hidden; background: #ebf2e4; }
.map-area iframe { width: 100%; height: 100%; border: none; }
.map-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 13px; }
.bandeau-info { position: absolute; top: 0; left: 0; right: 0; z-index: 10; background: var(--bg-warning);
  color: var(--text-warning); font-size: 12px; padding: 8px 16px; text-align: center; }

/* Right panel */
.panel { width: 380px; min-width: 380px; background: var(--surface-0); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
.tab-row { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tab {
  flex: 1; text-align: center; padding: 13px 0; font-size: 13px; color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; background: none; border-top: none; border-left: none; border-right: none;
  font-family: inherit;
}
.tab.active { color: var(--text-accent); font-weight: 500; border-bottom-color: var(--text-accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-title { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.metric-row { display: flex; gap: 10px; }
.metric-card { flex: 1; background: var(--surface-1); border-radius: var(--radius); padding: 10px 14px; }
.metric-val { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.metric-lbl { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.network-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); }
.network-row:last-child { border-bottom: none; }
.net-info { display: flex; align-items: center; gap: 8px; }
.net-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.net-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.net-detail { font-size: 11px; color: var(--text-secondary); margin-top: 1px; font-variant-numeric: tabular-nums; }
.risk-badge { font-size: 11px; padding: 2px 10px; border-radius: var(--radius-badge); font-weight: 500; }
.risk-eleve { background: var(--bg-danger); color: var(--text-danger); }
.risk-moyen { background: var(--bg-warning); color: var(--text-warning); }
.risk-faible { background: var(--bg-success); color: var(--text-success); }

.chantier-selector { display: flex; flex-direction: column; gap: 8px; }
.chantier-item { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-0); text-decoration: none; display: block; transition: background 0.15s, border-color 0.15s; }
.chantier-item:hover { background: var(--surface-2); }
.chantier-item.selected { border-color: var(--border-accent); background: var(--bg-accent); }
.chantier-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.chantier-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* Forms */
.form-page { padding: 32px; max-width: 480px; }
.form-page h1 { font-size: 18px; margin-bottom: 20px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px; }
.form-group input[type="text"], .form-group input[type="file"], .form-group input[type="number"],
.form-group input[type="email"], .form-group input[type="password"] {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-0); color: var(--text-primary); font-size: 13px; font-family: inherit;
}
.form-hint { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.form-erreurs { background: var(--bg-danger); color: var(--text-danger); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; font-size: 13px; }
.form-erreurs ul { margin: 0; padding-left: 18px; }
#mini-carte { height: 240px; border-radius: var(--radius); border: 1px solid var(--border-strong); margin-bottom: 10px; }
.numero-sous-zone {
  background: #E8722C; color: #ffffff; font-size: 12px; font-weight: 700; border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.boutons-carte { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.position-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.label-petit { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.form-group select {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-0); color: var(--text-primary); font-size: 13px; font-family: inherit;
}
.form-group input:disabled, .form-group select:disabled { color: var(--text-muted); background: var(--surface-1); }
.champ-bientot { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-style: italic; }
.table-wrap { padding: 24px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

.about-card { max-width: 480px; padding: 32px; }
.about-card h1 { font-size: 18px; margin-bottom: 16px; }
.about-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.about-row span:first-child { color: var(--text-secondary); }
