:root {
  --bg: #0b1016;
  --panel: #141c26;
  --line: #233040;
  --ink: #e6edf5;
  --muted: #8da2b8;
  --direct: #38bdf8;
  --ttn: #f59e0b;
  --bad: #f87171;
  --ok: #34d399;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--direct); }

.top {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.top h1 { margin: 0; font-size: 1.3rem; }

.menu {
  display: flex;
  gap: 0.2rem;
  padding: 0.2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.menu a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  font-size: 0.88rem;
}

.menu a[aria-current="page"] {
  color: var(--ink);
  background: var(--line);
}

.link-state {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.dot[data-state="ok"] { background: var(--ok); }
.dot[data-state="warn"] { background: var(--ttn); }
.dot[data-state="bad"] { background: var(--bad); }

.headline {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

#headAlt {
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.phase {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.phase[data-phase="montee"] { color: var(--ok); border-color: var(--ok); }
.phase[data-phase="descente"] { color: var(--ttn); border-color: var(--ttn); }

.banner {
  margin: 0;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  background: rgba(248, 113, 113, 0.12);
  border-bottom: 1px solid var(--bad);
  color: #fecaca;
}

.banner[data-kind="info"] {
  background: rgba(56, 189, 248, 0.1);
  border-bottom-color: var(--direct);
  color: #bae6fd;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 1rem;
  padding: 1rem 1.25rem 2rem;
  align-items: start;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

#map {
  height: 60vh;
  min-height: 22rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.measures {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tabbar {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.tabbar [role="tab"] {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.4rem 0.9rem;
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
}

.tabbar [role="tab"]:hover { color: var(--ink); }

.tabbar [role="tab"][aria-selected="true"] {
  color: var(--ink);
  background: var(--bg);
  border-color: var(--line);
  border-bottom: 1px solid var(--bg);
  font-weight: 600;
}

.pane {
  padding: 0.75rem;
  position: relative;
}

#altChart {
  display: block;
  width: 100%;
  height: 10rem;
}

.chart-label {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Position verticale posée par le script, qui la fait basculer pour ne pas
   recouvrir la courbe : une bulle fixe masquerait justement l'éclatement. */
.chart-tip {
  position: absolute;
  display: grid;
  gap: 0.1rem;
  padding: 0.45rem 0.6rem;
  background: rgba(11, 16, 22, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.chart-tip strong { color: var(--ink); font-size: 0.95rem; }

/* ------------------------------------------------------- historique */

.history .table-wrap {
  max-height: 19rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.history th,
.history td {
  padding: 0.3rem 0.6rem;
  text-align: left;
  white-space: nowrap;
}

.history td.num,
.history th.num { text-align: right; }

.history .unit {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  opacity: 0.65;
}

.history thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.history tbody tr {
  cursor: pointer;
  border-bottom: 1px solid rgba(35, 48, 64, 0.5);
}

.history tbody tr:hover { background: rgba(56, 189, 248, 0.07); }

.history tbody tr.designee { background: rgba(56, 189, 248, 0.16); }

.voie {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  color: var(--direct);
}

.voie[data-source="ttn"] { color: var(--ttn); }

aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.panel h2 {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel dl { margin: 0; display: grid; gap: 0.35rem; }

.panel dl > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.panel dt { color: var(--muted); font-size: 0.86rem; }

.panel dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.panel dd.bad { color: var(--bad); }

.hint {
  margin: 0.7rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  color: var(--direct);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

/* La carte de Leaflet est claire : on évite qu'elle éblouisse sur fond sombre. */
.leaflet-tile { filter: brightness(0.82) saturate(0.85); }
.leaflet-container { background: var(--panel); }

@media (max-width: 60rem) {
  main { grid-template-columns: minmax(0, 1fr); }
  #map { height: 46vh; }
  .headline { margin-left: 0; width: 100%; }
}

/* ------------------------------------------------------------- connexion */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  width: min(22rem, 100%);
  display: grid;
  gap: 0.75rem;
}

.login h1 { margin: 0; font-size: 1.2rem; }

.login input,
.login button[type="submit"] {
  font: inherit;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.login button[type="submit"] {
  background: var(--direct);
  color: #04202e;
  border-color: var(--direct);
  font-weight: 600;
  cursor: pointer;
}

.login .error { margin: 0; color: var(--bad); font-size: 0.86rem; }

/* ------------------------------------------------------- redressement video */

.redressement {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  max-width: 52rem;
}

.redressement form {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.redressement label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.redressement input,
.redressement select,
.redressement button,
.bouton {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.redressement button,
.bouton {
  background: var(--direct);
  color: #04202e;
  border-color: var(--direct);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  width: fit-content;
}

.redressement button:disabled { opacity: 0.5; cursor: default; }

.hint.mauvais { color: var(--bad); }

.barre {
  height: 8px;
  border-radius: 99px;
  background: var(--bg);
  overflow: hidden;
  margin-top: 1rem;
}

#barreFaite {
  height: 100%;
  width: 0;
  background: var(--direct);
}

#apercu {
  width: 100%;
  margin-top: 0.8rem;
  border-radius: 8px;
  background: #000;
}
