/* ============================================================
   SIXT//TMS — console de suivi · « terminal fret de nuit »
   ============================================================ */

:root {
  --bg:        #06090f;
  --bg2:       #0a0f17;
  --panel:     #0c121b;
  --panel-2:   #101826;
  --line:      rgba(126,150,182,.12);
  --line-hi:   rgba(126,150,182,.26);
  --ink:       #cdd9ea;
  --ink-dim:   #7587a0;
  --ink-faint: #46566c;

  --amber:  #FF6C37;   /* ex-jaune, désormais orange */
  --lime:   #5ef08a;
  --red:    #ff5d6c;
  --cyan:   #49d6e6;
  --btn:    #FF6C37;   /* CTA principaux */

  --glow-amber: rgba(255,108,55,.45);
  --glow-lime:  rgba(94,240,138,.40);
  --glow-red:   rgba(255,93,108,.40);
  --glow-cyan:  rgba(73,214,230,.40);
  --glow-btn:   rgba(255,108,55,.45);

  --mono: "JetBrains Mono", ui-monospace, monospace;
  --disp: "Chakra Petch", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(73,214,230,.07), transparent 60%),
    radial-gradient(900px 500px at 10% 0%, rgba(255,176,46,.05), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  background-attachment: fixed;
  min-height: 100%;
  position: relative;
}

/* fine grille d'ingénierie en fond */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 30%, #000 30%, transparent 90%);
  opacity: .5;
  pointer-events: none;
  z-index: 0;
}

/* scanlines + vignette */
.scanlines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.18) 2px 3px);
  mix-blend-mode: multiply; opacity: .35;
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  box-shadow: inset 0 0 240px 40px rgba(0,0,0,.7);
}

/* ---------------- topbar ---------------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line-hi);
  background: linear-gradient(180deg, rgba(16,24,38,.7), transparent);
  backdrop-filter: blur(3px);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand__led {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 12px 2px var(--glow-amber);
  align-self: center; animation: pulse 2.4s ease-in-out infinite;
}
.brand__mark {
  font-family: var(--disp); font-weight: 700; font-size: 20px;
  letter-spacing: 3px; color: #fff;
}
.brand__sub {
  font-family: var(--disp); font-weight: 500; font-size: 11px;
  letter-spacing: 4px; color: var(--ink-dim);
}
.topbar__meta {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px;
}
.meta-k { color: var(--ink-faint); letter-spacing: 2px; }
.meta-v { color: var(--ink); margin-right: 8px; }
.meta-v.live { color: var(--lime); text-shadow: 0 0 10px var(--glow-lime); }
/* "DERNIER SCAN X min" cliquable -> déclenche la synchro */
.lastscan {
  font-family: var(--mono); font-size: 11px; color: var(--ink);
  background: none; border: 0; padding: 0; margin-right: 8px; cursor: pointer;
  border-bottom: 1px dashed var(--line-hi);
  transition: color .15s, border-color .15s, text-shadow .15s;
}
.lastscan:hover { color: var(--lime); border-color: var(--lime); text-shadow: 0 0 10px var(--glow-lime); }
.lastscan.htmx-request { color: var(--lime); pointer-events: none; animation: pulse 1s ease-in-out infinite; }

/* ---------------- console layout ---------------- */
.console {
  position: relative; z-index: 2;
  max-width: 1320px; margin: 0 auto; padding: 26px 26px 60px;
}

/* ---------------- telemetry gauges ---------------- */
.telemetry {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 22px;
}
.telemetry--3 { grid-template-columns: repeat(3, 1fr); }
.gauge {
  position: relative; display: block;
  padding: 18px 18px 16px;
  background:
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  text-decoration: none; color: inherit; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.gauge:hover { border-color: var(--accent, var(--line-hi)); box-shadow: 0 0 26px -10px var(--accent-glow, transparent); transform: translateY(-1px); }
.gauge--on { border-color: var(--accent, var(--line-hi)); }
.gauge::before {  /* hairline accent en tête */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent, var(--ink-dim));
  box-shadow: 0 0 14px 1px var(--accent, transparent);
}
.gauge::after { /* coin technique */
  content: ""; position: absolute; right: 10px; top: 12px;
  width: 6px; height: 6px; border-top: 1px solid var(--line-hi);
  border-right: 1px solid var(--line-hi);
}
.gauge__label {
  display: block; font-family: var(--disp); font-weight: 600;
  font-size: 11px; letter-spacing: 3px; color: var(--ink-dim);
}
.gauge__value {
  display: block; font-family: var(--mono); font-weight: 800;
  font-size: 42px; line-height: 1.05; margin: 6px 0 2px;
  color: var(--accent, var(--ink)); text-shadow: 0 0 22px var(--accent-glow, transparent);
  font-variant-numeric: tabular-nums;
}
.gauge__value i { font-size: 20px; font-style: normal; opacity: .6; margin-left: 2px; }
.gauge__unit { font-size: 11px; color: var(--ink-faint); letter-spacing: .3px; }

.gauge--live { --accent: var(--lime);  --accent-glow: var(--glow-lime); }
.gauge--gone { --accent: var(--red);   --accent-glow: var(--glow-red); }
.gauge--cart { --accent: var(--amber); --accent-glow: var(--glow-amber); }

/* ---------------- filters ---------------- */
.filters {
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px 16px; margin-bottom: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
}
.filters__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span {
  font-family: var(--disp); font-weight: 600; font-size: 10px;
  letter-spacing: 2.5px; color: var(--ink-dim);
}
.field select, .field input {
  appearance: none;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line-hi); border-radius: 3px;
  padding: 8px 10px; font-family: var(--mono); font-size: 13px;
  min-width: 130px; transition: border-color .15s, box-shadow .15s;
}
.field--num input { min-width: 84px; }
.field select:focus, .field input:focus {
  outline: none; border-color: var(--amber);
  box-shadow: 0 0 0 1px var(--amber), 0 0 16px -2px var(--glow-amber);
}

.reset {
  align-self: flex-end; margin-left: auto;
  font-family: var(--disp); font-weight: 600; font-size: 11px; letter-spacing: 2px;
  color: var(--ink-dim); text-decoration: none; padding: 9px 12px;
  border: 1px dashed var(--line-hi); border-radius: 3px;
}
.reset:hover { color: var(--red); border-color: var(--red); }

/* ---------------- results ---------------- */
.results__head {
  display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 12px;
}
.results__count {
  font-family: var(--mono); font-weight: 800; font-size: 22px; color: var(--amber);
  text-shadow: 0 0 16px var(--glow-amber);
}
.results__cap { font-family: var(--disp); font-size: 11px; letter-spacing: 3px; color: var(--ink-dim); }
.results__spacer { flex: 1; }
.results__range {
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim); margin-left: 2px;
}
.legend {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-dim); margin-left: 14px; letter-spacing: .3px;
}

/* pagination */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 14px; }
.pager__btn {
  font-family: var(--disp); font-weight: 600; font-size: 11px; letter-spacing: 2px;
  color: var(--ink); text-decoration: none; padding: 9px 16px;
  border: 1px solid var(--line-hi); border-radius: 3px; background: var(--panel);
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.pager__btn:hover { color: var(--amber); border-color: var(--amber); box-shadow: 0 0 16px -4px var(--glow-amber); }
.pager__btn.is-off { color: var(--ink-faint); border-color: var(--line); pointer-events: none; opacity: .5; }
.pager__pos { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); letter-spacing: 1px; }
.pager__pos b { color: var(--ink); }

/* LED de statut */
.led { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.led--live { background: var(--lime); box-shadow: 0 0 9px 1px var(--glow-lime); animation: pulse 2.4s ease-in-out infinite; }
.led--gone { background: #3a2530; box-shadow: inset 0 0 0 1px var(--red); }

/* icône "nouveau" (ampoule discrète) */
.ic-new {
  width: 13px; height: 13px; vertical-align: -2px; margin-left: 6px;
  color: var(--amber); filter: drop-shadow(0 0 5px var(--glow-amber));
}
.legend .ic-new { margin-left: 0; }

/* ---------------- manifest table ---------------- */
.grid {
  border: 1px solid var(--line-hi); border-radius: 4px; overflow: hidden;
  background: linear-gradient(180deg, var(--panel), rgba(12,18,27,.6));
}
.manifest { width: 100%; border-collapse: collapse; }
.manifest thead th {
  text-align: left; padding: 11px 14px;
  font-family: var(--disp); font-weight: 600; font-size: 10px; letter-spacing: 2.5px;
  color: var(--ink-dim); background: rgba(8,12,19,.7);
  border-bottom: 1px solid var(--line-hi); position: sticky; top: 0; z-index: 1;
}
.manifest th.c-num, .manifest td.c-num { text-align: right; }

/* en-têtes triables */
.sort {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  color: inherit; text-decoration: none; cursor: pointer; letter-spacing: inherit;
  transition: color .15s;
}
.sort:hover { color: var(--ink); }
.sort--on { color: var(--amber); }
.sort__arr { font-size: 10px; line-height: 1; }
.manifest tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.manifest tbody tr:last-child td { border-bottom: 0; }

.row { animation: reveal .42s cubic-bezier(.2,.7,.3,1) backwards; animation-delay: calc(var(--i) * 22ms); }
.row:hover td { background: rgba(73,214,230,.05); }
.row { position: relative; }
.row:hover { box-shadow: inset 3px 0 0 var(--amber); }
.row--gone td { color: var(--ink-faint); }
.row--gone .veh, .row--gone .from, .row--gone .to { color: var(--ink-dim); }

.c-st { width: 26px; }
.veh { font-family: var(--body); font-weight: 300; font-size: 13.5px; color: var(--ink); }
.cat { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); letter-spacing: .5px; }
.c-route { min-width: 230px; }
.from { color: var(--ink); font-weight: 500; }
.arrow { color: var(--amber); margin: 0 8px; font-weight: 700; }
.to { color: var(--cyan); font-weight: 500; }

.c-num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.px { font-weight: 700; color: var(--lime); font-size: 15px; }
.px i { font-style: normal; font-size: 11px; opacity: .55; margin-left: 1px; }
.px-dm { color: var(--ink); }
.rate { color: var(--amber); font-weight: 700; font-size: 12.5px; }
.rate i { color: var(--amber); opacity: .55; }
.px-dm i, .c-num i { font-style: normal; font-size: 10px; opacity: .5; margin-left: 1px; color: var(--ink-dim); }
.c-date { font-family: var(--mono); font-size: 12.5px; color: var(--ink); white-space: nowrap; }
.c-seen { font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim); white-space: nowrap; }

/* action panier */
.c-cart { width: 120px; text-align: right; white-space: nowrap; }
.cart {
  font-family: var(--disp); font-weight: 600; font-size: 10px; letter-spacing: 1.5px;
  padding: 6px 10px; border-radius: 3px; transition: background .15s, color .15s, box-shadow .15s, opacity .15s;
}
.cart--add { color: var(--amber); background: transparent; border: 1px solid rgba(255,176,46,.4); cursor: pointer; }
.cart--add:hover { background: var(--amber); color: #06090f; box-shadow: 0 0 16px -3px var(--glow-amber); }
.cart--in { color: var(--lime); background: rgba(94,240,138,.08); border: 1px solid rgba(94,240,138,.4); }
.cart__cd { font-family: var(--mono); font-weight: 500; letter-spacing: 0; }
.cart--err { color: var(--red); background: transparent; border: 1px solid var(--red); cursor: pointer; }
.cart.htmx-request { opacity: .45; pointer-events: none; }
.cart-na { color: var(--ink-faint); }

/* empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 70px 20px; border: 1px dashed var(--line-hi); border-radius: 4px; background: var(--panel);
}
.empty__glyph { font-family: var(--mono); font-size: 46px; color: var(--ink-faint); }
.empty__msg { font-family: var(--disp); letter-spacing: 3px; font-size: 13px; color: var(--ink-dim); }
.empty__reset { color: var(--amber); font-family: var(--mono); font-size: 12px; text-decoration: none; }
.empty__reset:hover { text-decoration: underline; }

/* footer */
.footer {
  position: relative; z-index: 2; text-align: center; padding: 22px;
  font-family: var(--disp); font-size: 10px; letter-spacing: 3px; color: var(--ink-faint);
}
.footer .sep { margin: 0 8px; opacity: .5; }

/* ---------------- motion ---------------- */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .row, .brand__led, .led--live { animation: none; }
}

@media (max-width: 880px) {
  .telemetry { grid-template-columns: repeat(2, 1fr); }
  .manifest .c-seen { display: none; }
}

/* ---------------- auth ---------------- */
.user {
  font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
  margin-left: 10px; max-width: 200px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.logout {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin-left: 8px;
  color: var(--ink-dim); text-decoration: none;
  border: 1px solid var(--line-hi); border-radius: 4px; font-size: 13px;
  transition: color .15s, border-color .15s;
}
.logout:hover { color: var(--red); border-color: var(--red); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; z-index: 2; padding: 24px; }
.login__card {
  width: 100%; max-width: 380px; padding: 38px 32px; text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-hi); border-radius: 6px;
  box-shadow: 0 30px 80px -30px #000;
}
.login__brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.login__brand .brand__mark { font-family: var(--disp); font-weight: 700; font-size: 22px; letter-spacing: 3px; color: #fff; }
.login__sub { font-family: var(--disp); font-size: 11px; letter-spacing: 3px; color: var(--ink-dim); margin: 0 0 26px; }
.login__err {
  font-family: var(--mono); font-size: 12px; color: var(--red);
  background: rgba(255,93,108,.08); border: 1px solid rgba(255,93,108,.3);
  border-radius: 4px; padding: 8px 10px; margin: 0 0 18px;
}
.login__btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--disp); font-weight: 600; font-size: 13px; letter-spacing: 1px;
  color: #fff; background: var(--btn); text-decoration: none;
  padding: 12px 20px; border-radius: 4px; box-shadow: 0 0 24px -6px var(--glow-btn);
  transition: transform .1s, box-shadow .15s;
}
.login__btn:hover { transform: translateY(-1px); box-shadow: 0 0 32px -4px var(--glow-btn); }

/* ---------------- config ---------------- */
.cfg-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin-left: 8px;
  color: var(--ink-dim); text-decoration: none; font-size: 15px;
  border: 1px solid var(--line-hi); border-radius: 4px;
  transition: color .15s, border-color .15s;
}
.cfg-link:hover { color: var(--amber); border-color: var(--amber); }

.cfg-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 22px; }
.cfg-back { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); text-decoration: none; }
.cfg-back:hover { color: var(--amber); }
.cfg-title { font-family: var(--disp); font-weight: 700; font-size: 20px; letter-spacing: 3px; color: #fff; margin: 0; }
.cfg-saved { font-family: var(--mono); font-size: 12px; color: var(--lime); text-shadow: 0 0 10px var(--glow-lime); }
.cfg { display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.cfg-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 6px; padding: 22px 22px 10px;
}
.cfg-card__title { font-family: var(--disp); font-weight: 600; font-size: 12px; letter-spacing: 3px; color: var(--amber); margin: 0 0 6px; }
.cfg-card__desc { font-size: 12.5px; color: var(--ink-dim); line-height: 1.5; margin: 0 0 18px; }
.cfg-card__desc code { font-family: var(--mono); color: var(--ink); }
.cfg-toggle { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; cursor: pointer; font-family: var(--disp); font-size: 13px; letter-spacing: 1px; color: var(--ink); }
.cfg-toggle input { width: 16px; height: 16px; accent-color: var(--amber); }
.cfg-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.cfg-field > span { font-family: var(--disp); font-weight: 600; font-size: 10px; letter-spacing: 2px; color: var(--ink-dim); }
.cfg-field input {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line-hi);
  border-radius: 3px; padding: 9px 11px; font-family: var(--mono); font-size: 13px; max-width: 340px;
}
.cfg-field input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), 0 0 16px -2px var(--glow-amber); }
.cfg-save {
  align-self: flex-start; font-family: var(--disp); font-weight: 600; font-size: 12px; letter-spacing: 2px;
  color: #fff; background: var(--btn); border: 0; border-radius: 4px; padding: 12px 22px;
  cursor: pointer; box-shadow: 0 0 18px -5px var(--glow-btn);
}
.cfg-save:hover { box-shadow: 0 0 26px -4px var(--glow-btn); }
