/* =====================================================================
   PlannerBus — design system
   Navy (structure) + ambre "bus scolaire" (accent)
   ===================================================================== */
:root {
  --pb-navy: #0b1220;
  --pb-navy-2: #111a2e;
  --pb-navy-3: #1b2640;
  --pb-amber: #f5b301;
  --pb-amber-soft: #fff4d1;
  --pb-primary: #2457e6;
  --pb-primary-soft: #e8eeff;
  --pb-radius: 14px;
  --pb-radius-sm: 10px;
  --pb-sidebar-w: 264px;
  --pb-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --pb-shadow-lg: 0 12px 40px rgba(15, 23, 42, .14);

  --bs-font-sans-serif: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  --bs-body-font-size: .935rem;
  --bs-primary: #2457e6;
  --bs-primary-rgb: 36, 87, 230;
  --bs-link-color: #2457e6;
  --bs-link-color-rgb: 36, 87, 230;
  --bs-link-hover-color: #1a43b8;
  --bs-border-radius: .65rem;
  --bs-border-radius-sm: .5rem;
  --bs-border-radius-lg: .9rem;
}

[data-bs-theme="light"] {
  --bs-body-bg: #f3f5f9;
  --bs-body-color: #0f172a;
  --bs-secondary-color: #64748b;
  --bs-tertiary-color: #94a3b8;
  --bs-border-color: #e3e8f0;
  --bs-tertiary-bg: #f6f8fb;
  --pb-surface: #ffffff;
  --pb-surface-2: #f8fafc;
  --pb-hover: #f1f5fb;
}

[data-bs-theme="dark"] {
  --bs-body-bg: #0a0f1c;
  --bs-body-color: #e2e8f0;
  --bs-secondary-color: #94a3b8;
  --bs-tertiary-color: #64748b;
  --bs-border-color: #1f2a40;
  --bs-tertiary-bg: #111827;
  --pb-surface: #0f1729;
  --pb-surface-2: #131d33;
  --pb-hover: #16213a;
  --pb-primary-soft: rgba(36, 87, 230, .18);
  --pb-amber-soft: rgba(245, 179, 1, .14);
  --bs-link-color: #7aa2ff;
  --bs-link-color-rgb: 122, 162, 255;
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--bs-font-sans-serif); letter-spacing: -.005em; min-height: 100vh; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 700; letter-spacing: -.02em; }
::selection { background: var(--pb-amber); color: var(--pb-navy); }
.theme-dark-hide { display: inline-block; }
.theme-light-hide { display: none; }
[data-bs-theme="dark"] .theme-dark-hide { display: none; }
[data-bs-theme="dark"] .theme-light-hide { display: inline-block; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; padding: 24px 28px 40px; max-width: 1480px; width: 100%; margin: 0 auto; }
.app-footer { display: flex; justify-content: space-between; padding: 14px 28px; font-size: .75rem; color: var(--bs-tertiary-color); }

@media (max-width: 991.98px) {
  .content { padding: 16px 16px 32px; }
  .app-footer { padding: 12px 16px; }
  body.is-driver .content { padding-bottom: 96px; }
  body.is-driver .app-footer { padding-bottom: 84px; }
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--pb-sidebar-w);
  background: var(--pb-navy);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, .04);
}
@media (min-width: 992px) {
  .sidebar.offcanvas-lg { position: sticky; top: 0; height: 100vh; flex: 0 0 var(--pb-sidebar-w); background-color: var(--pb-navy) !important; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: 284px; --bs-offcanvas-bg: var(--pb-navy); }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 1.2rem; letter-spacing: -.02em; }
.brand b { font-weight: 800; color: var(--pb-amber); }
.brand:hover { color: #fff; }
.sidebar-company { margin: 0 14px 10px; padding: 9px 12px; border-radius: 10px; background: rgba(255, 255, 255, .05); display: flex; align-items: center; gap: 8px; font-size: .8rem; color: #e2e8f0; }
.sidebar-company span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; scrollbar-width: thin; }
.nav-group { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: #cbd5e1; text-decoration: none; font-size: .88rem; font-weight: 500; position: relative;
  background: none; border: 0; text-align: left; transition: background .15s, color .15s;
}
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(245, 179, 1, .12); color: #fff; }
.nav-item.active i { color: var(--pb-amber); opacity: 1; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--pb-amber); }
.nav-badge { margin-left: auto; background: var(--pb-amber); color: var(--pb-navy); font-size: .68rem; font-weight: 800; padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { padding: 10px 12px 18px; border-top: 1px solid rgba(255, 255, 255, .06); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: color-mix(in srgb, var(--bs-body-bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--bs-border-color);
}
@media (max-width: 991.98px) { .topbar { padding: 10px 12px; } }
.topbar-title { flex: 1; min-width: 0; }
.topbar-date { font-size: .82rem; color: var(--bs-secondary-color); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.btn-icon { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: transparent; color: var(--bs-body-color); padding: 0; }
.btn-icon:hover { background: var(--pb-hover); color: var(--bs-body-color); }
.btn-icon.btn-sm { width: 32px; height: 32px; border-radius: 8px; }
.dot-badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #ef4444; color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bs-body-bg); }
.user-chip { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 8px 4px 4px; border-radius: 12px; color: var(--bs-body-color); }
.user-chip:hover { background: var(--pb-hover); }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--pb-navy); color: var(--pb-amber); flex: 0 0 auto; }
.avatar.avatar-lg { width: 52px; height: 52px; font-size: 1.1rem; border-radius: 14px; }
.avatar.soft { background: var(--pb-primary-soft); color: var(--pb-primary); }

/* ---------- Bottom nav (chauffeur) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; justify-content: space-around;
  background: var(--pb-surface); border-top: 1px solid var(--bs-border-color);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(15, 23, 42, .06);
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; color: var(--bs-secondary-color); text-decoration: none; font-size: .68rem; font-weight: 600; border-radius: 10px; }
.bottom-nav a i { font-size: 1.25rem; }
.bottom-nav a.active { color: var(--pb-primary); }
.bottom-nav a.active i { color: var(--pb-primary); }

/* ---------- En-tête de page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 1.55rem; margin: 0; }
.page-head .sub { color: var(--bs-secondary-color); font-size: .88rem; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 575.98px) {
  .page-head h1 { font-size: 1.3rem; }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > .dropdown, .page-actions > form { flex: 1 1 auto; }
  .page-actions > .dropdown > .btn { width: 100%; }
}

/* ---------- Cartes ---------- */
.card { --bs-card-bg: var(--pb-surface); --bs-card-border-color: var(--bs-border-color); border-radius: var(--pb-radius); box-shadow: var(--pb-shadow); }
.card-header { background: transparent; border-bottom-color: var(--bs-border-color); padding: 14px 18px; font-weight: 600; }
.card-body { padding: 18px; }
.card-title-sm { font-size: .95rem; font-weight: 700; margin: 0; }
.card-flat { box-shadow: none; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--bs-secondary-color); margin-bottom: 10px; }

/* KPI */
.kpi { display: flex; gap: 14px; align-items: center; padding: 16px 18px; height: 100%; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: 0 0 auto; }
.kpi-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; letter-spacing: -.03em; }
.kpi-value { white-space: nowrap; }
.kpi > div:last-child { min-width: 0; }
@media (max-width: 575.98px) { .kpi { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; } .kpi-icon { width: 36px; height: 36px; font-size: 1.05rem; border-radius: 10px; } .kpi-value { font-size: 1.2rem; } }
.kpi-label { font-size: .78rem; color: var(--bs-secondary-color); font-weight: 600; }
.kpi-meta { font-size: .74rem; color: var(--bs-tertiary-color); }
a.kpi-link { color: inherit; text-decoration: none; display: block; height: 100%; }
a.kpi-link .card { transition: transform .15s, box-shadow .15s; }
a.kpi-link:hover .card { transform: translateY(-2px); box-shadow: var(--pb-shadow-lg); }
.tone-blue   { background: var(--pb-primary-soft); color: var(--pb-primary); }
.tone-amber  { background: var(--pb-amber-soft); color: #b77f00; }
.tone-green  { background: rgba(16, 185, 129, .12); color: #059669; }
.tone-red    { background: rgba(239, 68, 68, .12); color: #dc2626; }
.tone-violet { background: rgba(139, 92, 246, .12); color: #7c3aed; }
.tone-slate  { background: rgba(100, 116, 139, .12); color: #475569; }
[data-bs-theme="dark"] .tone-amber { color: #fbbf24; }
[data-bs-theme="dark"] .tone-slate { color: #cbd5e1; }

/* ---------- Tableaux ---------- */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--pb-hover); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .7rem .8rem; border-bottom-color: var(--bs-border-color); }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); font-weight: 700; background: var(--pb-surface-2); white-space: nowrap; border-bottom-width: 1px; }
.table-modern tbody tr:last-child td { border-bottom: 0; }
.table-modern td { vertical-align: middle; }
.table-card { border-radius: var(--pb-radius); overflow: hidden; }
.table-card .table thead th:first-child { padding-left: 18px; }
.table-card .table td:first-child { padding-left: 18px; }
.table-card .table thead th:last-child, .table-card .table td:last-child { padding-right: 18px; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: .78rem; color: var(--bs-secondary-color); }
.nowrap { white-space: nowrap; }
.truncate { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; }
tr.row-cancelled td { opacity: .55; }
tr.row-cancelled .cell-title { text-decoration: line-through; }

/* Tableau -> cartes sur mobile */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px 14px; border-bottom: 1px solid var(--bs-border-color); }
  .table-stack td { border: 0 !important; padding: 3px 0 !important; text-align: left !important; }
  .table-stack td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 92px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); }
  .table-stack td.td-actions { padding-top: 8px !important; }
  .table-stack td.td-check { display: none; }
  .table-card .table td:first-child { padding-left: 0; }
}

/* ---------- Badges statut ---------- */
.badge-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 99px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.bs-planned   { background: rgba(100, 116, 139, .14); color: #475569; }
.bs-confirmed { background: var(--pb-primary-soft); color: var(--pb-primary); }
.bs-started   { background: var(--pb-amber-soft); color: #a16c00; }
.bs-done      { background: rgba(16, 185, 129, .14); color: #047857; }
.bs-cancelled { background: rgba(239, 68, 68, .12); color: #b91c1c; }
[data-bs-theme="dark"] .bs-planned { color: #cbd5e1; }
[data-bs-theme="dark"] .bs-started { color: #fbbf24; }
[data-bs-theme="dark"] .bs-done { color: #34d399; }
[data-bs-theme="dark"] .bs-cancelled { color: #f87171; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; background: var(--pb-surface-2); border: 1px solid var(--bs-border-color); font-size: .76rem; font-weight: 600; color: var(--bs-body-color); text-decoration: none; white-space: nowrap; }
a.chip:hover { border-color: var(--pb-primary); color: var(--pb-primary); }
.chip-warn { background: var(--pb-amber-soft); border-color: transparent; color: #a16c00; }
.chip-danger { background: rgba(239, 68, 68, .1); border-color: transparent; color: #b91c1c; }

/* ---------- Boutons & formulaires ---------- */
.btn { font-weight: 600; border-radius: 10px; padding: .5rem .95rem; }
.btn-sm { border-radius: 8px; padding: .3rem .65rem; font-size: .82rem; }
.btn-primary { --bs-btn-bg: var(--pb-primary); --bs-btn-border-color: var(--pb-primary); --bs-btn-hover-bg: #1a47c7; --bs-btn-hover-border-color: #1a47c7; --bs-btn-active-bg: #163ca8; }
.btn-accent { background: var(--pb-amber); border-color: var(--pb-amber); color: var(--pb-navy); }
.btn-accent:hover, .btn-accent:focus { background: #e3a500; border-color: #e3a500; color: var(--pb-navy); }
.btn-dark { --bs-btn-bg: var(--pb-navy); --bs-btn-border-color: var(--pb-navy); }
.btn-light { --bs-btn-bg: var(--pb-surface-2); --bs-btn-border-color: var(--bs-border-color); --bs-btn-hover-bg: var(--pb-hover); --bs-btn-hover-border-color: var(--bs-border-color); --bs-btn-color: var(--bs-body-color); --bs-btn-hover-color: var(--bs-body-color); }
.btn-soft { background: var(--pb-primary-soft); color: var(--pb-primary); border: 0; }
.btn-soft:hover { background: var(--pb-primary); color: #fff; }
.btn-ghost { background: transparent; border: 0; color: var(--bs-secondary-color); }
.btn-ghost:hover { background: var(--pb-hover); color: var(--bs-body-color); }
.btn-ghost.text-danger:hover { background: rgba(239, 68, 68, .1); }
.form-control, .form-select { border-radius: 10px; border-color: var(--bs-border-color); background-color: var(--pb-surface); padding: .52rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--pb-primary); box-shadow: 0 0 0 .2rem rgba(36, 87, 230, .15); }
.form-label { font-size: .8rem; font-weight: 600; color: var(--bs-secondary-color); margin-bottom: .3rem; }
.form-text { font-size: .76rem; }
.input-group-text { background: var(--pb-surface-2); border-color: var(--bs-border-color); border-radius: 10px; }
.form-check-input:checked { background-color: var(--pb-primary); border-color: var(--pb-primary); }
.req::after { content: " *"; color: #ef4444; }
option.opt-busy { color: #dc2626; font-weight: 700; }
.avail-hint { font-size: .84rem; border-radius: 10px; padding: 8px 12px; display: none; }
.avail-hint.show { display: block; }
.avail-hint.ok { background: rgba(16, 185, 129, .1); color: #047857; }
.avail-hint.bad { background: rgba(239, 68, 68, .1); color: #b91c1c; }
[data-bs-theme="dark"] .avail-hint.ok { color: #34d399; }
[data-bs-theme="dark"] .avail-hint.bad { color: #f87171; }

/* Filtres */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-bar > * { flex: 1 1 160px; }
.filter-bar > .filter-actions { flex: 0 0 auto; display: flex; gap: 8px; }
.date-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--pb-surface); border: 1px solid var(--bs-border-color); border-radius: 12px; padding: 4px; }
.date-nav input[type=date] { border: 0; background: transparent; font-weight: 600; padding: 4px 6px; color: var(--bs-body-color); min-width: 0; }
.date-nav input[type=date]:focus { outline: none; }
.date-nav .btn-icon { width: 34px; height: 34px; }

@media (max-width: 767.98px) {
  .filter-bar .opt-filter { display: none; }
  .filter-bar.open .opt-filter { display: block; }
  .filter-bar.open button.opt-filter { display: inline-block; }
}

/* Segments */
.seg { display: inline-flex; background: var(--pb-surface-2); border: 1px solid var(--bs-border-color); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-size: .82rem; font-weight: 600; color: var(--bs-secondary-color); text-decoration: none; white-space: nowrap; }
.seg a.active, .seg button.active { background: var(--pb-surface); color: var(--bs-body-color); box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }
.seg .count { font-size: .7rem; opacity: .75; margin-left: 3px; }

/* Barre d'actions groupées */
.bulk-bar { position: sticky; bottom: 16px; z-index: 1010; display: none; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 10px 14px; border-radius: 14px; background: var(--pb-navy); color: #fff; box-shadow: var(--pb-shadow-lg); }
.bulk-bar.show { display: flex; }
.bulk-bar .btn { --bs-btn-padding-y: .3rem; }

/* ---------- États vides ---------- */
.empty-state { text-align: center; padding: 48px 16px; color: var(--bs-secondary-color); }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; font-size: 1.7rem; background: var(--pb-primary-soft); color: var(--pb-primary); }
.empty-state h2, .empty-state h1 { color: var(--bs-body-color); }

/* ---------- Modales ---------- */
.modal-content { border: 0; border-radius: 18px; background: var(--pb-surface); box-shadow: var(--pb-shadow-lg); }
.modal-header { border-bottom-color: var(--bs-border-color); padding: 16px 20px; }
.modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-body { padding: 20px; }
.modal-footer { border-top-color: var(--bs-border-color); padding: 12px 20px; }
.confirm-icon { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center; font-size: 1.5rem; background: rgba(239, 68, 68, .12); color: #dc2626; }
.confirm-icon.info { background: var(--pb-primary-soft); color: var(--pb-primary); }
.form-section { margin-top: 12px !important; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--bs-tertiary-color); margin: 6px 0 2px; display: flex; align-items: center; gap: 8px; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--bs-border-color); }
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-sm) { margin: 0; max-width: none; min-height: 100%; }
  .modal-dialog:not(.modal-sm) .modal-content { border-radius: 0; min-height: 100vh; }
}

/* ---------- Toasts / alertes ---------- */
.toast { border-radius: 12px; box-shadow: var(--pb-shadow-lg); background: var(--pb-surface); }
.toast-success i { color: #10b981; } .toast-danger i { color: #ef4444; } .toast-warning i { color: #f59e0b; } .toast-info i { color: var(--pb-primary); }
.alert { border-radius: 12px; border: 0; }
.alert-success { background: rgba(16, 185, 129, .12); color: #065f46; }
.alert-danger { background: rgba(239, 68, 68, .1); color: #991b1b; }
.alert-warning { background: var(--pb-amber-soft); color: #7a5200; }
.alert-info { background: var(--pb-primary-soft); color: #1e3a8a; }
[data-bs-theme="dark"] .alert-success { color: #6ee7b7; }
[data-bs-theme="dark"] .alert-danger { color: #fca5a5; }
[data-bs-theme="dark"] .alert-warning { color: #fcd34d; }
[data-bs-theme="dark"] .alert-info { color: #a5b4fc; }

/* ---------- Listes ---------- */
.list-clean { list-style: none; padding: 0; margin: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--bs-border-color); }
.list-row:last-child { border-bottom: 0; }
a.list-row { color: inherit; text-decoration: none; }
a.list-row:hover { background: var(--pb-hover); }
.time-pill { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .82rem; background: var(--pb-surface-2); border: 1px solid var(--bs-border-color); padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* Alertes flotte */
.alert-line { display: flex; gap: 10px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--bs-border-color); font-size: .86rem; }
.alert-line:last-child { border-bottom: 0; }
.alert-line .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; }

/* ---------- Graphique barres ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar { width: 100%; max-width: 44px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #4f7bff, var(--pb-primary)); position: relative; min-height: 3px; transition: height .4s; }
.bar.is-today { background: linear-gradient(180deg, #ffd04d, var(--pb-amber)); }
.bar-val { font-size: .72rem; font-weight: 700; color: var(--bs-secondary-color); }
.bar-lbl { font-size: .7rem; color: var(--bs-tertiary-color); font-weight: 600; white-space: nowrap; }

/* Progression */
.progress { height: 8px; border-radius: 99px; background: var(--pb-surface-2); }
.progress-bar { border-radius: 99px; }

/* ---------- Mission card (chauffeur & mobile) ---------- */
.mission-card { border-radius: var(--pb-radius); background: var(--pb-surface); border: 1px solid var(--bs-border-color); padding: 14px 16px; box-shadow: var(--pb-shadow); position: relative; overflow: hidden; }
.mission-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--bs-border-color); }
.mission-card.st-confirmed::before { background: var(--pb-primary); }
.mission-card.st-started::before { background: var(--pb-amber); }
.mission-card.st-done::before { background: #10b981; }
.mission-card.st-cancelled::before { background: #ef4444; }
.mission-time { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mission-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .84rem; color: var(--bs-secondary-color); }
.mission-meta i { margin-right: 4px; }

/* Stations (circuit) */
.stops { list-style: none; padding: 0; margin: 0; position: relative; }
.stops li { position: relative; padding: 6px 0 6px 28px; }
.stops li::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--bs-border-color); }
.stops li:first-child::before { top: 50%; }
.stops li:last-child::before { bottom: 50%; }
.stops li::after { content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 12px; height: 12px; border-radius: 50%; background: var(--pb-surface); border: 3px solid var(--pb-primary); }
.stops li:first-child::after { border-color: #10b981; }
.stops li:last-child::after { border-color: #ef4444; }
.drag-handle { cursor: grab; color: var(--bs-tertiary-color); }
.sortable-ghost { opacity: .4; background: var(--pb-primary-soft); }

/* ---------- Planning (timeline) ---------- */
.plan-wrap { overflow: auto; border-radius: var(--pb-radius); background: var(--pb-surface); border: 1px solid var(--bs-border-color); max-height: 75vh; overscroll-behavior: contain; }
.plan-grid { position: relative; min-width: max-content; }
.plan-row { display: flex; border-bottom: 1px solid var(--bs-border-color); }
.plan-row:last-child { border-bottom: 0; }
.plan-label { position: sticky; left: 0; z-index: 3; flex: 0 0 190px; width: 190px; padding: 10px 14px; background: var(--pb-surface); border-right: 1px solid var(--bs-border-color); display: flex; flex-direction: column; justify-content: center; }
.plan-label .n { font-weight: 700; font-size: .88rem; line-height: 1.2; }
.plan-label .s { font-size: .74rem; color: var(--bs-secondary-color); }
.plan-head { position: sticky; top: 0; z-index: 4; background: var(--pb-surface-2); }
.plan-head .plan-label { background: var(--pb-surface-2); z-index: 5; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--bs-secondary-color); }
.plan-track { position: relative; flex: 0 0 auto; height: 64px; }
.plan-head .plan-track { height: 38px; }
.plan-hour { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--bs-border-color); }
.plan-hour.half { border-left-style: dashed; opacity: .5; }
.plan-hour span { position: absolute; top: 10px; left: 6px; font-size: .72rem; font-weight: 700; color: var(--bs-secondary-color); }
.plan-block { position: absolute; top: 8px; bottom: 8px; border-radius: 9px; padding: 5px 8px; font-size: .74rem; line-height: 1.25; overflow: hidden; color: #fff; background: var(--pb-primary); box-shadow: 0 2px 6px rgba(15, 23, 42, .15); text-decoration: none; display: block; z-index: 1; }
.plan-block:hover { z-index: 2; color: #fff; filter: brightness(1.08); }
.plan-block b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-block span { white-space: nowrap; opacity: .9; }
.plan-block.st-planned { background: #64748b; }
.plan-block.st-started { background: #d99a00; }
.plan-block.st-done { background: #059669; }
.plan-block.st-cancelled { background: #ef4444; opacity: .5; }
.plan-block.is-conflict { outline: 2px solid #ef4444; outline-offset: 1px; }
.plan-now { position: absolute; top: 0; bottom: 0; width: 2px; background: #ef4444; z-index: 2; pointer-events: none; }
.plan-now::before { content: ""; position: absolute; top: -4px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }

/* ---------- Calendrier ---------- */
.fc { --fc-border-color: var(--bs-border-color); --fc-page-bg-color: var(--pb-surface); --fc-neutral-bg-color: var(--pb-surface-2); --fc-today-bg-color: var(--pb-amber-soft); --fc-event-bg-color: var(--pb-primary); --fc-event-border-color: var(--pb-primary); --fc-button-bg-color: var(--pb-surface-2); --fc-button-border-color: var(--bs-border-color); --fc-button-text-color: var(--bs-body-color); --fc-button-hover-bg-color: var(--pb-hover); --fc-button-hover-border-color: var(--bs-border-color); --fc-button-active-bg-color: var(--pb-navy); --fc-button-active-border-color: var(--pb-navy); }
.fc .fc-button { border-radius: 9px !important; font-weight: 600; font-size: .82rem; text-transform: capitalize; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 700; text-transform: capitalize; }
.fc .fc-daygrid-day-number { font-weight: 600; font-size: .82rem; color: var(--bs-body-color); text-decoration: none; }
.fc .fc-col-header-cell-cushion { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); text-decoration: none; }
.fc-daygrid-day { cursor: pointer; }
.fc .fc-event.ev-count { border-radius: 8px; padding: 2px 6px; font-weight: 700; font-size: .78rem; }
@media (max-width: 575.98px) { .fc .fc-toolbar { flex-direction: column; gap: 8px; } }

/* ---------- Connexion ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bs-body-bg); }
.auth-hero { background: var(--pb-navy); color: #e2e8f0; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(245, 179, 1, .22), transparent 65%); }
.auth-hero h1 { color: #fff; font-size: 2.3rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.1; max-width: 460px; }
.auth-hero h1 span { color: var(--pb-amber); }
.auth-hero ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; max-width: 420px; }
.auth-hero li { display: flex; gap: 10px; align-items: flex-start; color: #cbd5e1; }
.auth-hero li i { color: var(--pb-amber); margin-top: 2px; }
.road { position: absolute; left: 0; right: 0; bottom: 92px; height: 2px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 22px, transparent 22px 40px); }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 24px 36px; }
  .auth-hero h1 { font-size: 1.6rem; }
  .auth-hero ul, .road { display: none; }
}

/* ---------- Impression ---------- */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; color: #000 !important; font-size: 11px; }
  .sidebar, .topbar, .app-footer, .bottom-nav, .no-print, .btn, .page-actions, .toast-container, .bulk-bar { display: none !important; }
  .content { padding: 0 !important; max-width: none; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  .print-only { display: block !important; }
  .table thead th { background: #eee !important; color: #000 !important; }
  a { color: #000 !important; text-decoration: none !important; }
  .badge-status { border: 1px solid #999; }
}

/* Utilitaires */
.fw-800 { font-weight: 800; }
.text-amber { color: #b77f00; }
.bg-surface { background: var(--pb-surface); }
.rounded-pb { border-radius: var(--pb-radius); }
.gap-row { row-gap: 16px; }
.min-w-0 { min-width: 0; }
.cursor-pointer { cursor: pointer; }
.map-box { height: 380px; border-radius: 12px; overflow: hidden; border: 1px solid var(--bs-border-color); }
[data-bs-theme="dark"] .btn-dark { --bs-btn-bg: #24304a; --bs-btn-border-color: #2c3a58; --bs-btn-hover-bg: #2c3a58; --bs-btn-hover-border-color: #34446a; }

/* =====================================================================
   Planner Bus Connect — temps réel
   ===================================================================== */
.live-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: .74rem; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); white-space: nowrap; }
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.bus-marker { width: 40px; height: 40px; border-radius: 50%; background: var(--c, #2457e6); color: #fff; display: grid; place-items: center; font-size: 1.05rem; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.3); position: relative; }
.bus-dir { position: absolute; inset: -9px; pointer-events: none; }
.bus-dir::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-bottom: 9px solid var(--c, #2457e6); border-top: 0; }
.bus-label { position: absolute; top: 42px; left: 50%; transform: translateX(-50%); background: #0b1220; color: #fff; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.stop-marker { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid #94a3b8; color: #0f172a; font-size: .7rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.stop-marker.st-approach { border-color: #f59e0b; background: #fff7e0; }
.stop-marker.st-arrived { border-color: #16a34a; background: #16a34a; color: #fff; }
.stop-marker.st-passed { border-color: #64748b; background: #64748b; color: #fff; opacity: .8; }
.stop-marker.mine { box-shadow: 0 0 0 4px rgba(245,179,1,.6), 0 2px 6px rgba(0,0,0,.2); }
.me-marker { width: 22px; height: 22px; border-radius: 50%; background: #2457e6; border: 4px solid #fff; box-shadow: 0 0 0 6px rgba(36,87,230,.25); }
.stop-pill { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.stop-pill.st-pending { background: rgba(100,116,139,.12); color: #64748b; }
.stop-pill.st-approach { background: var(--pb-amber-soft); color: #a16c00; }
.stop-pill.st-arrived { background: rgba(22,163,74,.14); color: #15803d; }
.stop-pill.st-passed { background: rgba(15,23,42,.08); color: #475569; }
.live-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; height: calc(100vh - 190px); min-height: 520px; }
.live-side { overflow-y: auto; }
.live-map { border-radius: var(--pb-radius); overflow: hidden; border: 1px solid var(--bs-border-color); min-height: 420px; }
@media (max-width: 991.98px) { .live-layout { grid-template-columns: 1fr; height: auto; } .live-map { height: 55vh; order: -1; } }
.live-item { display: block; padding: 12px 14px; border-bottom: 1px solid var(--bs-border-color); color: inherit; text-decoration: none; cursor: pointer; }
.live-item:hover, .live-item.active { background: var(--pb-hover); }
.timeline-stops { list-style: none; padding: 0; margin: 0; }
.timeline-stops li { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.timeline-stops li::before { content: ""; position: absolute; left: 12px; top: 0; bottom: 0; width: 2px; background: var(--bs-border-color); }
.timeline-stops li:first-child::before { top: 50%; } .timeline-stops li:last-child::before { bottom: 50%; }
.timeline-stops .tl-dot { position: relative; z-index: 1; flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 800; background: var(--pb-surface); border: 3px solid #94a3b8; }
.timeline-stops .st-approach .tl-dot { border-color: #f59e0b; }
.timeline-stops .st-arrived .tl-dot { border-color: #16a34a; background: #16a34a; color: #fff; }
.timeline-stops .st-passed .tl-dot { border-color: #64748b; background: #64748b; color: #fff; }
.timeline-stops li.mine { background: var(--pb-amber-soft); border-radius: 12px; padding-left: 6px; padding-right: 6px; }
.gps-panel { position: sticky; top: 64px; z-index: 5; }
.big-cta { font-size: 1.1rem; padding: .9rem 1rem; border-radius: 14px; }
.eta-big { font-size: 2.6rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.5); } 70% { box-shadow: 0 0 0 12px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
.install-banner { display: none; }
.install-banner.show { display: flex; }
/* Centre d'alertes */
.alert-card { border-left: 4px solid transparent; }
.alert-card.sev-danger { border-left-color: #dc2626; }
.alert-card.sev-warning { border-left-color: #f59e0b; }
.alert-card.sev-info { border-left-color: var(--pb-primary, #2563eb); }
/* Application installée : marge pour l'encoche */
.pwa-standalone .topbar { padding-top: max(.5rem, env(safe-area-inset-top)); }
.timeline-stops .stop-pill { align-self: flex-start; white-space: nowrap; line-height: 1.4; }
/* Module Client : cartes */
.sp-pin span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 800; font-size: .75rem; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.sp-dot span { display: block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.sp-map { height: 420px; border-radius: 14px; overflow: hidden; }
.sp-map-lg { height: 560px; }
.sp-stops { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow: auto; }
.sp-stops li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--bs-border-color); }
.sp-stops .num { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--pb-primary); color: #fff; font-weight: 800; font-size: .75rem; display: grid; place-items: center; }
.sp-day { font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); padding: 14px 16px 6px; background: var(--bs-tertiary-bg); }
.sp-line-locked { background: rgba(22,163,74,.04); }
.sp-type-transfert { border-left: 3px solid #e8590c; }
.sp-type-excursion { border-left: 3px solid #9333ea; }
.sp-type-prive { border-left: 3px solid var(--pb-primary); }

/* Chauffeur le plus proche (fiche mission) */
.near-box { border: 1px solid var(--bs-border-color); border-radius: 12px; padding: 12px 14px; background: var(--bs-tertiary-bg); }
.near-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--bs-border-color); font-size: .9rem; flex-wrap: wrap; }
.near-row:first-child { border-top: 0; }
.near-row.best { background: rgba(22,163,74,.08); margin: 0 -8px; padding: 7px 8px; border-radius: 8px; }
.near-rank { width: 22px; height: 22px; border-radius: 50%; background: var(--bs-secondary-bg); display: grid; place-items: center; font-size: .75rem; font-weight: 700; flex: 0 0 auto; }

.return-box { background: var(--bs-tertiary-bg); }
.return-box .form-check-label { color: var(--bs-body-color); }
.po-row.po-bad { border-color: var(--bs-danger); }
.po-row.po-changed { border-color: var(--bs-success); }

/* V3.7 — suivi en direct : légende chauffeurs + frise horaire */
.legend-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color); border-radius: 999px; padding: 3px 11px; font-size: .8rem; font-weight: 600; }
.legend-chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.legend-chip.off { opacity: .45; text-decoration: line-through; }
.tl-wrap { overflow-x: auto; }
.tl-row { display: grid; grid-template-columns: 150px minmax(560px, 1fr); border-top: 1px solid var(--bs-border-color); min-height: 46px; align-items: center; }
.tl-head { min-height: 30px; border-top: 0; font-size: .74rem; color: var(--bs-secondary-color); }
.tl-name { padding: 6px 12px; font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; background: var(--bs-body-bg); z-index: 3; }
.tl-name .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.tl-axis, .tl-track { position: relative; height: 100%; min-height: 30px; margin: 0 26px 0 18px; }
.tl-axis span { position: absolute; top: 6px; transform: translateX(-50%); }
.tl-track { height: 38px; background-image: linear-gradient(to right, var(--bs-border-color) 1px, transparent 1px); background-size: calc(100% / var(--ticks, 1)) 100%; }
.tl-block { position: absolute; top: 5px; height: 28px; border-radius: 8px; background: color-mix(in srgb, var(--c) 22%, var(--bs-body-bg)); border: 2px solid var(--c); overflow: hidden; cursor: pointer; min-width: 22px; }
.tl-block.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 40%, transparent); }
.tl-block .tl-fill { position: absolute; inset: 0 auto 0 0; background: var(--c); opacity: .55; }
.tl-block .tl-txt { position: relative; padding: 0 7px; font-size: .72rem; font-weight: 700; line-height: 24px; white-space: nowrap; color: var(--bs-body-color); }
.tl-block.tl-un { background: repeating-linear-gradient(45deg, #fee2e2, #fee2e2 6px, #fecaca 6px, #fecaca 12px); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: #dc2626; z-index: 2; pointer-events: none; }

/* V3.16 — mouvement des bus : rotation douce du cap, bus sans signal estompé */
.bus-dir { transition: transform .9s linear; }
.bus-marker-wrap.bus-stale .bus-marker { opacity: .65; filter: grayscale(.4); }
.gps-sig { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; }
.gps-sig i { width: .6rem; height: .6rem; border-radius: 50%; background: var(--c, #16a34a); display: inline-block; }
.follow-btn { position: absolute; z-index: 800; top: 10px; left: 54px; }

@media (max-width:576px){.form-select.w-auto{max-width:100%}}

/* Noms de stations sur les cartes */
.pb-stn-wrap { pointer-events: none; }
.pb-stn-label { position: absolute; left: 0; transform: translateX(-50%); white-space: nowrap; background: rgba(255,255,255,.92); color: #0f172a; border: 1px solid rgba(15,23,42,.18); border-radius: 6px; padding: 1px 6px; font-size: .68rem; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.2); max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
[data-bs-theme=dark] .pb-stn-label { background: rgba(15,23,42,.9); color: #f1f5f9; border-color: rgba(255,255,255,.25); }
.leaflet-popup-content a.btn-primary { color: #fff !important; text-decoration: none; }

.pb-hide-labels .pb-stn-wrap { display: none; }
.pb-stn-ico, .pb-arrow { background: none; border: 0; }
.pb-stn-label { writing-mode: horizontal-tb !important; white-space: nowrap !important; }
.pb-show-labels .pb-stn-wrap { display: block !important; }
