:root {
  --bg: #0f1720;
  --panel: rgba(22, 30, 40, 0.92);
  --panel-solid: #161e28;
  --accent: #19a7ce;
  --text: #e7eef5;
  --muted: #93a4b5;
  --line: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); }
#map { position: absolute; inset: 0; background: #aadaff; z-index: 0; }

/* Menus déroulants (select) — thème sombre uniforme + flèche custom */
select {
  appearance: none; -webkit-appearance: none;
  background-color: var(--panel-solid);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2393a4b5' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 30px 8px 10px;
  font-size: 12px;
  cursor: pointer;
}
select:hover { border-color: rgba(255,255,255,0.22); }
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(25,167,206,0.25); }
select option { background: var(--panel-solid); color: var(--text); }
.full { width: 100%; }

/* Cases à cocher — couleur d'accent + taille homogène */
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* Barre supérieure */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 52px; z-index: 500;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--panel); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 13px; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.topctrl { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#model-select { max-width: 230px; }
#clock { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); text-align: right; line-height: 1.1; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
#clock:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.acct-btn { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.acct-btn:hover { border-color: var(--accent); }

/* Menu déroulant (Zones) */
.menu-wrap { position: relative; }
.dropdown { display: none; position: absolute; top: calc(100% + 6px); right: 0; width: 250px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); padding: 6px; z-index: 1500; }
.dropdown.show { display: block; }
.menu-item { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); border: none; border-radius: 7px; padding: 9px 10px; font-size: 13px; cursor: pointer; }
.menu-item:hover { background: rgba(25,167,206,0.18); }
.menu-item.active { background: var(--accent); color: #fff; }
.menu-sep { border-top: 1px solid var(--line); margin: 6px 2px; }
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 4px 10px; }
.zone-list { max-height: 220px; overflow-y: auto; }
.zone-item { display: flex; align-items: center; gap: 6px; border-radius: 7px; padding: 2px 4px 2px 10px; }
.zone-item:hover { background: rgba(255,255,255,0.06); }
.zi-name { flex: 1; font-size: 13px; cursor: pointer; padding: 7px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zi-del { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px 8px; border-radius: 6px; }
.zi-del:hover { color: #ff8a80; background: rgba(255,138,128,0.12); }
.zone-empty { color: var(--muted); font-size: 12px; padding: 6px 10px; }

/* Écran de connexion (site privé) */
.gate { position: fixed; inset: 0; z-index: 3000; background: radial-gradient(circle at 50% 30%, #16222e, #0b1219); display: none; align-items: center; justify-content: center; padding: 16px; }
.gate.show { display: flex; }
.gate-box { width: min(360px, 94vw); }
.gate-brand { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 16px; }
.gate-sub { font-size: 14px; color: var(--text); text-align: center; margin: 0 0 14px; }

/* Modale d'authentification */
.modal-overlay { position: absolute; inset: 0; z-index: 2000; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(340px, 92vw); position: relative; max-height: 90vh; overflow-y: auto; }
/* Modal profil : grand et confortable */
#profile-modal .modal { width: min(680px, 96vw); padding: 30px 34px; max-height: 92vh; }
#profile-modal .modal h2 { font-size: 22px; }
#profile-modal .modal .fld { font-size: 14px; margin-top: 16px; }
#profile-modal .modal input, #profile-modal .modal select { font-size: 14px; padding: 12px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal input { width: 100%; background: #0f1720; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 13px; margin-bottom: 10px; }
.modal input[type="range"] { padding: 0; background: transparent; border: none; accent-color: var(--accent); margin-bottom: 4px; }
.modal input[type="checkbox"] { width: auto; margin: 0; padding: 0; border: none; background: transparent; border-radius: 0; accent-color: var(--accent); }
.modal .fld { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.modal .chk { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text); margin: 8px 0; }
.modal-x { position: absolute; top: 10px; right: 10px; background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }
.auth-msg { font-size: 12px; color: #6ee7a0; margin-bottom: 8px; min-height: 0; }
.auth-msg.err { color: #ff8a80; }
.auth-switch { text-align: center; margin: 10px 0; }
.auth-switch a { color: var(--accent); font-size: 12px; text-decoration: none; }
.auth-sep { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 11px; margin: 12px 0; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.auth-sep span { padding: 0 10px; }
.oauth-btn { width: 100%; background: #fff; color: #222; border: none; border-radius: 8px; padding: 10px; font-size: 13px; font-weight: 600; cursor: pointer; margin-bottom: 8px; }
.oauth-btn.apple { background: #000; color: #fff; }
.auth-note { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* Éditeur de polaire */
.modal-wide { width: min(560px, 95vw); }
.polar-grid { overflow: auto; max-height: 56vh; border: 1px solid var(--line); border-radius: 8px; }
.polar-grid table { border-collapse: collapse; font-size: 11px; }
.polar-grid th, .polar-grid td { border: 1px solid var(--line); padding: 0; text-align: center; }
.polar-grid th { background: var(--panel); color: var(--muted); padding: 4px 6px; position: sticky; top: 0; z-index: 1; font-weight: 600; }
.polar-grid td:first-child, .polar-grid th:first-child { position: sticky; left: 0; background: var(--panel); color: var(--muted); padding: 4px 6px; z-index: 2; }
.polar-grid input { width: 42px; background: transparent; color: var(--text); border: none; text-align: center; padding: 5px 2px; font-size: 11px; }
.polar-grid input:focus { outline: 1px solid var(--accent); background: #0f1720; }
.polar-preset { width: 100%; margin-bottom: 8px; }

/* Modale de téléchargement */
.dl-models { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.dl-models label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 13px; color: var(--text); cursor: pointer; border-bottom: 1px solid var(--line); text-align: left; }
.dl-models label:last-child { border-bottom: none; }
.dl-models label:hover { background: rgba(25, 167, 206, 0.14); }
.dl-models input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }
.dl-mname { flex: 1; }
.dl-cov { font-size: 10px; padding: 2px 7px; border-radius: 10px; flex: 0 0 auto; font-weight: 600; }
.dl-cov-France { background: rgba(46,204,113,0.2); color: #5fd38a; }
.dl-cov-Europe { background: rgba(25,167,206,0.2); color: #5cc6e6; }
.dl-cov-Monde { background: rgba(155,120,230,0.2); color: #bfa6f0; }
.dl-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; display: none; }
.dl-bar.show { display: block; }
#dl-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

/* Contrôle "me localiser" */
.locate-ctrl { width: 34px; height: 34px; background: #fff; border: none; border-radius: 4px; box-shadow: 0 1px 5px rgba(0,0,0,0.4); cursor: pointer; font-size: 16px; line-height: 34px; text-align: center; }
.locate-ctrl:hover { background: #f4f4f4; }

/* Bandeau d'infos (chips) */
#chips { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 450; display: flex; gap: 8px; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; text-align: center; min-width: 86px; }
.chip .lbl { display: block; font-size: 11px; color: var(--muted); }
.chip .val { display: block; font-size: 15px; font-weight: 700; color: #6ee7a0; font-variant-numeric: tabular-nums; }

.panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(8px); }

/* Outils carte */
#map-tools { position: absolute; top: 60px; right: 12px; z-index: 450; padding: 10px; width: 168px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; }
.seg button { background: var(--panel-solid); color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; font-size: 12px; cursor: pointer; }
.seg button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 6px 0; cursor: pointer; }
#legend { margin-top: 8px; }
.legend-bar { height: 10px; border-radius: 5px; margin-bottom: 4px; }
.legend-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }

/* Curseur temps */
#timebar { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 450; display: flex; align-items: center; gap: 10px; padding: 8px 14px; width: min(620px, 90vw); }
#play-btn { background: var(--accent); color: #fff; border: none; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 14px; }
#time-slider { flex: 1; accent-color: var(--accent); }
#time-label { font-size: 12px; color: var(--text); min-width: 116px; text-align: right; font-variant-numeric: tabular-nums; }

/* Panneau routage */
#routing-panel {
  position: absolute; top: 52px; left: 0; bottom: 0; width: 340px; max-width: 88vw; z-index: 460;
  background: var(--panel); backdrop-filter: blur(10px); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 14px; transform: translateX(-105%); transition: transform 0.25s ease;
}
body.mode-routage #routing-panel { transform: translateX(0); }
body.mode-routage #chips, body.mode-routage #map-tools, body.mode-routage #timebar { display: none; }

.rp-section { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.rp-section h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
#routing-panel label { display: block; font-size: 12px; margin: 8px 0; color: var(--text); }
#routing-panel input[type="range"] { width: 100%; accent-color: var(--accent); }
#routing-panel select, #routing-panel .full { width: 100%; }
.route-pts div { font-size: 13px; margin: 4px 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.dot.dep { background: #2ecc71; } .dot.arr { background: #e74c3c; }
.muted { color: var(--muted); font-size: 12px; }

/* Recherche de ports */
.search-row { display: flex; gap: 5px; margin: 6px 0 2px; }
.search-in { flex: 1; background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 12px; }
.search-in:focus { outline: 1px solid var(--accent); }
.mini.geo { flex: 0 0 38px; font-size: 15px; }
.search-results { display: none; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 4px; max-height: 180px; overflow-y: auto; }
.search-results.show { display: block; }
.search-results div { padding: 7px 9px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-results div:hover { background: rgba(25, 167, 206, 0.2); }
.search-results .sr-sub { color: var(--muted); font-size: 10px; }

/* Sélection de zone */
.zone-row { display: flex; gap: 5px; margin: 8px 0 4px; }
.zone-row .mini.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#map.zone-drawing { cursor: crosshair; }
.quick { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.quick button { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px; font-size: 11px; cursor: pointer; }
.btn-row { display: flex; gap: 5px; margin: 8px 0; }
.mini { flex: 1; background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 11px; cursor: pointer; }
.primary { width: 100%; background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 12px; font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 12px; }
.primary:disabled { opacity: 0.6; cursor: wait; }

/* Résultats */
.result-card { background: var(--panel-solid); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: pointer; }
.result-card.sel { outline: 2px solid var(--accent); }
.rc-head { display: flex; justify-content: space-between; align-items: center; }
.rc-status { font-weight: 700; font-size: 13px; }
.rc-score { font-size: 12px; color: var(--muted); }
.rc-when { font-size: 13px; margin: 4px 0; }
.rc-cond { font-size: 11px; color: var(--muted); }
.rc-reason { font-size: 11px; margin-top: 4px; }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; color: #fff; }
#timeline-box { margin-top: 10px; }
.route-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.route-legend span { display: flex; align-items: center; gap: 5px; }
.route-legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }

/* Toast */
#toast { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); z-index: 600; background: #b5483d; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: opacity 0.3s; pointer-events: none; max-width: 80vw; text-align: center; }
#toast.show { opacity: 1; }

.leaflet-container { background: #aadaff; }
/* Décale les contrôles Leaflet (zoom, localisation) sous la barre du haut */
.leaflet-top { top: 58px; }
body.mode-routage .leaflet-left { left: 348px; } /* évite le panneau routage */
@media (max-width: 600px) {
  .brand { display: none; }
  #chips { top: 58px; flex-wrap: wrap; justify-content: center; width: 96vw; }
  .chip { min-width: 70px; padding: 4px 8px; }
}
