/* ============================================================
   TitanFleet TMS — Main Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover-bg: rgba(255,255,255,.07);
  --sidebar-active-bg: rgba(99,102,241,.25);
  --sidebar-text: rgba(255,255,255,.8);
  --topbar-height: 56px;
  --primary: #6366f1;
  --body-bg: #f4f6fa;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background: var(--body-bg);
  font-size: .875rem;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ════════════════════════════════════════════════
   APP WRAPPER — full-width flex container
   ════════════════════════════════════════════════ */
#app-wrapper {
  display: flex;
  height: 100vh;
  height: 100dvh; /* mobile browsers: accounts for the address bar showing/hiding,
                     so the layout doesn't size itself taller than what's actually visible */
  width: 100%;
  overflow: hidden;
}

/* ════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 1040;
}

.sidebar-brand {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}
.sidebar-brand .brand-text {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
}
.sidebar-brand:hover .brand-text { color: #e0e7ff; }

.sidebar-hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,.08);
  margin: 0;
}

/* Nav pills inside sidebar */
#sidebar .nav-pills {
  padding: .5rem .5rem 0;
}

#sidebar .nav-link {
  color: var(--sidebar-text);
  padding: .5rem .85rem;
  border-radius: .4rem;
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  transition: background .15s, color .15s;
  margin-bottom: 1px;
}
#sidebar .nav-link i { font-size: .95rem; opacity: .75; flex-shrink: 0; }
#sidebar .nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}
#sidebar .nav-link:hover i { opacity: 1; }
#sidebar .nav-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 600;
}
#sidebar .nav-link.active i { opacity: 1; }

.sidebar-section-label,
.nav-section-label {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.3);
  padding: .9rem 1rem .3rem;
  list-style: none;
}

.sidebar-user-area {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .85rem 1rem;
  flex-shrink: 0;
}
.sidebar-user-area a:hover { color: rgba(255,255,255,.85) !important; }

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-circle-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════
   MAIN CONTENT AREA
   ════════════════════════════════════════════════ */
#main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

/* ── Top bar ── */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ── Flash container + page content ── */
#flash-container { padding: .75rem 1.5rem 0; }
#flash-container:empty { padding: 0; }

/* ── Unacknowledged-defect attention icon (trips grid) ──
   A driver-flagged pre-trip fault a controller hasn't acknowledged yet —
   this pulses until someone opens the trip and acknowledges it (see
   trips.py::acknowledge_defect), unlike the other static status icons on
   the same row, so it's the one that visually demands attention. Respects
   prefers-reduced-motion. */
@keyframes iconPulseWarning {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}
.icon-pulse-warning {
  animation: iconPulseWarning 1.1s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .icon-pulse-warning { animation: none; }
}

/* Zero height on desktop — only takes up scroll room once the mobile
   media query below gives it one. */
.mobile-scroll-spacer { height: 0; }

main.flex-grow-1 {
  padding: 1.5rem;
  flex: 1;
}

/* ════════════════════════════════════════════════
   PAGE HEADER
   ════════════════════════════════════════════════ */
.page-header {
  margin-bottom: 1.5rem;
  padding-top: .25rem;
}
.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  color: #111827;
}
.page-header .text-muted { font-size: .82rem; margin: .15rem 0 0; }

/* ════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════ */
.card {
  border: 1px solid #e5e7eb;
  border-radius: .6rem;
  background: #fff;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  padding: .75rem 1.1rem;
  font-weight: 600;
  border-radius: .6rem .6rem 0 0 !important;
}
.card.shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,.07) !important; }

/* ════════════════════════════════════════════════
   KPI / STAT CARDS
   ════════════════════════════════════════════════ */
.kpi-card {
  border: none;
  border-radius: .75rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.07);
}
.kpi-icon {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ── Shared KPI tile (module overview strips) ──────────────────────────
   The pattern pods_list.html/tyres/index.html/the dispatch board each grew
   their own near-identical version of (white card, soft-coloured icon
   circle, bold value, muted label) — this is that pattern promoted to one
   place, so a new module page reaches for it instead of writing a fifth
   copy. Existing pages keep their own local versions for now (not a
   behaviour change to retrofit unasked); new ones should use this. */
.kpi-tile-link { text-decoration: none; color: inherit; display: block; height: 100%; }
.kpi-tile {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .65rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  padding: .85rem 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  transition: box-shadow .15s, transform .15s;
}
.kpi-tile-link:hover .kpi-tile,
a.kpi-tile:hover { box-shadow: 0 4px 12px rgba(0,0,0,.10); transform: translateY(-1px); }
.kpi-tile-value { font-size: 1.4rem; font-weight: 800; color: #111827; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-tile-label { font-size: .72rem; color: #6b7280; margin-top: .1rem; }
.kpi-tile-icon {
  width: 44px; height: 44px; border-radius: .55rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.kpi-tile-icon.is-primary   { background: rgba(99,102,241,.1);  color: #4f46e5; }
.kpi-tile-icon.is-success   { background: rgba(16,185,129,.1);  color: #047857; }
.kpi-tile-icon.is-warning   { background: rgba(245,158,11,.12); color: #b45309; }
.kpi-tile-icon.is-danger    { background: rgba(239,68,68,.1);   color: #dc2626; }
.kpi-tile-icon.is-info      { background: rgba(14,165,233,.1);  color: #0369a1; }
.kpi-tile-icon.is-secondary { background: rgba(100,116,139,.12); color: #475569; }

/* ── Shared section tabs (module sub-page nav: Overview / Results / …) ── */
.section-tabs .nav-link { color: var(--bs-body-color); border: none; border-bottom: 2px solid transparent; padding: .5rem .9rem; font-size: .85rem; }
.section-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: none; }
.section-tabs .nav-link:hover:not(.active) { color: var(--primary); }

/* ════════════════════════════════════════════════
   MESSAGING — split inbox (conversation list + open thread side by side,
   like Slack/Intercom — replaced a separate list page + detail page so
   opening a conversation doesn't lose your place in the list)
   ════════════════════════════════════════════════ */
.msg-split {
  display: flex;
  flex-direction: row; /* .card (Bootstrap) sets flex-direction: column on this
    element too, same specificity — without this explicit override the two
    panes stack instead of sitting side by side. */
  overflow: hidden;
  height: calc(100dvh - 230px);
  min-height: 460px;
}

/* ── List pane ── */
.msg-list-pane {
  width: 340px; min-width: 340px;
  min-height: 0; /* flex items default to min-height:auto, which lets their
    content push them taller than the row's fixed height and breaks the
    inner overflow-y:auto scroll below — this lets it actually shrink */
  border-right: 1px solid #e5e7eb;
  display: flex; flex-direction: column;
}
.msg-list-toolbar { padding: .9rem .9rem .6rem; flex-shrink: 0; }
.msg-search { position: relative; margin-bottom: .6rem; }
.msg-search i {
  position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
  color: #9ca3af; font-size: .8rem; pointer-events: none;
}
.msg-search input { padding-left: 1.9rem; font-size: .8rem; }
.msg-seg { display: flex; background: #f1f2f6; border-radius: .45rem; padding: .2rem; gap: .2rem; }
.msg-seg-btn {
  flex: 1; text-align: center; padding: .32rem 0; border-radius: .35rem;
  font-size: .76rem; color: #6b7280; text-decoration: none;
}
.msg-seg-btn.is-active { background: #fff; color: #4f46e5; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.msg-seg-btn:hover:not(.is-active) { color: #374151; }

.msg-list-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: .5rem; }
.msg-list-row {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .75rem .9rem; border-left: 3px solid transparent;
  text-decoration: none; color: inherit;
}
.msg-list-row:hover { background: #f8f9fb; }
.msg-list-row.is-selected { border-left-color: var(--primary); background: rgba(99,102,241,.05); }
.msg-list-row.is-unread .msg-list-row-subject { font-weight: 700; color: #1f2937; }
.msg-list-row.is-unread .msg-list-row-snippet { color: #374151; }
.msg-list-row-body { flex: 1 1 auto; min-width: 0; }
.msg-list-row-subject { display: block; font-size: .85rem; font-weight: 600; color: #1f2937; }
.msg-list-row-snippet {
  display: block; font-size: .78rem; color: #6b7280; margin-top: .1rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-list-row-chips { display: flex; gap: .35rem; margin-top: .35rem; }
.msg-list-row-meta { flex-shrink: 0; text-align: right; }
.msg-list-row-time { font-size: .7rem; color: #9ca3af; white-space: nowrap; }
.msg-unread-badge {
  display: inline-block; margin-top: .3rem; background: #ef4444; color: #fff;
  font-size: .68rem; font-weight: 700; padding: .05rem .38rem; border-radius: 999px;
}
.msg-list-empty { text-align: center; color: #9ca3af; padding: 3rem 1.25rem; font-size: .85rem; }
.msg-list-empty i { font-size: 1.8rem; display: block; margin-bottom: .5rem; opacity: .5; }

.msg-chip {
  display: inline-flex; align-items: center;
  font-size: .68rem; border: 1px solid #e5e7eb; background: #f9fafb; color: #6b7280;
  padding: .08rem .4rem; border-radius: .3rem;
}
.msg-chip.is-closed { border-color: transparent; background: #f3f4f6; }
a.msg-chip:hover { color: var(--primary); border-color: var(--primary); }

/* ── Thread pane ── */
.msg-thread-pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.msg-thread-placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #9ca3af; font-size: .85rem; text-align: center; padding: 2rem;
}
.msg-thread-placeholder i { font-size: 2rem; margin-bottom: .6rem; opacity: .5; }

.msg-thread-header {
  padding: .9rem 1.25rem; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: flex-start; gap: .6rem; flex-shrink: 0; flex-wrap: wrap;
}
.msg-status-pill { font-size: .68rem; font-weight: 600; padding: .15rem .5rem; border-radius: .3rem; }
.msg-status-pill.is-open { background: rgba(16,185,129,.12); color: #047857; }
.msg-status-pill.is-closed { background: #f3f4f6; color: #6b7280; }

.msg-thread-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 1.1rem 1.4rem; background: #fbfbfd; }
.msg-day-divider { text-align: center; margin: 0 0 1rem; }
.msg-day-divider span { font-size: .68rem; color: #9ca3af; background: #f1f2f6; padding: .2rem .7rem; border-radius: 999px; }

.msg-line { display: flex; gap: .6rem; margin-bottom: .2rem; align-items: flex-end; margin-top: 1rem; }
.msg-line.is-grouped { margin-top: .2rem; }
.msg-line.is-own { flex-direction: row-reverse; }
.msg-line .avatar-spacer { width: 28px; background: none; flex-shrink: 0; }
.msg-line-content { max-width: 66%; min-width: 0; }
.msg-line.is-own .msg-line-content { text-align: right; }
.msg-line-meta { font-size: .7rem; color: #9ca3af; margin-bottom: .2rem; }
.msg-bubble {
  display: inline-block; text-align: left; padding: .55rem .85rem;
  border-radius: .9rem; background: #f1f2f6; color: #1f2937;
  font-size: .85rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  border-bottom-left-radius: .25rem;
}
.msg-line.is-own .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: .25rem; border-bottom-left-radius: .9rem; }

.msg-composer {
  padding: .9rem 1.25rem; border-top: 1px solid #e5e7eb;
  display: flex; align-items: flex-end; gap: .6rem; flex-shrink: 0;
}
.msg-composer textarea {
  flex: 1; border: 1px solid #e5e7eb; border-radius: 1.2rem; padding: .55rem 1rem;
  font-size: .83rem; background: #f9fafb; resize: none; max-height: 140px;
  font-family: inherit;
}
.msg-composer textarea:focus {
  background: #fff; border-color: var(--primary); outline: none;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.msg-composer-send {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: none; cursor: pointer;
}
.msg-composer-send:hover { background: #4f46e5; }
.msg-closed-banner {
  padding: .9rem 1.25rem; border-top: 1px solid #e5e7eb; text-align: center;
  color: #6b7280; font-size: .82rem; flex-shrink: 0; background: #fafafa;
}

.msg-participants { display: flex; align-items: center; }
.msg-participants .avatar { border: 2px solid #fff; margin-left: -.5rem; }
.msg-participants .avatar:first-child { margin-left: 0; }

/* Colour-coded avatars for OTHER participants — current user's own avatar
   stays the plain primary indigo everywhere else in the app; these four
   extra hues exist only so people can tell others in a thread apart at a
   glance. Same lightness/chroma as --primary, hue rotated (oklch, with a
   hex fallback first for browsers that don't parse oklch()). */
/* Compound selector (.avatar.avatar-hue-N), not just .avatar-hue-N — the
   generic .avatar rule (styles/AVATAR section, below) sets the same
   background property and sits later in this file, so a same-specificity
   .avatar-hue-N alone would lose to it on source order. */
.avatar.avatar-hue-0 { background: #0e9aad; background: oklch(0.58 0.16 200); }
.avatar.avatar-hue-1 { background: #c17a3e; background: oklch(0.6 0.15 40); }
.avatar.avatar-hue-2 { background: #b8497a; background: oklch(0.55 0.14 340); }
.avatar.avatar-hue-3 { background: #3f9d6f; background: oklch(0.55 0.14 150); }

@media (max-width: 991.98px) {
  .msg-split { flex-direction: column; height: auto; }
  .msg-list-pane { width: 100%; min-width: 0; max-height: 320px; border-right: none; border-bottom: 1px solid #e5e7eb; }
  .msg-thread-pane { min-height: 480px; }
}

/* New-thread participant picker — checkbox list + selected chips, replacing
   a bare <select multiple> that gave no visual feedback on who was picked. */
.participant-picker { display: flex; gap: 1rem; flex-wrap: wrap; }
.participant-list {
  flex: 1 1 260px; max-height: 260px; overflow-y: auto;
  border: 1px solid #e5e7eb; border-radius: .5rem; padding: .4rem;
}
.participant-list .form-check {
  /* padding-left deliberately left at Bootstrap's own 1.5em default, not
     overridden here — .form-check-input has margin-left:-1.5em and needs
     that room, or the checkbox sits outside the row and gets clipped by
     .participant-list's edge (that was a real bug: a plain `padding:
     .35rem .5rem` shorthand here zeroed it out). */
  padding-top: .35rem; padding-right: .5rem; padding-bottom: .35rem;
  border-radius: .35rem; margin: 0;
}
.participant-list .form-check:hover { background: #f8f9fb; }
.participant-list .form-check-label { font-size: .84rem; cursor: pointer; width: 100%; }
.participant-list .form-check-input { cursor: pointer; }
.participant-group-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: #9ca3af; padding: .5rem .5rem .2rem;
}
.participant-selected { flex: 1 1 220px; }
.participant-chips {
  display: flex; flex-wrap: wrap; gap: .4rem; min-height: 44px;
  border: 1px dashed #e5e7eb; border-radius: .5rem; padding: .5rem;
}
.participant-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: rgba(79,70,229,.08); color: var(--primary);
  border-radius: 999px; padding: .2rem .3rem .2rem .3rem; font-size: .78rem; font-weight: 600;
}
.participant-chip .avatar { width: 20px; height: 20px; font-size: .58rem; }
.participant-chip button {
  border: none; background: none; color: inherit; opacity: .6; line-height: 1;
  padding: 0 .1rem; font-size: .9rem;
}
.participant-chip button:hover { opacity: 1; }
.participant-empty-hint { font-size: .78rem; color: #9ca3af; padding: .3rem; }

/* ════════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════════ */
.table { font-size: .82rem; }
.table td, .table th { vertical-align: middle; padding: .6rem .85rem; }
.table thead th {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}
.table-hover tbody tr:hover { background: rgba(99,102,241,.04); }

/* ════════════════════════════════════════════════
   AVATAR (generic)
   ════════════════════════════════════════════════ */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary);
  color: #fff; font-weight: 700; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-sm { width: 28px; height: 28px; font-size: .68rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

/* ════════════════════════════════════════════════
   STATUS BADGES
   ════════════════════════════════════════════════ */
.badge { font-size: .72rem; font-weight: 600; letter-spacing: .02em; }
.badge-pending    { background: #6c757d; }
.badge-confirmed  { background: #0d6efd; }
.badge-in_transit { background: #0dcaf0; color: #000; }
.badge-delivered  { background: #198754; }
.badge-complete   { background: #20c997; }
.badge-cancelled  { background: #343a40; }

/* ════════════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════════════ */
.pagination { margin-top: 1.25rem; margin-bottom: .25rem; }
.page-link { font-size: .8rem; padding: .35rem .65rem; color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ════════════════════════════════════════════════
   TIMELINE
   ════════════════════════════════════════════════ */
.timeline-dot {
  width: 14px; height: 14px; border-radius: 50%;
  flex-shrink: 0; margin-top: 4px;
}

/* ════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════ */
.form-label { font-weight: 600; font-size: .8rem; color: #374151; margin-bottom: .3rem; }
.form-control, .form-select {
  font-size: .85rem;
  border-color: #d1d5db;
  border-radius: .4rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════ */
.btn { font-size: .82rem; font-weight: 500; border-radius: .4rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }

/* ════════════════════════════════════════════════
   ALERTS
   ════════════════════════════════════════════════ */
.alert { font-size: .85rem; border-radius: .5rem; }

/* ════════════════════════════════════════════════
   FLEET REGISTER
   The fleet list carries a lot of numbers per row —
   spec, statutory dates, service, fuel, cost. These
   rules keep it dense and scannable rather than
   letting Bootstrap defaults stretch it out.
   ════════════════════════════════════════════════ */

/* ── KPI tiles ── */
.fl-kpi {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #9ca3af;
  border-radius: .6rem;
  padding: .7rem .9rem;
  height: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: box-shadow .15s, transform .15s;
}
a.fl-kpi:hover { box-shadow: 0 4px 12px rgba(0,0,0,.10); transform: translateY(-1px); }
.fl-kpi-label {
  font-size: .66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #6b7280; white-space: nowrap;
}
.fl-kpi-value { font-size: 1.5rem; font-weight: 700; color: #111827; line-height: 1.15; }
.fl-kpi-foot { font-size: .7rem; color: #6b7280; }
.fl-kpi-primary { border-left-color: #6366f1; }
.fl-kpi-primary .fl-kpi-value { color: #4f46e5; }
.fl-kpi-warning { border-left-color: #f59e0b; }
.fl-kpi-warning .fl-kpi-value { color: #b45309; }
.fl-kpi-danger  { border-left-color: #ef4444; }
.fl-kpi-danger  .fl-kpi-value { color: #b91c1c; }
.fl-kpi-info    { border-left-color: #0ea5e9; }
.fl-kpi-info    .fl-kpi-value { color: #0369a1; }

/* ── Register table ── */
.fl-table-wrap { max-height: calc(100vh - 380px); overflow: auto; }
.fl-table { font-size: .78rem; }
.fl-table thead th {
  position: sticky; top: 0; z-index: 3;
  white-space: nowrap;
}
.fl-table td { padding: .55rem .7rem; }
/* The plate stays on screen while the numbers scroll under it — without it a
   wide register loses track of which unit a row belongs to. */
.fl-table .fl-sticky {
  position: sticky; left: 0; z-index: 2;
  background: #fff;
  border-right: 1px solid #eef0f4;
  min-width: 190px;
}
.fl-table thead .fl-sticky { z-index: 4; background: #f9fafb; }
.fl-table tbody tr:hover .fl-sticky { background: #fafaff; }
.fl-row-alert { background: rgba(239,68,68,.045); }
.fl-row-alert:hover .fl-sticky,
.fl-row-alert .fl-sticky { background: #fef6f6; }

.fl-type-icon {
  width: 30px; height: 30px; border-radius: .45rem;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; flex-shrink: 0;
}
.fl-fleetno {
  font-size: .64rem; font-weight: 700; letter-spacing: .04em;
  background: #eef2ff; color: #4338ca;
  padding: .05rem .3rem; border-radius: .25rem;
  vertical-align: middle;
}

/* ── Expiry chips: three statutory dates in the width of one ── */
.fl-chip {
  display: inline-block;
  font-size: .64rem; font-weight: 600; line-height: 1.5;
  padding: .05rem .35rem; margin: 0 .15rem .15rem 0;
  border-radius: .25rem; white-space: nowrap;
  border: 1px solid transparent;
}
.fl-chip b { font-weight: 800; }
.fl-chip-success   { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.fl-chip-info      { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.fl-chip-warning   { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.fl-chip-danger    { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.fl-chip-secondary,
.fl-chip-blank     { background: #f3f4f6; color: #9ca3af; border-color: #e5e7eb; }

.fl-bar { height: 5px; border-radius: 3px; background: #eef0f4; }

/* ── Card view ── */
.fl-card { border-left: 3px solid #d1d5db; }
.fl-card-available      { border-left-color: #10b981; }
.fl-card-on_route       { border-left-color: #6366f1; }
.fl-card-in_maintenance { border-left-color: #f59e0b; }
.fl-card-offline        { border-left-color: #ef4444; }
.fl-card-metrics { background: #f9fafb; border-radius: .4rem; padding: .5rem 0; }
.fl-metric-value { font-size: .95rem; font-weight: 700; color: #111827; line-height: 1.2; }
.fl-metric-label {
  font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; color: #9ca3af;
}

/* ── Vehicle detail ── */
.fl-spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .75rem 1.25rem;
}
.fl-spec-label {
  font-size: .64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: #9ca3af;
}
.fl-spec-value { font-size: .85rem; font-weight: 600; color: #1f2937; }
.fl-hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d2d5a 100%);
  color: #fff; border-radius: .7rem; padding: 1.1rem 1.3rem;
}
.fl-hero .fl-hero-reg { font-size: 1.5rem; font-weight: 800; letter-spacing: .04em; }
.fl-hero .fl-hero-sub { color: rgba(255,255,255,.65); font-size: .8rem; }
.fl-hero-stat { border-left: 1px solid rgba(255,255,255,.15); padding-left: 1rem; }
.fl-hero-stat .v { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.fl-hero-stat .l {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
  color: rgba(255,255,255,.55);
}

@media (max-width: 991.98px) {
  .fl-table-wrap { max-height: none; }
  .fl-table .fl-sticky { position: static; }
}

/* ════════════════════════════════════════════════
   MOBILE SIDEBAR TOGGLE
   ════════════════════════════════════════════════ */
#sidebarToggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #374151;
  padding: 0;
  line-height: 1;
  display: none;
  cursor: pointer;
}

/* ════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    height: 100vh;
    height: 100dvh;
    box-shadow: none;
  }
  #sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  #main-content {
    margin-left: 0;
    width: 100%;
  }
  #sidebarToggle { display: block; }
  main.flex-grow-1 { padding: 1rem; }
  /* See the comment on .mobile-scroll-spacer in base.html — this can't be a
     padding-bottom on main.flex-grow-1 because Bootstrap's pb-5 utility
     (already on that element) is !important and wins over any padding rule
     here regardless of specificity. */
  .mobile-scroll-spacer { height: 6rem; }
}

/* ════════════════════════════════════════════════
   STATUS PILLS — light tint + coloured text, fully rounded.
   Originated on the dashboard's "Recent Loads" panel; promoted here so any
   page can render the same look instead of a solid Bootstrap badge. Kept in
   sync with the identical rules in dashboard/_overview_styles.html (that
   file's own .ov-wrap/.ov-card/etc shell styling is dashboard-only and
   stays there — only the pill belongs everywhere).
   ════════════════════════════════════════════════ */
.ov-pill{font-size:.675rem;font-weight:700;padding:.26rem .62rem;border-radius:999px;
         white-space:nowrap;flex-shrink:0;display:inline-block}
.ovp-transit{background:#e8f0fe;color:#2563eb}
.ovp-loading{background:#fef4e5;color:#b45309}
.ovp-delivered{background:#e7f7ee;color:#15803d}
.ovp-planned{background:#eef1f6;color:#64748b}
.ovp-cancelled{background:#fdecec;color:#dc2626}
