:root {
    --bg-primary: #fff;
    --bg-secondary: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #8e8e93;
    --border-color: #e5e5ea;
    --primary: #007aff;
    --primary-dark: #0056cc;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== SPLASH ===== */
#splash { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--primary); z-index: 9999; display: flex; align-items: center; justify-content: center; animation: fadeOut 0.4s 1.5s forwards; }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
.splash-logo { text-align: center; color: #fff; }
.splash-icon { font-size: 4rem; }
.splash-text { font-size: 1.5rem; font-weight: 600; letter-spacing: 2px; }

/* ===== HEADER ===== */
.app-header { position: sticky; top: 0; background: var(--bg-primary); padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 0.5px solid var(--border-color); z-index: 110; height: 52px; backdrop-filter: blur(10px); }
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }
.back-btn { font-size: 1.5rem; text-decoration: none; color: var(--primary); padding: 4px; }
.header-title { font-size: 1.1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.icon-btn { font-size: 1.3rem; text-decoration: none; position: relative; color: var(--text-primary); padding: 4px; }
.cart-badge { position: absolute; top: -4px; right: -6px; background: var(--danger); color: #fff; font-size: 0.65rem; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 600; }

/* ===== LAYOUT ===== */
.shop-layout { display: flex; max-width: 1400px; margin: 0 auto; min-height: calc(100vh - 52px); }
.sidebar { width: 280px; background: var(--bg-primary); padding: 20px; border-right: 0.5px solid var(--border-color); position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto; flex-shrink: 0; }
.sidebar-logo { font-size: 1.5rem; font-weight: 700; color: var(--primary); text-decoration: none; display: block; margin-bottom: 24px; }
.sidebar-title { font-size: 0.75rem; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; font-weight: 600; letter-spacing: 0.5px; }
.category-list { list-style: none; }
.category-link, .sidebar-link { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 10px; text-decoration: none; color: var(--text-primary); font-weight: 500; font-size: 0.95rem; transition: background 0.15s; }
.category-link:hover, .sidebar-link:hover { background: var(--bg-secondary); }
.category-link.active { background: var(--primary); color: #fff; }
.category-link.new-link { border: 1.5px solid var(--warning); }
.category-count { background: var(--bg-secondary); padding: 2px 10px; border-radius: 20px; font-size: 0.8rem; }
.category-link.active .category-count { background: rgba(255,255,255,0.2); color: #fff; }
.sidebar-section { margin-bottom: 24px; }
.main-content { flex: 1; padding: 16px; padding-bottom: 90px; min-width: 0; }
.overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 105; }
.overlay.show { display: block; }

/* ===== MOBILE HEADER ===== */
.mobile-header { display: none; align-items: center; justify-content: space-between; padding: 4px 0; margin-bottom: 12px; }
.menu-btn { font-size: 1.5rem; background: none; border: none; cursor: pointer; color: var(--text-primary); }
.mobile-logo { font-size: 1.3rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.cart-btn { position: relative; font-size: 1.5rem; text-decoration: none; color: var(--text-primary); }

/* ===== SEARCH ===== */
.search-wrapper { display: flex; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.search-input { flex: 1; padding: 12px 16px; border: none; background: transparent; font-size: 1rem; outline: none; color: var(--text-primary); }
.search-input::placeholder { color: var(--text-secondary); }
.search-btn { padding: 12px 20px; background: var(--primary); color: #fff; border: none; font-weight: 500; cursor: pointer; font-size: 0.95rem; }

/* ===== SECTION TITLE ===== */
.section-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 16px; }

/* ===== PRODUCTS GRID ===== */
.products-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 768px) { .products-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 1024px) { .products-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }

.product-card { background: var(--bg-primary); border-radius: 14px; overflow: hidden; box-shadow: var(--card-shadow); cursor: pointer; display: flex; flex-direction: column; border: 0.5px solid var(--border-color); }
.product-image { aspect-ratio: 1; background: var(--bg-secondary); position: relative; flex-shrink: 0; }
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.no-image { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 2.5rem; color: var(--text-secondary); }
.new-badge { position: absolute; top: 8px; left: 8px; background: var(--warning); color: #fff; padding: 3px 8px; border-radius: 12px; font-size: 0.65rem; font-weight: 600; z-index: 1; }
.product-info { padding: 10px 12px; display: flex; flex-direction: column; flex: 1; }
.product-name { font-weight: 500; margin-bottom: 4px; font-size: 0.85rem; line-height: 1.3; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-price { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.btn-add { width: 100%; padding: 9px; background: var(--primary); color: #fff; border: none; border-radius: 10px; font-weight: 500; cursor: pointer; margin-top: auto; font-size: 0.85rem; }

/* ===== PAGINATION ===== */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 24px; }
.page-link { padding: 8px 14px; background: var(--bg-primary); border-radius: 10px; text-decoration: none; font-weight: 500; font-size: 0.9rem; color: var(--text-primary); }
.page-link.active { background: var(--primary); color: #fff; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; background: var(--bg-primary); border-radius: 16px; }
.empty-icon { font-size: 4rem; margin-bottom: 16px; }

/* ===== BUTTONS ===== */
.btn { display: inline-block; padding: 12px 24px; border-radius: 12px; font-weight: 600; text-decoration: none; border: none; cursor: pointer; font-size: 0.95rem; text-align: center; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: var(--bg-primary); color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }

/* ===== BOTTOM NAV ===== */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-primary); border-top: 0.5px solid var(--border-color); padding: 8px 16px; padding-bottom: max(8px, env(safe-area-inset-bottom)); z-index: 100; }
.bottom-items { display: flex; justify-content: space-around; max-width: 500px; margin: 0 auto; }
.bottom-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--text-secondary); font-size: 0.7rem; padding: 6px 14px; border-radius: 20px; min-width: 55px; }
.bottom-item.active { color: var(--primary); }
.bottom-icon { font-size: 1.5rem; margin-bottom: 2px; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 100px; left: 20px; right: 20px; background: #1a1a1a; color: #fff; padding: 14px 20px; border-radius: 14px; text-align: center; max-width: 400px; margin: 0 auto; display: none; z-index: 200; animation: slideUp 0.3s; font-weight: 500; }
@keyframes slideUp { from { transform: translateY(100px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== SUCCESS PAGE ===== */
.success-container { max-width: 440px; margin: 40px auto; background: var(--bg-primary); border-radius: 24px; padding: 36px 28px; text-align: center; box-shadow: var(--card-shadow); }
.success-icon { font-size: 4rem; margin-bottom: 16px; }
.success-title { font-size: 1.8rem; font-weight: 700; color: var(--success); margin-bottom: 12px; }
.order-number { font-size: 1.8rem; font-weight: 700; background: var(--bg-secondary); padding: 16px; border-radius: 16px; margin: 20px 0; }

/* ===== CONTAINER ===== */
.container { max-width: 800px; margin: 0 auto; padding: 16px; padding-bottom: 100px; }

/* ===== ORDERS ===== */
.order-card { background: var(--bg-primary); border-radius: 16px; padding: 18px; margin-bottom: 12px; box-shadow: var(--card-shadow); cursor: pointer; border: 0.5px solid var(--border-color); }
.order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; flex-wrap: wrap; gap: 6px; }
.order-number { font-weight: 600; color: var(--primary); font-size: 0.95rem; }
.order-status { padding: 3px 10px; border-radius: 16px; font-size: 0.75rem; font-weight: 500; }
.status-new { background: #e8f0fe; color: #1967d2; }
.status-confirmed { background: #fef7e0; color: #e37400; }
.status-completed { background: #e6f4ea; color: #137333; }
.status-cancelled { background: #fce8e6; color: #c5221f; }
.order-date { color: var(--text-secondary); font-size: 0.85rem; margin: 4px 0; }
.order-total { font-size: 1.1rem; font-weight: 600; margin-top: 10px; padding-top: 10px; border-top: 0.5px solid var(--border-color); }
.order-card-actions { margin-top: 10px; padding-top: 10px; border-top: 0.5px solid var(--border-color); display: flex; gap: 8px; }

/* ===== ORDER DETAIL ===== */
.order-detail-card { background: var(--bg-primary); border-radius: 16px; padding: 20px; box-shadow: var(--card-shadow); }
.order-detail-header { display: flex; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.order-status-badge { padding: 5px 14px; border-radius: 16px; font-weight: 500; font-size: 0.9rem; }
.order-detail-header .status-new { background: #e8f0fe; color: #1967d2; }
.order-detail-header .status-confirmed { background: #fef7e0; color: #e37400; }
.order-detail-header .status-completed { background: #e6f4ea; color: #137333; }
.order-detail-header .status-cancelled { background: #fce8e6; color: #c5221f; }
.order-number-display { font-size: 1.2rem; font-weight: 600; margin-bottom: 14px; color: var(--primary); }
.order-customer { background: var(--bg-secondary); padding: 12px; border-radius: 12px; margin-bottom: 14px; font-size: 0.95rem; }
.order-items-list { margin: 14px 0; }
.order-item-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 0.5px solid var(--border-color); font-size: 0.9rem; }
.order-item-name { flex: 1; }
.order-item-qty { margin: 0 10px; color: var(--text-secondary); }
.order-item-price { font-weight: 500; white-space: nowrap; }
.order-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ===== PRODUCT PAGE ===== */
.gallery { background: var(--bg-primary); border-radius: 16px; overflow: hidden; margin-bottom: 12px; }
.main-image { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.main-image img { width: 100%; height: 100%; object-fit: contain; }
.no-image-large { font-size: 4rem; color: var(--text-secondary); }
.thumbs { display: flex; gap: 8px; padding: 12px; overflow-x: auto; }
.thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; flex-shrink: 0; }
.thumb.active { border-color: var(--primary); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.content { background: var(--bg-primary); border-radius: 16px; padding: 18px; margin-bottom: 12px; }
.product-category { color: var(--text-secondary); margin-bottom: 6px; font-size: 0.9rem; }
.product-category a { color: var(--text-secondary); text-decoration: none; }
.product-price-large { font-size: 1.8rem; font-weight: 700; margin: 14px 0; }
.stock-badge { display: inline-block; padding: 5px 14px; border-radius: 16px; font-weight: 500; font-size: 0.9rem; }
.stock-badge.in-stock { background: #e6f4ea; color: #137333; }
.product-description { line-height: 1.6; margin-top: 14px; font-size: 0.95rem; color: #3c3c43; }

/* ===== BUY BAR ===== */
.buy-section { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-primary); padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); box-shadow: 0 -1px 3px rgba(0,0,0,0.06); display: flex; gap: 10px; z-index: 90; max-width: 800px; margin: 0 auto; }
.qty-control { display: flex; align-items: center; gap: 6px; background: var(--bg-secondary); padding: 3px; border-radius: 12px; }
.qty-btn { width: 40px; height: 40px; border: none; background: var(--bg-primary); border-radius: 10px; font-size: 1.1rem; cursor: pointer; color: var(--text-primary); }
.qty-input { width: 44px; text-align: center; border: none; background: transparent; font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.btn-cart { flex: 1; padding: 14px; background: var(--primary); color: #fff; border: none; border-radius: 12px; font-weight: 600; font-size: 1rem; cursor: pointer; }

/* ===== MODAL ===== */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.95); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-image-wrapper { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.modal img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.3s; }
.modal-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; background: rgba(255,255,255,0.15); border: none; border-radius: 50%; color: #fff; font-size: 1.3rem; cursor: pointer; z-index: 201; display: flex; align-items: center; justify-content: center; }

/* ===== CART ===== */
.cart-container { max-width: 800px; margin: 0 auto; padding: 16px; }
.cart-message { padding: 12px 16px; border-radius: 12px; margin-bottom: 10px; font-size: 0.9rem; }
.cart-message.error { background: #fce8e6; color: #c5221f; }
.cart-message.warning { background: #fef7e0; color: #e37400; }

.cart-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.cart-item {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    border: 0.5px solid var(--border-color);
    align-items: center;
}
.cart-item-image {
    width: 90px;
    height: 90px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.cart-item-image img { width: 100%; height: 100%; object-fit: cover; }
.no-image-small { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 1.8rem; color: var(--text-secondary); }

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; margin-bottom: 4px; font-size: 0.95rem; }
.cart-item-name a { color: var(--text-primary); text-decoration: none; }
.cart-item-price { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.cart-item-stock { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; }
.cart-item-controls { display: flex; align-items: center; gap: 12px; }
.cart-item-controls .qty-control { background: var(--bg-secondary); padding: 2px; border-radius: 8px; }
.cart-item-controls .qty-btn { width: 34px; height: 34px; font-size: 1rem; }
.cart-item-controls .qty-input { width: 40px; font-size: 0.95rem; }
.remove-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.9rem; padding: 6px 10px; }

/* Итого и оформление */
.cart-summary {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    border: 0.5px solid var(--border-color);
    position: sticky;
    bottom: 16px;
}
.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.95rem;
}
.cart-total-row.total {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 0.5px solid var(--border-color);
}
.cart-total-row small { color: var(--text-secondary); font-weight: 400; }

.checkout-form { margin-top: 16px; }
.checkout-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.checkout-form input:focus { outline: none; border-color: var(--primary); }
.checkout-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .shop-layout { display: block; }
    .sidebar { position: fixed; top: 0; left: -100%; width: 85%; max-width: 320px; z-index: 120; transition: left 0.3s; height: 100vh; padding-top: 60px; }
    .sidebar.open { left: 0; }
    .mobile-header { display: flex; }
    .bottom-nav { display: block; }
    .main-content { padding-bottom: 80px; }
    .cart-item { align-items: flex-start; }
    .cart-item-image { width: 100px; height: 100px; }
    .btn { padding: 12px 20px; }
    .order-actions { flex-direction: column; }
    .order-actions .btn { width: 100%; }
    .header-title { max-width: 140px; font-size: 1rem; }
    .buy-section { padding: 10px 14px; }
    .qty-btn { width: 36px; height: 36px; }
}