/* Сброс и база */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
*::before,
*::after {
    box-sizing: border-box;
}
html, body {
    overflow-x: hidden;
    max-width: 100%;
}
body {
    background: #f6f8fa;
    color: #1e293b;
    line-height: 1.5;
}
img { max-width: 100%; height: auto; }
a { word-break: break-word; }

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* =============================================
   Шапка
   ============================================= */
header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

/* Логотип + телефон */
.logo-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
    gap: 2px;
    flex: 0 0 auto;
}
.logo {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #0f172a;
    text-decoration: none;
    white-space: nowrap;
}
.logo span { color: #2ed471; }

.header-phone {
    font-family: 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
    font-size: 15px;
    color: #334155;
    text-decoration: none;
    white-space: nowrap;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s;
}
.header-phone:hover { color: #2ed471; }

/* Поиск */
.header-search {
    flex: 1 1 300px;
    display: flex;
    min-width: 0;
}
.header-search form {
    display: flex;
    width: 100%;
    min-width: 0;
}
.header-search input {
    flex: 1;
    width: 100%;
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 30px 0 0 30px;
    font-size: 14px;
    outline: none;
    transition: border 0.2s;
    min-width: 0;
}
.header-search input:focus { border-color: #2ed471; }
.header-search button {
    background: #2ed471;
    border: none;
    color: #fff;
    padding: 10px 20px;
    border-radius: 0 30px 30px 0;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.header-search button:hover { background: #22b85f; }

/* Действия справа (корзина, войти) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}
.header-user {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
}

.header-cart {
    font-weight: 600;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 30px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: #0f172a;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.2s, opacity 0.2s;
}
.header-cart:hover { background: #e2e8f0; }
.header-cart--account {
    background: #eef4ff;
    color: #1d4ed8;
}
.header-cart--account:hover { background: #dbe7ff; }

.header-cart--success {
    background: #28a745;
    color: #fff;
}
.header-cart--success:hover { background: #218838; }
.header-cart--danger {
    background: #dc3545;
    color: #fff;
}
.header-cart--danger:hover { background: #c82333; }

/* =============================================
   Навигация
   ============================================= */
nav {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 0;
}
.nav-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
}
.nav-inner a {
    text-decoration: none;
    color: #334155;
    font-weight: 500;
    font-size: 14px;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s;
    white-space: nowrap;
}
.nav-inner a:hover {
    border-bottom-color: #2ed471;
    color: #0f172a;
}
.nav-catalog {
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* =============================================
   Баннер
   ============================================= */
.hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    padding: 50px 0;
    margin-bottom: 40px;
    border-radius: 24px;
    margin-top: 20px;
}
.hero-content {
    max-width: 600px;
    padding: 0 30px;
}
.hero h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}
.hero p {
    font-size: 18px;
    color: #cbd5e1;
    margin-bottom: 24px;
}
.hero .btn {
    background: #2ed471;
    color: #fff;
    border: none;
    padding: 12px 32px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
    transition: background 0.2s;
}
.hero .btn:hover { background: #22b85f; }

/* =============================================
   Заголовки секций
   ============================================= */
.section-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
    letter-spacing: -0.3px;
}

/* =============================================
   Сетка категорий
   ============================================= */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 200px));
    justify-content: center;
    gap: 20px;
    margin-bottom: 48px;
}
.category-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px 12px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.03);
    border: 1px solid #eef2f6;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: #0f172a;
    min-width: 0;
}
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px rgba(0,0,0,0.06);
    border-color: #a8e6cf;
}
.category-card .cat-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 10px;
    color: #2ed471;
}
.category-card .cat-icon img {
    display: inline-block;
    vertical-align: middle;
}
.category-card .cat-name {
    font-weight: 600;
    font-size: 15px;
    display: block;
}
.category-card .cat-count {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

/* =============================================
   Товары
   ============================================= */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 240px));
    justify-content: center;
    gap: 24px;
    margin-bottom: 48px;
}
.product-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #eef2f6;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
    min-width: 0;
}
.product-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    transform: translateY(-3px);
    border-color: #a8e6cf;
}
.product-card .img-wrap {
    position: relative;
    background: #f1f5f9;
    height: 180px;
    overflow: hidden;
    flex-shrink: 0;
}
.product-card .img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}
.product-card:hover .img-wrap img { transform: scale(1.04); }
.product-card .img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 14px;
}
.product-card .stock-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(46, 212, 113, 0.15);
    color: #2ed471;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    z-index: 1;
}
.product-card .card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.product-card .title-3 {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
    margin-bottom: 10px;
    transition: color 0.2s;
}
.product-card .title-3:hover { color: #2ed471; }
.product-card .price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    margin-bottom: 10px;
}
.product-card .price {
    font-weight: 700;
    color: #0f172a;
    font-size: 18px;
}
.product-card .btn-cart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #2ed471;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.1s;
    width: 100%;
    font-family: inherit;
}
.product-card .btn-cart:hover {
    background: #22b85f;
    color: #fff;
}
.product-card .btn-cart:active { transform: scale(0.98); }
.product-card .btn-cart svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* =============================================
   Преимущества
   ============================================= */
.benefits {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    background: #ffffff;
    padding: 40px 30px;
    border-radius: 24px;
    margin: 40px 0;
    border: 1px solid #eef2f6;
}
.benefit-item { text-align: center; }
.benefit-item .b-icon {
    font-size: 28px;
    display: block;
    color: #2ed471;
    margin-bottom: 8px;
}
.benefit-item h4 {
    font-weight: 600;
    margin-bottom: 4px;
}
.benefit-item p {
    font-size: 14px;
    color: #475569;
}

/* =============================================
   Футер
   ============================================= */
footer {
    background: #0f172a;
    color: #cbd5e1;
    padding: 40px 0;
    margin-top: 40px;
    border-radius: 24px 24px 0 0;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 30px;
}
.footer-grid h5 {
    color: #f8fafc;
    font-weight: 700;
    margin-bottom: 12px;
    font-size: 16px;
}
.footer-grid a {
    display: block;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 6px;
}
.footer-grid a:hover { color: #f8fafc; }
.footer-crm-link {
    color: #f8fafc;
    background: #2563eb;
    padding: 6px 14px;
    border-radius: 6px;
    display: inline-block;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
}
.footer-crm-link:hover { background: #1d4ed8; }
.footer-bottom {
    border-top: 1px solid #1e293b;
    margin-top: 30px;
    padding-top: 20px;
    text-align: center;
    font-size: 14px;
    color: #64748b;
}

/* =============================================
   ПЛАНШЕТ / МОБИЛЬНЫЙ
   ============================================= */
@media (max-width: 768px) {
    .container { padding: 0 14px; }

    .header-inner {
        flex-wrap: wrap;
        gap: 10px;
    }
    .logo-block {
        flex: 1 1 auto;
        gap: 2px;
    }
    .logo { font-size: 20px; }
    .header-phone { font-size: 13px; }

    .header-actions {
        order: 2;
        flex: 0 0 auto;
        gap: 6px;
    }
    .header-cart {
        padding: 6px 12px;
        font-size: 13px;
    }
    .header-user { font-size: 13px; }

    .header-search {
        order: 3;
        flex: 1 1 100%;
        min-width: 0;
    }
    .header-search input {
        padding: 8px 14px;
        font-size: 13px;
    }
    .header-search button {
        padding: 8px 16px;
        font-size: 13px;
    }

    .nav-inner {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 16px;
        padding: 8px 0;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .nav-inner::-webkit-scrollbar { display: none; }

    .hero {
        padding: 32px 0;
        margin-bottom: 24px;
        border-radius: 16px;
    }
    .hero-content { padding: 0 20px; }
    .hero h1 { font-size: 24px; }
    .hero p { font-size: 15px; margin-bottom: 18px; }
    .hero .btn { padding: 10px 24px; font-size: 14px; }

    .section-title { font-size: 22px; margin-bottom: 16px; }

    .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        justify-content: stretch;
        gap: 12px;
    }
    .category-card {
        padding: 16px 8px;
        border-radius: 12px;
    }
    .category-card .cat-icon { font-size: 22px; }
    .category-card .cat-name { font-size: 13px; }

    .featured-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
        gap: 12px;
    }

    .benefits {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        padding: 24px 16px;
        border-radius: 16px;
        margin: 24px 0;
    }
    .benefit-item p { font-size: 13px; }

    footer {
        padding: 30px 0 20px;
        border-radius: 16px 16px 0 0;
    }
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    /* Ловим инлайновые сетки в category_detail / search_results */
    [style*="minmax(220px"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    [style*="minmax(200px"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    /* Детальная страница товара: убираем фиксированные min-width */
    [style*="min-width: 260px"],
    [style*="min-width: 250px"],
    [style*="min-width:260px"],
    [style*="min-width:250px"] {
        min-width: 0 !important;
        flex: 1 1 100% !important;
    }

    table { width: 100%; table-layout: fixed; }
    td, th { word-wrap: break-word; overflow-wrap: break-word; }
}

@media (max-width: 480px) {
    .container { padding: 0 12px; }

    .logo { font-size: 18px; }
    .header-phone { font-size: 12px; }

    .hero h1 { font-size: 20px; }
    .hero p { font-size: 14px; }

    .section-title { font-size: 20px; }

    .category-grid { gap: 10px; }
    .category-card { padding: 12px 6px; }
    .category-card .cat-name { font-size: 12px; }

    .featured-grid { gap: 10px; }

    .product-card .img-wrap { height: 140px; }
    .product-card .price { font-size: 16px; }
    .product-card .btn-cart {
        padding: 9px 12px;
        font-size: 13px;
    }

    .benefits {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 20px 14px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    [style*="minmax(220px"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
}