@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0a0c0e;
  --panel: #0d1013;
  --panel-alt: #101418;
  --border: #1c2228;
  --border-strong: #2a333c;
  --border-faint: #14181c;
  --text: #d8dde2;
  --heading: #eef2f5;
  --muted: #8a97a2;
  --dim: #5d6a75;
  --dimmer: #3d4750;
  --accent: #f0a640;
  --accent-hover: #ffc069;
  --on-accent: #0a0c0e;
  --accent-tint-bg: #14110b;
  --green: #3dd68c;
  --red: #e5533d;
  --cyan: #4cc3ff;
  --terrain: #a9825a;
  --terrain-fill: rgba(169, 130, 90, .28);
  --status-ok-bg: #0f1a13;
  --status-ok-bd: #234a34;
  --status-warn-bg: #161206;
  --status-warn-bd: #4a3a1c;
  --status-crit-bg: #1a0f0d;
  --status-crit-bd: #5a2a24;
  --src-edge-bd: rgba(240, 166, 64, .4);
  --src-bb-bd: rgba(76, 195, 255, .4);
  --scanline-op: .12;
}

/* Thème clair : même grille et mêmes composants, fond blanc dominant avec
   des surfaces structurelles (header, cartouches, en-têtes de tableau)
   légèrement grisées — l'inverse du thème sombre où --bg est la teinte la
   plus foncée et --panel un cran plus clair. */
:root[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f6f7f8;
  --panel-alt: #edeff1;
  --border: #e2e5e8;
  --border-strong: #c5cad0;
  --border-faint: #edeff1;
  --text: #262b30;
  --heading: #12161a;
  --muted: #6b7580;
  --dim: #8b95a0;
  --dimmer: #b0b8c0;
  --accent: #c97a1f;
  --accent-hover: #a8660f;
  --on-accent: #12161a;
  --accent-tint-bg: #fbf1e3;
  --green: #1f9d5c;
  --red: #d64430;
  --cyan: #1f8fd6;
  --terrain: #8a6d3f;
  --terrain-fill: rgba(138, 109, 63, .22);
  --status-ok-bg: #f0faf3;
  --status-ok-bd: #bfe6cd;
  --status-warn-bg: #fdf5e7;
  --status-warn-bd: #eed3a0;
  --status-crit-bg: #fcefed;
  --status-crit-bd: #eec0b6;
  --src-edge-bd: rgba(201, 122, 31, .4);
  --src-bb-bd: rgba(31, 143, 214, .4);
  --scanline-op: 0;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
}

input::placeholder { color: var(--dim); }
input:focus { outline: 1px solid var(--accent); }
::selection { background: var(--accent); color: var(--on-accent); }

a { color: inherit; text-decoration: none; }
button { font: inherit; }
h1, h2, h3 { font-family: 'Chakra Petch', sans-serif; margin: 0; }

.tv-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.tv-main { flex: 1; display: flex; flex-direction: column; }

@keyframes fpvblink {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

.tv-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 3px, rgba(0,0,0,var(--scanline-op)) 3px, rgba(0,0,0,var(--scanline-op)) 4px);
  transition: background .2s ease;
}

/* Header / nav */
.tv-header {
  display: flex; align-items: center; gap: 28px; padding: 0 28px; height: 58px;
  border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 40;
}
.tv-logo { display: flex; align-items: baseline; gap: 8px; }
.tv-logo-trace { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 17px; letter-spacing: .14em; color: var(--accent); }
.tv-logo-vault { font-family: 'Chakra Petch', sans-serif; font-weight: 400; font-size: 17px; letter-spacing: .14em; color: var(--dim); }
.tv-nav { display: flex; gap: 4px; flex: 1; }
.tv-nav-link { padding: 10px 14px; font-size: 11px; letter-spacing: .15em; color: var(--muted); border-bottom: 2px solid transparent; }
.tv-nav-link:hover { color: var(--accent); }
.tv-nav-link.active { color: var(--accent); border-bottom-color: var(--accent); }
.tv-nav-user { display: flex; align-items: center; gap: 14px; }
.tv-nav-pilot { font-size: 11px; color: var(--dim); letter-spacing: .08em; }
.tv-nav-pilot span { color: var(--text); }
.tv-nav-account {
  font-size: 11px; color: var(--dim); letter-spacing: .08em; border: 1px solid var(--border-strong);
  padding: 6px 12px; white-space: nowrap;
}
.tv-nav-account span { color: var(--text); }
.tv-nav-account:hover, .tv-nav-account.active { border-color: var(--accent); color: var(--accent); }
.tv-btn-logout {
  background: none; border: 1px solid var(--border-strong); color: var(--muted);
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: .1em; padding: 6px 12px; cursor: pointer;
}
.tv-btn-logout:hover { border-color: var(--accent); color: var(--accent); }

.tv-nav-panel { display: contents; }
.tv-nav-toggle {
  display: none; margin-left: auto; background: none; border: 1px solid var(--border-strong);
  color: var(--muted); width: 36px; height: 36px; font-size: 15px; line-height: 1; cursor: pointer;
}
.tv-nav-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* Bandeau admin « voir en tant que » (lecture seule des vols d'un compte) */
.tv-viewas-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 9px 28px; background: var(--accent-tint-bg); border-bottom: 1px solid var(--accent);
  font-size: 11px; letter-spacing: .08em; color: var(--muted);
}
.tv-viewas-banner form { margin: 0; }
.tv-viewas-label b { color: var(--accent); font-weight: 600; }
.tv-viewas-quit {
  background: none; border: 1px solid var(--accent); color: var(--accent); cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: .1em; padding: 5px 12px;
}
.tv-viewas-quit:hover { background: var(--accent); color: var(--on-accent); }

/* Bascule thème sombre / clair */
.tv-theme-toggle {
  display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--border-strong);
  color: var(--muted); padding: 6px 8px 6px 12px; cursor: pointer; font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px; letter-spacing: .12em; flex-shrink: 0;
}
.tv-theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.tv-theme-toggle-track { position: relative; width: 28px; height: 15px; border: 1px solid var(--border-strong); background: var(--bg); flex-shrink: 0; }
.tv-theme-toggle-knob { position: absolute; top: 1px; left: 1px; width: 11px; height: 11px; background: var(--accent); transition: transform .18s ease; }
:root[data-theme="light"] .tv-theme-toggle-knob { transform: translateX(13px); }

/* Buttons */
.tv-btn-primary {
  background: var(--accent); border: none; color: var(--on-accent); font-family: 'Chakra Petch', sans-serif;
  font-weight: 600; font-size: 12px; letter-spacing: .1em; padding: 9px 20px; cursor: pointer; display: inline-block;
}
.tv-btn-primary:hover { background: var(--accent-hover); }
.tv-btn-lg { padding: 15px 34px; font-size: 14px; }
.tv-btn-block { width: 100%; padding: 13px; margin-top: 6px; }

.tv-btn-ghost {
  background: none; border: 1px solid var(--border-strong); color: var(--text); font-family: 'Chakra Petch', sans-serif;
  font-weight: 500; font-size: 14px; letter-spacing: .1em; padding: 15px 34px; cursor: pointer; display: inline-block;
}
.tv-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.tv-btn-outline-accent {
  background: none; border: 1px solid var(--accent); color: var(--accent); font-family: 'Chakra Petch', sans-serif;
  font-weight: 600; font-size: 12px; letter-spacing: .1em; padding: 11px 20px; cursor: pointer; display: inline-block;
}
.tv-btn-outline-accent:hover { background: var(--accent); color: var(--on-accent); }
.tv-btn-outline-accent.active { background: var(--accent); color: var(--on-accent); }

.tv-btn-outline-green {
  background: none; border: 1px solid var(--green); color: var(--green); font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px; letter-spacing: .1em; padding: 9px 14px; cursor: pointer; white-space: nowrap; display: inline-block;
}
.tv-btn-outline-green:hover { background: var(--green); color: var(--on-accent); }

.tv-link-muted { color: var(--dim); font-size: 11px; letter-spacing: .1em; cursor: pointer; }
.tv-link-muted:hover { color: var(--accent); }
.tv-link-accent { color: var(--accent); }
.tv-link-accent:hover { color: var(--accent-hover); }

.tv-row-hover:hover { background: var(--panel-alt); }

/* Shared bits */
.tv-kicker { font-size: 10px; letter-spacing: .25em; color: var(--accent); margin-bottom: 8px; }
.tv-page-title { font-weight: 600; font-size: 28px; color: var(--heading); }
.tv-page-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 26px; }
.tv-dim { color: var(--dimmer); font-weight: 400; }
.tv-dim-text { font-size: 10px; color: var(--dim); }
.tv-dimmer-text { font-size: 10px; color: var(--dimmer); }
.tv-muted-text { color: var(--muted); font-size: 11.5px; }
.tv-heading-text { color: var(--heading); }
.tv-accent-text { color: var(--accent); }
.tv-green { color: var(--green); }
.tv-red { color: var(--red); }
.tv-error { font-size: 11px; color: var(--red); }
.tv-card { border: 1px solid var(--border); background: var(--panel); }

.tv-back-row { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }

/* Home */
.tv-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 110px 24px 90px; position: relative; }
.tv-hero-corner { position: absolute; width: 26px; height: 26px; border-color: var(--border-strong); }
.tv-hero-corner-tl { top: 34px; left: 34px; border-top: 2px solid var(--border-strong); border-left: 2px solid var(--border-strong); }
.tv-hero-corner-tr { top: 34px; right: 34px; border-top: 2px solid var(--border-strong); border-right: 2px solid var(--border-strong); }
.tv-hero-corner-bl { bottom: 34px; left: 34px; border-bottom: 2px solid var(--border-strong); border-left: 2px solid var(--border-strong); }
.tv-hero-corner-br { bottom: 34px; right: 34px; border-bottom: 2px solid var(--border-strong); border-right: 2px solid var(--border-strong); }
.tv-hero-kicker { font-size: 11px; letter-spacing: .3em; color: var(--accent); margin-bottom: 22px; }
.tv-hero-title { font-weight: 700; font-size: 56px; line-height: 1.1; max-width: 760px; color: var(--heading); }
.tv-hero-sub { font-size: 15px; line-height: 1.7; color: var(--muted); max-width: 520px; margin: 26px auto 40px; }
.tv-hero-actions { display: flex; gap: 14px; justify-content: center; }
.tv-hero-secondary-link {
  display: inline-block; margin-top: 18px; font-size: 12px; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px;
}
.tv-hero-secondary-link:hover { color: var(--accent); }

.tv-features {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.tv-feature { background: var(--panel); padding: 36px 32px; }
.tv-feature-num { font-size: 11px; letter-spacing: .2em; color: var(--accent); margin-bottom: 12px; }
.tv-feature-title { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 18px; color: var(--heading); margin-bottom: 10px; }
.tv-feature p { font-size: 12.5px; line-height: 1.7; color: var(--muted); margin: 0; }

.tv-footer { padding: 22px 28px; font-size: 10px; letter-spacing: .12em; color: var(--dimmer); display: flex; justify-content: space-between; }

/* Login / register */
.tv-center { align-items: center; justify-content: center; padding: 40px 24px; }
.tv-login-card { width: 380px; max-width: 100%; padding: 38px 36px 34px; position: relative; }
.tv-corner-accent { position: absolute; width: 14px; height: 14px; }
.tv-corner-accent-tl { top: -1px; left: -1px; border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.tv-corner-accent-br { bottom: -1px; right: -1px; border-bottom: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.tv-card-title { font-weight: 600; font-size: 24px; margin: 0 0 26px; color: var(--heading); }
.tv-form { display: flex; flex-direction: column; gap: 16px; }
.tv-label { display: flex; flex-direction: column; gap: 7px; font-size: 10px; letter-spacing: .15em; color: var(--dim); }
.tv-input {
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--text);
  font-family: 'IBM Plex Mono', monospace; font-size: 13px; padding: 11px 12px;
}
.tv-fineprint { font-size: 10.5px; line-height: 1.6; color: var(--dimmer); margin: 22px 0 0; }

/* Locked */
.tv-locked { align-items: center; justify-content: center; gap: 18px; padding: 40px; }
.tv-locked-icon { font-size: 26px; color: var(--accent); animation: fpvblink 1.6s infinite; }
.tv-locked-title { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 20px; color: var(--heading); }

/* Flights list */
.tv-flights { padding: 48px 40px; }
.tv-flights-tools { display: flex; gap: 10px; align-items: center; }
.tv-search { margin: 0; }
.tv-search-input { font-size: 12px; padding: 10px 14px; width: 230px; }
.tv-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.tv-filters .tv-input { font-size: 12px; padding: 9px 11px; }
.tv-filter-search { width: 200px; }
.tv-filter-field { min-width: 130px; max-width: 210px; }
/* Les <select> se dimensionnent au contenu : on laisse respirer les libellés
   longs ("Toutes les sources", nom de drone) plutôt que de les tronquer. */
select.tv-filter-field { width: auto; }
.tv-filter-check { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.tv-filter-btn { padding: 9px 18px; }
.tv-filter-reset { font-size: 11px; }
.tv-table { border: 1px solid var(--border); }
.tv-table-row {
  display: grid; grid-template-columns: minmax(200px, 2fr) 100px 84px 96px 96px 100px 140px 120px;
  align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border-faint); font-size: 12.5px;
}
/* Carnet unifié « Mes vols » : colonne SOURCE en plus (EdgeTX + blackbox). */
.tv-table-src .tv-table-row {
  grid-template-columns: minmax(180px, 2fr) 86px 100px 84px 92px 92px 96px 132px 108px;
}
.tv-src-badge {
  display: inline-block; font-size: 9px; letter-spacing: .08em; padding: 3px 8px;
  border: 1px solid var(--border-strong);
}
.tv-src-edge { color: var(--accent); border-color: var(--src-edge-bd); }
.tv-src-bb { color: var(--cyan); border-color: var(--src-bb-bd); }
.tv-table-head {
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
  font-size: 9.5px; letter-spacing: .18em; color: var(--dim);
}
.tv-table-empty { padding: 24px 18px; color: var(--muted); font-size: 12px; }
.tv-ta-right { text-align: right; }
.tv-sort-link {
  display: inline-flex; align-items: center; gap: 4px; color: var(--dim);
  text-decoration: none; cursor: pointer;
}
.tv-sort-link:hover { color: var(--accent); }
.tv-sort-link.active { color: var(--accent); }
.tv-sort-arrow { font-size: 8px; width: 8px; }
.tv-flight-session { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tv-date-cell { display: flex; flex-direction: column; gap: 2px; }
.tv-date-time { font-size: 10.5px; color: var(--dim); }
.tv-session-line { display: flex; align-items: center; gap: 8px; color: var(--heading); min-width: 0; }
.tv-session-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-drone-mini { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.tv-gps-badge { font-size: 8.5px; letter-spacing: .1em; color: var(--green); border: 1px solid var(--status-ok-bd); padding: 1px 5px; flex-shrink: 0; }
.tv-tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tv-tag { font-size: 9.5px; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--border-strong); padding: 2px 7px; }
.tv-row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Détail vol — drone associé */
.tv-drone-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.tv-drone-info form { margin: 0; }

/* Sélecteur de drone (Mes vols + fiche détail) */
.tv-drone-select { font-size: 11px; padding: 6px 8px; max-width: 140px; }

/* Détail vol — notes libres et partage public */
.tv-notes-block { margin-bottom: 20px; }
.tv-notes-block .tv-compare-label { display: block; margin-bottom: 8px; }
.tv-notes-form, .tv-share-row { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.tv-notes-form form, .tv-share-row form { margin: 0; }
.tv-notes-textarea { flex: 1; min-width: 240px; min-height: 44px; resize: vertical; font-size: 12.5px; }
.tv-notes-readonly { font-size: 13px; line-height: 1.6; color: var(--text); white-space: pre-wrap; margin: 0; }
.tv-share-row { align-items: center; margin-bottom: 6px; }
.tv-share-url { flex: 1; min-width: 200px; font-size: 11.5px; color: var(--muted); }
.tv-share-expiry { display: block; font-size: 12.5px; color: var(--muted); }

/* Vols jumeaux — suggestion d'appariement (fiche) */
.tv-twin-suggest {
  border: 1px solid var(--border-strong); margin-bottom: 20px; padding: 16px 18px;
  background: linear-gradient(180deg, rgba(240,166,64,.05), rgba(240,166,64,0));
}
.tv-twin-suggest-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tv-twin-mark {
  font-size: 12px; color: var(--on-accent); background: var(--accent); font-weight: 700;
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 999px; flex: none;
}
.tv-twin-suggest-title { font-family: 'Chakra Petch', sans-serif; font-weight: 600; color: var(--heading); font-size: 14px; }
.tv-twin-dismiss { margin-left: auto; background: none; border: none; color: var(--dim); cursor: pointer; font-size: 13px; padding: 4px; }
.tv-twin-dismiss:hover { color: var(--accent); }
.tv-twin-reasons { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px 32px; }
.tv-twin-reason { font-size: 11px; color: var(--muted); border: 1px solid var(--border); padding: 5px 10px; background: var(--bg); }
.tv-twin-suggest-actions { display: flex; gap: 10px; margin-left: 32px; flex-wrap: wrap; align-items: center; }
.tv-twin-suggest-actions form { margin: 0; }
.tv-twin-ghost { border-color: var(--border-strong) !important; color: var(--muted) !important; }
.tv-twin-ghost:hover { border-color: var(--accent) !important; color: var(--accent) !important; background: none !important; }

/* Vols jumeaux — carte du jumeau associé (fiche) */
.tv-twin-card { border: 1px solid var(--border); margin-bottom: 20px; padding: 14px 18px; }
.tv-twin-card.twin-edge { border-left: 2px solid var(--accent); }
.tv-twin-card.twin-bb { border-left: 2px solid var(--cyan); }
.tv-twin-src { font-size: 10px; letter-spacing: .2em; color: var(--dim); }
.tv-twin-card.twin-edge .tv-twin-src { color: var(--accent); }
.tv-twin-card.twin-bb .tv-twin-src { color: var(--cyan); }
.tv-twin-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.tv-twin-mini { width: 11px; height: 11px; border-radius: 999px; flex: none; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.tv-twin-card.twin-edge .tv-twin-mini { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.tv-twin-lbl { display: block; font-size: 9px; letter-spacing: .18em; color: var(--dim); margin-bottom: 2px; }
.tv-twin-name { font-family: 'Chakra Petch', sans-serif; font-weight: 600; color: var(--heading); font-size: 14px; }
.tv-twin-name:hover { color: var(--accent); }
.tv-twin-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tv-twin-actions form { margin: 0; }
.tv-twin-dissoc { border-color: var(--border-strong) !important; color: var(--muted) !important; }
.tv-twin-dissoc:hover { border-color: var(--red) !important; color: var(--red) !important; background: none !important; }

/* Vols jumeaux — analyse synchronisée */
.tv-twin-legend { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; font-size: 11.5px; color: var(--muted); }
.tv-twin-legend span { display: inline-flex; align-items: center; gap: 7px; }
.tv-twin-legend b { color: var(--text); font-weight: 500; }
.tv-twin-legend-hint { color: var(--dim); }
.tv-twin-swatch { width: 20px; height: 3px; display: inline-block; flex: none; }
.tv-sw-edge { background: var(--accent); }
.tv-sw-bb { background: var(--cyan); }
.tv-sw-edge-text { color: var(--accent); }
.tv-sw-bb-text { color: var(--cyan); }
.tv-twin-cursor-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tv-twin-readouts { display: flex; gap: 18px; flex-wrap: wrap; flex: 1; }
.tv-twin-ro { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.tv-twin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); }
.tv-twin-col { padding: 14px 16px; min-width: 0; }
.tv-twin-col-bb { border-left: 1px solid var(--border); }
.tv-twin-col-head { font-size: 10px; letter-spacing: .16em; margin-bottom: 12px; }
.tv-twin-col .tv-charts-grid { grid-template-columns: 1fr; gap: 14px; }
.tv-twin-note { margin-top: 16px; font-size: 12px; color: var(--dim); max-width: 80ch; line-height: 1.7; }
@media (max-width: 860px) {
  .tv-twin-cols { grid-template-columns: 1fr; }
  .tv-twin-col-bb { border-left: none; border-top: 1px solid var(--border); }
}

/* Détail vol — verdict santé */
.tv-health { padding: 16px 18px; margin-bottom: 20px; border: 1px solid; }
.tv-health-ok { border-color: var(--status-ok-bd); background: var(--status-ok-bg); }
.tv-health-warn { border-color: var(--status-warn-bd); background: var(--status-warn-bg); }
.tv-health-crit { border-color: var(--status-crit-bd); background: var(--status-crit-bg); }
.tv-health-head { display: flex; align-items: center; gap: 14px; }
.tv-health-badge {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; font-size: 16px;
  display: flex; align-items: center; justify-content: center; border: 2px solid currentColor;
}
.tv-health-verdict { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 16px; }
.tv-health-ok .tv-health-badge, .tv-health-ok .tv-health-verdict { color: var(--green); }
.tv-health-warn .tv-health-badge, .tv-health-warn .tv-health-verdict { color: var(--accent); }
.tv-health-crit .tv-health-badge, .tv-health-crit .tv-health-verdict { color: var(--red); }
.tv-health-ok .tv-health-badge { background: color-mix(in srgb, var(--green) 12%, transparent); }
.tv-health-warn .tv-health-badge { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tv-health-crit .tv-health-badge { background: color-mix(in srgb, var(--red) 12%, transparent); }
.tv-health-flags { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.tv-health-flag { font-size: 12px; color: var(--text); display: flex; gap: 8px; }
.tv-flag-crit { color: var(--red); }
.tv-flag-warn { color: var(--accent); }

/* Détail vol — événements détectés */
.tv-anomaly-block { padding: 18px 20px; margin-bottom: 26px; }
.tv-anomaly-badge {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: .1em;
  color: var(--accent); border: 1px solid var(--accent); padding: 3px 9px; white-space: nowrap;
}
.tv-anomaly-timeline { position: relative; height: 28px; margin: 18px 2px 20px; }
.tv-anomaly-track { position: absolute; top: 50%; left: 0; right: 0; height: 2px; background: var(--border-strong); transform: translateY(-50%); }
.tv-anomaly-dot {
  position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%;
  transform: translate(-50%, -50%); border: 2px solid var(--bg); cursor: pointer; padding: 0;
}
.tv-anomaly-dot.tv-anomaly-warning { background: var(--accent); }
.tv-anomaly-dot.tv-anomaly-danger { background: var(--red); }
.tv-anomaly-dot:hover, .tv-anomaly-dot.active { box-shadow: 0 0 0 4px rgba(240, 166, 64, .2); }
.tv-anomaly-dot.tv-anomaly-danger:hover, .tv-anomaly-dot.tv-anomaly-danger.active { box-shadow: 0 0 0 4px rgba(229, 83, 61, .2); }

.tv-anomaly-detail {
  display: flex; align-items: center; gap: 12px; min-height: 20px;
  background: var(--panel-alt); border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  padding: 12px 14px;
}
.tv-anomaly-detail.tv-anomaly-warning { border-left-color: var(--accent); }
.tv-anomaly-detail.tv-anomaly-danger { border-left-color: var(--red); }
.tv-anomaly-hint { font-size: 11px; color: var(--dim); }
.tv-anomaly-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
.tv-anomaly-detail.tv-anomaly-warning .tv-anomaly-icon { color: var(--accent); }
.tv-anomaly-detail.tv-anomaly-danger .tv-anomaly-icon { color: var(--red); }
.tv-anomaly-text { display: flex; flex-direction: column; gap: 2px; }
.tv-anomaly-item-title { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 12.5px; color: var(--heading); }
.tv-anomaly-item-detail { font-size: 11px; color: var(--dim); }

.tv-anomaly-highlight { fill: var(--accent); opacity: .18; transition: opacity .9s ease; pointer-events: none; }
.tv-anomaly-highlight.fade { opacity: 0; }

/* Détail vol — curseur synchronisé */
.tv-cursor-bar {
  display: flex; gap: 20px; flex-wrap: wrap; align-items: center; padding: 11px 16px;
  border: 1px solid var(--border-strong); background: var(--panel-alt); margin-bottom: 18px; font-size: 12px;
}
.tv-cursor-time { font-family: 'Chakra Petch', sans-serif; color: var(--accent); letter-spacing: .06em; }
.tv-cursor-items { color: var(--heading); display: flex; gap: 14px; flex-wrap: wrap; }
.tv-c-lbl { color: var(--dim); }
.tv-c-sep { color: var(--dimmer); margin: 0 2px; }

/* Import */
.tv-import { align-items: center; padding: 60px 24px; }
.tv-import-inner { width: 640px; max-width: 100%; }
.tv-dropzone {
  display: block; border: 2px dashed var(--border-strong); background: var(--panel);
  padding: 56px 30px; text-align: center; cursor: pointer; transition: all .15s;
}
.tv-dropzone.dragging { border-color: var(--accent); background: var(--accent-tint-bg); }
.tv-hidden-input { display: none; }
.tv-dropzone-icon { font-size: 34px; color: var(--accent); line-height: 1; }
.tv-dropzone-title { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 16px; color: var(--heading); margin-top: 14px; }
.tv-dropzone-sub { font-size: 11.5px; color: var(--dim); margin-top: 8px; }
.tv-import-result {
  margin-top: 20px; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.tv-import-success { border: 1px solid var(--status-ok-bd); background: var(--status-ok-bg); }
.tv-import-result-title { font-size: 12px; color: var(--green); letter-spacing: .08em; }
.tv-import-result-detail { font-size: 11px; color: var(--dim); margin-top: 5px; }
.tv-import-error { border: 1px solid var(--status-crit-bd); background: var(--status-crit-bg); font-size: 12px; color: var(--red); }
.tv-import-warn { border: 1px solid var(--status-warn-bd); background: var(--status-warn-bg); font-size: 12px; color: var(--accent); }
.tv-import-dup { margin-top: 20px; border: 1px solid var(--status-warn-bd); background: var(--status-warn-bg); padding: 16px 18px; }
.tv-import-dup-text { font-size: 12px; color: var(--accent); }
.tv-import-dup-actions { display: flex; gap: 10px; margin-top: 12px; }
.tv-import-cols-label { margin-top: 36px; font-size: 10px; letter-spacing: .2em; color: var(--dimmer); }
.tv-import-cols { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tv-import-cols span { border: 1px solid var(--border); color: var(--muted); font-size: 10.5px; padding: 5px 10px; }

/* Bandeau démo publique */
.tv-demo-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 11px 16px; margin-bottom: 20px; border: 1px solid var(--border-strong); background: var(--panel);
  font-size: 12px; color: var(--muted);
}
.tv-demo-banner strong { color: var(--accent); }
.tv-demo-banner-cta { padding: 7px 14px; font-size: 10.5px; white-space: nowrap; }

/* Flight detail */
.tv-flight-detail { padding: 40px 40px 60px; }
.tv-compare-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tv-compare-label { font-size: 10px; letter-spacing: .15em; color: var(--dim); }
.tv-compare-btn {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: .08em; padding: 8px 13px; cursor: pointer;
  background: none; border: 1px solid var(--border-strong); color: var(--muted); display: inline-block;
}
.tv-compare-btn:hover { border-color: var(--accent); }
.tv-compare-btn.active { background: var(--panel-alt); }
.tv-compare-legend { display: flex; gap: 22px; margin-bottom: 18px; font-size: 11px; letter-spacing: .1em; flex-wrap: wrap; }

.tv-compare-dropdown { position: relative; }
.tv-compare-toggle {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: .08em; padding: 8px 13px; cursor: pointer;
  background: none; border: 1px solid var(--border-strong); color: var(--muted); display: inline-flex; align-items: center; gap: 8px;
}
.tv-compare-toggle:hover { border-color: var(--accent); }
.tv-compare-caret { font-size: 9px; }
.tv-compare-panel {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  min-width: 240px; max-height: 260px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border-strong);
}
.tv-compare-panel.open { display: block; }
.tv-compare-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; color: var(--muted); border-left: 2px solid transparent; border-bottom: 1px solid var(--border-faint);
}
.tv-compare-item:last-child { border-bottom: none; }
.tv-compare-item:hover { background: var(--panel-alt); color: var(--heading); }
.tv-compare-item.active { background: var(--panel-alt); }
.tv-compare-check { width: 12px; color: var(--accent); flex-shrink: 0; }
.tv-compare-empty { padding: 12px; font-size: 11px; color: var(--dimmer); }
.tv-compare-hint { padding: 10px 12px; font-size: 10.5px; line-height: 1.5; color: var(--dim); border-bottom: 1px solid var(--border-faint); }
.tv-compare-legend-note { color: var(--dim); font-size: 10.5px; }

/* Séparateurs portés par les cartes (bord droit/bas) plutôt que par un fond
   gris + gap : ainsi les cases vides de la dernière ligne (nombre de stats
   non multiple de la largeur) se fondent avec le fond au lieu d'afficher des
   rectangles gris. */
.tv-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--border); border-right: 0; border-bottom: 0; margin-bottom: 28px;
}
.tv-stat-card {
  background: var(--panel); padding: 16px 18px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.tv-stat-label { font-size: 9.5px; letter-spacing: .18em; color: var(--dim); }
.tv-stat-value { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 22px; margin-top: 6px; }
.tv-stat-unit { font-size: 12px; color: var(--dim); margin-left: 4px; }

.tv-chart-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tv-chart-tab {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: .1em; padding: 9px 15px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--muted);
}
.tv-chart-tab:hover { color: var(--accent); border-color: var(--accent); }
.tv-chart-tab.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.tv-charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }
.tv-chart-group { display: none; }
.tv-chart-group.active { display: grid; }
.tv-chart-card, .tv-gps-card { padding: 18px 20px 14px; }
.tv-chart-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.tv-chart-title { font-size: 11px; letter-spacing: .15em; color: var(--heading); }
.tv-chart-range { font-size: 10px; color: var(--dim); }
.tv-chart-svg { width: 100%; height: auto; display: block; }
.tv-chart-grid-line { stroke: var(--border-faint); stroke-width: 1; }
.tv-chart-axis-line { stroke: var(--border-strong); stroke-width: 1; }
.tv-chart-axis-label { fill: var(--dim); }
.tv-chart-key2-line { stroke: var(--muted); }
.tv-chart-footer { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--dimmer); margin-top: 8px; padding-left: 7.3%; }

/* Légende sous chaque graphique (série(s) + vols comparés) */
.tv-chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; padding-left: 7.3%; }
.tv-chart-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; letter-spacing: .04em; color: var(--muted); }
.tv-chart-legend-swatch { width: 16px; height: 3px; flex: none; background: var(--sw-color, var(--accent)); }
.tv-chart-legend-swatch.dashed {
  background: repeating-linear-gradient(90deg, var(--sw-color, var(--muted)) 0 4px, transparent 4px 7px);
}
.tv-chart-legend-swatch.terrain { height: 9px; background: var(--terrain-fill); border-top: 2px solid var(--terrain); }

/* Profil de terrain : relief SRTM en aire de fond derrière l'altitude du drone. */
.tv-chart-terrain-area { fill: var(--terrain-fill); stroke: var(--terrain); stroke-width: 1.4; }

/* Courbes de signal radio : sens du lien, repères du bilan de liaison,
   échelle de couleur absolue et note de contexte. */
.tv-chart-subtitle {
  font-size: 10px; color: var(--dim); letter-spacing: .02em; margin: -6px 0 10px;
}
.tv-chart-ref-line { stroke: var(--dimmer); stroke-width: 1; opacity: .75; }
.tv-chart-ref-label { fill: var(--dim); letter-spacing: .04em; }
.tv-chart-scale {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-left: 7.3%;
}
.tv-chart-scale-end { font-size: 9px; letter-spacing: .14em; flex: none; }
.tv-chart-scale-track { flex: 1; min-width: 60px; display: flex; flex-direction: column; gap: 3px; }
.tv-chart-scale-bar { height: 6px; }
.tv-chart-scale-unit { font-size: 9px; color: var(--dimmer); flex: none; }
.tv-chart-scale-ticks {
  display: flex; justify-content: space-between; font-size: 9px; color: var(--dimmer);
  font-variant-numeric: tabular-nums;
}
.tv-chart-note {
  font-size: 9.5px; color: var(--dim); letter-spacing: .03em; margin-top: 10px; padding-left: 7.3%;
}

.tv-gps-map-wrap { position: relative; }
.tv-gps-panel-map { width: 100%; height: 300px; }
/* Chip volontairement toujours sombre (lisible sur la tuile satellite,
   claire ou foncée selon l'endroit) : couleurs fixes, indépendantes du
   thème de l'appli — sinon le texte suit --heading et devient noir sur
   fond noir en thème clair. */
.tv-gps-fullscreen-btn {
  position: absolute; top: 10px; right: 10px; z-index: 1000;
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: .08em;
  padding: 7px 12px; background: rgba(13, 16, 19, .88); border: 1px solid rgba(255, 255, 255, .18);
  color: #eef2f5; backdrop-filter: blur(2px);
}
.tv-gps-fullscreen-btn:hover { border-color: #f0a640; color: #f0a640; }
.tv-gps-legend { display: flex; gap: 18px; font-size: 9.5px; color: var(--dim); margin-top: 8px; }
.tv-gps-empty {
  height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; border: 1px dashed var(--border-strong); font-size: 11px; color: var(--dim); text-align: center; padding: 20px;
}
.tv-gps-empty-icon { font-size: 22px; color: var(--dimmer); }

/* Flotte / drones */
.tv-fleet { padding: 48px 40px 60px; max-width: 920px; }
.tv-drone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tv-drone-card { border: 1px solid var(--border); background: var(--panel); padding: 20px 20px 18px; position: relative; overflow: hidden; }
.tv-drone-bar { position: absolute; top: 0; left: 0; width: 4px; height: 100%; }
.tv-drone-head { display: flex; align-items: center; gap: 12px; }
.tv-drone-dot { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.tv-drone-titles { min-width: 0; }
.tv-drone-name { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 16px; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-drone-type { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tv-drone-specs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 15px; }
.tv-drone-specs span { font-size: 10px; letter-spacing: .04em; color: var(--text); background: var(--border-faint); border: 1px solid var(--border); padding: 3px 8px; }
.tv-drone-notes { font-size: 10.5px; color: var(--dim); margin-top: 10px; line-height: 1.5; }
.tv-drone-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-faint); }
.tv-drone-actions { display: flex; gap: 6px; }
.tv-icon-btn {
  background: none; border: 1px solid var(--border-strong); color: var(--muted); font-size: 13px;
  min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; line-height: 1;
}
.tv-icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.tv-icon-btn-danger:hover { border-color: var(--red); color: var(--red); }

.tv-drone-form { padding: 24px 24px 22px; }
.tv-drone-form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px 20px; }
.tv-col-2 { grid-column: span 2; }
.tv-col-3 { grid-column: span 3; }
.tv-drone-form select.tv-input { appearance: none; }
.tv-drone-form-color-label { font-size: 10px; letter-spacing: .15em; color: var(--dim); margin: 20px 0 10px; }
.tv-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.tv-swatch { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 1px var(--border-strong); display: inline-block; position: relative; }
.tv-swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.tv-swatch:has(input:checked) { box-shadow: 0 0 0 2px var(--heading), 0 0 12px currentColor; }
.tv-drone-form-actions { display: flex; align-items: center; gap: 12px; margin-top: 22px; }

/* Invitations (admin) */
.tv-field-hint { font-size: 10px; color: var(--dim); letter-spacing: 0; }
.tv-invite-code-box { border: 1px solid var(--green); background: var(--status-ok-bg); padding: 20px 22px; margin-bottom: 24px; }
.tv-invite-code-label { font-size: 10px; letter-spacing: .2em; color: var(--dim); }
.tv-invite-code-label span { color: var(--green); }
.tv-invite-code { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 34px; letter-spacing: .3em; color: var(--heading); margin: 8px 0 6px; }
.tv-invite-code-note { font-size: 11px; color: var(--dim); }
.tv-ilist { border: 1px solid var(--border); }
.tv-ilist-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) 100px minmax(0, 1fr) 100px;
  align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border-faint); font-size: 12.5px;
}
.tv-ilist-row:last-child { border-bottom: none; }
.tv-ilist-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-ilist-head { background: var(--panel); border-bottom: 1px solid var(--border); font-size: 9.5px; letter-spacing: .18em; color: var(--dim); }
.tv-ilist-row.tv-cols-3 { grid-template-columns: minmax(0, 1fr) 90px minmax(0, 1fr); }
.tv-ulist-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) 80px 100px 110px minmax(0, 200px);
  align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border-faint); font-size: 12.5px;
}
.tv-ulist-row:last-child { border-bottom: none; }
.tv-ulist-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-ulist-row .tv-row-actions { overflow: visible; }
.tv-mini-btn {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: .04em; padding: 6px 11px;
  cursor: pointer; background: none; border: 1px solid var(--border-strong); color: var(--muted);
}
.tv-mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.tv-mini-btn.active { border-color: var(--accent); color: var(--accent); background: var(--panel-alt); }
.tv-mini-btn-danger:hover { border-color: var(--red); color: var(--red); }
.tv-csv-limit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.tv-csv-limit-row > a.tv-mini-btn { text-decoration: none; }
.tv-csvlist-row {
  display: grid; grid-template-columns: 60px minmax(0, 1.3fr) 130px 140px 90px 40px;
  align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border-faint); font-size: 12.5px;
}
.tv-csvlist-row:last-child { border-bottom: none; }
.tv-csvlist-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-csvlist-row > a.tv-mini-btn { justify-self: end; text-decoration: none; }
.tv-mergelist-row {
  display: grid; grid-template-columns: 120px minmax(0, 1.2fr) minmax(0, 1.4fr) 70px 130px;
  align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border-faint); font-size: 12.5px;
}
.tv-mergelist-row:last-child { border-bottom: none; }
.tv-mergelist-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .tv-ilist-row { grid-template-columns: 1fr 90px; }
  .tv-ilist-row > :nth-child(3), .tv-ilist-row > :nth-child(4) { display: none; }
  .tv-ulist-row { grid-template-columns: 1fr 90px auto; }
  .tv-ulist-row > :nth-child(2), .tv-ulist-row > :nth-child(4) { display: none; }
  .tv-csvlist-row { grid-template-columns: 40px 1fr 90px 40px; }
  .tv-csvlist-row > :nth-child(3), .tv-csvlist-row > :nth-child(5) { display: none; }
  .tv-mergelist-row { grid-template-columns: 100px 1fr 60px; }
  .tv-mergelist-row > :nth-child(3), .tv-mergelist-row > :nth-child(5) { display: none; }
  .tv-coherence-row { grid-template-columns: 70px 1fr 90px; }
  .tv-coherence-row > :nth-child(4) { display: none; }
}

/* Contrôle de cohérence (admin) */
.tv-coherence-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.tv-coherence-applied {
  margin: 18px 0; padding: 12px 16px; background: var(--accent-tint-bg); border: 1px solid var(--accent);
  color: var(--accent); font-size: 12.5px; letter-spacing: .04em;
}
.tv-coherence-row {
  display: grid; grid-template-columns: 90px minmax(0, 1.1fr) 90px minmax(0, 1.3fr);
  align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border-faint); font-size: 12.5px;
}
.tv-coherence-row:last-child { border-bottom: none; }
.tv-coherence-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Console admin : onglets */
.tv-tabbar {
  display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--border);
  padding-bottom: 18px; margin-bottom: 30px;
}
.tv-tab-btn { font-size: 11px; padding: 10px 18px; }
.tv-tab-panel { display: none; }
.tv-tab-panel.active { display: block; }
@media (max-width: 720px) {
  .tv-tabbar { gap: 6px; }
  .tv-tab-btn { padding: 8px 12px; font-size: 10px; }
}

/* Encart d'aide au survol / focus clavier (critères de regroupement) */
.tv-help, .tv-help-inline { position: relative; display: inline-block; }
.tv-help { margin-left: 7px; vertical-align: middle; }
.tv-help-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  border-radius: 50%; border: 1px solid var(--border-strong); color: var(--dim); font-size: 10px; cursor: help;
}
.tv-help:hover .tv-help-mark, .tv-help:focus .tv-help-mark { border-color: var(--accent); color: var(--accent); }
.tv-help-inline {
  color: var(--accent); cursor: help; text-decoration: underline dotted; text-underline-offset: 2px;
}
.tv-help-pop {
  position: absolute; z-index: 60; left: 0; top: calc(100% + 8px); width: min(460px, 82vw);
  padding: 14px 16px; background: var(--panel-alt); border: 1px solid var(--border-strong);
  color: var(--muted); font-size: 11.5px; line-height: 1.55; letter-spacing: normal; text-transform: none;
  font-weight: 400; box-shadow: 0 10px 34px rgba(0, 0, 0, .35);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease, visibility .12s; pointer-events: none;
}
.tv-help:hover .tv-help-pop, .tv-help:focus .tv-help-pop, .tv-help:focus-within .tv-help-pop,
.tv-help-inline:hover .tv-help-pop, .tv-help-inline:focus .tv-help-pop {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.tv-help-pop strong { display: block; color: var(--heading); font-size: 12px; margin-bottom: 8px; }
.tv-help-pop b { color: var(--heading); font-weight: 600; }
.tv-help-list { display: block; margin: 8px 0; }
.tv-help-list > span { display: block; padding: 3px 0 3px 13px; position: relative; }
.tv-help-list > span::before { content: "›"; position: absolute; left: 0; color: var(--accent); }
.tv-help-pop-inline { width: min(360px, 82vw); }

/* Mon compte */
.tv-account { padding: 48px 40px 60px; max-width: 640px; margin: 0 auto; width: 100%; }

/* Admin — utilisateurs & invitations : plus large que .tv-account pour
   laisser la place au tableau des comptes, formulaire gardé étroit. */
.tv-invitations { padding: 48px 40px 60px; max-width: 900px; }
.tv-invite-form { max-width: 560px; }
.tv-user-link { color: var(--heading); text-decoration: none; }
.tv-user-link:hover { color: var(--accent); }

.tv-admin-actions { position: relative; display: inline-block; }
.tv-admin-actions-panel {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  min-width: 210px; background: var(--panel); border: 1px solid var(--border-strong);
}
.tv-admin-actions-panel.open { display: block; }
.tv-admin-action-item {
  width: 100%; text-align: left; display: block; font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--muted); background: none; border: none; border-bottom: 1px solid var(--border-faint);
  padding: 9px 12px; cursor: pointer;
}
.tv-admin-actions-panel form:last-child .tv-admin-action-item { border-bottom: none; }
.tv-admin-action-item:hover { background: var(--panel-alt); color: var(--heading); }
.tv-admin-action-danger:hover { color: var(--red); }

.tv-log-box {
  border: 1px solid var(--border); background: var(--panel); max-height: 320px; overflow-y: auto;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
}
.tv-log-line { padding: 6px 14px; border-bottom: 1px solid var(--border-faint); color: var(--muted); white-space: pre-wrap; word-break: break-all; }
.tv-log-line:last-child { border-bottom: none; }
.tv-admin-flights .tv-table-row { grid-template-columns: minmax(200px, 2fr) 100px 84px 96px 96px 100px; }
.tv-admin-srctabs { display: flex; gap: 2px; }
.tv-admin-srctab {
  font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 11px; letter-spacing: .1em;
  padding: 8px 16px; border: 1px solid var(--border-strong); color: var(--muted);
}
.tv-admin-srctab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
a.tv-admin-srctab:hover { border-color: var(--accent); color: var(--accent); }
a.tv-admin-srctab.active:hover { color: var(--on-accent); }
.tv-account-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 32px; }
.tv-account-sub span { color: var(--text); }
.tv-account-form { display: flex; flex-direction: column; gap: 22px; }
.tv-account-block { border: 1px solid var(--border); background: var(--panel); padding: 26px 26px 22px; }
.tv-account-block-title { font-size: 10px; letter-spacing: .2em; color: var(--dim); margin-bottom: 18px; }
.tv-account-note { font-size: 11px; color: var(--dim); margin: 0 0 16px; }
.tv-account-block .tv-label { margin-top: 16px; }
.tv-account-block .tv-label:first-of-type { margin-top: 0; }
.tv-account-actions { display: flex; align-items: center; gap: 16px; }

/* Tableau de bord */
.tv-dash { padding: 48px 40px 60px; }
.tv-dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); margin-bottom: 22px; }
.tv-dash-tile { background: var(--panel); padding: 24px 22px; }
.tv-dash-value { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 34px; line-height: 1; color: var(--heading); }
.tv-dash-unit { font-size: 15px; color: var(--dim); margin-left: 5px; font-weight: 400; }
.tv-dash-label { font-size: 10px; letter-spacing: .16em; color: var(--dim); margin-top: 12px; }
.tv-dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.tv-dash-records, .tv-dash-last { padding: 22px 24px; }
.tv-dash-record { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--border-faint); font-size: 13px; color: var(--muted); }
.tv-dash-record b { color: var(--heading); font-family: 'Chakra Petch', sans-serif; font-weight: 600; }
.tv-dash-more { margin-top: 14px; font-size: 12px; }
.tv-dash-last-name { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 18px; color: var(--heading); margin-top: 4px; }
.tv-dash-last-meta { font-size: 11px; letter-spacing: .06em; color: var(--dim); margin-top: 8px; }
.tv-dash-record-link { text-decoration: none; }
.tv-dash-record-link:hover b { color: var(--accent); }
.tv-dash-rec-badge {
  font-size: 8.5px; letter-spacing: .12em; color: var(--on-accent); background: var(--green);
  padding: 2px 6px; margin-left: 9px; vertical-align: middle; font-weight: 600;
}
.tv-dash-side { display: flex; flex-direction: column; gap: 22px; }
.tv-dash-drone { padding: 22px 24px; }
.tv-dash-drone-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.tv-dash-drone-name { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 17px; color: var(--heading); }
.tv-dash-drone-meta { font-size: 11px; letter-spacing: .06em; color: var(--dim); margin-top: 8px; }
@media (max-width: 720px) { .tv-dash-cols { grid-template-columns: 1fr; } }

/* Statistiques */
.tv-stats { padding: 48px 40px 60px; max-width: 1000px; }
.tv-stats-intro { font-size: 13px; color: var(--muted); margin: 0 0 40px; }
.tv-stats-primary { display: flex; flex-wrap: wrap; gap: 48px 72px; padding-bottom: 38px; border-bottom: 1px solid var(--border); }
.tv-stats-big { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 52px; line-height: 1; }
.tv-stats-big-unit { font-size: 18px; color: var(--dim); margin-left: 6px; font-weight: 400; }
.tv-stats-label { font-size: 11px; letter-spacing: .14em; color: var(--muted); margin-top: 12px; }
.tv-stats-hint { font-size: 11px; color: var(--dim); margin-top: 4px; }
.tv-stats-list { display: flex; flex-direction: column; margin-top: 14px; }
.tv-stats-row { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding: 16px 2px; border-bottom: 1px solid var(--border-faint); }
.tv-stats-row-link { color: inherit; text-decoration: none; }
.tv-stats-row-link:hover { background: var(--panel-alt); }
.tv-stats-row-label { flex: 1; }
.tv-stats-row-label > span:first-child { font-size: 13px; color: var(--text); }
.tv-stats-row-hint { font-size: 11px; color: var(--dim); margin-left: 12px; }
.tv-stats-row-value { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 19px; white-space: nowrap; }
.tv-stats-row-unit { font-size: 12px; color: var(--dim); margin-left: 4px; font-weight: 400; }
.tv-stats-section-title { font-size: 10px; letter-spacing: .2em; color: var(--accent); margin: 40px 0 16px; }
.tv-bars { display: flex; flex-direction: column; gap: 14px; }
.tv-bar-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--text); margin-bottom: 6px; }
.tv-bar-head .tv-drone-mini { margin-right: 7px; }
.tv-bar-val { font-size: 11px; color: var(--dim); white-space: nowrap; }
.tv-bar-track { height: 8px; background: var(--border-faint); border: 1px solid var(--border); }
.tv-bar-fill { height: 100%; background: var(--accent); min-width: 2px; transition: width .2s linear; }
.tv-import-progress { margin-top: 20px; }
.tv-bar-fill.indeterminate {
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: tv-progress-sweep 1.4s linear infinite;
}
@keyframes tv-progress-sweep {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* GPS full map */
.tv-flight-map { padding: 40px 40px 60px; display: flex; flex-direction: column; }
.tv-map-wrap { border: 1px solid var(--border); background: var(--panel); padding: 10px; height: 560px; }
.tv-map { width: 100%; height: 100%; }
.tv-empty-block {
  height: 560px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; border: 1px dashed var(--border-strong); color: var(--dim); font-size: 11px; text-align: center;
}
.tv-empty-icon { font-size: 22px; color: var(--dimmer); }

.leaflet-container { background: var(--panel) !important; }

/* Carte GPS — barre d'outils */
.tv-map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; margin-bottom: 16px; }
.tv-map-toolgroup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tv-map-btn {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: .06em; padding: 7px 12px;
  cursor: pointer; background: none; border: 1px solid var(--border-strong); color: var(--muted);
}
.tv-map-btn:hover:not(:disabled) { border-color: var(--accent); }
.tv-map-btn.active { background: var(--panel-alt); border-color: var(--accent); color: var(--accent); }
.tv-map-btn:disabled { color: var(--dimmer); cursor: not-allowed; }
.tv-map-legend { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--dim); }
.tv-map-legend[hidden] { display: none; }
.tv-legend-gradient {
  width: 120px; height: 8px; display: inline-block;
  background: linear-gradient(90deg, hsl(210,85%,55%), hsl(140,85%,55%), hsl(60,85%,55%), hsl(0,85%,55%));
}
.tv-map-vol-select { min-width: 260px; max-width: 380px; }

@media (max-width: 1200px) {
  .tv-table-row { grid-template-columns: minmax(180px, 2fr) 100px 84px 96px 140px 120px; }
  .tv-table-row > :nth-child(5), .tv-table-row > :nth-child(6) { display: none; }
  .tv-admin-flights .tv-table-row { grid-template-columns: minmax(180px, 2fr) 100px 84px 96px; }
  /* Carnet unifié : masque RSSI + CONSO, garde SOURCE et BATT. */
  .tv-table-src .tv-table-row { grid-template-columns: minmax(160px, 2fr) 82px 100px 84px 92px 132px 108px; }
  .tv-table-src .tv-table-row > :nth-child(5) { display: block; }
  .tv-table-src .tv-table-row > :nth-child(6), .tv-table-src .tv-table-row > :nth-child(7) { display: none; }
}

@media (max-width: 860px) {
  .tv-charts-grid { grid-template-columns: 1fr; }
  .tv-table-row { grid-template-columns: 1fr 84px 140px 120px; }
  .tv-table-row > :nth-child(2), .tv-table-row > :nth-child(4),
  .tv-table-row > :nth-child(5), .tv-table-row > :nth-child(6) { display: none; }
  .tv-admin-flights .tv-table-row { grid-template-columns: 1fr 84px; }
  /* Carnet unifié en mobile : session, source, durée, actions. Colonnes fixes
     resserrées + gap réduit pour tenir sur ~360px de large sans que la source
     et la session ne se chevauchent (les cellules gardent min-width:0 pour
     tronquer proprement). */
  .tv-table-src .tv-table-row {
    grid-template-columns: minmax(0, 1fr) 70px 52px 100px; column-gap: 6px; padding-left: 12px; padding-right: 12px;
  }
  .tv-table-src .tv-table-row > * { min-width: 0; }
  .tv-table-src .tv-table-row > :nth-child(2), .tv-table-src .tv-table-row > :nth-child(4) { display: block; }
  .tv-table-src .tv-table-row > :nth-child(3), .tv-table-src .tv-table-row > :nth-child(5),
  .tv-table-src .tv-table-row > :nth-child(6), .tv-table-src .tv-table-row > :nth-child(7),
  .tv-table-src .tv-table-row > :nth-child(8) { display: none; }
  .tv-table-src .tv-row-actions { gap: 4px; }
  .tv-table-src .tv-row-actions .tv-icon-btn { min-width: 28px; height: 28px; }
  .tv-drone-form-grid { grid-template-columns: 1fr 1fr; }
  .tv-col-2, .tv-col-3 { grid-column: span 2; }

  /* Nav mobile : bascule vers un panneau déroulant sous l'en-tête sticky */
  .tv-nav-toggle { display: flex; align-items: center; justify-content: center; }
  .tv-nav-panel {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--panel); border-bottom: 1px solid var(--border);
    padding: 8px 20px 18px; max-height: calc(100vh - 58px); overflow-y: auto; z-index: 39;
  }
  .tv-nav-panel.open { display: flex; }
  .tv-nav { flex: none; flex-direction: column; }
  .tv-nav-link { border-bottom: 1px solid var(--border-faint); border-left: 2px solid transparent; padding: 13px 10px; }
  .tv-nav-link.active { border-bottom-color: var(--border-faint); border-left-color: var(--accent); background: var(--panel-alt); }
  .tv-nav-user { flex-direction: column; align-items: stretch; gap: 10px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
  .tv-nav-account, .tv-btn-logout { text-align: center; }
  .tv-nav-panel > .tv-btn-primary { margin-top: 12px; text-align: center; }
  .tv-theme-toggle { margin-top: 12px; justify-content: center; }
}

@media (max-width: 600px) {
  .tv-hero { padding: 60px 20px 60px; }
  .tv-hero-title { font-size: 34px; }
  .tv-hero-sub { font-size: 13.5px; }
  .tv-features { grid-template-columns: 1fr; }
  .tv-flights, .tv-flight-detail, .tv-fleet, .tv-account, .tv-invitations, .tv-dash,
  .tv-stats, .tv-flight-map, .tv-import { padding-left: 18px; padding-right: 18px; }
  /* Le viewBox du graphique (600 unités) est mis à l'échelle avec sa largeur
     réelle : sous ~600px, la largeur rétrécit assez pour rendre les labels
     d'axe (10 unités) illisibles (~5px réels). On fige une largeur minimale
     proche de l'échelle native et on laisse défiler horizontalement plutôt
     que de continuer à réduire le texte. */
  .tv-chart-card { overflow-x: auto; }
  .tv-chart-svg { min-width: 560px; }
  .tv-drone-form-grid { grid-template-columns: 1fr; }
  .tv-col-2, .tv-col-3 { grid-column: span 1; }
  .tv-map-wrap, .tv-empty-block { height: 380px; }
  .tv-gps-panel-map { height: 220px; }
  .tv-filter-search, .tv-filter-field { max-width: none; width: 100%; }
  .tv-stats-primary { gap: 28px 40px; }
  .tv-stats-big { font-size: 40px; }
  .tv-compare-panel { left: 0; right: auto; max-width: calc(100vw - 36px); }
}
