:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1d2733; --muted: #5d6b7a; --line: #dfe5ec; --accent: #12477a;
  --ok: #1f8a4c; --warn: #c27c0e; --stop: #4a6fa5; --off: #8a95a3; --err: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
button { font: inherit; border: 0; border-radius: 6px; background: var(--accent); color: #fff; padding: 7px 12px; cursor: pointer; }
button.link { background: none; color: var(--accent); padding: 4px 0; text-decoration: underline; }
button.icon { background: none; color: var(--muted); font-size: 22px; padding: 0 4px; line-height: 1; }
input { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; width: 100%; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--err); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 360px; display: grid; gap: 8px; }
.login-card button { margin-top: 10px; }

.app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 14px; gap: 10px; }
.side-head { display: flex; justify-content: space-between; align-items: center; }
.counts { display: flex; flex-wrap: wrap; gap: 6px; }
.count { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--bg); }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.list li { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 7px; cursor: pointer; display: grid; gap: 2px; }
.list li:hover, .list li.sel { border-color: var(--accent); background: #eef4fa; }
.list .row { display: flex; justify-content: space-between; gap: 8px; }
.list .name { font-weight: 600; }
.live { font-size: 12px; color: var(--muted); margin: 0; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); display: inline-block; }
.dot.on { background: var(--ok); }

.status { font-size: 12px; font-weight: 600; }
.st-en_marche { color: var(--ok); } .st-contact_arret { color: var(--warn); } .st-arrete { color: var(--stop); }
.st-hors_ligne, .st-jamais_vu { color: var(--off); }
.badge { display: inline-block; margin: 4px 0 0; font-size: 12px; font-weight: 600; }

.main { position: relative; min-width: 0; }
.map { position: absolute; inset: 0; }
.detail { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 360px; max-width: calc(100% - 24px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; z-index: 1000; box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; font-weight: 600; }
.history-form { display: flex; gap: 8px; }
.history-form input { flex: 1; }
#h-result { display: grid; gap: 6px; }
.sensors { width: 100%; border-collapse: collapse; font-size: 13px; }
.sensors td { border-top: 1px solid var(--line); padding: 4px 2px; }
.sensors td:last-child { text-align: right; font-weight: 600; }

.veh { width: 30px; height: 30px; }
.veh svg { width: 30px; height: 30px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.veh-label { background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 11px; font-weight: 600; white-space: nowrap; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 45vh 55vh; }
  .side { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .main { order: 1; }
  .detail { top: auto; height: 70%; width: auto; left: 8px; right: 8px; bottom: 8px; }
}
