:root {
    --primary: #1a3a5c;
    --primary-dark: #0f2540;
    --accent: #e8a020;
    --accent-dark: #c08518;
    --surface: #ffffff;
    --bg: #f0f2f5;
    --text-muted: #6c757d;
    --navbar-height: 60px;
}

body {
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    padding-top: var(--navbar-height);
}

/* ==========  TOP NAVBAR  ========== */
.app-navbar {
    background: var(--primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    height: var(--navbar-height);
}
.app-navbar .navbar-brand {
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    padding-right: 0.5rem;
    margin-right: 0.25rem;
}
.app-navbar .navbar-brand .brand-icon { color: var(--accent); font-size: 1.15rem; }
.app-navbar .navbar-brand .brand-text { line-height: 1.1; white-space: nowrap; }
@media (max-width: 991.98px) {
    .app-navbar .navbar-brand { font-size: 0.95rem; gap: 6px; }
    .app-navbar .navbar-brand .brand-icon { font-size: 1.05rem; }
}
.app-navbar .nav-link {
    color: rgba(255, 255, 255, 0.78) !important;
    padding: 8px 10px !important;
    border-radius: 6px;
    margin: 0 1px;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all 0.2s;
}
@media (min-width: 992px) {
    .app-navbar .nav-link { padding: 8px 14px !important; font-size: 0.9rem; margin: 0 2px; }
}
.app-navbar .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff !important;
}
.app-navbar .nav-link.active {
    background: var(--accent);
    color: #fff !important;
}
.app-navbar .nav-link i { margin-right: 6px; }

/* Nav: icon + label side-by-side, very compact so all 8 items fit */
.app-navbar .nav-icons .nav-link {
    padding: 6px 7px !important;
    margin: 0;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.app-navbar .nav-icons .nav-link i {
    font-size: 0.9rem;
    width: 1em;
    text-align: center;
    margin-right: 0 !important;
}
.app-navbar .nav-icons .nav-link .nav-label {
    font-size: 0.74rem;
    letter-spacing: 0;
    display: inline;
}
@media (min-width: 992px) {
    .app-navbar .nav-icons .nav-link { padding: 7px 9px !important; gap: 0.4rem; }
    .app-navbar .nav-icons .nav-link i { font-size: 0.95rem; }
    .app-navbar .nav-icons .nav-link .nav-label { font-size: 0.8rem; }
}
@media (min-width: 1200px) {
    .app-navbar .nav-icons .nav-link { padding: 8px 11px !important; gap: 0.5rem; }
    .app-navbar .nav-icons .nav-link i { font-size: 1rem; }
    .app-navbar .nav-icons .nav-link .nav-label { font-size: 0.85rem; }
}
@media (min-width: 1400px) {
    .app-navbar .nav-icons .nav-link { padding: 8px 13px !important; }
    .app-navbar .nav-icons .nav-link .nav-label { font-size: 0.9rem; }
}
/* Right-side icon cluster stays icon-only, very tight */
.app-navbar .nav-icons.nav-icons-right .nav-link {
    padding: 7px 8px !important;
    gap: 0;
}
.app-navbar .nav-icons.nav-icons-right .nav-link .nav-label { display: none !important; }
.app-navbar .nav-icons form.d-inline .nav-link { padding: 7px 8px !important; }
.app-navbar .container-fluid { padding-left: 0.75rem; padding-right: 0.75rem; }

/* Subtle chevron on nav items that open a dropdown */
.app-navbar .nav-link .nav-caret {
    font-size: 0.6rem;
    margin-left: 0.35rem;
    opacity: 0.55;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.app-navbar .nav-link.nav-has-children:hover .nav-caret,
.app-navbar .nav-link.nav-has-children[aria-expanded="true"] .nav-caret {
    opacity: 0.9;
}
.app-navbar .nav-link.nav-has-children[aria-expanded="true"] .nav-caret {
    transform: rotate(180deg);
}

/* User dropdown menu */
.app-navbar .nav-link.dropdown-toggle.no-caret::after { display: none; }
.app-navbar .nav-link.dropdown-toggle i { font-size: 1.15rem; }
.user-menu {
    min-width: 240px;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    padding: 0.4rem 0;
    margin-top: 0.4rem;
}
.user-menu .dropdown-header { padding: 0.75rem 1rem 0.65rem; }
.user-menu .um-name { font-weight: 600; color: var(--primary); font-size: 0.95rem; }
.user-menu .um-handle { color: var(--text-muted); font-size: 0.78rem; }
.user-menu .dropdown-item {
    padding: 0.55rem 1rem;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
}
.user-menu .dropdown-item:hover { background: rgba(0, 0, 0, 0.04); }
.user-menu form .dropdown-item { width: 100%; text-align: left; border: none; background: transparent; }
.user-menu .dropdown-divider { margin: 0.3rem 0; }
.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.3);
}
.navbar-toggler-icon {
    filter: invert(1) opacity(0.8);
}

/* ==========  LAYOUT  ========== */
.main-content { padding: 24px; }

.topbar {
    background: var(--surface);
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.topbar h4 { margin: 0; color: var(--primary); font-weight: 700; }

/* ==========  CARDS  ========== */
.card { border: none; border-radius: 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07); }
.card-header {
    background: var(--primary);
    color: #fff;
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
}

/* ==========  DRIVER CHIP (selected-vehicle header)  ========== */
.driver-chip {
    background: linear-gradient(135deg, #eef4fb, #dbe7f7);
    border: 1px solid #b9cbe6;
    min-width: 220px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.driver-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(26, 58, 92, 0.12);
}
.driver-chip a { color: var(--primary); }
.driver-chip a:hover { color: var(--primary-dark); }
.driver-chip--empty {
    background: #f8f9fa;
    border-style: dashed;
    border-color: #ced4da;
}

/* ==========  STAT CARDS  ========== */
.stat-card { border-radius: 12px; padding: 20px; color: #fff; }
.stat-card.blue   { background: linear-gradient(135deg, #1a3a5c, #2d6ab4); }
.stat-card.green  { background: linear-gradient(135deg, #1a7a4a, #28a86b); }
.stat-card.orange { background: linear-gradient(135deg, #c05a00, #e8821c); }
.stat-card.red    { background: linear-gradient(135deg, #8b1a1a, #c0392b); }
.stat-card .stat-number { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label  { font-size: 0.85rem; opacity: 0.85; }
.stat-card .stat-icon   { font-size: 2rem; opacity: 0.3; }

.mini-stat {
    background: var(--surface);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.mini-stat .value { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.mini-stat .label { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 4px; }

/* ==========  BADGES  ========== */
.badge-active      { background: #d4edda; color: #155724; }
.badge-maintenance { background: #fff3cd; color: #856404; }
.badge-rented      { background: #cce5ff; color: #004085; }
.badge-inactive    { background: #f8d7da; color: #721c24; }
.badge-paid        { background: #d4edda; color: #155724; }
.badge-pending     { background: #fff3cd; color: #856404; }

/* ==========  TABLES  ========== */
.table thead th {
    background: #f8f9fa;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.table tbody tr:hover { background: #f8f9ff; }

/* ==========  FORMS  ========== */
.form-control, .form-select { border-radius: 6px; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(232, 160, 32, 0.25);
}

/* ==========  BUTTONS  ========== */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-warning {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-warning:hover, .btn-warning:focus {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: #fff;
}

/* ==========  MODAL  ========== */
.modal-content { border: none; border-radius: 12px; }
.modal-header { background: var(--primary); color: #fff; border-radius: 12px 12px 0 0; }
.modal-header .btn-close { filter: invert(1) opacity(0.9); }
.modal-header.bg-danger { background: #c0392b !important; }

/* ==========  DOCUMENT CARDS  ========== */
.doc-card {
    background: var(--surface);
    border: 1px solid #e4e7eb;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.doc-card:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
    transform: translateY(-2px);
}
.doc-preview {
    background: #f6f7fa;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #e4e7eb;
}
.doc-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.doc-pdf-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #c0392b;
    text-decoration: none;
    width: 100%;
    height: 100%;
}
.doc-pdf-thumb i { font-size: 3rem; }
.doc-pdf-thumb:hover { color: #8b1a1a; }
.doc-meta {
    padding: 12px 14px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* ==========  AVATARS  ========== */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    object-fit: cover;
    background: #f1f3f5;
    color: #8a93a0;
    overflow: hidden;
    flex-shrink: 0;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.08);
}
.avatar-sm { width: 36px;  height: 36px;  font-size: 15px; }
.avatar-md { width: 56px;  height: 56px;  font-size: 24px; }
.avatar-lg {
    width: 120px; height: 120px; font-size: 48px;
    border: 3px solid var(--surface);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.avatar-fallback i { line-height: 1; }
/* Compact "avatar + name" cell used in person tables */
.avatar-cell { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.avatar-cell .avatar-name { font-weight: 600; line-height: 1.2; min-width: 0; }
.table tbody tr.has-avatar td { vertical-align: middle; }

/* ==========  TOASTS  ========== */
.toast-container { top: calc(var(--navbar-height) + 12px) !important; }
.app-toast {
    border: none;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    min-width: 320px;
    max-width: 420px;
    overflow: hidden;
    border-left: 4px solid var(--primary);
    background: #ffffff;
}
.app-toast .toast-body {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    font-size: 0.92rem;
    color: #2d2d2d;
}
.app-toast .toast-icon { font-size: 1.25rem; flex-shrink: 0; }
.app-toast .toast-message { flex-grow: 1; line-height: 1.4; word-break: break-word; }
.app-toast .btn-close { font-size: 0.7rem; padding: 0.3rem; opacity: 0.5; }
.app-toast .btn-close:hover { opacity: 0.9; }
.app-toast.showing, .app-toast.show { animation: toast-slide-in 0.3s ease-out; }
@keyframes toast-slide-in {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
.app-toast-success { border-left-color: #28a86b; background: #f0faf4; }
.app-toast-success .toast-icon { color: #28a86b; }
.app-toast-error   { border-left-color: #c0392b; background: #fdf2f2; }
.app-toast-error   .toast-icon { color: #c0392b; }
.app-toast-warning { border-left-color: var(--accent); background: #fffaef; }
.app-toast-warning .toast-icon { color: var(--accent-dark); }
.app-toast-info    { border-left-color: #2d6ab4; background: #f0f5fb; }
.app-toast-info    .toast-icon { color: #2d6ab4; }
.app-toast-debug   { border-left-color: #6c757d; background: #f8f9fa; }
.app-toast-debug   .toast-icon { color: #6c757d; }

/* ==========  FOOTER  ========== */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    padding: 18px 0;
    font-size: 0.82rem;
}

/* ==========  VEHICLE STATUS DOTS (sidebar picker)  ========== */
.vehicle-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c1c8d4;
    flex-shrink: 0;
}
.vehicle-status-dot.status-active        { background: #28a86b; }
.vehicle-status-dot.status-rented        { background: #2d6ab4; }
.vehicle-status-dot.status-in-maintenance{ background: #e8a020; }
.vehicle-status-dot.status-inactive      { background: #6c757d; }

/* ==========  TOM SELECT — vehicle dropdown  ========== */
.ts-wrapper.vehicle-ts .ts-control { padding: 6px 10px; min-height: 38px; }
.ts-wrapper.vehicle-ts .option { display: flex; align-items: center; gap: 0.5rem; padding: 6px 10px; }
.ts-wrapper.vehicle-ts .option .vs-plate { font-weight: 600; }
.ts-wrapper.vehicle-ts .option .vs-meta  { color: #6c757d; font-size: 0.85em; }
.ts-wrapper.vehicle-ts .option .vs-badges { margin-left: auto; display: flex; gap: 4px; }
.ts-wrapper.vehicle-ts .vs-pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    text-transform: uppercase;
}
.ts-wrapper.vehicle-ts .vs-pill.vs-active        { background: #d6f3e3; color: #1c7a4f; }
.ts-wrapper.vehicle-ts .vs-pill.vs-rented        { background: #d6e6f7; color: #1f4e87; }
.ts-wrapper.vehicle-ts .vs-pill.vs-maintenance   { background: #fbe7c4; color: #8a5a0d; }
.ts-wrapper.vehicle-ts .vs-pill.vs-inactive      { background: #e2e3e5; color: #495057; }
.ts-wrapper.vehicle-ts .vs-pill.vs-svc-overdue   { background: #f8d7da; color: #842029; }
.ts-wrapper.vehicle-ts .vs-pill.vs-svc-due-soon  { background: #fff3cd; color: #664d03; }

/* ==========  RESPONSIVE  ========== */
@media (max-width: 767px) {
    .app-navbar .nav-link.active { background: transparent; color: var(--accent) !important; }
    .app-navbar .navbar-collapse { background: var(--primary-dark); margin-top: 8px; border-radius: 8px; padding: 8px; }
}
