/* =====================================================================
   FleetPro UI  —  Bootstrap 5.3 skin driven by CSS variables (see App\Libraries\Theme)
   ===================================================================== */
:root {
  --fp-sidebar-w: 264px;
  --fp-topbar-h: 60px;
  --fp-surface: #ffffff;
  --fp-body: #f4f6fa;
  --fp-border: #e5e8ef;
  --fp-muted: #6b7280;
  --fp-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
[data-bs-theme=dark] {
  --fp-surface: #151b26;
  --fp-body: #0d1118;
  --fp-border: #253041;
  --fp-muted: #94a3b8;
  --fp-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --bs-body-bg: #0d1118;
  --bs-body-color: #dbe2ec;
  --bs-secondary-bg: #1b2331;
  --bs-tertiary-bg: #171e2b;
  --bs-border-color: #253041;
  --bs-emphasis-color: #f1f5f9;
}

html, body { font-family: var(--fp-font); }
body { background: var(--fp-body); font-size: .9rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.text-muted, .form-text { color: var(--fp-muted) !important; }
.fw-semibold { font-weight: 600 !important; }
.tabular, .num { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }

/* ---------- primary colour overrides (compiled bootstrap uses fixed colours) ---------- */
.btn-primary { --bs-btn-bg: var(--fp-primary); --bs-btn-border-color: var(--fp-primary); --bs-btn-hover-bg: var(--fp-primary-dark); --bs-btn-hover-border-color: var(--fp-primary-dark); --bs-btn-active-bg: var(--fp-primary-dark); --bs-btn-active-border-color: var(--fp-primary-dark); --bs-btn-disabled-bg: var(--fp-primary); --bs-btn-disabled-border-color: var(--fp-primary); }
.btn-outline-primary { --bs-btn-color: var(--fp-primary); --bs-btn-border-color: var(--fp-primary); --bs-btn-hover-bg: var(--fp-primary); --bs-btn-hover-border-color: var(--fp-primary); --bs-btn-active-bg: var(--fp-primary); --bs-btn-active-border-color: var(--fp-primary); }
[data-bs-theme=dark] .btn-outline-primary { --bs-btn-color: var(--fp-primary-light); --bs-btn-border-color: var(--fp-primary-light); }
.btn-accent { --bs-btn-color: #fff; --bs-btn-bg: var(--fp-accent); --bs-btn-border-color: var(--fp-accent); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--fp-accent); --bs-btn-hover-border-color: var(--fp-accent); filter: saturate(1.05); }
.bg-primary { background-color: var(--fp-primary) !important; }
.text-primary { color: var(--fp-primary) !important; }
[data-bs-theme=dark] .text-primary { color: var(--fp-primary-light) !important; }
.border-primary { border-color: var(--fp-primary) !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--fp-primary-rgb), .55); box-shadow: 0 0 0 .2rem rgba(var(--fp-primary-rgb), .15); }
.form-check-input:checked { background-color: var(--fp-primary); border-color: var(--fp-primary); }
.nav-pills .nav-link.active { background: var(--fp-primary); }
.page-link { color: var(--fp-primary); }
.active > .page-link, .page-link.active { background-color: var(--fp-primary); border-color: var(--fp-primary); }
.progress-bar { background-color: var(--fp-primary); }

/* ---------- layout ---------- */
.fp-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--fp-sidebar-w); z-index: 1040;
  background: var(--fp-sb-bg); color: var(--fp-sb-text); display: flex; flex-direction: column;
  border-right: 1px solid var(--fp-sb-border); transition: transform .2s ease;
}
.fp-brand { height: var(--fp-topbar-h); display: flex; align-items: center; gap: .65rem; padding: 0 1.1rem; border-bottom: 1px solid var(--fp-sb-border); color: var(--fp-sb-active-text); font-weight: 700; letter-spacing: .2px; }
.fp-brand img { height: 34px; width: auto; border-radius: 6px; background: #fff; padding: 2px; }
.fp-brand small { display: block; font-weight: 500; font-size: .7rem; color: var(--fp-sb-muted); letter-spacing: .4px; text-transform: uppercase; }
.fp-nav { overflow-y: auto; padding: .6rem .6rem 2rem; flex: 1; scrollbar-width: thin; }
.fp-nav .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--fp-sb-muted); padding: 1rem .75rem .35rem; font-weight: 600; }
.fp-nav a.nav-link, .fp-nav button.nav-link {
  display: flex; align-items: center; gap: .7rem; width: 100%; color: var(--fp-sb-text); padding: .5rem .75rem;
  border-radius: calc(var(--fp-radius) * .9); font-size: .87rem; border: 0; background: transparent; text-align: left;
}
.fp-nav .nav-link i.bi { font-size: 1.05rem; width: 1.2rem; opacity: .9; }
.fp-nav .nav-link:hover { background: var(--fp-sb-hover); color: var(--fp-sb-active-text); }
.fp-nav .nav-link.active { background: var(--fp-sb-active); color: var(--fp-sb-active-text); font-weight: 600; }
.fp-nav .nav-link .chev { margin-left: auto; transition: transform .2s; font-size: .75rem; }
.fp-nav .nav-link[aria-expanded=true] .chev { transform: rotate(90deg); }
.fp-nav .sub { padding-left: 1.9rem; }
.fp-nav .sub .nav-link { font-size: .83rem; padding: .38rem .7rem; color: var(--fp-sb-muted); }
.fp-nav .sub .nav-link:hover, .fp-nav .sub .nav-link.active { color: var(--fp-sb-active-text); }
.fp-nav .sub .nav-link.active::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--fp-accent); margin-left: -1rem; margin-right: .3rem; }
.fp-nav .count { margin-left: auto; background: var(--fp-accent); color: #111; font-size: .68rem; font-weight: 700; padding: .05rem .45rem; border-radius: 1rem; }

.fp-main { margin-left: var(--fp-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.fp-topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--fp-topbar-h); background: var(--fp-surface);
  border-bottom: 1px solid var(--fp-border); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
}
.fp-topbar .search { max-width: 380px; flex: 1; }
.fp-topbar .search .form-control { background: var(--bs-tertiary-bg); border-color: transparent; padding-left: 2.2rem; }
.fp-topbar .search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--fp-muted); }
.fp-icon-btn { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--bs-body-color); background: transparent; border: 0; position: relative; }
.fp-icon-btn:hover { background: var(--bs-tertiary-bg); }
.fp-icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; font-size: .62rem; border-radius: 8px; background: #ef4444; color: #fff; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.fp-avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(var(--fp-primary-rgb), .14); color: var(--fp-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
[data-bs-theme=dark] .fp-avatar { color: var(--fp-primary-light); }
.fp-content { padding: 1.4rem 1.5rem 3rem; flex: 1; }
.fp-footer { padding: .9rem 1.5rem; color: var(--fp-muted); font-size: .78rem; border-top: 1px solid var(--fp-border); }

.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.2rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-header .breadcrumb { margin: .15rem 0 0; font-size: .78rem; }
.page-header .actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- cards & tiles ---------- */
.card { border-color: var(--fp-border); box-shadow: var(--fp-shadow); background: var(--fp-surface); border-radius: var(--fp-radius); }
.card-header { background: transparent; border-bottom-color: var(--fp-border); font-weight: 600; padding: .85rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-header .card-title { margin: 0; font-size: .95rem; font-weight: 600; }
.card-body { padding: 1.1rem; }
.kpi { position: relative; overflow: hidden; }
.kpi .kpi-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fp-muted); font-weight: 600; }
.kpi .kpi-value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: .78rem; color: var(--fp-muted); margin-top: .2rem; }
.kpi .kpi-icon { position: absolute; right: 1rem; top: 1rem; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; background: rgba(var(--fp-primary-rgb), .1); color: var(--fp-primary); }
.kpi.accent .kpi-icon { background: rgba(var(--fp-accent-rgb), .15); color: var(--fp-accent); }
.kpi .trend-up { color: #16a34a; } .kpi .trend-down { color: #dc2626; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 200px; } .chart-box.lg { height: 340px; }

/* ---------- tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: var(--fp-cell-pad) .75rem; border-bottom-color: var(--fp-border); vertical-align: middle; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--fp-muted); font-weight: 600; background: var(--bs-tertiary-bg); white-space: nowrap; }
.table tfoot th, .table tfoot td { font-weight: 700; background: var(--bs-tertiary-bg); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(var(--fp-primary-rgb), .04); }
div.dt-container .dt-search input { min-width: 220px; }
div.dt-container div.dt-layout-row { margin: .5rem 0; }
.dt-buttons .btn { --bs-btn-padding-y: .25rem; --bs-btn-font-size: .8rem; }
.table-actions { white-space: nowrap; }
.table-actions .btn { --bs-btn-padding-y: .15rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .8rem; }

/* ---------- badges ---------- */
.badge { font-weight: 600; letter-spacing: .02em; }
.badge[class*=badge-soft-] { padding: .35em .65em; border-radius: 999px; font-size: .72rem; }
.badge-soft-primary { background: rgba(var(--fp-primary-rgb), .12); color: var(--fp-primary); }
.badge-soft-success { background: rgba(22, 163, 74, .12); color: #15803d; }
.badge-soft-warning { background: rgba(245, 158, 11, .16); color: #b45309; }
.badge-soft-danger { background: rgba(220, 38, 38, .12); color: #b91c1c; }
.badge-soft-info { background: rgba(14, 165, 233, .14); color: #0369a1; }
.badge-soft-secondary { background: rgba(100, 116, 139, .14); color: #475569; }
.badge-soft-dark { background: rgba(15, 23, 42, .12); color: #1e293b; }
.badge-soft-orange { background: rgba(234, 88, 12, .14); color: #c2410c; }
[data-bs-theme=dark] .badge-soft-primary { color: var(--fp-primary-light); }
[data-bs-theme=dark] .badge-soft-success { color: #4ade80; } [data-bs-theme=dark] .badge-soft-warning { color: #fbbf24; }
[data-bs-theme=dark] .badge-soft-danger { color: #f87171; } [data-bs-theme=dark] .badge-soft-info { color: #38bdf8; }
[data-bs-theme=dark] .badge-soft-secondary { color: #cbd5e1; } [data-bs-theme=dark] .badge-soft-dark { color: #e2e8f0; background: rgba(226, 232, 240, .1); }
[data-bs-theme=dark] .badge-soft-orange { color: #fb923c; }

/* ---------- forms ---------- */
.form-label { font-weight: 600; font-size: .8rem; margin-bottom: .3rem; }
.form-label .req { color: #dc2626; margin-left: 2px; }
.form-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--fp-muted); font-weight: 700; margin: .5rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--fp-border); }
.ts-control { border-radius: var(--bs-border-radius) !important; }
[data-bs-theme=dark] .ts-control, [data-bs-theme=dark] .ts-dropdown { background: var(--bs-body-bg); color: var(--bs-body-color); border-color: var(--bs-border-color); }
[data-bs-theme=dark] .ts-dropdown .active { background: rgba(var(--fp-primary-rgb), .3); color: #fff; }
.summary-box { background: var(--bs-tertiary-bg); border-radius: var(--fp-radius); padding: 1rem; }
.summary-box .row-line { display: flex; justify-content: space-between; padding: .25rem 0; }
.summary-box .row-line.total { border-top: 1px solid var(--fp-border); margin-top: .35rem; padding-top: .55rem; font-weight: 700; font-size: 1.05rem; }

/* ---------- timeline (dispatch tracking) ---------- */
.fp-timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.fp-timeline::before { content: ""; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: var(--fp-border); }
.fp-timeline li { position: relative; padding-left: 2.4rem; padding-bottom: 1rem; }
.fp-timeline li .dot { position: absolute; left: 4px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--fp-surface); border: 2px solid var(--fp-border); display: flex; align-items: center; justify-content: center; font-size: .65rem; }
.fp-timeline li.done .dot { border-color: var(--fp-primary); background: var(--fp-primary); color: #fff; }
.fp-timeline li.current .dot { border-color: var(--fp-accent); box-shadow: 0 0 0 4px rgba(var(--fp-accent-rgb), .2); }
.stepper { display: flex; gap: .25rem; flex-wrap: wrap; }
.stepper .step { flex: 1; min-width: 90px; text-align: center; font-size: .72rem; color: var(--fp-muted); position: relative; padding-top: 1.5rem; }
.stepper .step::before { content: ""; position: absolute; top: .45rem; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--fp-border); }
.stepper .step.done::before { background: var(--fp-primary); }
.stepper .step.current::before { background: var(--fp-accent); }
.stepper .step.done, .stepper .step.current { color: var(--bs-body-color); font-weight: 600; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(160deg, rgba(var(--fp-primary-rgb), .92), rgba(15, 23, 42, .92)), var(--auth-bg, none) center/cover; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h2 { font-weight: 700; font-size: 2rem; max-width: 460px; }
.auth-hero .feat { display: flex; gap: .6rem; align-items: center; opacity: .92; margin-top: .6rem; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--fp-surface); }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------- portals (client/station): top nav + mobile bottom bar ---------- */
.portal-top { background: var(--fp-surface); border-bottom: 1px solid var(--fp-border); position: sticky; top: 0; z-index: 1030; }
.portal-top .navbar-brand img { height: 34px; }
.portal-top .nav-link { color: var(--bs-body-color); font-weight: 500; font-size: .88rem; border-radius: var(--fp-radius); padding: .45rem .8rem !important; }
.portal-top .nav-link.active, .portal-top .nav-link:hover { background: rgba(var(--fp-primary-rgb), .1); color: var(--fp-primary); }
.portal-content { max-width: 1200px; margin: 0 auto; padding: 1.4rem 1rem 6rem; }
.bottom-bar { display: none; }
@media (max-width: 991.98px) {
  .bottom-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035; background: var(--fp-surface); border-top: 1px solid var(--fp-border); padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom)); }
  .bottom-bar a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: .66rem; color: var(--fp-muted); gap: .1rem; padding: .25rem 0; }
  .bottom-bar a i { font-size: 1.25rem; }
  .bottom-bar a.active { color: var(--fp-primary); font-weight: 600; }
}

/* ---------- responsive ---------- */
.fp-backdrop { display: none; }
@media (max-width: 991.98px) {
  .fp-sidebar { transform: translateX(-100%); }
  body.sidebar-open .fp-sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  body.sidebar-open .fp-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1039; }
  .fp-main { margin-left: 0; }
  .fp-content { padding: 1rem .85rem 5.5rem; }
  .fp-topbar { padding: 0 .75rem; }
  .page-header h1 { font-size: 1.15rem; }
}
@media (min-width: 992px) {
  body.sidebar-collapsed .fp-sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed .fp-main { margin-left: 0; }
}

/* ---------- print (invoices, reports) ---------- */
.print-only { display: none; }
@media print {
  .fp-sidebar, .fp-topbar, .fp-footer, .no-print, .bottom-bar, .portal-top, .dt-buttons, .dt-search, .dt-length, .dt-paging, .page-header .actions { display: none !important; }
  .fp-main { margin: 0 !important; } .fp-content, .portal-content { padding: 0 !important; }
  body { background: #fff !important; font-size: 11px; color: #000; }
  .card { box-shadow: none !important; border: 0 !important; }
  .print-only { display: block; }
  [data-bs-theme=dark] { --bs-body-bg: #fff; --bs-body-color: #000; }
  a { color: #000 !important; }
}

/* ---------- documents (invoice / receipt) ---------- */
.doc { background: #fff; color: #111; max-width: 900px; margin: 0 auto; padding: 2rem 2.2rem; border-radius: var(--fp-radius); box-shadow: var(--fp-shadow); }
.doc .doc-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 3px solid var(--fp-primary); padding-bottom: 1rem; margin-bottom: 1.2rem; }
.doc .doc-title { font-size: 1.7rem; font-weight: 800; letter-spacing: .04em; color: var(--fp-primary); }
.doc table { font-size: .82rem; } .doc .table thead th { background: #f1f5f9; color: #334155; }
.doc .totals td { padding: .3rem .6rem; }
.doc .totals .grand td { font-weight: 800; font-size: 1rem; border-top: 2px solid #111; }
@media print { .doc { box-shadow: none; padding: 0; max-width: none; } }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--fp-muted); }
.empty-state i { font-size: 2.4rem; opacity: .5; display: block; margin-bottom: .5rem; }
.cursor-pointer { cursor: pointer; }
.min-w-0 { min-width: 0; }
.list-kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .86rem; }
.list-kv dt { color: var(--fp-muted); font-weight: 500; } .list-kv dd { margin: 0; font-weight: 500; }
.swatch { width: 28px; height: 28px; border-radius: 8px; display: inline-block; border: 2px solid rgba(0, 0, 0, .08); }
.preset-card { cursor: pointer; border: 2px solid var(--fp-border); border-radius: var(--fp-radius); padding: .7rem; transition: border-color .15s; }
.preset-card.active, .preset-card:hover { border-color: var(--fp-primary); }
.btn-link { text-decoration: none; }
.form-control, .form-select, .input-group-text { font-size: .875rem; }
.form-control-lg { font-size: 1rem; }
.badge { white-space: nowrap; }
