@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #0f0f0f;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --text: #f5f5f7;
    --hint: #8e8e93;
    --link: #0a84ff;
    --btn: #2563eb;
    --btn-text: #ffffff;
    --accent: #30d158;
    --danger: #ff453a;
    --card-radius: 16px;
    --nav-h: 64px;

    --glass-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.03),
        inset 1.8px 3px 0px -2px rgba(255, 255, 255, 0.27),
        inset -2px -2px 0px -2px rgba(255, 255, 255, 0.24),
        inset -3px -8px 1px -6px rgba(255, 255, 255, 0.18),
        inset -0.3px -1px 4px 0px rgba(0, 0, 0, 0.24),
        inset -1.5px 2.5px 0px -2px rgba(0, 0, 0, 0.4),
        inset 0px 3px 4px -2px rgba(0, 0, 0, 0.4),
        inset 2px -6.5px 1px -4px rgba(0, 0, 0, 0.2),
        0px 1px 5px 0px rgba(0, 0, 0, 0.2),
        0px 6px 16px 0px rgba(0, 0, 0, 0.16);
    --glass-shadow-active:
        inset 0 0 0 1px rgba(255, 255, 255, 0.03),
        inset 1px 1px 0 0 rgba(255, 255, 255, 0.15),
        inset -1px -1px 0 0 rgba(255, 255, 255, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.15);
    --glass-shadow-indicator:
        inset 0 0 0 1px #ffffff08,
        inset 2px 1px 0 -1px #ffffff45,
        inset -1.5px -1px 0 -1px #ffffff3d,
        inset -2px -6px 1px -5px #ffffff2e,
        inset -1px 2px 3px -1px #0006,
        inset 0 -4px 1px -2px #0003,
        0 3px 6px #00000029;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    background: #0f0f0f;
    background-image:
        radial-gradient(ellipse at 15% 15%, rgba(37, 99, 235, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 80%, rgba(48, 209, 88, 0.07) 0%, transparent 55%);
    background-attachment: fixed;
    color: var(--text);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    overscroll-behavior-y: contain;
}

.hidden { display: none !important; }

/* ─── Кнопки ─── */
.btn {
    padding: 12px 18px; border-radius: 12px; border: none; cursor: pointer;
    background: var(--btn); color: var(--btn-text); font-size: 15px; font-weight: 600;
    transition: opacity .1s, transform .1s;
}
.btn:active { opacity: .85; transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn--block { width: 100%; margin-bottom: 10px; }
.btn--primary { background: var(--btn); color: var(--btn-text); }
.btn--ghost { background: var(--bg-secondary); color: var(--text); }
.btn--add { width: 100%; padding: 9px; font-size: 13px; margin-top: 8px; }

/* ─── Шапка ─── */
.app-header {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    background: rgba(15, 15, 15, 0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    box-shadow: var(--glass-shadow);
}
.app-header__title { font-size: 20px; font-weight: 700; }
.app-header__title span { color: var(--btn); }

.icon-btn {
    background: none; border: none; color: var(--text);
    font-size: 18px; cursor: pointer; padding: 6px 8px; border-radius: 10px;
}
.icon-btn:active { background: rgba(255,255,255,0.08); }

/* ─── Поиск ─── */
.search-bar {
    position: sticky; top: 56px; z-index: 19;
    display: flex; gap: 8px; padding: 10px 16px;
    background: var(--bg); border-bottom: 1px solid rgba(255,255,255,0.06);
}
.search-bar input {
    flex: 1; padding: 10px 14px; border-radius: 12px; border: none;
    background: var(--bg-secondary); color: var(--text); font-size: 15px; outline: none;
}

/* ─── Страницы ─── */
.page { display: none; padding: 12px 16px; animation: fade .2s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ─── Категории-чипсы ─── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
    background: var(--bg-secondary); color: var(--text); font-size: 14px;
    border: none; cursor: pointer; white-space: nowrap; transition: .15s;
}
.chip.active { background: rgba(37, 99, 235, 0.30); color: var(--btn-text); font-weight: 600; box-shadow: var(--glass-shadow-indicator); }

/* ─── Сетка товаров ─── */
.products-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.product-card {
    background: rgba(28, 28, 30, 0.60);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    padding: 14px; cursor: pointer; display: flex; flex-direction: column;
    transition: transform .1s;
}
.product-card:active { transform: scale(.99); }
.product-card__thumb {
    height: 90px; border-radius: 12px; margin-bottom: 10px;
    background: linear-gradient(135deg, #2c2c2e, #1c1c1e);
    display: flex; align-items: center; justify-content: center;
    font-size: 34px; font-weight: 700; color: #fff;
}
.product-card__name { font-size: 14px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.product-card__rating { font-size: 11px; color: var(--hint); margin-bottom: 6px; }
.product-card__price { font-size: 16px; font-weight: 700; margin-top: auto; }

/* ─── Пустые состояния ─── */
.empty { text-align: center; padding: 60px 20px; color: var(--hint); font-size: 15px; line-height: 1.8; }
.loader { text-align: center; padding: 40px; color: var(--hint); }

/* ─── Корзина ─── */
.cart-list { margin-bottom: 4px; }
.cart-item {
    display: flex; align-items: center; gap: 12px; padding: 14px;
    background: rgba(28, 28, 30, 0.60);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    margin-bottom: 10px;
}
.cart-item__info { flex: 1; }
.cart-item__name { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.cart-item__meta { font-size: 13px; color: var(--hint); }
.cart-item__sum { font-size: 15px; font-weight: 700; }
.cart-item__remove {
    width: 30px; height: 30px; border-radius: 8px; border: none;
    background: var(--bg); color: var(--danger); font-size: 15px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}

.promo-box { display: flex; gap: 8px; margin: 16px 0; }
.promo-box input {
    flex: 1; padding: 12px 14px; border-radius: 12px; border: none;
    background: var(--bg-secondary); color: var(--text); font-size: 15px; outline: none;
    text-transform: uppercase;
}

.cart-total {
    background: rgba(28, 28, 30, 0.60);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    padding: 16px; margin-bottom: 12px;
}
.cart-total__row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.cart-total__discount { color: var(--accent); }
.cart-total__final { font-size: 18px; font-weight: 700; margin-top: 10px; margin-bottom: 0; }

/* ─── Заказы ─── */
.order-card {
    background: rgba(28, 28, 30, 0.60);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    padding: 14px; margin-bottom: 10px;
}
.order-card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-card__id { font-weight: 700; }
.order-card__badge { font-size: 11px; padding: 3px 8px; border-radius: 8px; background: rgba(46,160,67,.2); color: var(--accent); }
.order-card__name { font-size: 14px; margin-bottom: 8px; }
.order-card__foot { display: flex; justify-content: space-between; align-items: center; }
.order-card__foot > span:first-child { font-size: 12px; color: var(--hint); }
.order-card__sum { font-size: 15px; font-weight: 700; color: var(--accent); }

/* ─── Профиль ─── */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 20px; }
.profile-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, #2c2c2e, #1c1c1e);
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; font-weight: 700; color: #fff; margin-bottom: 4px;
}
.profile-name { font-size: 20px; font-weight: 700; }
.profile-id { font-size: 13px; color: var(--hint); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat {
    background: rgba(28, 28, 30, 0.60);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    padding: 16px; text-align: center;
}
.stat__val { font-size: 20px; font-weight: 700; }
.stat__label { font-size: 12px; color: var(--hint); margin-top: 4px; }

.ref-box {
    background: rgba(28, 28, 30, 0.60);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    padding: 16px;
}
.ref-box__title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.ref-box__text { font-size: 13px; color: var(--hint); margin-bottom: 12px; line-height: 1.5; }
.ref-code {
    background: var(--bg); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
    font-size: 18px; font-weight: 700; letter-spacing: 2px; text-align: center;
}

/* ─── Нижняя навигация ─── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: flex; height: var(--nav-h);
    background: rgba(15, 15, 15, 0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: var(--glass-shadow);
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
    flex: 1; background: none; border: none; color: var(--hint); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    position: relative; font-size: 11px;
}
.nav-btn.active { color: var(--btn); }
.nav-btn__icon { font-size: 22px; }
.nav-btn__label { font-size: 11px; }
.badge {
    position: absolute; top: 6px; right: 28%;
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
    min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
}

/* ─── Нижний лист товара ─── */
.sheet-overlay {
    position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5);
    display: flex; align-items: flex-end; animation: fade .2s;
}
.sheet {
    width: 100%; background: rgba(18, 18, 18, 0.82);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border-radius: 20px 20px 0 0;
    box-shadow: var(--glass-shadow);
    padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
    max-height: 85vh; overflow-y: auto;
    transform: translateY(100%); transition: transform .25s ease;
}
.sheet.open { transform: translateY(0); }
.sheet__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--hint); margin: 8px auto 16px; opacity: .5; }
.sheet__thumb {
    height: 150px; border-radius: 16px; margin-bottom: 16px;
    background: linear-gradient(135deg, #2c2c2e, #1c1c1e);
    display: flex; align-items: center; justify-content: center;
    font-size: 60px; font-weight: 700; color: #fff;
}
.sheet__title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.sheet__rating { font-size: 13px; color: var(--hint); margin-bottom: 10px; }
.sheet__desc { font-size: 14px; color: var(--hint); line-height: 1.5; margin-bottom: 16px; }
.sheet__price { font-size: 28px; font-weight: 700; margin-bottom: 2px; }
.sheet__stock { font-size: 13px; color: var(--hint); margin-bottom: 18px; }

/* ─── Тост ─── */
.toast {
    position: fixed; bottom: calc(var(--nav-h) + 20px); left: 50%; transform: translateX(-50%);
    background: #000; color: #fff; padding: 12px 20px; border-radius: 12px;
    font-size: 14px; z-index: 100; opacity: .95; max-width: 80%; text-align: center;
    animation: fade .2s;
}
