:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #eef4ff;
    --border: #d9e2ef;
    --text: #162033;
    --muted: #5b6b83;
    --primary: #1967d2;
    --primary-dark: #0f4da3;
    --success: #1a8f5c;
    --warning: #c97a10;
    --danger: #bf3f4d;
    --shadow: 0 18px 48px rgba(18, 33, 61, 0.08);
    --radius: 20px;
    --sidebar-width: 280px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(180deg, #eef4ff 0%, #f7f9fc 100%); color: var(--text); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ─── APP SHELL ─────────────────────────────────────────── */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
    background: #0f1729;
    color: #f8fbff;
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}
.brand-block { padding: 8px 8px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand-title { font-size: 1.7rem; font-weight: 700; }
.brand-subtitle { margin-top: 8px; color: rgba(255,255,255,0.7); font-size: 0.95rem; }
.nav-list { display: grid; gap: 10px; }
.nav-link { padding: 14px 16px; border-radius: 14px; color: rgba(255,255,255,0.78); transition: background 0.2s ease, color 0.2s ease; display: block; }
.nav-link:hover, .nav-link.is-active { background: rgba(255,255,255,0.1); color: #ffffff; }
.sidebar-footer { margin-top: auto; }

/* Mobile menu toggle button — hidden on desktop */
.menu-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 300;
    background: #0f1729;
    color: #fff;
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* Overlay behind sidebar on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
}
.sidebar-overlay.active { display: block; }

/* ─── MAIN CONTENT ───────────────────────────────────────── */
.main-content { padding: 28px; min-width: 0; }
.page-header { margin-bottom: 22px; }
.page-header h1 { margin: 0 0 8px; font-size: 2rem; word-break: break-word; }
.page-header p { margin: 0; color: var(--muted); }

/* ─── HERO ───────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, #1967d2 0%, #2c83f2 100%);
    color: #fff;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.hero h1, .hero h2 { margin: 0 0 8px; }

/* ─── PANELS / CARDS ─────────────────────────────────────── */
.panel, .card, .table-wrap, .auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel, .table-wrap, .auth-card { padding: 24px; }

/* ─── GRIDS ──────────────────────────────────────────────── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }

/* ─── STATS ──────────────────────────────────────────────── */
.stats-card { padding: 22px; }
.stats-label { color: var(--muted); font-size: 0.92rem; }
.stats-value { margin-top: 10px; font-size: 2rem; font-weight: 700; }

/* ─── TOOLBAR ────────────────────────────────────────────── */
.toolbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ─── CAR CARDS ──────────────────────────────────────────── */
.car-card { overflow: hidden; }
.car-card img { width: 100%; height: 220px; object-fit: cover; }
.car-body { padding: 20px; }
.car-meta, .feature-list, .split, .inline-list { display: flex; gap: 12px; flex-wrap: wrap; }
.split { justify-content: space-between; align-items: center; }
.meta-pill, .badge { display: inline-flex; align-items: center; padding: 7px 12px; border-radius: 999px; font-size: 0.84rem; font-weight: 600; }
.meta-pill { background: var(--surface-soft); color: var(--primary); }
.badge-success { background: #dbf5ea; color: var(--success); }
.badge-warning { background: #fff0d6; color: var(--warning); }
.badge-danger { background: #ffe0e3; color: var(--danger); }
.badge-muted { background: #e9edf4; color: #66758c; }
.price { font-size: 1.85rem; font-weight: 700; color: var(--primary); }
.price small { font-size: 0.9rem; font-weight: 500; color: var(--muted); }

/* ─── BUTTONS ────────────────────────────────────────────── */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 600; cursor: pointer; font-size: 0.95rem; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { background: #e8f0ff; color: var(--primary); }
.button-ghost { background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.1); }
.button-block { width: 100%; }
.button-muted { background: #f1f5fb; color: var(--text); }

/* ─── MISC ───────────────────────────────────────────────── */
.muted { color: var(--muted); }
.notice { margin-bottom: 18px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); }
.notice-success { background: #e6f7ef; border-color: #b8e4cb; color: #146c43; }
.notice-error { background: #ffe8eb; border-color: #ffc8cf; color: #9f2330; }
.notice-warning { background: #fff4df; border-color: #f7d89e; color: #9a6209; }
.section-title { margin: 0 0 14px; font-size: 1.2rem; }

/* ─── TABLES ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
td { word-break: break-word; }

/* ─── AUTH ───────────────────────────────────────────────── */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.auth-grid { width: min(1120px, 100%); display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 28px; align-items: center; }
.auth-visual {
    color: #fff;
    background: linear-gradient(135deg, rgba(15,24,48,0.75), rgba(25,103,210,0.45)),
        url("https://images.unsplash.com/photo-1685143114226-84d683366af8?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&q=80&w=1200") center/cover;
    padding: 34px;
    border-radius: 28px;
    min-height: 560px;
    display: flex;
    flex-direction: column;
    justify-content: end;
}
.auth-card h1 { margin-top: 0; }
.info-banner { margin-bottom: 20px; padding: 16px; border-radius: 16px; background: #edf4ff; border: 1px solid #cfe1ff; color: #17427f; }
.field-group { display: grid; gap: 8px; margin-bottom: 16px; }
.input, select { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 1rem; }
.input:focus, select:focus { outline: 2px solid rgba(25,103,210,0.18); border-color: var(--primary); }

/* ─── DETAIL / PROFILE ───────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1.4fr 0.9fr; gap: 22px; }
.detail-photo { border-radius: var(--radius); height: 420px; object-fit: cover; width: 100%; }
.feature-list span { background: #f2f6fb; border-radius: 999px; padding: 8px 12px; }
.summary-box { position: sticky; top: 24px; }
.stack { display: grid; gap: 18px; }
.profile-grid { display: grid; grid-template-columns: 320px 1fr; gap: 22px; }
.avatar { width: 110px; height: 110px; border-radius: 50%; background: linear-gradient(135deg, #1967d2, #2e89ff); color: #fff; display: grid; place-items: center; margin: 0 auto 16px; font-size: 2rem; font-weight: 700; }
.center { text-align: center; }
.spaced > * + * { margin-top: 16px; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════════════════════════ */

/* ─── TABLET (≤ 1080px) ──────────────────────────────────── */
@media (max-width: 1080px) {
    :root { --sidebar-width: 240px; }

    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
    .auth-grid { grid-template-columns: 1fr; }
    .auth-visual { display: none; }
    .page-header h1 { font-size: 1.6rem; }
}

/* ─── MOBILE (≤ 768px) ───────────────────────────────────── */
@media (max-width: 768px) {

    /* Show hamburger button */
    .menu-toggle { display: flex; }

    /* App shell becomes single column */
    .app-shell { grid-template-columns: 1fr; }

    /* Sidebar slides in from left */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        z-index: 250;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }

    /* Push main content down to avoid hamburger button overlap */
    .main-content { padding: 70px 16px 24px; }

    .page-header h1 { font-size: 1.4rem; }
    .page-header p { font-size: 0.9rem; }

    .grid-4,
    .grid-3,
    .grid-2,
    .card-grid { grid-template-columns: 1fr; }

    .stats-value { font-size: 1.6rem; }

    .toolbar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .toolbar-actions { width: 100%; }
    .toolbar-actions .button { flex: 1; text-align: center; }

    .hero { padding: 22px 18px; }
    .hero h2 { font-size: 1.3rem; }

    .car-card img { height: 180px; }

    .auth-shell { padding: 16px; }
    .auth-grid { grid-template-columns: 1fr; gap: 0; }
    .auth-visual { display: none; }
    .auth-card { padding: 24px 20px; }

    .detail-photo { height: 240px; }
    .summary-box { position: static; }

    .panel, .table-wrap { padding: 16px; }

    .button { padding: 11px 14px; font-size: 0.9rem; }

    /* Tables scroll horizontally */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 480px; }
    th, td { padding: 10px 8px; font-size: 0.88rem; }

    .profile-grid { grid-template-columns: 1fr; }
    .avatar { width: 88px; height: 88px; font-size: 1.6rem; }

    .price { font-size: 1.5rem; }
}

/* ─── SMALL MOBILE (≤ 400px) ─────────────────────────────── */
@media (max-width: 400px) {
    .main-content { padding: 64px 12px 20px; }
    .brand-title { font-size: 1.4rem; }
    .stats-value { font-size: 1.4rem; }
    .button { padding: 10px 12px; }
    .input, select { padding: 11px 12px; }
    .page-header h1 { font-size: 1.2rem; }
}
