:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --bg: #f1f5f9;
    --white: #ffffff;
    --radius: 12px;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 8px 20px -4px rgb(0 0 0 / 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== TOPBAR ========== */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 800;
    font-size: 1.2rem;
    white-space: nowrap;
}

.brand i {
    color: var(--primary);
}

.brand .accent {
    color: var(--primary);
}

.search-form {
    flex: 1;
    display: flex;
    min-width: 160px;
}

.search-input-wrap {
    flex: 1;
    position: relative;
}

.search-input-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 14px;
}

.search-form input {
    width: 100%;
    padding: 11px 12px 11px 38px;
    border: 1px solid var(--border);
    border-radius: 8px 0 0 8px;
    font-size: 14px;
    outline: none;
    background: #f8fafc;
}

.search-form input:focus {
    border-color: var(--primary);
    background: white;
}

.search-form button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 18px;
    border-radius: 0 8px 8px 0;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.top-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn-ghost,
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
}

.btn-ghost {
    border: 1px solid var(--border);
    color: var(--text);
    background: transparent;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-lg {
    padding: 13px 22px;
    font-size: 14px;
}

/* ========== LAYOUT ========== */
.layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 28px;
    padding: 24px 20px 48px;
    min-height: 60vh;
}

.mobile-filter-btn {
    display: none;
    width: 100%;
    padding: 13px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 16px;
    cursor: pointer;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mobile-only {
    display: none;
}

/* Sidebar */
.sidebar {
    position: sticky;
    top: 84px;
    height: fit-content;
}

.filter-block {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.filter-block h3 {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.cat-list {
    list-style: none;
}

.cat-list > li > a {
    display: block;
    padding: 8px 11px;
    border-radius: 7px;
    text-decoration: none;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
}

.cat-list > li > a:hover,
.cat-list > li > a.active {
    background: #eef2ff;
    color: var(--primary);
}

.sub-list {
    list-style: none;
    margin: 4px 0 8px 12px;
}

.sub-list a {
    display: block;
    padding: 5px 10px;
    font-size: 12.5px;
    color: var(--muted);
    text-decoration: none;
    border-radius: 5px;
}

.sub-list a:hover,
.sub-list a.active {
    color: var(--primary);
    background: #f5f3ff;
}

.filter-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 10px;
    outline: none;
}

.btn-filter {
    width: 100%;
    padding: 10px;
    background: var(--text);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

/* Results bar */
.results-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    gap: 14px;
    flex-wrap: wrap;
}

.results-info h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.results-info .sep {
    color: var(--muted);
    font-weight: 400;
}

.count {
    font-size: 13.5px;
    color: var(--muted);
}

.sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-wrap label {
    font-size: 13px;
    color: var(--muted);
}

.sort-wrap select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    background: white;
}

/* ========== LISTING CARDS ========== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    box-shadow: var(--shadow);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.card-img {
    aspect-ratio: 1 / 1;
    background: #e2e8f0;
    overflow: hidden;
    position: relative;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-body {
    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.card-body h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
    min-height: 2.7em;
}

.meta {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: auto;
}

.meta i {
    width: 13px;
    margin-right: 4px;
    opacity: 0.7;
}

.tag {
    display: inline-block;
    margin-top: 10px;
    font-size: 11px;
    background: #f1f5f9;
    color: var(--muted);
    padding: 3px 8px;
    border-radius: 5px;
    width: fit-content;
}

/* Empty state */
.empty {
    text-align: center;
    padding: 56px 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.empty i {
    font-size: 42px;
    color: #cbd5e1;
    margin-bottom: 14px;
}

.empty h3 {
    margin-bottom: 6px;
}

.empty p {
    color: var(--muted);
    margin-bottom: 18px;
    font-size: 14px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.page-btn,
.page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text);
    background: white;
    border: 1px solid var(--border);
}

.page-num.current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.dots {
    color: var(--muted);
    padding: 0 4px;
}

/* CTA */
.cta-banner {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    padding: 36px 0;
}

.cta-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.cta-inner h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.cta-inner p {
    opacity: 0.9;
    font-size: 14.5px;
}

.cta-banner .btn-primary {
    background: white;
    color: var(--primary);
}

/* Footer */
.footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 28px 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.footer .safety {
    margin-top: 4px;
    font-size: 12.5px;
}

/* ========== DETAIL PAGE ========== */
.detail-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 40px;
    padding: 32px 20px 56px;
}

.gallery .main-img {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
}

.gallery .main-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery .main-img.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    gap: 10px;
}

.thumbs {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.thumbs button {
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    background: none;
    width: 72px;
    height: 72px;
}

.thumbs button:hover {
    border-color: var(--primary);
}

.thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.price-lg {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 6px;
}

.info h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 24px;
}

.desc {
    margin-bottom: 28px;
}

.desc h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.desc p {
    color: #334155;
    white-space: pre-wrap;
    line-height: 1.65;
}

.seller-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

.seller-top {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.avatar {
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.seller-loc {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

.contact-btns {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact-btns a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 13px;
    border-radius: 9px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14.5px;
}

.btn-call {
    background: #0f172a;
    color: white;
}

.btn-wa {
    background: #25d366;
    color: white;
}

.btn-mail {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
}

.safety-note {
    margin-top: 16px;
    font-size: 12.5px;
    color: var(--muted);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ========== MOBILE (≤ 900px) ========== */
@media (max-width: 900px) {
    .container {
        padding-left: 18px;
        padding-right: 18px;
    }

    .topbar-inner {
        padding: 14px 0 16px;
        gap: 12px 14px;
        min-height: auto;
    }

    .brand {
        font-size: 1.15rem;
        padding: 4px 0;
    }

    .top-actions {
        gap: 10px;
        padding: 2px 0;
    }

    .btn-ghost,
    .btn-primary {
        padding: 10px 14px;
        min-height: 40px;
    }

    .search-form {
        margin-top: 4px;
        margin-bottom: 2px;
    }

    .search-form input {
        padding: 12px 12px 12px 40px;
        min-height: 44px;
    }

    .search-form button {
        min-height: 44px;
        padding: 0 18px;
    }

    .layout {
        grid-template-columns: 1fr;
        padding: 20px 18px 48px;
        gap: 0;
    }

    .mobile-filter-btn {
        display: flex;
        margin-bottom: 20px;
        padding: 14px 16px;
        min-height: 48px;
    }

    .mobile-only {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 86%;
        max-width: 340px;
        height: 100%;
        background: white;
        z-index: 200;
        transform: translateX(-105%);
        transition: transform 0.28s ease;
        overflow-y: auto;
        padding: 20px 18px;
        box-shadow: 8px 0 30px rgb(0 0 0 / 0.18);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 18px;
        padding-bottom: 14px;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-header button {
        background: none;
        border: none;
        font-size: 22px;
        cursor: pointer;
        color: var(--muted);
        padding: 4px;
    }

    .results-bar {
        margin-bottom: 20px;
        padding: 0 2px;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 0 2px;
    }

    .card-body {
        padding: 12px 12px 14px;
    }

    .price {
        font-size: 1.05rem;
    }

    .card-body h3 {
        font-size: 13.5px;
        min-height: 2.6em;
    }

    .detail-layout {
        grid-template-columns: 1fr;
        padding: 20px 18px 48px;
        gap: 28px;
    }
}

/* ========== SMALL PHONES (≤ 600px) ========== */
@media (max-width: 600px) {
    .container {
        padding-left: 16px!important;
        padding-right: 16px!important;
    }

    .topbar-inner {
        padding: 12px 0 14px;
        gap: 10px;
    }

    .brand {
        font-size: 1.1rem;
    }

    .top-actions .btn-ghost,
    .top-actions .btn-primary {
        padding: 9px 12px;
        min-height: 38px;
    }

    .btn-text {
        display: none;
    }

    .search-form {
        order: 3;
        width: 100%;
        flex-basis: 100%;
    }

    .top-actions {
        margin-left: auto;
    }

    .layout {
        padding: 16px 16px 44px;
    }

    .mobile-filter-btn {
        margin-bottom: 18px;
    }

    .results-bar {
        margin-bottom: 18px;
    }

    .results-info h1 {
        font-size: 1.15rem;
    }

    .grid {
        gap: 14px;
    }

    .card {
        border-radius: 12px;
    }

    .card-body {
        padding: 13px 13px 15px;
    }

    .cta-inner {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .cta-banner {
        padding: 28px 0;
    }
}