:root {
    --hw-red:        #e31937;
    --hw-red-dark:   #c0152e;
    --hw-yellow:     #ffd700;
    --sidebar-bg:    #1a1c23;
    --sidebar-text:  #a0a3b1;
    --sidebar-active:#e31937;
    --topbar-h:      64px;
    --sidebar-w:     260px;
    --body-bg:       #f0f2f5;
    --card-shadow:   0 2px 16px rgba(0,0,0,0.08);
    --card-radius:   14px;
}

/* ===================== RESET & BASE ===================== */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--body-bg);
    color: #333;
    margin: 0;
    font-size: 14px;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ===================== LAYOUT ===================== */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

#main-content {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    max-width: calc(100vw - var(--sidebar-w));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin 0.3s ease;
    overflow-x: hidden;
}

/* ===================== SIDEBAR BRAND ===================== */
.sidebar-brand {
    padding: 20px 22px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 42px; height: 42px;
    background: var(--hw-red);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: var(--hw-yellow);
    flex-shrink: 0;
}
.sidebar-brand .brand-text { color: #fff; }
.sidebar-brand .brand-name {
    font-weight: 800;
    font-size: 0.95rem;
    line-height: 1.2;
    letter-spacing: 0.3px;
}
.sidebar-brand .brand-sub {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* ===================== SIDEBAR NAV ===================== */
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section {
    padding: 14px 22px 5px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.3);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 22px;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    position: relative;
}
.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.sidebar-nav a:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
    border-left-color: rgba(255,255,255,0.3);
}
.sidebar-nav a.active {
    color: #fff;
    background: rgba(227,25,55,0.15);
    border-left-color: var(--hw-red);
}
.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--hw-red);
    font-size: 0.65rem;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 14px 22px;
    flex-shrink: 0;
}
.sidebar-footer .user-info { display: flex; align-items: center; gap: 10px; }
.sidebar-footer .user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--hw-red);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.8rem;
    flex-shrink: 0;
}
.sidebar-footer .user-name {
    font-size: 0.825rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}
.sidebar-footer .user-role {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.35);
}

/* ===================== TOPBAR ===================== */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 99;
    flex-shrink: 0;
}
.topbar .sidebar-toggle {
    background: none; border: none; cursor: pointer;
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #666; font-size: 1rem;
    transition: background 0.2s;
}
.topbar .sidebar-toggle:hover { background: var(--body-bg); color: #333; }
.topbar .page-title-area { flex: 1; }
.topbar .page-title { font-size: 1rem; font-weight: 700; color: #222; margin: 0; }
.topbar .page-breadcrumb { font-size: 0.75rem; color: #888; margin: 0; }
.topbar .topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.topbar-icon-btn {
    background: none; border: none; cursor: pointer;
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #666; font-size: 1rem;
    transition: all 0.2s; position: relative;
}
.topbar-icon-btn:hover { background: var(--body-bg); color: var(--hw-red); }

.topbar-user {
    display: flex; align-items: center; gap: 9px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 10px;
    transition: background 0.2s;
}
.topbar-user:hover { background: var(--body-bg); }
.topbar-user img, .topbar-user .user-initials {
    width: 34px; height: 34px;
    border-radius: 50%;
    object-fit: cover;
}
.topbar-user .user-initials {
    background: var(--hw-red);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center;
}
.topbar-user .name { font-size: 0.85rem; font-weight: 600; color: #333; }
.topbar-user .role { font-size: 0.7rem; color: #888; }

/* ===================== CONTENT AREA ===================== */
.content-area {
    padding: 24px;
    flex: 1;
}

/* ===================== PAGE HEADER ===================== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap; gap: 12px;
}
.page-header h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: #1a1c23;
    margin: 0;
}
.page-header .subtitle {
    font-size: 0.8rem; color: #888; margin: 2px 0 0;
}

/* ===================== STAT CARDS ===================== */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 22px;
    display: flex; align-items: center; gap: 16px;
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.stat-icon {
    width: 54px; height: 54px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: #fff; flex-shrink: 0;
}
.stat-icon.red    { background: linear-gradient(135deg, #e31937, #c0152e); }
.stat-icon.blue   { background: linear-gradient(135deg, #0d6efd, #0a58ca); }
.stat-icon.green  { background: linear-gradient(135deg, #28a745, #1e7e34); }
.stat-icon.orange { background: linear-gradient(135deg, #fd7e14, #e96b02); }
.stat-icon.purple { background: linear-gradient(135deg, #6f42c1, #59339d); }
.stat-icon.teal   { background: linear-gradient(135deg, #20c997, #12a17a); }

.stat-info { flex: 1; min-width: 0; }
.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #1a1c23;
    line-height: 1;
    margin-bottom: 3px;
}
.stat-label { font-size: 0.78rem; color: #888; font-weight: 500; }
.stat-change {
    font-size: 0.72rem; font-weight: 600;
    display: flex; align-items: center; gap: 3px;
    margin-top: 4px;
}
.stat-change.up { color: #28a745; }
.stat-change.down { color: #dc3545; }

/* ===================== CARDS ===================== */
.hw-card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0,0,0,0.04);
}
.hw-card-header {
    padding: 18px 22px;
    border-bottom: 1px solid #f0f0f0;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.hw-card-header h5 {
    font-size: 0.95rem; font-weight: 700; color: #222; margin: 0;
    display: flex; align-items: center; gap: 8px;
}
.hw-card-body { padding: 22px; }
.hw-card-footer { padding: 14px 22px; border-top: 1px solid #f0f0f0; }

/* ===================== TABLES ===================== */
.table-hover tbody tr { transition: background 0.15s; }
.table thead th {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    border-bottom: 2px solid #f0f0f0;
    padding: 10px 12px;
    white-space: nowrap;
    background: #fafafa;
}
.table tbody td { padding: 11px 12px; vertical-align: middle; font-size: 0.875rem; }
.table tbody tr:last-child td { border-bottom: none; }

/* ===================== BUTTONS ===================== */
.btn-hw-red {
    background: var(--hw-red);
    border-color: var(--hw-red);
    color: #fff;
    font-weight: 600;
}
.btn-hw-red:hover { background: var(--hw-red-dark); border-color: var(--hw-red-dark); color: #fff; }
.btn-hw-red:focus { box-shadow: 0 0 0 0.2rem rgba(227,25,55,0.3); }

.btn-action {
    width: 30px; height: 30px;
    border-radius: 7px;
    border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.8rem; transition: all 0.2s;
    text-decoration: none;
}
.btn-action.edit   { background: #e8f0fe; color: #1a73e8; }
.btn-action.delete { background: #fce8e6; color: #d93025; }
.btn-action.view   { background: #e6f4ea; color: #188038; }
.btn-action:hover { opacity: 0.8; transform: scale(1.1); }

/* ===================== FORMS ===================== */
.form-label { font-weight: 600; font-size: 0.85rem; color: #444; margin-bottom: 5px; }
.form-control, .form-select {
    border-radius: 9px;
    border: 1.5px solid #e0e0e0;
    font-size: 0.875rem;
    padding: 9px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--hw-red);
    box-shadow: 0 0 0 0.2rem rgba(227,25,55,0.15);
}
.form-control.is-invalid { border-color: #dc3545; }
.input-group-text { border-radius: 9px; font-size: 0.875rem; }

/* ===================== BADGES ===================== */
.badge { font-size: 0.7rem; font-weight: 600; padding: 4px 8px; border-radius: 6px; }

/* ===================== AVATAR ===================== */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--hw-red);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.avatar.lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar.xl { width: 80px; height: 80px; font-size: 1.4rem; }

/* ===================== CAR CARD ===================== */
.car-card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}
.car-card:hover { transform: translateY(-4px); box-shadow: 0 10px 30px rgba(0,0,0,0.13); }
.car-card .car-photo {
    height: 160px;
    object-fit: cover;
    width: 100%;
    background: #f5f5f5;
    display: block;
}
.car-card .car-photo-placeholder {
    height: 160px;
    background: linear-gradient(135deg, #f5f5f5, #ebebeb);
    display: flex; align-items: center; justify-content: center;
    color: #ccc; font-size: 2.5rem;
}
.car-card .car-body { padding: 14px 16px 12px; }
.car-card .car-title {
    font-size: 0.9rem; font-weight: 700; color: #222;
    margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.car-card .car-meta { font-size: 0.75rem; color: #888; display: flex; gap: 8px; flex-wrap: wrap; }
.car-card .car-footer {
    padding: 10px 16px;
    border-top: 1px solid #f5f5f5;
    display: flex; align-items: center; justify-content: space-between;
}

/* ===================== PHOTO UPLOAD ===================== */
.photo-upload-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.photo-slot {
    border: 2px dashed #ddd;
    border-radius: 10px;
    aspect-ratio: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
    position: relative; overflow: hidden;
    background: #fafafa;
}
.photo-slot:hover { border-color: var(--hw-red); background: rgba(227,25,55,0.03); }
.photo-slot .slot-label {
    font-size: 0.75rem; font-weight: 600; color: #888;
    margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.photo-slot .slot-icon { font-size: 1.5rem; color: #ccc; }
.photo-slot input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.photo-slot .preview-img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}
.photo-slot .remove-photo {
    position: absolute; top: 5px; right: 5px;
    background: rgba(220,53,69,0.9); color: #fff;
    border: none; border-radius: 50%;
    width: 22px; height: 22px;
    display: none; align-items: center; justify-content: center;
    font-size: 0.7rem; cursor: pointer; z-index: 2;
}
.photo-slot:hover .remove-photo.visible { display: flex; }

/* ===================== PUBLIC / LANDING ===================== */
.landing-hero {
    background: linear-gradient(135deg, #1a1c23 0%, #2d1010 60%, #1a0a0a 100%);
    min-height: 100vh; position: relative; overflow: hidden;
}
.landing-hero::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at 70% 50%, rgba(227,25,55,0.2) 0%, transparent 60%);
}
.hero-content { position: relative; z-index: 1; }
.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    color: #fff;
    line-height: 1.05;
    letter-spacing: -1px;
}
.hero-title span { color: var(--hw-yellow); }
.hero-subtitle { font-size: 1.1rem; color: rgba(255,255,255,0.65); max-width: 480px; }

.feature-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    transition: all 0.3s;
}
.feature-card:hover { background: rgba(255,255,255,0.07); border-color: rgba(227,25,55,0.4); transform: translateY(-4px); }
.feature-card .icon { font-size: 2.2rem; margin-bottom: 14px; }
.feature-card h5 { color: #fff; font-weight: 700; font-size: 1rem; }
.feature-card p { color: rgba(255,255,255,0.5); font-size: 0.85rem; margin: 0; }

.public-nav {
    background: rgba(26,28,35,0.95);
    backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 999;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.public-nav .navbar-brand {
    font-weight: 900; font-size: 1.1rem;
    color: #fff; letter-spacing: -0.3px;
}
.public-nav .navbar-brand span { color: var(--hw-yellow); }

/* ===================== LOGIN / REGISTER ===================== */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1c23 0%, #2d1010 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.5);
    width: 100%; max-width: 440px;
    overflow: hidden;
}
.auth-header {
    background: linear-gradient(135deg, var(--hw-red), var(--hw-red-dark));
    padding: 32px 36px;
    text-align: center;
}
.auth-header .logo-icon {
    width: 60px; height: 60px;
    background: rgba(255,255,255,0.15);
    border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.8rem; margin-bottom: 12px;
}
.auth-header h2 { color: #fff; font-weight: 800; margin: 0; font-size: 1.3rem; }
.auth-header p { color: rgba(255,255,255,0.7); margin: 4px 0 0; font-size: 0.85rem; }
.auth-body { padding: 32px 36px; }
.auth-footer { padding: 16px 36px 24px; text-align: center; font-size: 0.85rem; color: #888; }
.auth-footer a { color: var(--hw-red); font-weight: 600; }
.btn-auth {
    background: var(--hw-red); border-color: var(--hw-red);
    color: #fff; font-weight: 700; padding: 12px;
    border-radius: 10px; width: 100%; font-size: 0.95rem;
    transition: all 0.2s;
}
.btn-auth:hover { background: var(--hw-red-dark); border-color: var(--hw-red-dark); color: #fff; }

/* ===================== RESPONSIVE ===================== */
body, .app-wrapper { overflow-x: hidden; min-width: 0; }
#main-content { overflow-x: hidden; }

/* Sidebar collapsed on desktop */
body.sidebar-collapsed #sidebar { transform: translateX(-100%); }
body.sidebar-collapsed #main-content { margin-left: 0; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1049;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
        z-index: 1050;
    }
    #sidebar.show { transform: translateX(0); }
    #main-content { margin-left: 0 !important; }
    .content-area { padding: 14px 12px; }
    .photo-upload-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .page-header h1 { font-size: 1.1rem; }
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar .page-title { font-size: 0.9rem; }
    .topbar .page-breadcrumb { display: none; }
    .hw-card-body { padding: 14px; }
    .hw-card-header { padding: 12px 14px; }
    .hw-card-footer { padding: 10px 14px; }
    .stat-card { padding: 14px; }
    .table-responsive-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 767.98px) {
    .stat-card { padding: 12px; }
    .stat-value { font-size: 1.3rem; }
    .stat-icon { width: 44px; height: 44px; font-size: 1.1rem; border-radius: 10px; }
    .content-area { padding: 10px; }
    .row.g-4 { --bs-gutter-y: 0.75rem; --bs-gutter-x: 0.75rem; }
    .hw-card-body { overflow-x: auto; }
    .table { min-width: 520px; }
}

@media (max-width: 575.98px) {
    .photo-upload-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat-card { padding: 12px 10px; gap: 10px; }
    .stat-value { font-size: 1.2rem; }
    .topbar-user .name, .topbar-user .role { display: none; }
    .table thead th, .table tbody td { padding: 8px; font-size: 0.8rem; }
    .hw-card-body { padding: 12px 10px; }
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ===================== UTILITIES ===================== */
.text-hw-red { color: var(--hw-red) !important; }
.bg-hw-red { background: var(--hw-red) !important; }
.border-hw-red { border-color: var(--hw-red) !important; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.rounded-10 { border-radius: 10px; }
.rounded-12 { border-radius: 12px; }
.gap-2 { gap: 8px; }
.cursor-pointer { cursor: pointer; }
