:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f59e0b;
    --error: #dc2626;
    --success: #16a34a;
    --bg: #f3f4f6;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; }

/* ---------- Header ---------- */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    font-size: 22px;
    font-weight: 800;
    text-decoration: none;
    color: var(--text);
    white-space: nowrap;
}
.logo span { color: var(--primary); }

.search-form {
    flex: 1;
    display: flex;
    max-width: 520px;
}
.search-form input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 8px 0 0 8px;
    font-size: 14px;
}
.search-form button {
    padding: 9px 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-size: 14px;
}

.header-nav {
    display: flex;
    gap: 18px;
    align-items: center;
    white-space: nowrap;
}
.nav-link {
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    position: relative;
}
.nav-link-accent { color: var(--primary); }

.cart-badge {
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 4px;
}

/* ---------- Layout ---------- */
.site-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

.site-footer {
    background: #fff;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px;
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Catalog ---------- */
.catalog-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
}

.sidebar {
    background: #fff;
    border-radius: var(--radius);
    padding: 18px;
    height: fit-content;
}
.sidebar h3 { margin-top: 0; font-size: 15px; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin-bottom: 8px; }
.sidebar a {
    text-decoration: none;
    font-size: 14px;
    color: var(--text);
}
.sidebar a.active, .sidebar a:hover { color: var(--primary); font-weight: 600; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.product-card {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: box-shadow .15s;
}
.product-card:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.08); }

.product-thumb {
    width: 100%;
    aspect-ratio: 1/1;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }

.product-info { padding: 12px 14px 16px; }
.product-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-price { font-size: 16px; font-weight: 700; color: var(--primary); }
.product-old-price {
    font-size: 13px;
    color: var(--muted);
    text-decoration: line-through;
    margin-left: 6px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

/* ---------- Product page ---------- */
.product-page {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 32px;
    background: #fff;
    border-radius: var(--radius);
    padding: 28px;
}
.product-gallery-main {
    width: 100%;
    aspect-ratio: 1/1;
    background: #f3f4f6;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--muted);
}
.product-gallery-main img { width: 100%; height: 100%; object-fit: cover; }

.product-detail h1 { margin-top: 0; font-size: 24px; }
.product-detail .price-row { display: flex; align-items: baseline; gap: 12px; margin: 14px 0; }
.product-detail .price-row .price { font-size: 30px; font-weight: 800; color: var(--primary); }
.seller-line { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.stock-line { font-size: 13px; margin-bottom: 18px; }
.stock-line.in-stock { color: var(--success); }
.stock-line.out-stock { color: var(--error); }

.qty-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.qty-row input {
    width: 64px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
}

.btn { 
    display: inline-block;
    padding: 11px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--error); }
.btn-small { padding: 6px 14px; font-size: 13px; }

.product-description { margin-top: 28px; line-height: 1.6; }

/* ---------- Cart ---------- */
.cart-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.cart-table th, .cart-table td { padding: 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.cart-table th { background: #fafafa; font-size: 13px; color: var(--muted); }
.cart-product { display: flex; align-items: center; gap: 12px; }
.cart-product .thumb { width: 56px; height: 56px; border-radius: 8px; background: #f3f4f6; flex-shrink: 0; overflow: hidden; }
.cart-product .thumb img { width: 100%; height: 100%; object-fit: cover; }

.cart-summary {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
    max-width: 360px;
    margin-left: auto;
}
.cart-summary .total-row { display: flex; justify-content: space-between; font-size: 17px; font-weight: 700; margin-bottom: 16px; }

/* ---------- Forms (checkout, product form) ---------- */
.form-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px;
    max-width: 620px;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* ---------- Tables (admin/seller panels) ---------- */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.data-table th { background: #fafafa; color: var(--muted); }
.status-pill { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status-active, .status-completed, .status-approved { background: #f0fdf4; color: var(--success); }
.status-pending, .status-new { background: #fffbeb; color: var(--accent); }
.status-blocked, .status-rejected, .status-cancelled { background: #fef2f2; color: var(--error); }

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-nav { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.panel-nav a { text-decoration: none; font-size: 14px; font-weight: 600; color: var(--muted); padding: 8px 14px; border-radius: 8px; }
.panel-nav a.active, .panel-nav a:hover { background: #eff6ff; color: var(--primary); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 18px; }
.stat-card .num { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat-card .label { font-size: 13px; color: var(--muted); margin-top: 4px; }

@media (max-width: 800px) {
    .catalog-layout { grid-template-columns: 1fr; }
    .product-page { grid-template-columns: 1fr; }
    .header-inner { flex-wrap: wrap; gap: 10px; }
    .search-form { order: 3; max-width: 100%; }
}

@media (max-width: 640px) {
    .site-main { padding: 16px 12px 40px; }
    .header-inner { padding: 10px 14px; }
    .logo { font-size: 18px; }
    .header-nav { gap: 10px; flex-wrap: wrap; }
    .nav-link { font-size: 13px; }

    .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .product-info { padding: 8px 10px 10px; }
    .product-title { font-size: 13px; }
    .product-price { font-size: 14px; }

    .form-card { padding: 18px; }
    .form-row { grid-template-columns: 1fr; gap: 0; }

    .panel-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .panel-nav { gap: 8px; }
    .panel-nav a { padding: 6px 10px; font-size: 13px; }

    .stat-cards { grid-template-columns: repeat(2, 1fr); }

    /* Таблицы превращаются в карточки на маленьких экранах */
    .data-table, .cart-table { display: block; }
    .data-table thead, .cart-table thead { display: none; }
    .data-table tbody, .cart-table tbody { display: block; }
    .data-table tr, .cart-table tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 10px 14px;
    }
    .data-table td, .cart-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        border-bottom: none;
        padding: 8px 0;
        font-size: 13px;
    }
    .data-table td:not(:last-child), .cart-table td:not(:last-child) {
        border-bottom: 1px dashed var(--border);
    }

    .cart-summary { max-width: 100%; }
    .auth-card { padding: 24px 20px; }
}

@media (max-width: 400px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-cards { grid-template-columns: 1fr 1fr; }
}
