/* CASAGPS Fleet Analytics — feuille de style
   Bleu marine (structure), blanc, bleu clair (accents), orange (alertes), vert (positif). */
:root {
  --navy-900: #0b1f44;
  --navy-800: #12295a;
  --navy-700: #1b3a7a;
  --blue-600: #2f62c9;
  --blue-500: #3e74de;
  --blue-100: #e3ecfb;
  --blue-50: #f1f5fd;
  --orange: #e07a26;
  --orange-bg: #fdf0e4;
  --red: #c8372d;
  --red-bg: #fbe9e7;
  --green: #16a34a;
  --green-bg: #e5f5eb;

  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e1e7f0;
  --text: #13213b;
  --text-2: #4a5872;
  --muted: #7a879d;

  --series: #2f62c9;
  --series-prev: #94a3b8;
  --grid: #e8edf4;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 34, 70, .06), 0 4px 16px rgba(16, 34, 70, .05);
  --sidebar-w: 240px;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1424; --surface: #0f1c31; --surface-2: #13233c; --border: #1f3252;
    --text: #e6ecf6; --text-2: #a9b6cc; --muted: #7e8ca5;
    --blue-100: #1a3260; --blue-50: #142844;
    --orange-bg: #3a2614; --red-bg: #3a1a18; --green-bg: #12301f;
    --series: #5b8def; --series-prev: #64748b; --grid: #1c2d48;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1424; --surface: #0f1c31; --surface-2: #13233c; --border: #1f3252;
  --text: #e6ecf6; --text-2: #a9b6cc; --muted: #7e8ca5;
  --blue-100: #1a3260; --blue-50: #142844;
  --orange-bg: #3a2614; --red-bg: #3a1a18; --green-bg: #12301f;
  --series: #5b8def; --series-prev: #64748b; --grid: #1c2d48;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--blue-600); }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- login */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #1b3a7a 0, transparent 60%), var(--navy-900);
}
/* position/overflow : la barre de progression de la connexion reste dans la carte. */
.login-card { position: relative; overflow: hidden; width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
/* Progression de la connexion : barre animée en haut de la carte, message d'étape, bouton occupé. */
.login-progress { position: absolute; inset: 0 0 auto 0; height: 4px; background: transparent; opacity: 0; transition: opacity .2s; }
.login-progress span { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: linear-gradient(90deg, var(--blue-500), #f08a24); border-radius: 0 2px 2px 0; }
.login-card.busy .login-progress { opacity: 1; background: color-mix(in srgb, var(--blue-500) 15%, transparent); }
.login-card.busy .login-progress span { animation: login-progress 8s cubic-bezier(.1, .7, .2, 1) forwards; }
.login-card.done .login-progress span { animation: none; width: 100%; transition: width .3s; }
@keyframes login-progress { 0% { width: 0; } 30% { width: 45%; } 100% { width: 92%; } }
.login-status { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 13px; font-weight: 600; color: var(--blue-600); }
.btn .btn-spinner { display: none; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.loading .btn-spinner { display: inline-block; }
.login-card.busy input { opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--blue-500), var(--navy-700)); display: grid; place-items: center; color: #fff; }
.login h1 { font-size: 20px; margin: 24px 0 4px; }
.login p.sub { color: var(--text-2); margin: 0 0 20px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.input, select.input { height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); outline: none; }
.input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; margin-bottom: 16px; }
.btn { height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.btn-primary:hover { background: var(--navy-700); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
a.btn { color: var(--text); text-decoration: none; }
a.btn.btn-wa, .btn-wa { background: #25d366; border-color: #25d366; color: #fff; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
a.btn.btn-wa:hover, .btn-wa:hover { background: #1ebe5b; border-color: #1ebe5b; color: #fff; }
.ann-bar { display: flex; align-items: center; gap: 8px; padding: 9px 24px; font-size: 13.5px; border-bottom: 1px solid var(--border); background: var(--blue-100); color: var(--blue-600); }
.ann-bar b { font-weight: 700; white-space: nowrap; }
.ann-bar span { flex: 1; }
.ann-bar.warning { background: var(--red-bg); color: var(--red); }
.ann-bar.success { background: var(--green-bg); color: var(--green); }
.ann-close { margin-left: auto; background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; opacity: .7; padding: 0 4px; }
.ann-close:hover { opacity: 1; }
.ann-preview .ann-bar { border-radius: 8px; margin: 4px 0 12px; border: 0; }
.adm-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin: 12px 0; }
.adm-pages fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.adm-pages legend { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 4px; }
.phones-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; margin: 12px 0; }
.phones-grid .field span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.input.invalid { border-color: var(--red); background: var(--red-bg); }
.btn-stop { color: var(--red); border-color: var(--red); background: var(--red-bg); }
.btn-stop:hover { background: var(--red); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.form-error { background: var(--red-bg); color: var(--red); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.login .divider { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0; }
.login .note { font-size: 12px; color: var(--muted); margin-top: 16px; }

/* --------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; background: linear-gradient(to right, var(--navy-900) var(--sidebar-w), var(--bg) var(--sidebar-w)); }
.sidebar { background: var(--navy-900); color: #c9d4ea; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sidebar .brand { color: #fff; padding: 4px 8px 18px; }
.brand-logo { background: #fff; border-radius: 10px; justify-content: center; }
.brand-logo img { display: block; width: auto; max-width: 100%; object-fit: contain; }
.login .brand-logo { width: fit-content; margin: 0 auto 4px; padding: 10px 18px; border: 1px solid rgba(15,28,49,.08); box-shadow: 0 1px 2px rgba(15,28,49,.06); }
.login .brand-logo img { height: 44px; }
.sidebar .brand-logo { margin: 0 4px 18px; padding: 8px 10px; }
.sidebar .brand-logo img { height: 30px; }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav-group { margin: 10px 10px 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #7f8db0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; color: #c9d4ea; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--blue-600); color: #fff; }
.nav .count { margin-left: auto; background: var(--orange); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #8ea0c2; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot button { background: rgba(255,255,255,.08); border: 0; color: #dce4f3; border-radius: 8px; padding: 8px; cursor: pointer; }
svg.ico { width: 18px; height: 18px; flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 500; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.topbar h2 { margin: 0; font-size: 18px; }
.topbar .period { color: var(--text-2); font-size: 13px; }
.topbar .spacer { flex: 1; }
.refresh-info { font-size: 12px; color: var(--muted); }
.menu-toggle { display: none; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.filters .field { margin: 0; min-width: 130px; }
.filters .field.grow { flex: 1; min-width: 160px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 24px 0; background: var(--surface); }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--text-2); }
.chip.active { background: var(--blue-100); border-color: var(--blue-500); color: var(--blue-600); font-weight: 600; }

.demo-banner { background: var(--orange-bg); color: var(--orange); border-bottom: 1px solid color-mix(in srgb, var(--orange) 30%, transparent); padding: 8px 24px; font-size: 13px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.progress { height: 3px; background: var(--blue-100); overflow: hidden; }
.progress > div { height: 100%; background: var(--blue-600); width: 0; transition: width .2s; }

.content { padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: 2fr 1fr; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; animation: fade .25s ease; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 14.5px; }
.card-head .hint { font-size: 12px; color: var(--muted); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.kpi { display: flex; gap: 12px; align-items: flex-start; }
.kpi .ico-wrap { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue-600); flex: none; }
.kpi .ico-wrap.green { background: var(--green-bg); color: var(--green); }
.kpi .ico-wrap.orange { background: var(--orange-bg); color: var(--orange); }
.kpi .ico-wrap.gray { background: var(--surface-2); color: var(--muted); }
.kpi .label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi .value { font-size: 22px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; color: var(--muted); }
.kpi .delta.up { color: var(--green); } .kpi .delta.down { color: var(--orange); }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.chart-box.lg { height: 340px; }
.map { height: 420px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); z-index: 0; }

/* -------------------------------------------------------------- tables */
.table-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.table-tools .input { height: 34px; flex: 1; min-width: 180px; max-width: 320px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
.dt th { text-align: left; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; }
.dt th.sorted::after { content: ' ▾'; } .dt th.sorted.asc::after { content: ' ▴'; }
.dt td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dt td.r, .dt th.r { text-align: right; font-variant-numeric: tabular-nums; }
.dt tr:last-child td { border-bottom: 0; }
.dt tbody tr:hover { background: var(--blue-50); }
.dt tr.click { cursor: pointer; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.pager .btns { display: flex; gap: 6px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.moving { background: var(--green-bg); color: var(--green); }
.badge.stopped { background: var(--blue-100); color: var(--blue-600); }
.badge.offline { background: var(--orange-bg); color: var(--orange); }
.badge.danger { background: var(--red-bg); color: var(--red); }
.badge.warning { background: var(--orange-bg); color: var(--orange); }
.badge.info { background: var(--blue-100); color: var(--blue-600); }
.badge.cat { background: var(--surface-2); color: var(--text-2); }

.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rank li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; cursor: pointer; padding: 3px 4px; border-radius: 6px; }
.rank li:hover { background: var(--blue-50); }
.rank .pos { color: var(--muted); font-size: 12px; font-weight: 600; text-align: right; }
.rank .bar { height: 6px; border-radius: 3px; background: var(--series); margin-top: 4px; }
.rank .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .sub { font-size: 11.5px; color: var(--muted); }
.rank .val { font-variant-numeric: tabular-nums; font-weight: 600; }

.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.alert:hover { border-color: var(--blue-500); }
.alert .t { font-weight: 600; }
.alert .m { color: var(--text-2); font-size: 13px; }
.alert .d { color: var(--muted); font-size: 12px; white-space: nowrap; }

.notice { background: var(--blue-50); border: 1px solid var(--blue-100); color: var(--text-2); padding: 10px 14px; border-radius: 10px; font-size: 13px; }
.notice.warn { background: var(--orange-bg); border-color: transparent; color: var(--orange); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 18px; }
.facts div span { display: block; font-size: 12px; color: var(--muted); }
.facts div b { font-size: 15px; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.dash { height: 0; border-top: 2px dashed var(--series-prev); border-radius: 0; width: 16px; vertical-align: 3px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-kpi { height: 86px; } .sk-chart { height: 300px; }

.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.settings .card .field { margin-bottom: 10px; }
.days-pick { display: flex; gap: 4px; flex-wrap: wrap; }
.days-pick label { border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer; }
.days-pick input { margin-right: 4px; }
.wh-form { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: flex-end; }
.wh-form .field { margin-bottom: 12px; }
.wh-form input[type=number] { width: 110px; }
.wh-form .field.grow { flex: 1; min-width: 240px; }
.live-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.live-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.live-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.live-chip i, .live-row i { flex: none; width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.2); }
.live-chip.off { opacity: .4; text-decoration: line-through; }
.live-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.live-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.live-map { height: calc(100vh - 230px); min-height: 420px; }
.live-list { max-height: calc(100vh - 300px); min-height: 360px; overflow-y: auto; margin-top: 10px; }
.live-row { display: flex; align-items: center; gap: 12px; padding: 9px 6px; border-bottom: 1px solid var(--border); cursor: pointer; }
.live-row:hover { background: var(--surface-2); }
.live-row .who { flex: 1; min-width: 0; }
.live-row .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-row .meta { font-size: 12px; color: var(--muted); }
.live-tip { font-size: 11px; font-weight: 600; padding: 1px 6px; }
.rk-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rk-place { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px; border: 1px solid var(--border); border-radius: 12px; text-align: center; cursor: pointer; }
.rk-place:hover, .rk-low:hover { background: var(--surface-2); }
.rk-place b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-medal { font-size: 30px; line-height: 1; }
.rk-score { font-size: 24px; font-weight: 800; }
.rk-low { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--border); cursor: pointer; }
.rk-place .meta, .rk-low .meta { display: block; font-size: 12px; color: var(--muted); }
.pt-map { height: 360px; }
.pt-add { margin-top: 12px; }
.pt-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.pt-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.pt-off { color: var(--muted); font-size: 11px; }
.cost-acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.cost-causes td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.cost-causes td.r { text-align: right; }
.planning th, .planning td { white-space: nowrap; font-size: 12px; }
.planning td.pl-cell { cursor: pointer; text-align: center; border-radius: 4px; }
.planning td.pl-cell:hover { background: var(--surface-2); }
.planning td.pl-temp { background: var(--orange-bg); color: var(--orange); font-weight: 700; }
.planning .pl-today { box-shadow: inset 0 -2px 0 var(--blue-600); }
.pt-rm { border: 0; background: none; color: var(--red); font-weight: 700; font-size: 14px; cursor: pointer; margin-left: 6px; padding: 0 2px; }
.zone-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.zone-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.pct-bar { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--surface-2); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.pct-bar span { display: block; height: 100%; background: var(--orange); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-left: auto; }
.seg button { border: 0; background: var(--surface); color: var(--text-2); padding: 6px 12px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--blue-600); color: #fff; }
.heat-wrap { overflow-x: auto; }
.heat { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 12px; }
.heat th { text-align: left; font-weight: 600; color: var(--text-2); white-space: nowrap; padding: 4px 8px; }
.heat thead th { text-align: center; }
.heat td { text-align: center; min-width: 30px; height: 26px; border-radius: 4px; background: var(--surface-2); color: var(--text); }
.heat td.tot, .heat-total td { background: transparent; font-weight: 700; }
.heat-total th { font-weight: 700; }
.heat tr[data-zone] { cursor: pointer; }
.heat tr[data-zone]:hover th { color: var(--blue-600); }

.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(16,34,70,.16); padding: 6px; min-width: 260px; z-index: 1000; }
.dropdown-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.dropdown-menu button:hover { background: var(--blue-50); }
.dropdown-menu .sep { border-top: 1px solid var(--border); margin: 6px 0; }
.dropdown-menu .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 6px 10px 2px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 2000; font-size: 13px; max-width: 380px; animation: fade .2s; }
.toast.err { background: var(--red); }

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-size: 13px; cursor: pointer; border: 0; background: none; padding: 0; }

@media (max-width: 1100px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 1500; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .topbar, .filters, .content, .presets, .demo-banner { padding-left: 16px; padding-right: 16px; }
}

/* Vue globale : bloc du secteur */
.sector-head { display: flex; align-items: baseline; gap: 10px; margin: 6px 2px 10px; }
.sector-head h2 { font-size: 15px; font-weight: 700; color: var(--text-2); margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.demo-sector { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.demo-sector select { flex: 1; background: rgba(255,255,255,.08); color: #dce4f3; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.demo-sector option { color: #13213b; }
.cost-acts.nowrap { flex-wrap: nowrap; }
.btn-icon { width: 32px; padding: 0; font-size: 15px; }
.dr-exit { border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px 10px; margin: 4px 0 0; }
.dr-exit legend { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 4px; }
/* Entretien : entretiens d'un véhicule regroupés dans sa ligne */
.mt-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 5px 0; }
.mt-line + .mt-line { border-top: 1px dashed var(--border); }
.mt-line .mt-left { margin-left: auto; font-weight: 600; white-space: nowrap; }
.mt-line .pt-meta { flex-basis: 100%; margin-top: 0; }

/* Planning de la flotte (transport) */
.pl-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pl-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 12px; margin-bottom: 8px; color: var(--text-2); }
.pl-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.pl-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 10px; }
.pl-grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
.pl-grid th, .pl-grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 4px; vertical-align: top; min-width: 112px; }
.pl-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 600; text-align: center; white-space: nowrap; }
.pl-grid .pl-veh { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 170px; max-width: 220px; }
.pl-grid thead .pl-veh { z-index: 3; text-align: left; }
.pl-grid th.pl-today { background: color-mix(in srgb, var(--blue-500) 18%, var(--surface-2)); }
.pl-grid td.pl-today { background: color-mix(in srgb, var(--blue-500) 6%, transparent); }
.pl-grid td.pl-free { cursor: copy; }
.pl-grid td.pl-free:hover { background: color-mix(in srgb, var(--green) 10%, transparent); }
.pl-warn { display: block; color: var(--orange); font-size: 11px; font-weight: 600; margin-top: 2px; }
.pl-chip { border-radius: 5px; padding: 3px 6px; margin-bottom: 3px; color: #fff; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.pl-chip:hover { filter: brightness(1.1); }
.k-personnel { background: #2f62c9; } .k-tourisme { background: #16a34a; } .k-transfert { background: #7c3aed; } .k-autre { background: #64748b; }
.k-panne { background: repeating-linear-gradient(45deg, #dc2626 0 6px, #b91c1c 6px 12px); color: #fff; cursor: default; }
.fv-sum { margin: 6px 0 8px; }
.fv-no td { opacity: .75; }
.fv-unav summary { cursor: pointer; margin-top: 10px; color: var(--text-2); }
.pl-seats { padding: 14px 18px; }
.pl-seats summary { cursor: pointer; }

/* Circuits de ramassage (transport) */
.k-circuit { background: #0e7490; }
.ci-today { display: flex; flex-direction: column; }
.ci-run { display: grid; grid-template-columns: minmax(180px, 260px) auto 1fr; gap: 6px 14px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.ci-run:hover { background: var(--surface-2); }
.ci-stops { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ci-stop { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 7px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); white-space: nowrap; }
.ci-stop i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.ci-arrow { color: var(--muted); }
.ci-day { display: inline-block; width: 22px; text-align: center; font-size: 11px; border-radius: 4px; margin-right: 2px; color: var(--muted); background: var(--surface-2); }
.ci-day.on { color: #fff; background: var(--blue-600); }
.ci-editor { display: grid; grid-template-columns: minmax(300px, 1fr) 1.3fr; gap: 14px; margin: 8px 0; }
.ci-erow { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.ci-erow .input { height: 34px; }
.ci-num { width: 22px; height: 22px; border-radius: 50%; background: var(--blue-600); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.ci-matrix td, .ci-matrix th { white-space: nowrap; }
@media (max-width: 900px) { .ci-editor { grid-template-columns: 1fr; } .ci-run { grid-template-columns: 1fr; } }

/* Compte connecté (bas du menu) */
.user-label { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.06); color: #dce4f3; }
.user-label .user-ico svg { width: 16px; height: 16px; display: block; }
.user-label .user-mail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 12.5px; color: #f0a24a; }
.user-label .user-admin { flex-basis: 100%; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #f0a24a; }

/* Temps de travail (transport) */
.wt-day { font-size: 12px; font-weight: 600; padding: 2px 6px; border-radius: 5px; background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); margin-bottom: 3px; text-align: center; }
.wt-day.bad { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.wt-leave { background: repeating-linear-gradient(45deg, #94a3b8 0 6px, #64748b 6px 12px); color: #fff; cursor: default; }
.mf-warn { margin: 4px 0 8px; line-height: 1.6; }
.mf-ok { margin: 4px 0 8px; color: var(--green); font-weight: 600; font-size: 13px; }

/* Rotations des véhicules (transport) */
.rt-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.rt-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.rt-tr-i { background: repeating-linear-gradient(45deg, #cbd5e1 0 4px, #e2e8f0 4px 8px); }
.rt-bad-i { background: transparent; outline: 2px solid var(--red); outline-offset: -2px; }
.rt-axis, .rt-row { display: grid; grid-template-columns: 170px 1fr 120px; gap: 10px; align-items: center; }
.rt-hours { position: relative; height: 16px; font-size: 10.5px; color: var(--muted); }
.rt-hours span { position: absolute; transform: translateX(-50%); }
.rt-row { padding: 6px 0; border-top: 1px solid var(--border); }
.rt-veh .pt-meta { margin-top: 1px; }
/* Une ligne par heure : --n = nombre d'heures affichées (même échelle que l'axe). */
.rt-track { position: relative; height: 30px; background: linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / calc(100% / var(--n, 19)) 100%; border-right: 1px solid var(--border); border-radius: 6px; }
.rt-svc { position: absolute; top: 3px; height: 24px; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 600; padding: 4px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.rt-svc.bad { outline: 3px solid var(--red); outline-offset: -1px; }
.rt-svc.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue-500) 60%, transparent); }
.rt-tr { position: absolute; top: 11px; height: 8px; border-radius: 4px; background: repeating-linear-gradient(45deg, #cbd5e1 0 4px, #e2e8f0 4px 8px); }
.rt-stat { text-align: right; }
.rt-selbox { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.rt-opt-sum { margin: 12px 0 8px; font-size: 14px; }
.rt-chip { display: inline-block; color: #fff; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; margin: 1px 0; }
@media (max-width: 900px) { .rt-axis, .rt-row { grid-template-columns: 110px 1fr 70px; } }

/* Missions : arrêts réels numérotés sur la carte */
.ms-stop-ico span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #d35400; color: #fff; font-size: 11px; font-weight: 700; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
