:root {
    --sidebar: #111827;
    --sidebar-muted: #9ca3af;
    --surface: #ffffff;
    --page: #f3f6fb;
    --line: #dfe5ee;
    --ink: #1f2937;
    --muted: #6b7280;
    --blue: #2563eb;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-size: 15px;
}

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 48%, #ecfeff 100%);
}

.auth-shell {
    width: min(440px, calc(100vw - 32px));
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 22px 70px rgba(31, 41, 55, 0.14);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.login-brand span,
.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
}

.login-brand h1,
.topbar h1,
.panel h2 {
    margin: 0;
    letter-spacing: 0;
}

.login-brand h1 {
    font-size: 1.35rem;
}

.login-brand p,
.topbar p,
.panel-header p {
    margin: 0;
    color: var(--muted);
}

.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--sidebar);
    color: #fff;
    padding: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    margin-bottom: 22px;
}

.admin-menu {
    display: grid;
    gap: 6px;
}

.menu-group {
    display: grid;
    gap: 4px;
}

.menu-toggle,
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    width: 100%;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--sidebar-muted);
    padding: 10px 12px;
    text-align: left;
    text-decoration: none;
}

.menu-toggle {
    justify-content: space-between;
    color: #d1d5db;
    font-weight: 700;
}

.menu-toggle span {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-toggle:hover,
.menu-toggle:not(.collapsed) {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.menu-chevron {
    font-size: 0.8rem;
    transition: transform 0.18s ease;
}

.menu-toggle:not(.collapsed) .menu-chevron {
    transform: rotate(180deg);
}

.submenu {
    display: grid;
    gap: 2px;
    margin: 2px 0 6px 18px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.submenu .nav-link {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 0.92rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.main-panel {
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 78px;
    padding: 18px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.notification-bell { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #e2e8f0; border-radius: 10px; color: #334155; background: #fff; text-decoration: none; }
.notification-bell:hover { color: #2563eb; border-color: #bfdbfe; }
.notification-bell span { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; color: #fff; background: #dc2626; font-size: .68rem; font-weight: 700; }
.notification-icon { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; color: #2563eb; background: #eff6ff; }
.notification-unread { border-left: 3px solid #2563eb !important; background: #f8fbff; padding-left: 12px !important; }

.topbar h1 {
    font-size: 1.45rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #e0f2fe;
    color: #075985;
    font-weight: 700;
}

.user-chip strong,
.user-chip span {
    display: block;
    line-height: 1.2;
}

.user-chip span {
    color: var(--muted);
    font-size: 0.83rem;
}

.content {
    padding: 28px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 42px rgba(31, 41, 55, 0.06);
}

.stat-card {
    position: relative;
    min-height: 126px;
    padding: 18px;
    overflow: hidden;
}

.stat-card i {
    font-size: 1.6rem;
}

.stat-card span {
    display: block;
    margin-top: 12px;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    font-size: 2rem;
    line-height: 1;
}

.accent-blue i { color: #2563eb; }
.accent-green i { color: #059669; }
.accent-yellow i { color: #ca8a04; }
.accent-red i { color: #dc2626; }

.panel {
    padding: 18px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel h2 {
    font-size: 1.05rem;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    color: #4b5563;
    font-size: 0.78rem;
    text-transform: uppercase;
    border-bottom-color: var(--line);
}

.table-subtext {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
}

.maintenance-total {
    min-height: 31px;
    display: inline-flex;
    align-items: center;
    font-size: 0.86rem;
}

.icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
}

.vehicle-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
}

.vehicle-cell span {
    display: block;
    color: var(--muted);
    font-size: 0.86rem;
}

.vehicle-thumb {
    display: grid;
    place-items: center;
    width: 58px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f8fafc;
    color: #64748b;
    overflow: hidden;
}

.vehicle-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vehicle-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.vehicle-image-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
    position: relative;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.vehicle-image-card::before {
    content: "Main image";
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    padding: 4px 8px;
    border-radius: 7px;
    background: #2563eb;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}

.vehicle-image-card.is-primary-image {
    border-color: #93c5fd;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.14);
}

.vehicle-image-card.is-primary-image::before {
    display: block;
}

.vehicle-image-card.is-dragging {
    opacity: 0.55;
    border-style: dashed;
}

.vehicle-image-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

.vehicle-image-card form,
.vehicle-image-card > .btn {
    padding: 10px;
}

.image-order-tools {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 8px;
    padding: 10px 10px 0;
}

.image-drag-handle {
    cursor: grab;
    min-height: 42px;
}

.image-drag-handle:active {
    cursor: grabbing;
}

.image-order-field {
    display: grid;
    gap: 4px;
}

.image-order-field span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.report-link {
    display: grid;
    gap: 8px;
    min-height: 140px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--ink);
    text-decoration: none;
}

.report-link:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.report-link i {
    color: var(--blue);
    font-size: 1.6rem;
}

.report-link span {
    color: var(--muted);
}

.report-filter {
    display: grid;
    grid-template-columns: minmax(260px, 420px) auto;
    gap: 12px;
    align-items: end;
}

.report-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
}

.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.report-summary-grid .stat-card strong {
    font-size: 1.2rem;
    line-height: 1.25;
}

.report-print-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    padding-bottom: 18px;
}

.report-print-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.report-table tfoot th {
    border-top: 2px solid var(--ink);
    font-size: 1rem;
}

.form-panel {
    max-width: 980px;
}

.search-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    gap: 10px;
    margin-bottom: 18px;
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 10px;
    min-height: 360px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
}

.empty-state i {
    font-size: 3rem;
    color: #dc2626;
}

@media (max-width: 980px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .admin-menu {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .menu-group {
        min-width: 220px;
    }

    .sidebar .nav {
        flex-direction: row !important;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .sidebar .nav-link {
        white-space: nowrap;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.dashboard-chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 18px;
}

.chart-panel {
    min-width: 0;
}

.chart-container {
    position: relative;
    height: 330px;
}

.profit-stats-grid .stat-card strong {
    font-size: clamp(1.05rem, 1.6vw, 1.45rem);
}

@media (max-width: 900px) {
    .dashboard-chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .topbar,
    .content {
        padding: 18px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid,
    .search-row {
        grid-template-columns: 1fr;
    }

    .report-filter,
    .report-summary-grid {
        grid-template-columns: 1fr;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Modern mobile-first admin shell */
:root {
    --sidebar: #0b1220;
    --sidebar-muted: #94a3b8;
    --surface: #ffffff;
    --page: #f4f7fb;
    --line: #e5eaf1;
    --ink: #172033;
    --muted: #718096;
    --blue: #c80000;
    --blue-dark: #9f0000;
    --blue-soft: #fff1f1;
    --radius: 16px;
    --shadow: 0 8px 30px rgba(15, 23, 42, .06);
}

.admin-layout { grid-template-columns: 270px minmax(0, 1fr); }

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

.sidebar {
    width: 270px;
    padding: 20px 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    z-index: 1040;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.brand { margin: 0; min-width: 0; }
.brand > span:last-child { display: grid; line-height: 1.1; }
.brand strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { margin-top: 5px; color: #64748b; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { flex: 0 0 42px; border-radius: 13px; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); box-shadow: 0 8px 24px rgba(200, 0, 0, .3); }
.sidebar-close { display: none; border: 0; background: rgba(255,255,255,.08); color: #fff; width: 40px; height: 40px; border-radius: 12px; }

.menu-toggle, .sidebar .nav-link { min-height: 46px; border-radius: 12px; padding: 11px 12px; }
.menu-toggle { font-size: .9rem; }
.menu-toggle:hover, .menu-toggle:not(.collapsed), .sidebar .nav-link:hover { background: rgba(255,255,255,.07); }
.sidebar .nav-link.active { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); box-shadow: 0 6px 18px rgba(200, 0, 0, .22); }
.submenu { margin-left: 19px; border-color: rgba(148,163,184,.18); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: 76px;
    padding: 14px 28px;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.topbar h1 { font-size: 1.35rem; font-weight: 750; }
.topbar p { font-size: .82rem; }
.mobile-menu-button { display: none; width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink); font-size: 1.4rem; }
.avatar { width: 42px; height: 42px; background: var(--blue-soft); color: var(--blue); }
.user-chip .btn { width: 40px; height: 40px; border-radius: 12px; }

.content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 26px; }
.stat-card, .panel { border-color: rgba(226,232,240,.9); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card { min-height: 138px; padding: 20px; transition: transform .2s ease, box-shadow .2s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 14px 35px rgba(15,23,42,.09); }
.stat-card i { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #f8fafc; font-size: 1.35rem; }
.stat-card span { margin: 14px 0 5px; font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.stat-card strong { font-size: clamp(1.35rem, 2vw, 1.85rem); }
.panel { padding: 20px; }
.panel h2 { font-size: 1.08rem; font-weight: 750; }
.panel-header p { margin-top: 3px; font-size: .86rem; }
.form-control, .form-select { min-height: 44px; border-color: #dce3ec; border-radius: 11px; }
.form-control:focus, .form-select:focus { border-color: #dc5252; box-shadow: 0 0 0 4px rgba(200, 0, 0, .12); }
.btn { min-height: 40px; border-radius: 11px; font-weight: 650; }
.btn-primary { border-color: var(--blue); background: var(--blue); }
.table-responsive { border-radius: 12px; -webkit-overflow-scrolling: touch; }
.table > :not(caption) > * > * { padding: .85rem .75rem; }
.table tbody tr { border-color: #edf1f5; }
.table tbody tr:hover { background: #fafbff; }
.table td:last-child, .table th:last-child { white-space: nowrap; }
.badge { padding: .48em .7em; border-radius: 8px; }
.alert { border: 0; border-radius: 13px; }
.mobile-bottom-nav, .sidebar-backdrop { display: none; }

@media (max-width: 1023.98px) {
    body { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
    body.sidebar-open { overflow: hidden; }
    .admin-layout { display: block; min-height: 100vh; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(88vw, 330px);
        height: 100dvh;
        padding: 18px 14px calc(24px + env(safe-area-inset-bottom));
        transform: translateX(-105%);
        transition: transform .25s cubic-bezier(.22,1,.36,1);
        box-shadow: 24px 0 60px rgba(2,6,23,.28);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-head { position: sticky; top: -18px; z-index: 2; padding: 18px 0 14px; background: var(--sidebar); }
    .sidebar-close { display: grid; place-items: center; flex: 0 0 40px; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 1035; background: rgba(15,23,42,.52); opacity: 0; visibility: hidden; display: block; transition: .2s ease; }
    body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
    .admin-menu { display: grid; overflow: visible; padding: 0; }
    .menu-group { min-width: 0; }
    .sidebar .nav-link { white-space: normal; }
    .mobile-menu-button { display: grid; place-items: center; }
    .topbar { align-items: center; flex-direction: row; justify-content: flex-start; padding: 12px 16px; min-height: 68px; }
    .topbar-title { min-width: 0; flex: 1; }
    .topbar-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.08rem; }
    .topbar-title p { display: none; }
    .user-chip { gap: 7px; }
    .avatar { width: 38px; height: 38px; }
    .content { padding: 16px; }
    .mobile-bottom-nav {
        position: fixed; left: 10px; right: 10px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 1030;
        display: flex; justify-content: space-around; min-height: 62px; padding: 7px 6px;
        border: 1px solid rgba(226,232,240,.9); border-radius: 18px; background: rgba(255,255,255,.96);
        box-shadow: 0 12px 40px rgba(15,23,42,.18); backdrop-filter: blur(16px);
    }
    .mobile-bottom-nav a, .mobile-bottom-nav button { display: grid; place-items: center; gap: 1px; min-width: 54px; border: 0; border-radius: 12px; background: transparent; color: #8490a3; padding: 5px 8px; text-decoration: none; font-size: .68rem; font-weight: 700; }
    .mobile-bottom-nav i { font-size: 1.18rem; }
    .mobile-bottom-nav .active { color: var(--blue); background: var(--blue-soft); }
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
    .stat-card { min-height: 125px; padding: 15px; }
    .stat-card i { width: 36px; height: 36px; font-size: 1.1rem; }
    .stat-card span { margin-top: 11px; font-size: .68rem; }
    .panel { padding: 16px; }
    .panel-header { align-items: center; flex-direction: row; flex-wrap: wrap; gap: 12px; }
    .panel-header > .btn, .panel-header > a.btn { flex: 0 0 auto; }
    .table { min-width: 680px; }
    .table-responsive::after { content: "Swipe to see more →"; position: sticky; left: 12px; display: inline-block; padding: 6px 0 2px; color: var(--muted); font-size: .72rem; }
    .form-panel { max-width: none; }
    .search-row { grid-template-columns: 1fr auto auto; }
    .chart-container { height: 280px; }
}

@media (max-width: 575.98px) {
    .content { padding: 13px; }
    .topbar { padding-inline: 12px; }
    .user-chip .avatar { display: none; }
    .panel { padding: 14px; }
    .panel-header { align-items: flex-start; }
    .panel-header > div { min-width: 0; flex: 1; }
    .panel-header > .btn, .panel-header > a.btn { width: auto; }
    .search-row, .report-filter { grid-template-columns: 1fr; }
    .search-row .btn, .report-filter .btn { width: 100%; }
    .form-panel .row > [class*="col-"] { width: 100%; }
    .form-panel .d-flex.justify-content-end { flex-direction: column-reverse; }
    .form-panel .d-flex.justify-content-end .btn { width: 100%; }
    .modal-dialog { margin: 10px; }
    .modal-content { border: 0; border-radius: 18px; }
    .dashboard-chart-grid { gap: 13px; }
    .chart-container { height: 250px; }
}

@media (max-width: 359.98px) {
    .stats-grid { grid-template-columns: 1fr; }
}

@media print {
    body {
        background: #fff;
        font-size: 12px;
    }

    .sidebar,
    .topbar,
    .mobile-bottom-nav,
    .no-print,
    .alert {
        display: none !important;
    }

    .admin-layout {
        display: block;
        min-height: 0;
    }

    .content {
        padding: 0;
    }

    .panel {
        border: 0;
        box-shadow: none;
        padding: 0;
    }

    .report-summary-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .stat-card {
        box-shadow: none;
        min-height: auto;
        padding: 10px;
    }

    .stat-card i {
        display: none;
    }

    .stat-card span {
        margin-top: 0;
    }

    .stat-card strong {
        font-size: 0.95rem;
    }

    .table {
        font-size: 11px;
    }
}
