:root {
  --bg: #f4f5f7; --card: #fff; --text: #16181d; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --accent-2: #dbeafe; --ok: #16a34a; --ok-bg: #dcfce7;
  --warn: #d97706; --warn-bg: #fef3c7; --bad: #dc2626; --bad-bg: #fee2e2;
  --radius: 14px; --shadow: 0 1px 3px rgba(0,0,0,.08);
  --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #1a1d24; --text: #eceef2; --muted: #9aa1ad; --line: #2a2f39;
    --accent: #60a5fa; --accent-2: #1e3a5f; --ok: #4ade80; --ok-bg: #14331f;
    --warn: #fbbf24; --warn-bg: #3a2c0c; --bad: #f87171; --bad-bg: #3d1515;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.hidden { display: none !important; }

header.top { position: sticky; top: 0; z-index: 10; background: var(--bg);
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
header.top .back { font-size: 1.4rem; padding: 0 6px 0 0; color: var(--text); }
header.top h1 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { padding: 0 16px; max-width: 720px; margin: 0 auto; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 12px; border: 1px solid var(--line); }
.card.vehicle { border-left: 6px solid var(--vcolor, var(--accent)); cursor: pointer; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.km-big { font-size: 1.5rem; font-weight: 700; }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px;
  font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.retard { background: var(--bad-bg); color: var(--bad); }
.badge.bientot { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.inconnu, .badge.inactif { background: var(--line); color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.retard { background: var(--bad); } .dot.bientot { background: var(--warn); }
.dot.ok { background: var(--ok); } .dot.inconnu, .dot.inactif { background: var(--muted); }

.list { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; margin-bottom: 12px; }
.list .item { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.list .item:last-child { border-bottom: 0; }
.list .item.click { cursor: pointer; }
.list .item .meta { font-size: .85rem; color: var(--muted); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.tabs button { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .9rem; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; padding: 12px 18px; cursor: pointer; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--accent-2); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.small { padding: 7px 12px; font-size: .88rem; border-radius: 10px; }
.btn:disabled { opacity: .55; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.btns .btn { flex: 1; }

form .field { margin-bottom: 12px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
textarea { min-height: 70px; resize: vertical; }

.line-edit { display: grid; grid-template-columns: 1fr 92px 36px; gap: 6px; margin-bottom: 6px; }
.line-edit select { grid-column: 1 / 4; font-size: .85rem; padding: 7px 10px; }
.line-edit .x { border: 0; background: none; color: var(--bad); font-size: 1.3rem; }
.line-block { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; }

nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b); background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: center; }
nav.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted);
  font-size: .72rem; padding: 6px 0; }
nav.bottom a .ico { font-size: 1.35rem; line-height: 1; }
nav.bottom a.active { color: var(--accent); }
nav.bottom a.scan .ico { background: var(--accent); color: #fff; width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-top: -26px; box-shadow: 0 4px 12px rgba(37,99,235,.35); }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90vw;
  font-size: .92rem; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast.error { background: #991b1b; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 3rem; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.thumbs .t { width: 84px; height: 110px; border-radius: 8px; border: 1px solid var(--line); background: var(--line) center/cover;
  display: flex; align-items: center; justify-content: center; font-size: .8rem; color: var(--muted); position: relative; cursor: pointer; }
.thumbs .t .x { position: absolute; top: -6px; right: -6px; background: var(--bad); color: #fff; border: 0; border-radius: 50%;
  width: 22px; height: 22px; font-size: .8rem; }

.spinner { width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 24px auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice { background: var(--accent-2); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-bottom: 12px; }
.notice.warn { background: var(--warn-bg); }
.notice.bad { background: var(--bad-bg); }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); margin-top: 4px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; background: var(--c); }

.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 60; overflow: auto; padding: 16px; }
.viewer img { width: 100%; margin-bottom: 12px; border-radius: 6px; }
.viewer .close { position: fixed; top: 10px; right: 14px; color: #fff; font-size: 2rem; background: none; border: 0; }

.login { max-width: 380px; margin: 12vh auto 0; padding: 0 20px; }
.login .logo { font-size: 3.5rem; text-align: center; }
.login h1 { text-align: center; margin-bottom: 20px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

.vphoto { margin: -14px -16px 12px; height: 150px; background: var(--line) center/cover no-repeat;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.card.vehicle .vphoto { margin-left: -16px; border-top-left-radius: 0; }
.vphoto.big { height: 190px; }
