* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== ТЁМНАЯ ТЕМА ===== */
[data-theme="dark"] {
    --bg: #0d0d14;
    --bg-card: #16161f;
    --bg-card-hover: #1e1e2a;
    --bg-input: #1a1a24;
    --text: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --border: #252535;
    --shadow: rgba(0, 0, 0, 0.6);
    --accent: #6c5ce7;
    --accent-hover: #5a4bd1;
    --green: #00b894;
    --red: #ff6b6b;
}

[data-theme="light"] {
    --bg: #f5f5f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0f0;
    --bg-input: #f0f0f0;
    --text: #1a1a2e;
    --text-secondary: #666688;
    --text-muted: #9999bb;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.08);
    --accent: #6c5ce7;
    --accent-hover: #5a4bd1;
    --green: #00b894;
    --red: #ff6b6b;
}

body {
    background: var(--bg);
    color: var(--text);
    padding-bottom: 0;
    transition: background 0.3s, color 0.3s;
}

/* ============================================
   ===== ШАПКА =====
   ============================================ */
.header {
    background: var(--bg-card);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.header-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

.back-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    position: relative;
}

#cart-count {
    background: var(--accent);
    color: white;
    border-radius: 50%;
    padding: 1px 6px;
    font-size: 11px;
    position: absolute;
    top: -6px;
    right: -8px;
}

/* ============================================
   ===== ПОИСК =====
   ============================================ */
.search-bar {
    padding: 8px 20px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: none;
}

.search-bar input {
    width: 100%;
    padding: 10px 16px;
    border-radius: 30px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.search-bar input:focus {
    border-color: var(--accent);
}

/* ============================================
   ===== БАННЕР =====
   ============================================ */
.banner-carousel {
    position: relative;
    margin: 10px 16px;
    border-radius: 16px;
    overflow: hidden;
    height: 180px;
    background: var(--bg-card);
}

.banner-carousel .banner-track {
    display: flex;
    transition: transform 0.5s ease;
    height: 100%;
}

.banner-carousel .banner-slide {
    min-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: white;
    padding: 20px;
    text-align: center;
}

.banner-carousel .banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banner-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border: none;
    color: white;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
}

.banner-btn.prev {
    left: 8px;
}

.banner-btn.next {
    right: 8px;
}

.banner-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
}

.banner-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s;
}

.banner-dots span.active {
    background: white;
    width: 18px;
    border-radius: 4px;
}

/* ============================================
   ===== ИКОНКИ КАТЕГОРИЙ =====
   ============================================ */
.category-icons {
    display: flex;
    gap: 14px;
    padding: 12px 16px;
    overflow-x: auto;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}

.category-icons::-webkit-scrollbar {
    display: none;
}

.cat-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 56px;
    cursor: pointer;
    transition: transform 0.15s;
}

.cat-icon:active {
    transform: scale(0.9);
}

.cat-icon .cat-emoji {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.cat-icon .cat-emoji svg {
    width: 28px;
    height: 28px;
}

.cat-icon .cat-emoji img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cat-icon .cat-name {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* ============================================
   ===== ТОВАРЫ =====
   ============================================ */
.products {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px 16px 100px 16px;
}

.product-card {
    background: var(--bg-card);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s;
}

.product-card:active {
    transform: scale(0.96);
}

.product-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: #2a2a3a;
}

.product-card .product-info {
    padding: 10px 12px 14px;
}

.product-card .product-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
}

.product-card .product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--green);
    margin-top: 4px;
}

.product-card .product-stock {
    font-size: 11px;
    color: var(--text-muted);
}

.product-card .product-category {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================
   ===== КОРЗИНА =====
   ============================================ */
.cart-items {
    padding: 12px 16px;
    flex: 1;
    overflow-y: auto;
    margin-bottom: 80px;
}

.cart-item {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px var(--shadow);
}

.item-info {
    flex: 1;
}

.item-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}

.item-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--green);
    margin-top: 2px;
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:active {
    transform: scale(0.9);
}

.qty-number {
    font-size: 16px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
    color: var(--text);
}

.remove-btn {
    background: none;
    border: none;
    color: var(--red);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

/* ===== НИЖНЯЯ ПАНЕЛЬ КОРЗИНЫ ===== */
.cart-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 100;
}

.cart-total {
    display: flex;
    flex-direction: column;
}

.total-label {
    font-size: 12px;
    color: var(--text-muted);
}

.total-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--green);
}

.checkout-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.checkout-btn:active {
    transform: scale(0.95);
}

/* ===== ПУСТАЯ КОРЗИНА ===== */
.empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-text {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.empty-hint {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   ===== КАРТОЧКА ТОВАРА =====
   ============================================ */
.product-detail {
    padding: 16px;
    padding-bottom: 100px;
}

.product-detail img {
    width: 100%;
    height: 260px;
    object-fit: cover;
    border-radius: 16px;
    background: #2a2a3a;
}

.product-detail h1 {
    font-size: 22px;
    margin: 16px 0 8px;
}

.product-detail .price {
    font-size: 26px;
    font-weight: 700;
    color: var(--green);
}

.product-detail .description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 12px 0;
}

.product-detail .stock-info {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 10px;
}

.product-detail .category-info {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 5px;
}

.actions {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
}

.actions .btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.actions .btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
}

/* ============================================
   ===== ПРОФИЛЬ =====
   ============================================ */
.profile {
    padding: 16px;
    padding-bottom: 80px;
}

.profile .avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 12px;
}

.profile .name {
    text-align: center;
    font-size: 20px;
    font-weight: 600;
}

.profile .balance {
    text-align: center;
    font-size: 16px;
    color: var(--green);
    margin: 4px 0 16px;
}

.profile .orders-title {
    margin-top: 20px;
    margin-bottom: 12px;
    font-size: 16px;
}

.profile .order-item {
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 8px;
}

.profile .order-item .order-id {
    font-weight: 600;
}

.profile .order-item .order-status {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   ===== РЕФЕРАЛКА =====
   ============================================ */
.referral {
    padding: 16px;
    padding-bottom: 80px;
}

.referral .ref-header {
    text-align: center;
    padding: 20px 0;
}

.referral .ref-header .icon {
    font-size: 48px;
    display: block;
}

.referral .ref-header h2 {
    margin-top: 8px;
}

.referral .ref-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.referral .ref-stats {
    display: flex;
    justify-content: space-around;
    margin: 16px 0;
}

.referral .ref-stats .stat {
    text-align: center;
}

.referral .ref-stats .stat .num {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.referral .ref-stats .stat .label {
    font-size: 12px;
    color: var(--text-muted);
}

.referral .ref-link {
    background: var(--bg-card);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 13px;
    word-break: break-all;
    margin-top: 12px;
}

.referral .copy-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 30px;
    background: var(--accent);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
}

.referral .copy-btn:active {
    transform: scale(0.95);
}

/* ============================================
   ===== ОБЩЕЕ =====
   ============================================ */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty .emoji {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

/* ===== НИЖНЯЯ ПАНЕЛЬ НАВИГАЦИИ ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    z-index: 200;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 6px 16px;
    border-radius: 10px;
    transition: all 0.2s;
}

.nav-item.active {
    color: var(--accent);
    background: rgba(108, 92, 231, 0.12);
}

/* ===== СКРОЛЛ ===== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}