/* ═══════════════════════════════════════════════════════════
   CarScout AI — Design System v2 (Sidebar Layout)
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties — Light Mode (default) ─────── */
:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface2: #f0f1f5;
    --border: #d8dbe5;
    --text: #1a1d27;
    --text2: #5a6078;
    --accent: #0ea5a0;
    --accent2: #0d9488;
    --accent-light: rgba(14, 165, 160, .08);
    --gold: #d97706;
    --red: #dc2626;
    --orange: #ea580c;
    --muted: #6b7280;
    --radius: 12px;
    --sidebar-w: 240px;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --card-border: #e5e7eb;
    --card-hover-shadow: rgba(0,0,0,.08);
    --topbar-bg: #ffffff;
    --input-bg: #f5f6fa;
    --input-border: #d1d5db;
    --modal-bg: #ffffff;
    --modal-overlay: rgba(0,0,0,.4);
    --heading: #111827;
    --divider: #e5e7eb;
    --pro-bg: rgba(217,119,6,.08);
    --pro-text: #92400e;
}

/* ── Dark Mode ─────────────────────────────────────────── */
[data-theme="dark"] {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #232735;
    --border: #2d3148;
    --text: #e4e6f0;
    --text2: #9096b0;
    --accent: #4ecdc4;
    --accent2: #36d399;
    --accent-light: rgba(78, 205, 196, .1);
    --gold: #f5b83d;
    --red: #f87171;
    --orange: #f97316;
    --muted: #888;
    --sidebar-bg: #13151e;
    --card-bg: #161825;
    --card-border: #1e2035;
    --card-hover-shadow: rgba(0,0,0,.3);
    --topbar-bg: #13151e;
    --input-bg: #1e2035;
    --input-border: #2a2a4a;
    --modal-bg: #161825;
    --modal-overlay: rgba(0,0,0,.85);
    --heading: #fff;
    --divider: #1e2035;
    --pro-bg: rgba(245,184,61,.15);
    --pro-text: #f5b83d;
}

/* ── Reset & Base ───────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ╔══════════════════════════════════════════════════════════╗
   ║  App Layout — Sidebar + Main Content                    ║
   ╚══════════════════════════════════════════════════════════╝ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform .25s ease;
}
.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo a {
    color: var(--heading);
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-logo a span { color: var(--accent); }

.sidebar-section {
    padding: 16px 12px 8px;
}
.sidebar-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text2);
    padding: 0 8px 8px;
}
.sidebar-nav {
    list-style: none;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text2);
    text-decoration: none;
    font-size: 14px;
    transition: all .15s;
    position: relative;
}
.sidebar-nav li a:hover {
    background: rgba(78, 205, 196, .06);
    color: var(--text);
}
.sidebar-nav li a.active {
    background: rgba(78, 205, 196, .1);
    color: var(--accent);
    font-weight: 600;
}
.sidebar-nav li a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.sidebar-nav .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}
.sidebar-nav .nav-badge {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}
.sidebar-nav .badge-pro {
    background: rgba(245, 184, 61, .15);
    color: var(--gold);
}
.sidebar-nav .badge-lock {
    background: rgba(255, 255, 255, .05);
    color: #666;
}
.sidebar-nav .badge-free {
    background: rgba(59, 130, 246, .12);
    color: #6b9fff;
}
.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 12px;
}

/* Sidebar footer — user info */
.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--border);
}
.sidebar-upgrade {
    display: block;
    text-align: center;
    padding: 10px 16px;
    margin: 0 0 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--gold), #e6a520);
    color: var(--bg);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    transition: all .15s;
}
.sidebar-upgrade:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(245, 184, 61, .3);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .03);
}
.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(78, 205, 196, .15);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-user-info {
    min-width: 0;
    flex: 1;
}
.sidebar-user-email {
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-plan {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.sidebar-user-plan.plan-pro { color: var(--gold); }
.sidebar-user-plan.plan-expert { color: #a855f7; }
.sidebar-user-plan.plan-free { color: #6b9fff; }
.sidebar-user-actions {
    display: flex;
    gap: 6px;
    padding: 6px 8px 0;
}
.sidebar-user-actions button,
.sidebar-user-actions .sidebar-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text2);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    transition: all .15s;
    text-decoration: none;
}
.sidebar-user-actions button:hover,
.sidebar-user-actions .sidebar-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.sidebar-lang-switch {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.sidebar-lang-switch button {
    background: none;
    border: 1px solid transparent;
    color: var(--muted);
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}
.sidebar-lang-switch button.active-lang {
    color: var(--accent);
    border-color: var(--accent);
}

/* ── Mobile hamburger ───────────────────────────────────── */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 150;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    align-items: center;
    justify-content: center;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 90;
}

/* ── Main Content Area ──────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Top Bar (compact) ──────────────────────────────────── */
.top-bar {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 52px;
}
.top-bar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--heading);
    white-space: nowrap;
}
.top-bar-search {
    flex: 1;
    max-width: 400px;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color .15s;
}
.top-bar-search:focus { border-color: var(--accent); }
.top-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ╔══════════════════════════════════════════════════════════╗
   ║  PRO Blur Overlay (for gated content)                   ║
   ╚══════════════════════════════════════════════════════════╝ */
.pro-gate {
    position: relative;
}
.pro-gate-blur {
    filter: blur(6px);
    pointer-events: none;
    user-select: none;
    opacity: .5;
}
.pro-gate-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: radial-gradient(ellipse at center, rgba(15,17,23,.6) 0%, rgba(15,17,23,.9) 70%);
}
.pro-gate-card {
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--gold);
    border-radius: 16px;
    padding: 40px 48px;
    max-width: 420px;
}
.pro-gate-card .gate-icon { font-size: 48px; margin-bottom: 16px; }
.pro-gate-card h2 {
    font-size: 22px;
    color: var(--heading);
    margin-bottom: 8px;
}
.pro-gate-card p {
    color: var(--text2);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}
.pro-gate-card .gate-features {
    text-align: left;
    margin-bottom: 24px;
}
.pro-gate-card .gate-features li {
    list-style: none;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text2);
}
.pro-gate-card .gate-features li::before {
    content: '✓';
    color: var(--accent);
    font-weight: 700;
    margin-right: 8px;
}
.pro-gate-card .btn-upgrade {
    display: inline-block;
    padding: 12px 32px;
    background: linear-gradient(135deg, var(--gold), #e6a520);
    color: var(--bg);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 15px;
    transition: all .15s;
    border: none;
    cursor: pointer;
}
.pro-gate-card .btn-upgrade:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(245, 184, 61, .35);
}

/* ── Legacy Header (kept for login page) ────────────────── */
.header {
    background: var(--surface);
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
}
.header h1 {
    font-size: 24px;
    color: var(--heading);
    white-space: nowrap;
}
.header h1 span { color: var(--accent); }
.header nav {
    display: flex;
    align-items: center;
    gap: 4px;
}
.header nav a {
    color: var(--text2);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.15s;
}
.header nav a:hover {
    color: var(--accent);
    background: rgba(78, 205, 196, 0.08);
}
.header nav a.active { color: var(--accent); }

/* ── Pro Badge ──────────────────────────────────────────── */
.pro-badge {
    background: var(--gold);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ── User Nav ───────────────────────────────────────────── */
.nav-user {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.nav-user .user-email { color: var(--text2); }
.nav-user .user-plan {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.nav-user .plan-free { background: rgba(59,130,246,.15); color: #3b82f6; }
.nav-user .plan-pro { background: rgba(245,184,61,.15); color: var(--gold); }
.nav-user .plan-expert { background: rgba(168,85,247,.18); color: #a855f7; }
.nav-user .btn-logout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text2);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.nav-user .btn-logout:hover { border-color: #ef4444; color: #ef4444; }

/* ── Container ──────────────────────────────────────────── */
.container {
    padding: 24px 32px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Controls / Filter Bar ──────────────────────────────── */
.controls {
    padding: 16px 0;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--divider);
    margin-bottom: 24px;
}
.controls select,
.controls input {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.controls select:focus,
.controls input:focus { border-color: var(--accent); }
.controls input[type="number"] { width: 100px; }
.controls .search-box { flex: 1; min-width: 180px; }
.filter-label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--card-border);
}
.stat-card .label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--heading);
    margin-top: 4px;
}
.stat-card .value.green { color: var(--accent); }
.stat-card .value.gold { color: var(--gold); }
.stat-card .value.blue { color: #3b82f6; }
.stat-card .value.teal { color: var(--accent); }
.stat-card .value.red { color: #ff6b6b; }
.stat-card .sub {
    font-size: 13px;
    color: var(--accent);
    margin-top: 4px;
}

/* ── Grid Layout ────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* ── Card / Deal Card Base ──────────────────────────────── */
.card,
.deal-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    cursor: pointer;
}
.card:hover,
.deal-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 8px 30px var(--card-hover-shadow);
}
.card.featured { border-color: var(--gold); }
.badge-featured {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--gold);
    color: var(--bg);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 6px;
    z-index: 2;
}

/* ── Card Image ─────────────────────────────────────────── */
.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--input-bg);
    display: block;
}
.card-img-placeholder {
    width: 100%;
    height: 200px;
    background: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 40px;
}

/* ── Card Body ──────────────────────────────────────────── */
.card-body { padding: 14px 16px; }
.card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-title .year { color: var(--muted); font-weight: 400; font-size: 14px; }
.card-price {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 10px;
}
.card-price .currency { font-size: 14px; font-weight: 400; color: var(--muted); }
.card-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.spec-tag {
    background: var(--input-bg);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--muted);
}
.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--divider);
    padding-top: 10px;
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
    gap: 0.75rem;
    flex-wrap: wrap;
}
.card-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.card-meta .location { font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; }
.card-actions .btn { padding: 5px 12px; font-size: 12px; }

/* ── Source Badges ──────────────────────────────────────── */
.source-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
    backdrop-filter: blur(6px);
}
.source-badge.mobile_bg { background: rgba(255,107,53,.85); color: var(--heading); }
.source-badge.cars_bg { background: rgba(59,130,246,.85); color: var(--heading); }
.source-badge.autoscout24 { background: rgba(255,165,0,.85); color: var(--bg); }
.source-badge.kleinanzeigen { background: rgba(134,199,51,.85); color: var(--bg); }

/* ── Score Badges ───────────────────────────────────────── */
.score-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    backdrop-filter: blur(8px);
}
.score-badge.excellent { background: rgba(78,205,196,.85); color: var(--heading); }
.score-badge.good { background: rgba(59,130,246,.85); color: var(--heading); }
.score-badge.decent { background: rgba(249,115,22,.85); color: var(--heading); }
.score-badge.low { background: rgba(107,114,128,.7); color: #ddd; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary,
.controls > button {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
}
.btn-primary:hover,
.controls > button:hover { background: #45b7aa; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text2);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-gold { background: var(--gold); color: var(--bg); }
.btn-featured-active { background: var(--gold); color: var(--bg); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: var(--input-bg);
    border: none;
    color: var(--text2);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    z-index: 5;
}
.modal-close:hover { color: var(--heading); }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--divider);
}
.modal-header .modal-close {
    position: static;
    background: none;
    width: auto;
    height: auto;
    font-size: 24px;
}
.modal-gallery {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    background: #111;
    scroll-snap-type: x mandatory;
}
.modal-gallery img {
    max-height: 400px;
    object-fit: contain;
    flex-shrink: 0;
    scroll-snap-align: start;
}
.modal-body { padding: 20px; }
.modal-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.modal-price { font-size: 28px; font-weight: 800; color: var(--accent); margin-bottom: 16px; }
.modal-specs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
    margin-bottom: 16px;
}
.modal-spec {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--divider);
    font-size: 14px;
}
.modal-spec .label { color: var(--muted); }
.spec-item { font-size: 14px; }
.spec-item .spec-label { color: var(--muted); }
.spec-item .spec-val { font-weight: 600; }
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    padding-bottom: 30px;
    flex-wrap: wrap;
    align-items: center;
}
.pagination button,
.page-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}
.pagination button:hover,
.page-btn:hover { border-color: var(--accent); }
.pagination button.active,
.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}
.pagination button:disabled { opacity: .4; cursor: default; }

/* ── Loading / Empty ────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #1e2035;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty p { font-size: 1rem; }

/* ── Footer ─────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 32px;
    color: var(--muted);
    font-size: 13px;
    border-top: 1px solid var(--divider);
    margin-top: 40px;
}
.footer a { color: var(--accent); text-decoration: none; }

/* ── Results bar ────────────────────────────────────────── */
.results-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.results-bar .count { color: var(--muted); font-size: 14px; }

/* ── Responsive ─────────────────────────────────────────── */

/* Tablet and below: hamburger sidebar */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .mobile-toggle {
        display: flex;
    }
    .main-content {
        margin-left: 0;
    }
    .top-bar {
        padding-left: 56px; /* room for hamburger */
    }
    .container { padding: 16px; }
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 12px;
    }
    .modal-specs { grid-template-columns: 1fr; }
    .controls { gap: 8px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .header { padding: 16px; grid-template-columns: 1fr; gap: 8px; text-align: center; }
    .header h1 { font-size: 20px; }
}

/* Phone: single-column, larger touch targets, smaller padding */
@media (max-width: 600px) {
    body { font-size: 14px; }

    /* Top bar — compact */
    .top-bar {
        padding: 10px 12px 10px 56px;
        gap: 8px;
        min-height: 48px;
        flex-wrap: wrap;
    }
    .top-bar-title {
        font-size: 14px;
    }
    .top-bar-search {
        font-size: 13px;
        padding: 8px 12px;
        max-width: none;
        flex: 1 1 100%;
        order: 99;
    }
    .top-bar-right {
        gap: 8px;
    }

    /* Container — minimal padding to prevent horizontal overflow */
    .container {
        padding: 12px;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Grids stack to single column */
    .grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* Stat cards — tighter */
    .stat-card { padding: 14px; }
    .stat-card .value { font-size: 22px; }
    .stat-card .label { font-size: 11px; }

    /* Cards — shorter images, tighter body */
    .card-img,
    .card-img-placeholder {
        height: 180px;
    }
    .card-body { padding: 12px 14px; }
    .card-title { font-size: 15px; }
    .card-price { font-size: 19px; margin-bottom: 8px; }
    .spec-tag { font-size: 11px; padding: 3px 8px; }
    .card-meta { font-size: 12px; padding-top: 8px; gap: .5rem; }

    /* Controls / filter bar — wrap into columns */
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px 0;
    }
    .controls select,
    .controls input {
        width: 100%;
        font-size: 14px;
        padding: 10px 12px;
    }
    .controls .search-box {
        width: 100%;
        min-width: 0;
    }
    .controls input[type="number"] { width: 100%; }
    .controls > button { width: 100%; padding: 10px 16px; }

    /* Modal — full width, scrollable */
    .modal-overlay { padding: 8px; }
    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 95vh;
        border-radius: 12px;
    }
    .modal-body { padding: 16px; }
    .modal-title { font-size: 18px; }
    .modal-price { font-size: 22px; margin-bottom: 12px; }
    .modal-gallery img { max-height: 280px; }
    .modal-specs {
        grid-template-columns: 1fr;
        gap: 4px 12px;
    }
    .modal-spec { font-size: 13px; padding: 4px 0; }
    .modal-actions { flex-direction: column; gap: 8px; }
    .modal-actions .btn { width: 100%; justify-content: center; }
    .modal-close { top: 8px; right: 8px; width: 36px; height: 36px; }

    /* Buttons — bigger touch targets on phones */
    .btn {
        padding: 10px 18px;
        font-size: 14px;
        min-height: 40px;
    }

    /* Pagination */
    .pagination { gap: 4px; padding-bottom: 20px; }
    .pagination button,
    .page-btn { padding: 8px 12px; font-size: 12px; min-width: 36px; }

    /* Header (legacy login) */
    .header { padding: 14px; }
    .header h1 { font-size: 18px; }
    .header nav { flex-wrap: wrap; gap: 4px; justify-content: center; }
    .header nav a { font-size: 12px; padding: 5px 10px; }
    .nav-user { font-size: 11px; gap: 6px; flex-wrap: wrap; justify-content: center; }
    .nav-user .user-email {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Sidebar hamburger position */
    .mobile-toggle {
        top: 8px;
        left: 8px;
        width: 38px;
        height: 38px;
    }

    /* Footer */
    .footer { padding: 24px 16px; font-size: 12px; }

    /* Pro gate card on small screens */
    .pro-gate-card {
        padding: 28px 22px;
        max-width: 90%;
    }
    .pro-gate-card h2 { font-size: 18px; }
    .pro-gate-card p { font-size: 13px; }

    /* Form inputs — prevent iOS auto-zoom by using 16px+ font */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    input[type="search"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px;
    }
}

/* ── Theme Toggle Button ───────────────────────────────── */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text2);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    flex-shrink: 0;
    position: relative;
}
.theme-toggle::after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.5px solid var(--text2);
    background: linear-gradient(to right, var(--text2) 50%, transparent 50%);
    transition: all .2s;
    box-shadow:
        0 -6px 0 -4.5px var(--text2),
        0 6px 0 -4.5px var(--text2),
        6px 0 0 -4.5px var(--text2),
        -6px 0 0 -4.5px var(--text2),
        4.2px -4.2px 0 -4.5px var(--text2),
        -4.2px 4.2px 0 -4.5px var(--text2),
        4.2px 4.2px 0 -4.5px var(--text2),
        -4.2px -4.2px 0 -4.5px var(--text2);
}
.theme-toggle:hover {
    border-color: var(--accent);
}
.theme-toggle:hover::after {
    border-color: var(--accent);
    background: linear-gradient(to right, var(--accent) 50%, transparent 50%);
    box-shadow:
        0 -6px 0 -4.5px var(--accent),
        0 6px 0 -4.5px var(--accent),
        6px 0 0 -4.5px var(--accent),
        -6px 0 0 -4.5px var(--accent),
        4.2px -4.2px 0 -4.5px var(--accent),
        -4.2px 4.2px 0 -4.5px var(--accent),
        4.2px 4.2px 0 -4.5px var(--accent),
        -4.2px -4.2px 0 -4.5px var(--accent);
}
