/* ==========================================================================
   GPS Tracker : espace client et Back Office (rouge · blanc · gris foncé)
   ========================================================================== */
:root {
    --ink: #10292b; --ink-2: #2f4a4c; --muted: #566b6d; --line: #e1ecec; --line-strong: #c9dada;
    --bg: #f1f6f6; --card: #fff;
    --brand: #00a39e; --brand-600: #008c88; --brand-700: #007572; --brand-50: #e6f6f5; --brand-100: #c4ece9;
    --ok: #15803d; --ok-bg: #e3f6ea; --warn: #9a5b00; --warn-bg: #fff1d6; --bad: #b91c1c; --bad-bg: #fee2e2; --info: #1d4ed8; --info-bg: #e0e9ff;
    --radius: 14px; --shadow: 0 1px 2px rgba(16,41,43,.06), 0 6px 20px rgba(16,41,43,.05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --side: 252px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.app { margin: 0; font: 15px/1.55 var(--font); color: var(--ink-2); background: var(--bg); }
img, svg { max-width: 100%; display: block; }
a { color: var(--brand-700); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
:focus-visible { outline: 3px solid rgba(0,163,158,.45); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); } .right { text-align: right; } .nowrap { white-space: nowrap; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em; }

/* Structure */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 18px 14px; background: #10292b; color: #c3c8cf; }
.sidebar-brand { display: block; padding: 4px 8px 10px; background: #fff; border-radius: 12px; margin-bottom: 14px; }
.sidebar-brand img { height: 48px; width: auto; margin: 0 auto; }
.sidebar-tag { align-self: flex-start; margin: 0 8px 10px; padding: 2px 10px; border-radius: 999px; background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #c3c8cf; font-weight: 550; text-decoration: none; }
.sidebar a svg { width: 19px; height: 19px; flex: none; }
.sidebar a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.is-active { background: var(--brand); color: #fff; }
.sidebar a em { margin-left: auto; font-style: normal; font-size: .74rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: #fff; color: var(--brand-700); }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 2px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px clamp(14px, 3vw, 28px); background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-title { margin: 0; font-size: 1.2rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: .85rem; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-balance { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: var(--brand-50); color: var(--brand-700); font-weight: 600; text-decoration: none !important; }
.chip-balance svg { width: 18px; height: 18px; }
.icon-btn { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.icon-btn svg { width: 19px; height: 19px; } .icon-btn i { position: absolute; top: -5px; right: -5px; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff; font: 700 .7rem/18px var(--font); text-align: center; }
.burger { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); padding: 0; place-items: center; } .burger svg { width: 20px; height: 20px; margin: auto; }
.scrim { display: none; }
.content { padding: clamp(14px, 3vw, 28px); display: grid; gap: 20px; align-content: start; max-width: 1360px; width: 100%; }
@media (max-width: 980px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: fixed; z-index: 60; inset: 0 auto 0 0; width: min(84vw, 300px); transform: translateX(-102%); transition: transform .25s; }
    .sidebar-open .sidebar { transform: none; }
    .sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); }
    .burger { display: grid; } .who { display: none; }
}

/* Cartes et grilles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card > h2:first-child, .card-head h2 { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; } .card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; } .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-ic { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--brand-50); color: var(--brand-700); }
.stat-ic svg { width: 23px; height: 23px; }
.stat-card--green .stat-ic { background: var(--ok-bg); color: var(--ok); } .stat-card--dark .stat-ic { background: var(--ink); color: #fff; }
.stat-card--amber .stat-ic { background: var(--warn-bg); color: var(--warn); } .stat-card--blue .stat-ic { background: var(--info-bg); color: var(--info); }
.stat-card--grey .stat-ic { background: #eceff2; color: var(--ink-2); }
.stat-label { display: block; font-size: .8rem; color: var(--muted); } .stat-value { display: block; font-size: 1.5rem; color: var(--ink); letter-spacing: -.02em; line-height: 1.25; } .stat-card small { color: var(--muted); font-size: .76rem; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 11px; font: 600 .92rem var(--font); cursor: pointer; text-decoration: none !important; transition: background .15s, border-color .15s; }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--brand); color: #fff; } .btn--primary:hover { background: var(--brand-600); color: #fff; }
.btn--secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); } .btn--secondary:hover { background: #f8f8f9; color: var(--ink); }
.btn--danger { background: #fff; color: var(--bad); border-color: #9fd8d5; } .btn--danger:hover { background: var(--bad-bg); }
.btn--ok { background: var(--ok); color: #fff; }
.btn--sm { min-height: 32px; padding: 0 11px; font-size: .84rem; border-radius: 9px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } .actions form { margin: 0; }

/* Badges */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 650; white-space: nowrap; background: #eceff2; color: var(--ink-2); }
.pill--ok { background: var(--ok-bg); color: var(--ok); } .pill--warn { background: var(--warn-bg); color: var(--warn); } .pill--bad { background: var(--bad-bg); color: var(--bad); }
.pill--info { background: var(--info-bg); color: var(--info); } .pill--mute { background: #eceff2; color: var(--muted); }

/* Tableaux */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
.t th { padding: 9px 12px; text-align: left; font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; } .t tbody tr:hover { background: #fafafb; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } .neg { color: var(--bad); } .pos { color: var(--ok); }
.empty { padding: 28px 10px; text-align: center; color: var(--muted); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; } .tabs a { padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: .86rem; text-decoration: none; } .tabs a.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Alertes */
.flash { padding: 12px 16px; border-radius: 12px; font-weight: 550; border: 1px solid transparent; }
.flash--success { background: var(--ok-bg); color: var(--ok); } .flash--danger, .flash--error { background: var(--bad-bg); color: var(--bad); } .flash--warning { background: var(--warn-bg); color: var(--warn); } .flash--info { background: var(--info-bg); color: var(--info); }
.banner { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); font-weight: 550; }
.banner--bad { background: var(--bad-bg); color: var(--bad); } .banner .btn { margin-left: auto; }

/* Formulaires */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } @media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 5px; } .field--full { grid-column: 1 / -1; }
.field label { font-size: .84rem; font-weight: 650; color: var(--ink); }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1.5px solid var(--line-strong); border-radius: 10px; background: #fff; font: inherit; color: var(--ink); }
.field textarea { min-height: 90px; resize: vertical; } .field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0,163,158,.13); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--brand); } .field-error { margin: 0; color: var(--brand-700); font-size: .82rem; font-weight: 600; }
.field .hint, .hint { font-size: .8rem; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; } .check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--brand); flex: none; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; } .inline-form .field { min-width: 150px; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Détails */
.dl { margin: 0; } .dl > div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); } .dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; text-align: right; color: var(--ink); font-weight: 600; word-break: break-word; }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.shortcut { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); font-weight: 650; text-decoration: none !important; box-shadow: var(--shadow); }
.shortcut:hover { border-color: var(--brand-100); background: var(--brand-50); } .shortcut svg { width: 22px; height: 22px; color: var(--brand); }
.bars { display: grid; gap: 8px; } .bar { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: .86rem; } .bar i { display: block; height: 10px; border-radius: 6px; background: var(--brand); min-width: 3px; } .bar span { color: var(--muted); }
.kv { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.notif { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); } .notif:last-child { border-bottom: 0; } .notif.unread b::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--brand); }
pre.log { margin: 0; white-space: pre-wrap; font: .82rem/1.5 ui-monospace, Menlo, monospace; background: #f3f8f8; padding: 10px 12px; border-radius: 10px; max-height: 240px; overflow: auto; }

/* Carte et historique */
.map-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; height: calc(100vh - 150px); min-height: 520px; }
.map-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.map-list { overflow-y: auto; display: grid; gap: 6px; align-content: start; padding-right: 2px; }
.map-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; text-align: left; font: inherit; color: var(--ink); width: 100%; }
.map-item:hover, .map-item.is-sel { border-color: var(--brand); background: var(--brand-50); }
.map-item small { display: block; color: var(--muted); }
.dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: #98a0ab; } .dot--moving { background: #16a34a; box-shadow: 0 0 0 4px rgba(22,163,74,.2); } .dot--idle { background: #f59e0b; } .dot--offline { background: #98a0ab; } .dot--disabled { background: #cfd3d9; }
#map, #hmap { border-radius: var(--radius); border: 1px solid var(--line); min-height: 380px; height: 100%; z-index: 1; }
.map-wrap { position: relative; min-height: 0; } .map-status { position: absolute; z-index: 500; left: 12px; bottom: 12px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); font-size: .8rem; }
.map-status.is-err { background: var(--bad-bg); color: var(--bad); }
.map-panel { position: absolute; z-index: 500; top: 12px; right: 12px; width: min(320px, calc(100% - 24px)); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: none; max-height: calc(100% - 24px); overflow: auto; }
.map-panel.is-open { display: block; } .map-panel h3 { margin-bottom: 8px; } .map-panel .x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .8rem; color: var(--muted); } .legend span { display: inline-flex; align-items: center; gap: 6px; }
.veh-pin { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50% 50% 50% 8%; transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); color: #fff; }
.veh-pin svg { transform: rotate(45deg); width: 17px; height: 17px; } .veh-pin--moving { background: #16a34a; } .veh-pin--idle { background: #f59e0b; } .veh-pin--offline { background: #6b7380; } .veh-pin--disabled { background: #b8bec7; }
@media (max-width: 860px) { .map-layout { grid-template-columns: minmax(0, 1fr); height: auto; } .map-wrap { height: 62vh; } .map-list { max-height: 240px; } }

/* Authentification */
body.auth { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 14px; background: linear-gradient(135deg, #10292b, #2f4a4c); font: 15px/1.55 var(--font); color: var(--ink-2); }
.auth-card { width: min(100%, 460px); background: #fff; border-radius: 20px; padding: clamp(22px, 5vw, 36px); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.auth-card--wide { width: min(100%, 640px); } .auth-card img { height: 64px; width: auto; margin: 0 auto 14px; } .auth-card h1 { text-align: center; font-size: 1.4rem; } .auth-card .sub { text-align: center; color: var(--muted); margin: -4px 0 20px; }
.auth-links { margin-top: 18px; text-align: center; font-size: .9rem; display: grid; gap: 6px; }
@media print { .sidebar, .topbar, .no-print, .flash { display: none !important; } .shell { display: block; } body.app { background: #fff; } .card { box-shadow: none; border: 0; padding: 0; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
