/* AubeRadar : console d'opérations.
   Style suisse : noir pur, blanc, filets de 1 px, Inter et chasse fixe, aucun
   italique. La couleur ne sert qu'à l'état (en ligne, dégradé, hors ligne,
   alerte). */

:root {
  --bg: #000;
  --panel: #000;
  --fg: #fff;
  --muted: #9a9a9a;
  --faint: #5c5c5c;
  --rule: #262626;
  --rule-strong: #3a3a3a;
  --ok: #30d158;
  --warn: #ffb020;
  --crit: #ff3b30;
  --focus: #fff;
  --sans: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --header-h: 48px;
  --sidebar-w: 420px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body { font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
em, i { font-style: normal; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 1px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.label {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}

/* -- boutons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border: 1px solid var(--rule-strong); background: transparent;
  cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn:hover { border-color: var(--fg); }
.btn-primary { background: var(--fg); color: #000; border-color: var(--fg); }
.btn-primary:hover { background: #d9d9d9; }
.btn-small { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-icon { width: 32px; padding: 0; }

/* -- page d'accueil ------------------------------------------------------------ */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing header, .landing footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--rule);
}
.landing footer { border-bottom: 0; border-top: 1px solid var(--rule); margin-top: auto; color: var(--muted); font-size: 12px; }
.wordmark { font-weight: 700; letter-spacing: .02em; font-size: 16px; }
.landing main { max-width: 880px; padding: 72px 24px; }
.landing h1 { font-size: clamp(32px, 6vw, 56px); line-height: 1.05; margin: 0 0 24px; font-weight: 700; letter-spacing: -.02em; }
.landing p.lead { font-size: 18px; color: #d0d0d0; max-width: 640px; margin: 0 0 32px; }
.landing .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); border-top: 1px solid var(--rule); margin-top: 56px; }
.landing .facts div { padding: 20px 20px 20px 0; border-bottom: 1px solid var(--rule); }
.landing .facts h2 { font-size: 13px; margin: 0 0 6px; letter-spacing: .06em; text-transform: uppercase; }
.landing .facts p { margin: 0; color: var(--muted); font-size: 14px; }

/* -- connexion ----------------------------------------------------------------- */
.login {
  min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 24px 16px;
}
.login form { width: 100%; max-width: 360px; border: 1px solid var(--rule-strong); padding: 28px 24px; }
.login h1 { font-size: 20px; margin: 0 0 20px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; margin-bottom: 6px; }
.field input {
  width: 100%; height: 40px; padding: 0 12px; background: #000; border: 1px solid var(--rule-strong);
}
.field input:focus { border-color: var(--fg); outline: none; }
.password-row { display: flex; }
.password-row input { flex: 1; border-right: 0; }
.password-row button { width: 44px; border: 1px solid var(--rule-strong); background: transparent; cursor: pointer; color: var(--muted); }
.form-error { color: var(--crit); min-height: 20px; margin: 0 0 12px; font-size: 13px; }
.login .btn { width: 100%; height: 40px; }

/* -- console : en-tête ----------------------------------------------------------- */
.topbar {
  height: var(--header-h); display: flex; align-items: center; gap: 16px; padding: 0 16px;
  border-bottom: 1px solid var(--rule); position: relative; z-index: 3; background: var(--bg);
  overflow: hidden; /* filet de sécurité : l'en-tête ne doit jamais élargir la page sur téléphone */
}
.topbar .site { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--rule-strong);
  padding: 2px 8px; white-space: nowrap;
}
.chip-warn { border-color: var(--warn); color: var(--warn); }
.topbar .spacer { flex: 1; }
.link-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }
.clock { font-size: 13px; white-space: nowrap; }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }

/* -- console : corps --------------------------------------------------------------- */
.console { display: grid; grid-template-columns: minmax(0, 1fr) var(--sidebar-w); height: calc(100vh - var(--header-h)); }
.map-wrap { position: relative; min-width: 0; border-right: 1px solid var(--rule); }
#map { position: absolute; inset: 0; background: #050505; }
.sidebar { overflow-y: auto; min-width: 0; }

.section { border-bottom: 1px solid var(--rule); padding: 14px 16px 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }
.section-head .count { font-family: var(--mono); color: var(--muted); font-size: 12px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.stat { padding: 10px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.stat .value { font: 600 22px/1.1 var(--mono); }
.stat .value.crit { color: var(--crit); }
.stat .value.warn { color: var(--warn); }
.stat .label { display: block; margin-top: 4px; }

/* tableaux */
.table-wrap { overflow-x: auto; max-height: 340px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { text-align: left; padding: 6px 6px 6px 0; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: .04em; position: sticky; top: 0; background: var(--bg); cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " \2191"; }
th[aria-sort="descending"]::after { content: " \2193"; }
td.num, th.num { text-align: right; padding-right: 6px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #111; }
tbody tr.selected { background: #1c1c1c; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }
table caption { caption-side: bottom; text-align: left; padding-top: 8px; font-size: 10px; }
td .sub { font-size: 11px; color: var(--muted); }

/* alertes */
.alerts { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.alerts li { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.alerts .dot { margin-top: 6px; }
.alerts .msg { font-size: 13px; overflow-wrap: anywhere; }
.alerts .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.alerts li.ack .msg { color: var(--muted); }

/* -- carte : contrôles et fiches ------------------------------------------------------ */
.map-tools { position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: calc(100% - 24px); }
.map-tools .btn { background: rgba(0, 0, 0, .85); }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; }
/* Choix des données affichées : Tout, Réel, Simulation. */
.segmented { display: inline-flex; border: 1px solid var(--rule-strong); background: rgba(0, 0, 0, .85); }
.segmented button {
  height: 30px; padding: 0 10px; border: 0; background: transparent; color: var(--muted);
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.segmented button + button { border-left: 1px solid var(--rule-strong); }
.segmented button[aria-pressed="true"] { background: var(--fg); color: #000; }
.segmented button:hover:not([aria-pressed="true"]) { color: var(--fg); }
.layers {
  background: rgba(0, 0, 0, .92); border: 1px solid var(--rule-strong); padding: 12px 14px; width: 250px; max-width: 100%;
  max-height: calc(100vh - var(--header-h) - 80px); overflow-y: auto;
}
.layers fieldset { border: 0; margin: 0 0 10px; padding: 0; }
.layers legend { padding: 0; margin-bottom: 6px; }
.layers label { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.layers input[type="checkbox"] { accent-color: #fff; width: 14px; height: 14px; margin: 0; }
.layers select { width: 100%; height: 30px; background: #000; border: 1px solid var(--rule-strong); padding: 0 6px; }

.card {
  position: absolute; left: 12px; bottom: 12px; z-index: 2; width: 340px; max-width: calc(100% - 24px);
  max-height: calc(100% - 64px); overflow-y: auto; background: rgba(0, 0, 0, .94); border: 1px solid var(--rule-strong);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: #000; }
.card-head h3 { margin: 0; font: 600 18px/1.2 var(--mono); }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card dl { margin: 0; padding: 6px 14px 4px; display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 14px; }
.card dt { color: var(--muted); font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.card dd { margin: 0; padding: 6px 0; border-bottom: 1px solid var(--rule); font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.card dl > :nth-last-child(-n+2) { border-bottom: 0; }
.card .actions { display: flex; gap: 8px; padding: 10px 14px 14px; flex-wrap: wrap; }
.state { font-family: var(--sans); font-size: 11px; letter-spacing: .08em; border: 1px solid var(--rule-strong); padding: 1px 6px; }
.state.TRACKING { border-color: var(--fg); }
.state.COASTING { color: var(--muted); }
.state.NEW { color: var(--faint); }

/* légende de l'image du radar météo */
.weather-legend {
  background: rgba(0, 0, 0, .85); border: 1px solid var(--rule-strong); padding: 8px 10px; max-width: 280px;
  font-size: 11.5px; line-height: 1.5;
}
.weather-legend .label { margin-bottom: 2px; }
.weather-legend .sub { color: var(--muted); margin-top: 4px; }
.weather-legend .swatches { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.weather-legend .swatches i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }

/* vue radar (PPI) */
.scope {
  position: absolute; right: 12px; bottom: 34px; z-index: 2; width: 360px; max-width: calc(100% - 24px);
  background: #000; border: 1px solid var(--rule-strong);
}
.scope-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px; border-bottom: 1px solid var(--rule); }
.scope-head select { flex: 1; min-width: 0; height: 28px; background: #000; border: 1px solid var(--rule-strong); padding: 0 6px; }
.scope canvas { display: block; width: 100%; aspect-ratio: 1 / 1; cursor: crosshair; }
.scope-note { margin: 0; padding: 6px 8px; border-top: 1px solid var(--rule); font-size: 10px; }
.scope-note:empty { display: none; }

.toast {
  position: absolute; right: 12px; top: 12px; z-index: 2; background: #000; border: 1px solid var(--rule-strong);
  padding: 8px 12px; font-size: 13px; max-width: calc(100% - 24px);
}

.maplibregl-ctrl-attrib { background: rgba(0, 0, 0, .7) !important; color: var(--muted) !important; font-size: 10px !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-group { background: #000 !important; border: 1px solid var(--rule-strong) !important; border-radius: 0 !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--rule-strong) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }

/* -- téléphone et tablette ------------------------------------------------------------- */
@media (max-width: 1100px) {
  :root { --sidebar-w: 360px; }
  .stat .value { font-size: 18px; }
}
@media (max-width: 820px) {
  .console { display: block; height: auto; }
  .map-wrap { height: 62vh; min-height: 340px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .sidebar { overflow: visible; }
  .card { left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; max-height: 70%; }
  .scope { right: 8px; left: 8px; top: 52px; bottom: auto; width: auto; max-width: 360px; margin: 0 auto; }
  .map-tools { top: 8px; left: 8px; }
  .weather-legend { max-width: 230px; font-size: 11px; }
  .weather-legend .flow { display: none; }
  /* La vue radar s'ouvre en haut de la carte : la légende lui laisse la place. */
  .map-wrap:has(#scope:not([hidden])) .weather-legend { display: none; }
  .topbar { gap: 10px; padding: 0 10px; }
  .topbar .site, .clock .zone { display: none; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat .value { font-size: 18px; }
}
@media (max-width: 560px) {
  .clock, #user-role { display: none; }
  /* Le sélecteur Tout / Réel / Simulation dit déjà ce que montre la carte. */
  body:has(#domain-switch:not([hidden])) #sim-chip { display: none; }
}
@media (max-width: 480px) {
  .topbar .link-state .text, .user .name { display: none; }
  .landing main { padding: 40px 16px; }
  .landing header, .landing footer { padding: 14px 16px; }
}
