:root {
    --fox-navy: #10233f;
    --fox-blue: #2457d6;
    --fox-ink: #172b4d;
    --fox-muted: #78869a;
    --fox-line: #e7ecf3;
    --fox-surface: #ffffff;
    --fox-bg: #f4f7fb;
    --fox-sidebar-width: 252px;
}

html, body { min-height: 100%; margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--fox-bg); color: var(--fox-ink); }
body.app-body { min-height: 100vh; overflow-x: hidden; }
.app-shell { min-height: 100vh; }
.app-sidebar { width: var(--fox-sidebar-width); position: fixed; inset: 0 auto 0 0; z-index: 1040; display: flex; flex-direction: column; background: var(--fox-navy); color: #d7e2f0; box-shadow: 4px 0 18px rgba(16,35,63,.08); }
.app-brand { height: 100px; flex: 0 0 100px; display: flex; align-items: center; justify-content: center; background: #fff; padding: 8px 20px; }
.app-brand img { display: block; width: min(100%, 190px); height: 80px; object-fit: contain; }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 18px 12px 12px; scrollbar-width: thin; scrollbar-color: #344966 transparent; }
.nav-section-label { display: block; padding: 12px 13px 7px; color: #8295af; font-size: .65rem; font-weight: 700; letter-spacing: .11em; }
.app-nav-link, .nav-group > summary { min-height: 42px; margin: 3px 0; padding: 10px 12px; display: flex; align-items: center; gap: 11px; border-radius: 9px; color: #d7e2f0; text-decoration: none; font-size: .88rem; transition: background .16s ease, color .16s ease; cursor: pointer; list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.app-nav-link:hover, .nav-group > summary:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-nav-link.active { background: var(--fox-blue); color: #fff; font-weight: 650; box-shadow: 0 5px 14px rgba(36,87,214,.24); }
.nav-icon { width: 20px; flex: 0 0 20px; text-align: center; color: #a9bdd7; font-size: 1.05rem; line-height: 1; }
.active .nav-icon { color: #fff; }
.nav-group > summary > span:nth-child(2) { flex: 1; }
.nav-chevron { color: #93a5bd; transition: transform .15s ease; }
.nav-group[open] .nav-chevron { transform: rotate(180deg); }
.nav-submenu { margin: 0 0 5px 22px; padding: 3px 0 3px 14px; border-left: 1px solid #344966; }
.nav-submenu a { display: block; padding: 8px 10px; border-radius: 7px; color: #b7c6d9; text-decoration: none; font-size: .82rem; }
.nav-submenu a:hover, .nav-submenu a.active { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-footer { flex: 0 0 auto; padding: 13px 15px 16px; border-top: 1px solid rgba(210,225,245,.13); }
.sidebar-profile-link { display: flex; align-items: center; gap: 10px; padding: 5px 2px 12px; color: #fff; text-decoration: none; }
.sidebar-profile-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.sidebar-profile-copy strong, .topbar-account strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; font-weight: 650; }
.sidebar-profile-copy small, .topbar-account small { color: #9eb0c8; font-size: .68rem; }
.sidebar-avatar { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 34px; border-radius: 50%; background: #e7edff; color: var(--fox-blue); font-size: .84rem; font-weight: 700; }
.sidebar-logout { width: 100%; padding: 8px 10px; border: 1px solid rgba(215,226,240,.16); border-radius: 8px; background: transparent; color: #c7d4e4; text-align: left; font-size: .8rem; }
.sidebar-logout:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-logout span { padding-right: 7px; }

.app-main { min-height: 100vh; margin-left: var(--fox-sidebar-width); display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1020; min-height: 74px; display: flex; align-items: center; justify-content: flex-end; gap: 18px; padding: 0 32px; border-bottom: 1px solid var(--fox-line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.topbar-company { margin-right: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.company-context-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #20a56a; box-shadow: 0 0 0 4px #e8f8ef; }
.topbar-company > span:last-child, .topbar-account > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.topbar-company small { color: var(--fox-muted); font-size: .67rem; }
.topbar-company strong { max-width: 320px; overflow: hidden; color: var(--fox-ink); text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; font-weight: 650; }
.topbar-account { display: flex; align-items: center; gap: 9px; color: var(--fox-ink); text-decoration: none; }
.topbar-account small { color: var(--fox-muted); }
.sidebar-toggle { display: none; width: 38px; height: 38px; padding: 9px; border: 1px solid var(--fox-line); border-radius: 9px; background: #fff; }
.sidebar-toggle span { display: block; height: 2px; margin: 3px 0; border-radius: 2px; background: var(--fox-navy); }
.app-page { width: 100%; max-width: 1700px; flex: 1 0 auto; padding: 27px 32px 20px; }
.app-footer { padding: 15px 32px 19px; color: #98a4b4; font-size: .72rem; text-align: right; }
.sidebar-backdrop { display: none; }

/* Shared page surfaces keep existing forms, lists and details in one visual system. */
.main-content { width: 100%; min-height: 0; margin: 0; padding: 0 !important; }
.main-content h1, .app-page > h1 { color: var(--fox-ink); font-size: clamp(1.45rem, 2vw, 1.85rem); font-weight: 700; letter-spacing: -.025em; }
.main-content hr { margin: 1rem 0 1.35rem; border-color: var(--fox-line); opacity: 1; }
.main-content .card, .app-page > .card, .main-content .modal-content { border: 1px solid rgba(226,232,240,.8); border-radius: 13px; box-shadow: 0 4px 15px rgba(23,43,77,.045); }
.main-content .card-header, .main-content .card-footer { border-color: #edf1f5; background: #fff; }
.main-content .card-header { border-radius: 13px 13px 0 0; padding: 15px 18px; }
.main-content .card-body { padding: 18px; }
.main-content .table { margin-bottom: 0; color: #35465f; font-size: .84rem; }
.main-content .table thead th { padding: 12px 14px; background: #f8fafc; color: #8290a2; font-size: .67rem; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
.main-content .table tbody td, .main-content .table tbody th { padding: 13px 14px; border-color: #edf0f4; vertical-align: middle; }
.main-content .table-responsive { border-radius: 0 0 13px 13px; }
.main-content .form-label { margin-bottom: .4rem; color: #52637b; font-size: .8rem; font-weight: 600; }
.main-content .form-control, .main-content .form-select { min-height: 40px; border-color: #dfe5ed; border-radius: 8px; color: #35465f; font-size: .86rem; }
.main-content .form-control:focus, .main-content .form-select:focus { border-color: #91aaf1; box-shadow: 0 0 0 .2rem rgba(36,87,214,.12); }
.main-content .btn { border-radius: 8px; font-weight: 550; }
.main-content .btn-primary { border-color: var(--fox-blue); background: var(--fox-blue); }
.main-content .text-muted { color: var(--fox-muted) !important; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-heading h1 { margin: 0 0 5px; color: var(--fox-ink); font-size: clamp(1.45rem, 2vw, 1.85rem); font-weight: 700; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--fox-muted); font-size: .86rem; }
.page-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.main-content .badge { padding: .48em .72em; font-weight: 600; }
.collection-map { min-height: 320px; border-radius: 0 0 12px 12px; }
.dashboard-page .page-heading { margin-bottom: 20px; }
.metric-card { min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border: 1px solid #e7ecf3; border-radius: 13px; background: #fff; box-shadow: 0 4px 15px rgba(23,43,77,.045); }
.metric-card > div { display: flex; flex-direction: column; gap: 10px; }
.metric-card > div > span { color: var(--fox-muted); font-size: .78rem; }
.metric-card > div > strong { color: var(--fox-ink); font-size: 2rem; font-weight: 700; line-height: 1; }
.metric-icon { width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 46px; border-radius: 14px; font-size: 1.3rem; }
.metric-card.blue .metric-icon { background: #eaf0ff; color: #2457d6; }
.metric-card.amber .metric-icon { background: #fff4df; color: #c88512; }
.metric-card.green .metric-icon { background: #e8f8ef; color: #16834a; }
.metric-card.violet .metric-icon { background: #f0ebff; color: #7354c7; }
.dashboard-panel.card { overflow: hidden; border: 1px solid #e7ecf3; border-radius: 13px; background: #fff; box-shadow: 0 4px 15px rgba(23,43,77,.045); }
.dashboard-panel .card-header { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid #edf0f4; }
.dashboard-panel .card-header h2 { margin: 0; color: var(--fox-ink); font-size: .96rem; font-weight: 700; }
.dashboard-panel .card-header p { margin: 4px 0 0; color: var(--fox-muted); font-size: .73rem; }
.dashboard-panel .card-header > a { flex: 0 0 auto; color: var(--fox-blue); font-size: .77rem; font-weight: 600; text-decoration: none; }
.dashboard-panel .card-header > a:hover { text-decoration: underline; }
.modality-summary { display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.modality-row > div:first-child { margin-bottom: 8px; color: #43536a; font-size: .82rem; }
.modality-row > div:first-child strong { color: var(--fox-ink); }
.modality-row > div:first-child span, .modality-row small { color: var(--fox-muted); font-size: .73rem; }
.modality-row .progress { height: 8px; margin-bottom: 6px; border-radius: 6px; background: #e9eef5; }
.modality-row .progress-bar { border-radius: 6px; }
.modality-row .progress-bar.blue { background: #2457d6; }
.modality-row .progress-bar.green { background: #20a56a; }
.modality-row .progress-bar.amber { background: #e49b1b; }
.dashboard-summary-note { display: flex; align-items: center; gap: 8px; padding-top: 7px; color: var(--fox-muted); font-size: .72rem; }
.summary-dot, .live-dot { width: 8px; height: 8px; display: inline-block; flex: 0 0 8px; border-radius: 50%; background: #20a56a; }
.map-refresh-status { display: flex; align-items: center; gap: 7px; color: #718096; font-size: .72rem; white-space: nowrap; }
.live-dot { box-shadow: 0 0 0 4px #e8f8ef; }
.dashboard-map { height: 315px; min-height: 270px; background: #eaf1ef; }
.map-legend { min-height: 42px; display: flex; align-items: center; gap: 16px; padding: 0 16px; color: #66758b; font-size: .7rem; }
.map-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend #dashboard-map-count { margin-left: auto; font-weight: 650; }
.map-type-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; }
.map-type-dot.rt { background: #2457d6; }.map-type-dot.ftl { background: #20a56a; }.map-type-dot.extra { background: #e49b1b; }
.dashboard-map-empty { max-width: 260px; margin: 12px; padding: 10px 13px; border: 1px solid #e2e8f0; border-radius: 9px; background: rgba(255,255,255,.96); color: #52637b; box-shadow: 0 2px 10px rgba(23,43,77,.1); font-size: .76rem; }
.dashboard-truck-icon { border: 0; background: transparent; }
.dashboard-truck-icon span { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; border-radius: 50%; background: #2457d6; box-shadow: 0 3px 10px rgba(16,35,63,.28); font-size: 19px; }
.dashboard-truck-icon.ftl span { background: #20a56a; }.dashboard-truck-icon.extra span { background: #e49b1b; }
.dashboard-panel .table-responsive { border-radius: 0 0 13px 13px; }
.dashboard-panel .table { font-size: .78rem; }
.dashboard-panel .table thead th { padding: 11px 13px; }
.dashboard-panel .table tbody td { padding: 11px 13px; }

/* Authentication pages keep their independent centered layout. */
body.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef3ff 0%, #f6f8fb 52%, #edf5f2 100%); }
.login-container { width: 100%; max-width: 440px; padding: 20px; margin: auto; }
.login-box { padding: 2.3rem; border: 1px solid rgba(226,232,240,.8); border-radius: 16px; background: #fff; box-shadow: 0 18px 55px rgba(23,43,77,.12); }
.login-logo { display: block; width: min(100%, 220px); max-height: 105px; object-fit: contain; margin: 0 auto 1.5rem; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-102%); transition: transform .22s ease; }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open { overflow: hidden; }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .app-topbar { min-height: 66px; justify-content: flex-start; padding: 0 18px; }
    .topbar-company { margin-left: 1px; }
    .topbar-company strong { max-width: min(42vw, 300px); }
    .topbar-account { margin-left: auto; }
    .topbar-account > span:last-child { display: none; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 1030; border: 0; background: rgba(9,20,37,.48); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .app-page { padding: 22px 20px 16px; }
}
@media (max-width: 575.98px) {
    .app-topbar { gap: 10px; padding: 0 13px; }
    .app-page { padding: 17px 13px 12px; }
    .topbar-company small { font-size: .61rem; }
    .topbar-company strong { max-width: 47vw; font-size: .76rem; }
    .app-page .main-content h1 { font-size: 1.4rem; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .page-heading-actions { width: 100%; }
    .page-heading-actions .btn { flex: 1; }
    .main-content .card-body { padding: 14px; }
    .app-footer { padding: 12px 14px 16px; text-align: center; }
    .collection-map { min-height: 280px; }
    .metric-card { min-height: 96px; padding: 15px; }
    .dashboard-map { height: 285px; }
    .dashboard-panel .card-header { align-items: flex-start; }
    .dashboard-panel .card-header p { max-width: 60vw; }
}
