:root {
  --bg: #0e1116;
  --surface: #171c24;
  --surface-2: #1f2530;
  --border: #2a313d;
  --text: #e6e9ef;
  --muted: #8a93a3;
  --accent: #cc0000;
  --ok: #2ea043;
  --warn: #d29922;
  --info: #3b82f6;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.muted { color: var(--muted); font-size: .9rem; }
.hidden { display: none !important; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 6px; font-size: .85em; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
.vehicle-select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .45rem .7rem; font-size: .9rem;
}

/* Tabs */
.tabs {
  display: flex; gap: .25rem; padding: 0 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  background: none; border: 0; color: var(--muted);
  padding: .9rem 1rem; font-size: .95rem; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Layout */
.container { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
h2 { font-size: 1.2rem; margin: 0 0 1rem; }

/* Cards / login */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; margin-top: 1rem;
  max-width: 600px;
}
.btn {
  display: inline-block; background: var(--accent); color: #fff;
  padding: .6rem 1.2rem; border-radius: 8px; text-decoration: none;
  border: 0; font-size: 1rem; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

/* Dashboard grid */
.dash-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.tile h3 { margin: 0 0 .75rem; font-size: .85rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em; }
.tile .big { font-size: 2rem; font-weight: 700; }
.tile .sub { color: var(--muted); font-size: .9rem; }

/* Battery gauge */
.gauge { display: flex; align-items: center; gap: 1rem; }
.gauge-bar {
  flex: 1; height: 28px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden; position: relative;
}
.gauge-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.gauge-pct { font-size: 1.6rem; font-weight: 700; min-width: 3.5ch; text-align: right; }

/* Bannière charge forcée */
.boost-banner {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1rem; padding: .7rem 1rem;
  background: #14331f; color: #4ade80;
  border: 1px solid #1f6b3a; border-radius: var(--radius);
  font-size: .95rem;
}

/* State badge */
.state-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .75rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
}
.state-parked  { background: #1f2937; color: #9ca3af; }
.state-driving { background: #15324f; color: #60a5fa; }
.state-charging{ background: #14331f; color: #4ade80; }

/* Chart */
.chart-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; height: 360px;
}
.range-toggle { display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg { background: none; border: 0; color: var(--muted);
  padding: .4rem .9rem; cursor: pointer; font-size: .85rem; }
.seg.active { background: var(--accent); color: #fff; }

/* Tables */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .75rem 1rem; text-align: left; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600;
  text-transform: uppercase; font-size: .72rem; letter-spacing: .03em; }
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--surface-2); }

.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge-sc { background: #14331f; color: #4ade80; }
.badge-ac { background: #1f2937; color: #9ca3af; }

/* Sélection + export Odoo */
.export-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.export-comment {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .4rem .6rem; font-size: .85rem; min-width: 180px;
}
.col-check { width: 1%; white-space: nowrap; text-align: center; }
.col-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }
.exported-mark { color: var(--ok); font-weight: 700; margin-left: .25rem; }

/* Form (réglages) */
.form {
  display: grid; gap: 1rem; max-width: 460px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}
.form label { display: grid; gap: .35rem; font-size: .9rem; color: var(--muted); }
.form input {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .55rem .7rem; font-size: .95rem;
}
.form input:focus { outline: none; border-color: var(--accent); }
.form small { font-size: .78rem; }
.form-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.form-sep { border: 0; border-top: 1px solid var(--border); margin: .5rem 0; width: 100%; }
.form-title { margin: 0; font-size: 1rem; color: var(--text); }
.form .check { grid-auto-flow: column; justify-content: start; align-items: center; gap: .5rem; color: var(--text); }
.form .check input { width: auto; }

/* Map */
#map { height: 480px; border-radius: var(--radius); border: 1px solid var(--border); }
.leaflet-container { background: var(--surface-2); }

/* Footer */
.config {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
}

@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .container { padding: 1rem .75rem 2rem; }
  th, td { padding: .55rem .6rem; }
}
