/* Moving Power Lab - Style v2 */

/* ── Tokens ── */
:root {
  /* Charte Moving Power Lab — vert / crème / or */
  --green-deep:    #143D2B;   /* titres, texte le plus foncé */
  --green-dark:    #1E6C4C;   /* texte fort, CTA, footer */
  --green-mid:     #2F9E5B;   /* CTA, liens, eyebrows */
  --green-light:   #67B76A;
  --green-lime:    #90C267;
  --green-accent:  #90C267;
  --green-pale:    #EAF2E2;   /* tint clair pour survols / surfaces actives */

  --gold:          #FCD980;   /* accent soleil (sur fond sombre) */
  --gold-deep:     #F4B740;

  --bg:            #FFFEF8;   /* surface des cartes (blanc chaud) */
  --surface:       #F4F1E6;   /* crème — champs, zones secondaires */
  --surface-2:     #F7F4EA;   /* crème clair — graphes, lignes GPS */
  --border:        rgba(30, 108, 76, 0.16);
  --text:          #234034;
  --text-muted:    #5d6f63;
  --text-faint:    #8a988f;

  --shadow-sm: 0 1px 3px rgba(20,61,43,0.08);
  --shadow-md: 0 4px 16px rgba(20,61,43,0.10);
  --shadow-lg: 0 8px 32px rgba(20,61,43,0.13);

  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --radius-full: 9999px;

  --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', system-ui, sans-serif;
  --font-body: 'Hanken Grotesk', 'Helvetica Neue', system-ui, sans-serif;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --bg-page: #F4F1E6;   /* crème — fond de page */
  --shadow-card: 0 2px 12px rgba(20,61,43,0.07), 0 1px 3px rgba(20,61,43,0.04);

  /* Dégradés signature (repris du site + QCM) */
  --grad-green: linear-gradient(135deg, var(--green-mid) 0%, var(--green-dark) 100%);
  --grad-ray:   linear-gradient(90deg, var(--green-lime), var(--green-mid) 52%, var(--green-dark));
  --grad-sun:   linear-gradient(90deg, var(--gold), var(--gold-deep));
  /* Ombre longue et douce des cartes du site */
  --shadow-soft: 0 30px 60px -38px rgba(20,61,43,0.42), 0 2px 8px rgba(20,61,43,0.05);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; max-width: 100%; overflow-x: hidden; }

img, canvas { max-width: 100%; }

body {
  background-color: var(--bg-page);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Halo solaire ambiant : vert au levant, or au couchant (signature MPL) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 14% 10%, rgba(144, 194, 103, 0.18), transparent 42%),
    radial-gradient(circle at 88% 90%, rgba(244, 183, 64, 0.15), transparent 46%);
}

/* Les polices Bricolage Grotesque + Hanken Grotesk sont chargées via <link> dans index.html */

/* ── Container ── */
#container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  background: transparent;
  border: none;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--green-deep) 0%, var(--green-dark) 46%, var(--green-mid) 100%);
  padding: max(1rem, env(safe-area-inset-top)) 1.5rem 1rem;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  overflow: hidden;
}
/* Halo solaire dans l'angle du header */
header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(120% 150% at 90% -30%, rgba(252, 217, 128, 0.30), transparent 55%);
}
.header-logos,
.status-bar { position: relative; z-index: 1; }

.header-logos {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

.logo-left {
  flex-shrink: 0;
  height: 80px;
}

.header-center-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.status-bar {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.status-chip {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-full);
  padding: 0.28rem 0.85rem;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
  white-space: nowrap;
}


.logo {
  height: 60px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.logo.logo-left {
  height: 80px;
}

.logo-center {
  height: 40px;
}

header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 700;
  color: #ffffff;
  text-align: center;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
  padding: 0;
  background: none;
  border: none;
}

header nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header nav ul li {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.45rem 1.2rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border: 1px solid rgba(255,255,255,0.2);
  min-height: unset;
  height: auto;
  width: auto;
  display: inline-flex;
  align-items: center;
}

header nav ul li:hover,
header nav ul li.active {
  background: rgba(255,255,255,0.95);
  color: var(--green-dark);
}

/* ── Boutons Connect/Disconnect (dans le header) ── */
button {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1.4rem;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  margin: 0;
}

#connect-btn {
  font-size: 0.8rem;
  padding: 0.4rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--green-dark);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
#connect-btn:hover { background: #ffffff; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
#connect-btn:active { transform: scale(0.97); }

#disconnect-btn {
  font-size: 0.85rem;
  padding: 0.38rem 0.65rem;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.2);
}
#disconnect-btn:hover { background: rgba(220,50,50,0.35); color: #fff; border-color: rgba(220,50,50,0.5); }
#disconnect-btn:active { transform: scale(0.97); }

#reset_chart_view {
  width: auto;
  padding: 0.3rem 0.7rem;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}
#reset_chart_view:hover { background: var(--green-pale); color: var(--green-dark); }

/* ── Accessibilité ── */
:focus-visible {
  outline: 3px solid var(--green-mid);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Cibles tactiles : min 44px sur les éléments cliquables */
header nav ul li,
#connect-btn,
#disconnect-btn,
.popup-mode-btn,
.footer-btn { min-height: 44px; }
header nav ul li,
.footer-btn { display: inline-flex; align-items: center; }
/* Lignes du tableau historique cliquables */
#weekly_tbody tr { cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Data Spot Cards ── */
.data-spot {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
/* Rayon solaire en tête de carte (signature reprise du site) */
.data-spot::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--grad-ray);
}

/* ── Section Headings (eyebrow vert + tiret doré) ── */
.data-spot h2 {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--green-mid);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.data-spot h2::before {
  content: "";
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad-sun);
  flex: none;
}

.side_by_side h2 { margin-bottom: 0; }
#weekly_datas_title { margin-bottom: 0.85rem; }

/* ── KPI Power Display ── */
.kpi-card {
  padding: 0.35rem 0 0.85rem;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--green-deep);
  background: linear-gradient(120deg, var(--green-mid), var(--green-dark) 58%, var(--green-deep));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kpi-unit {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--green-mid);
  -webkit-text-fill-color: var(--green-mid);
  margin-left: 0.08em;
  vertical-align: 0.18em;
}

.kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--green-mid);
  margin-top: 0.5rem;
}

/* ── GPS Section ── */
.gps-status-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  margin-bottom: 0.1rem;
  transition: border-color var(--transition);
}

.gps-status-row[data-status="green"]  { border-left-color: #22c55e; }
.gps-status-row[data-status="orange"] { border-left-color: #f97316; }
.gps-status-row[data-status="red"]    { border-left-color: #ef4444; }

.gps-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.32rem;
  background: var(--text-faint);
  transition: background var(--transition), box-shadow var(--transition);
}

.gps-dot[data-status="green"]  { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,0.2); }
.gps-dot[data-status="orange"] { background: #f97316; box-shadow: 0 0 0 3px rgba(249,115,22,0.18); }
.gps-dot[data-status="red"]    { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }

.gps-status-content { flex: 1; min-width: 0; }

.gps-status-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  transition: color var(--transition);
}

.gps-status-label[data-status="green"]  { color: #15803d; }
.gps-status-label[data-status="orange"] { color: #b45309; }
.gps-status-label[data-status="red"]    { color: #b91c1c; }

.gps-address {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.28rem;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-card {
  margin-top: 0.9rem;
}

#bike-map {
  width: 100%;
  min-height: 280px;
  height: 42vh;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #e9f7ef 0%, #f7fbf8 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}

#bike-map-hint {
  margin-top: 0.55rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-faint);
}

.leaflet-container {
  font-family: var(--font-body);
}

.bike-marker-icon {
  background: transparent;
  border: none;
}

.bike-marker-icon__dot {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #22c55e;
  border: 3px solid #ffffff;
  border-radius: 9999px;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* ── Recharge data ── */
#recharge_data_title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--green-deep);
}
#recharge_data_title::before { display: none; }

.side_by_side {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

@media (max-width: 640px) {
  #bike-map {
    min-height: 240px;
    height: 36vh;
  }
}

/* ── Charts ── */
.chart {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

#puissance-chart {
  min-height: 40vh;
  height: 45vh;
}

#thingspeak-chart {
  min-height: 22vh;
  height: 30vh;
  display: none;
}

#puissance-chart canvas,
#puissance-data-canvas,
#thingspeak-chart canvas,
#thingspeak-chart-canvas { width: 100%; height: 100%; }

#preview_chart_canvas { width: 100%; height: 300px; }

/* ── Navigation boutons historique ── */
#recharge-buttons {
  display: grid;
  grid-template-columns: 7fr 86fr 7fr;
  gap: 0.5rem;
  align-items: center;
}

#button_right, #button_left {
  height: auto;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.4rem;
}
#button_right:hover, #button_left:hover { background: var(--green-pale); color: var(--green-dark); }

.hourly-display-btn {
  min-width: 23%;
  max-width: 23%;
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.hourly-display-btn:hover { background: var(--green-pale); color: var(--green-dark); }

#slider { width: 99%; accent-color: var(--green-mid); }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; }

tr {
  display: grid;
  grid-template-columns: 2fr 1fr;
  height: auto;
  min-height: 2.5rem;
  border: none;
  border-bottom: 1px solid var(--border);
  margin: 0;
  padding: 0;
}
tr:last-child { border-bottom: none; }
tr:hover { background: var(--green-pale); }
tr:hover td { font-weight: 600; }

tr td:first-child { padding: 0.6rem 0.5rem; font-size: 0.875rem; }
tr td:last-child { padding: 0.6rem 0.5rem; text-align: right; font-size: 0.875rem; font-variant-numeric: tabular-nums; color: var(--green-dark); font-weight: 500; }

/* ── Popup ── */
.popupContainer {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  z-index: 1001;
}

.popupContainer.active {
  opacity: 1;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.42);
  transition: opacity var(--transition);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.popupContainer .popupContent {
  background: var(--bg);
  border-radius: var(--radius-lg);
  width: 92%;
  max-width: 360px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22), 0 4px 16px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transform: scale(0.92) translateY(16px);
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.popupContainer.active .popupContent {
  transform: scale(1) translateY(0);
}

/* Header dégradé */
.popup-header {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  padding: 1.6rem 1.25rem 1.3rem;
  text-align: center;
}

.popup-header-icon {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.popup-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
}

.popup-subtitle {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.72);
  margin: 0;
  min-height: 1.1em;
}

/* Sélecteur de mode (4G / Bluetooth) */
.popup-mode {
  display: flex;
  gap: 0.4rem;
  padding: 0.85rem 1.25rem 0.25rem;
}
.popup-mode-btn {
  flex: 1;
  padding: 0.5rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.popup-mode-btn.active {
  background: var(--green-mid);
  color: #fff;
  border-color: var(--green-mid);
  box-shadow: 0 4px 12px -4px rgba(30,108,76,0.5);
}

/* Panneau Bluetooth */
.popup-ble-note {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
  padding: 0.9rem 1.25rem 0.4rem;
  margin: 0;
}
.popup-ble-warn {
  font-size: 0.8rem;
  line-height: 1.45;
  color: #b45309;
  background: rgba(252,217,128,0.22);
  border: 1px solid rgba(244,183,64,0.4);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
  margin: 0 1.25rem 0.6rem;
}
.popup-ble-connect {
  width: calc(100% - 2.5rem);
  margin: 0.4rem 1.25rem 1rem;
  padding: 0.8rem;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--green-mid), var(--green-dark));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 12px 26px -12px rgba(30,108,76,0.6);
}
.popup-ble-connect:hover { transform: translateY(-2px); box-shadow: 0 18px 32px -12px rgba(30,108,76,0.7); }
.popup-ble-connect:active { transform: scale(0.98); }

/* Liste de vélos */
.popup-body { padding: 0.25rem 0 0; }

#bike-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#bike-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), color var(--transition);
  user-select: none;
}

#bike-list li:last-child { border-bottom: none; }

#bike-list li::after {
  content: "›";
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--text-faint);
  transition: color var(--transition), transform var(--transition);
}

#bike-list li:hover                { background: var(--green-pale); color: var(--green-dark); }
#bike-list li:hover::after         { color: var(--green-mid); transform: translateX(3px); }
#bike-list li[data-selected="true"]::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.25);
  margin-right: 0.6rem;
  flex-shrink: 0;
}

.bike-name { font-weight: 500; display: flex; align-items: center; gap: 0.55rem; }
.bike-num  {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--green-dark);
  background: var(--green-pale);
  border: 1px solid rgba(46,139,87,0.25);
  border-radius: var(--radius-full);
  padding: 0.1rem 0.55rem;
  letter-spacing: 0.02em;
}

/* Connexion manuelle */
.popup-manual {
  padding: 0.8rem 1.25rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.popup-divider {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin: 0 0 0.55rem;
}

.popup-input-row {
  display: flex;
  gap: 0.4rem;
}

.popup-input-row input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.popup-input-row input:focus { border-color: var(--green-mid); }

.popup-input-btn {
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--green-mid);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
}
.popup-input-btn:hover { background: var(--green-dark); }

/* Footer */
.popup-footer {
  padding: 0.8rem 1.25rem;
  border-top: 1px solid var(--border);
}

.closePopup {
  width: 100%;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}
.closePopup:hover { background: var(--green-pale); color: var(--green-dark); border-color: var(--green-light); }

/* ── Footer ── */
footer {
  margin-top: 2.5rem;
  padding: 1.5rem 1rem 2rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

.footer-tagline {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--green-mid);
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.footer-tagline::before,
.footer-tagline::after {
  content: "";
  display: block;
  width: 28px;
  height: 1px;
  background: var(--green-light);
  opacity: 0.6;
}

footer p {
  font-size: 0.7rem;
  color: var(--text-faint);
  background: none;
  border: none;
  padding: 0;
  cursor: default;
  letter-spacing: 0.02em;
}

.footer-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.4rem 0 1rem;
}
.footer-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--green-dark);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.footer-btn:hover { background: var(--green-pale); border-color: var(--green-light); }

/* ── Notes ── */
.muted-note {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-faint);
  margin: 0.6rem 0 0;
}

/* ── Météo ── */
.weather-now {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 0 1rem;
}
.weather-emoji { font-size: 3rem; line-height: 1; }
.weather-temp {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--green-deep);
  line-height: 1;
}
.weather-label { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.25rem; }
.weather-loc   { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.15rem; }

.charge-forecast {
  background: linear-gradient(135deg, var(--green-dark), var(--green-deep));
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  text-align: center;
  margin-bottom: 1rem;
}
.charge-value {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.charge-unit  { font-size: 1.3rem; font-weight: 600; }
.charge-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,254,248,0.82);
  margin-top: 0.4rem;
}
/* Prévision de charge : deux scénarios côte à côte (à plat / bien orienté) */
.charge-split { display: flex; align-items: stretch; justify-content: center; gap: 1rem; margin-top: 0.7rem; }
.charge-split .charge-value { font-size: 2.1rem; }
.charge-col { flex: 1; }
.charge-col--hi .charge-value { color: var(--gold); }
.charge-sep { width: 1px; background: rgba(255,254,248,0.18); }
.charge-sub { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,254,248,0.7); margin-top: 0.3rem; }
#weather-chart { min-height: 32vh; height: 36vh; }
#weather-chart canvas, #weather-chart-canvas { width: 100%; height: 100%; }

/* ── Inclinateur — boussole instrument ── */
.compass {
  position: relative;
  width: min(290px, 80vw);
  aspect-ratio: 1;
  margin: 0.4rem auto 1.5rem;
  padding: 14px;
  border-radius: 50%;
  background: conic-gradient(from 200deg,
    var(--green-deep), var(--green-dark), var(--green-mid),
    var(--green-dark), var(--green-deep));
  box-shadow: 0 14px 34px rgba(20, 61, 43, 0.22),
              0 2px 6px rgba(20, 61, 43, 0.14),
              inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.compass-face {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #ffffff 0%, var(--surface-2) 62%, var(--surface) 100%);
  box-shadow: inset 0 2px 10px rgba(20, 61, 43, 0.12),
              inset 0 0 0 1px rgba(20, 61, 43, 0.06);
}
/* Rose des vents fixe : le N reste toujours en haut, ce sont les aiguilles qui tournent */
.compass-card {
  position: absolute;
  inset: 0;
}
.compass-ticks {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg,
    var(--green-dark) 0deg 0.7deg, transparent 0.7deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 0 40%, #000 40% 47%, transparent 47%);
          mask: radial-gradient(circle, transparent 0 40%, #000 40% 47%, transparent 47%);
  opacity: 0.45;
}
.compass-dir {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.compass-dir--n { top: 6.5%;    left: 50%; transform: translateX(-50%); color: #d2362a; font-size: 1.1rem; font-weight: 800; }
.compass-dir--e { right: 7.5%;  top: 50%;  transform: translateY(-50%); }
.compass-dir--s { bottom: 6.5%; left: 50%; transform: translateX(-50%); }
.compass-dir--o { left: 7.5%;   top: 50%;  transform: translateY(-50%); }
/* Aiguilles : partent du centre vers le bord (transform-origin en bas) */
.compass-needle,
.compass-needle-n {
  position: absolute;
  left: 50%; bottom: 50%;
  width: 16px; height: 37%;
  transform: translateX(-50%) rotate(var(--needle, 0deg));
  transform-origin: bottom center;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Aiguille dorée : direction conseillée du panneau */
.compass-needle { z-index: 3; }
.compass-needle::before {
  content: "";
  position: absolute; inset: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: linear-gradient(to bottom, var(--gold-deep), var(--gold));
  box-shadow: 0 1px 5px rgba(20, 61, 43, 0.28);
}
.compass-needle-sun {
  position: absolute;
  top: -7px; left: 50%;
  transform: translateX(-50%);
  width: 15px; height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff7da, var(--gold-deep));
  box-shadow: 0 0 10px 2px rgba(244, 183, 64, 0.55);
  z-index: 1;
}
/* Aiguille rouge : pointe le nord */
.compass-needle-n {
  width: 13px;
  transform: translateX(-50%) rotate(var(--north, 0deg));
  z-index: 2;
}
.compass-needle-n::before {
  content: "";
  position: absolute; inset: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: linear-gradient(to bottom, #d2362a, #e85a4d);
  box-shadow: 0 1px 4px rgba(20, 61, 43, 0.22);
}
.compass-hub {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff, var(--surface));
  border: 2px solid var(--green-dark);
  box-shadow: inset 0 1px 3px rgba(20, 61, 43, 0.14), var(--shadow-sm);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 4;
}
.compass-hub-val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--green-deep);
  font-variant-numeric: tabular-nums;
}
.compass-hub-label {
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .compass-needle, .compass-needle-n { transition: none; }
}
.incl-readout { display: flex; flex-direction: column; gap: 0.55rem; }
.incl-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--text-muted);
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}
.incl-line strong { text-align: right; }
.incl-line:last-child { border-bottom: none; }
.incl-line strong { color: var(--green-deep); font-weight: 700; }
.incl-tip {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--green-pale);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  margin: 1rem 0 0;
}
.incl-compass-btn {
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.7rem;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--green-mid), var(--green-dark));
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.incl-card { text-align: center; padding: 1.5rem 0.5rem; }
.incl-emoji { font-size: 3rem; }
.incl-msg { color: var(--text-muted); margin-top: 0.6rem; }

/* ── Planificateur de recharge ── */
.incl-planner {
  margin-top: 0.6rem;
}
.incl-planner-sub { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 0.9rem; line-height: 1.5; }
.incl-planner-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.incl-planner-row label { font-size: 0.9rem; font-weight: 600; }
.incl-planner-row input {
  width: 5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
}
.incl-planner-unit { font-size: 0.9rem; color: var(--text-muted); }
.incl-planner-row .incl-compass-btn { width: auto; margin-top: 0; flex: 1 1 auto; min-width: 8rem; }
#tilt-plan-result:not(:empty) { margin-top: 1rem; }
.incl-warn { color: #b4541e; font-size: 0.88rem; margin: 0.8rem 0 0; }

/* ── Feedback ── */
.feedback-body { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.feedback-field-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.3rem;
}
#feedback-name, #feedback-message {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
}
#feedback-name:focus, #feedback-message:focus { border-color: var(--green-mid); }
.feedback-status { font-size: 0.82rem; min-height: 1.1em; margin: 0; color: var(--text-muted); }
.feedback-status[data-state="ok"]    { color: #15803d; font-weight: 600; }
.feedback-status[data-state="error"] { color: #b91c1c; font-weight: 600; }
.feedback-body .popup-ble-connect { width: 100%; margin: 0.2rem 0 0; }

/* ── Responsive ── */
@media (max-width: 600px) {
  #container {
    padding: 0 0.65rem 2rem;
    padding-left: max(0.65rem, env(safe-area-inset-left));
    padding-right: max(0.65rem, env(safe-area-inset-right));
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }
  #recharge-buttons { display: none; }
  header {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    padding: max(0.9rem, env(safe-area-inset-top)) 1rem 0.9rem;
  }
  .logo { height: 45px; }
  .logo.logo-left { height: 60px; }
  .logo-left { display: none; }
  .data-spot { padding: 1rem; border-radius: var(--radius-md); }
  .kpi-value { font-size: 2.6rem; }

  /* La nav passe sur sa propre ligne pleine largeur sous le logo + boutons */
  .header-center-section { display: contents; }
  .header-logos {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo actions"
      "nav  nav";
    row-gap: 0.7rem;
    column-gap: 0.75rem;
    align-items: center;
  }
  .logo-center { grid-area: logo; justify-self: start; }
  .header-actions {
    grid-area: actions;
    flex-direction: row;
    gap: 0.4rem;
  }
  header nav { grid-area: nav; }
  header nav ul {
    width: 100%;
    gap: 0.4rem;
    justify-content: space-between;
  }
  header nav ul li {
    flex: 1;
    justify-content: center;
    text-align: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.82rem;
    white-space: nowrap;
  }
  .status-bar {
    gap: 0.5rem;
    margin-top: 0.6rem;
  }
  .status-chip {
    font-size: 0.73rem;
    padding: 0.25rem 0.7rem;
  }
  header h1 { margin-bottom: 0.5rem; }
}

@media (max-width: 380px) {
  header nav ul { gap: 0.3rem; }
  header nav ul li { padding: 0.5rem 0.3rem; font-size: 0.74rem; }
  .logo-center { height: 34px; }
  #connect-btn { padding: 0.4rem 0.75rem; font-size: 0.75rem; }
  .kpi-value { font-size: 2.2rem; }
}
