:root {
    --bg: #071312;
    --surface: #0d1d1b;
    --surface-strong: #132724;
    --surface-soft: rgba(255, 255, 255, 0.055);
    --text: #f4f8f7;
    --muted: #90a5a1;
    --green: #29a8ff;
    --green-deep: #0878c9;
    --orange: #e8b94f;
    --line: rgba(255, 255, 255, 0.09);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
    --tg-safe-top: var(--tg-content-safe-area-inset-top, 0px);
    --tg-safe-bottom: var(--tg-content-safe-area-inset-bottom, 0px);
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    background:
        radial-gradient(circle at 90% -10%, rgba(41, 168, 255, 0.15), transparent 35%),
        radial-gradient(circle at -15% 35%, rgba(232, 185, 79, 0.08), transparent 30%),
        var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.app-shell {
    width: min(100%, 760px);
    min-height: 100vh;
    margin: 0 auto;
    padding: calc(12px + var(--tg-safe-top)) 18px calc(102px + var(--tg-safe-bottom));
}

.topbar {
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 10;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
}

.brand-emblem {
    width: 46px;
    height: 46px;
    object-fit: contain;
    filter: drop-shadow(0 5px 12px rgba(23, 138, 255, 0.24));
}

.brand-name {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 5px;
    align-items: baseline;
    font-size: 1.05rem;
    font-weight: 850;
    letter-spacing: 0.015em;
}

.brand-name b {
    color: #e7bb55;
    font-size: 0.85em;
    letter-spacing: 0.12em;
}

.brand-name small {
    grid-column: 1 / -1;
    margin-top: -1px;
    color: #69bfff;
    font-size: 0.48em;
    font-style: italic;
    font-weight: 650;
    letter-spacing: 0.16em;
}

.avatar {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(232, 185, 79, 0.55);
    border-radius: 50%;
    color: #ffffff;
    background: linear-gradient(145deg, #168ee2, #063c79);
    box-shadow: inset 0 0 0 1px rgba(255, 214, 112, 0.36), 0 8px 20px rgba(0, 94, 180, 0.25);
    font-weight: 800;
    cursor: pointer;
}

.view { display: none; animation: view-in 240ms ease both; }
.view.is-active { display: block; }

@keyframes view-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero {
    position: relative;
    min-height: 380px;
    overflow: hidden;
    padding: 46px 24px 30px;
    border: 1px solid var(--line);
    border-radius: 30px;
    background:
        linear-gradient(145deg, rgba(41, 168, 255, 0.12), transparent 48%),
        linear-gradient(155deg, #0d2031 0%, #08131c 70%);
    box-shadow: var(--shadow);
}

.hero::before,
.hero::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(41, 168, 255, 0.18);
    border-radius: 50%;
    pointer-events: none;
}

.hero::before { width: 260px; height: 260px; right: -100px; top: -88px; }
.hero::after { width: 180px; height: 180px; right: -60px; top: -48px; }

.eyebrow {
    margin: 0 0 10px;
    color: var(--green);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.18em;
}

h1, h2, p { margin-top: 0; }

.hero h1 {
    max-width: 510px;
    margin-bottom: 16px;
    font-size: clamp(2rem, 9vw, 3.8rem);
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.hero-copy {
    max-width: 380px;
    margin-bottom: 28px;
    color: var(--muted);
    line-height: 1.55;
}

.primary-button,
.secondary-button {
    border: 0;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 800;
    transition: transform 160ms ease, filter 160ms ease;
}

.primary-button {
    display: inline-flex;
    gap: 22px;
    align-items: center;
    padding: 15px 19px;
    color: #052017;
    background: linear-gradient(135deg, #f0c765 0%, #29a8ff 100%);
    box-shadow: 0 12px 32px rgba(41, 168, 255, 0.22);
}

.secondary-button { padding: 13px 20px; color: var(--text); background: var(--surface-strong); }
.primary-button:active, .secondary-button:active { transform: scale(0.97); }

.signal {
    position: absolute;
    right: 24px;
    bottom: 26px;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 34px;
    opacity: 0.48;
}

.signal span { width: 3px; border-radius: 4px; background: var(--green); animation: signal 1.2s ease-in-out infinite; }
.signal span:nth-child(1), .signal span:nth-child(5) { height: 10px; }
.signal span:nth-child(2), .signal span:nth-child(4) { height: 22px; animation-delay: 120ms; }
.signal span:nth-child(3) { height: 34px; animation-delay: 240ms; }
@keyframes signal { 0%, 100% { transform: scaleY(0.6); } 50% { transform: scaleY(1); } }

.news-card {
    display: flex;
    gap: 13px;
    align-items: flex-start;
    margin-top: 16px;
    padding: 17px;
    border: 1px solid rgba(232, 185, 79, 0.20);
    border-radius: 18px;
    background: rgba(232, 185, 79, 0.07);
}

.news-card p { margin: 1px 0 0; color: #d8e2e0; line-height: 1.45; white-space: pre-line; }
.news-pill { flex: 0 0 auto; padding: 5px 8px; border-radius: 8px; color: #ffe2a0; background: rgba(232, 185, 79, 0.16); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; }
.is-hidden { display: none !important; }

.section-block { margin-top: 34px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2, .page-title h1 { margin-bottom: 0; letter-spacing: -0.035em; }
.text-button { padding: 8px 0; border: 0; color: var(--green); background: transparent; cursor: pointer; font-weight: 700; }

.featured-grid, .catalog-grid { display: grid; gap: 14px; }
.featured-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.catalog-grid { grid-template-columns: 1fr; }

.product-card {
    position: relative;
    overflow: hidden;
    min-height: 196px;
    padding: 19px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(150deg, var(--surface-strong), var(--surface));
}

.product-card::after {
    content: "";
    position: absolute;
    width: 100px;
    height: 100px;
    right: -46px;
    bottom: -46px;
    border: 18px solid rgba(41, 168, 255, 0.055);
    border-radius: 50%;
}

.product-kind { color: var(--green); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.product-card h3 { margin: 11px 0 8px; font-size: 1.1rem; line-height: 1.2; }
.product-description { min-height: 42px; margin-bottom: 18px; color: var(--muted); font-size: 0.83rem; line-height: 1.42; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-footer { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.product-price small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 0.66rem; }
.product-price strong { font-size: 1.25rem; }
.round-button { position: relative; z-index: 1; width: 36px; height: 36px; border: 1px solid rgba(41, 168, 255, 0.32); border-radius: 50%; color: var(--green); background: rgba(41, 168, 255, 0.08); cursor: pointer; font-size: 1.15rem; }

.page-title { padding: 34px 4px 20px; }
.page-title h1 { margin-bottom: 8px; font-size: clamp(2rem, 8vw, 3.2rem); }
.page-title > p:last-child { color: var(--muted); line-height: 1.5; }

.filter-row { display: flex; gap: 8px; overflow-x: auto; margin: 0 -18px 18px; padding: 0 18px 5px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-button { flex: 0 0 auto; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-soft); cursor: pointer; }
.filter-button.is-active { border-color: rgba(41, 168, 255, 0.35); color: #021a2b; background: var(--green); font-weight: 800; }

.catalog-grid .product-card { min-height: 180px; }
.account-summary { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 12px; }
.balance-card, .stat-card, .account-section, .empty-state { border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.balance-card, .stat-card { padding: 20px; }
.balance-card span, .stat-card span { color: var(--muted); font-size: 0.75rem; }
.balance-card strong { display: block; margin-top: 8px; font-size: 2rem; letter-spacing: -0.04em; }
.stat-card strong { display: block; margin-top: 12px; color: var(--green); font-size: 1.6rem; }
.account-section { margin-top: 14px; padding: 20px; }
.account-section h2 { margin-bottom: 14px; font-size: 1rem; }
.service-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.service-row:first-of-type { border-top: 0; }
.service-row p { margin: 0 0 4px; font-weight: 700; }
.service-row small { color: var(--muted); }
.status-pill { padding: 5px 8px; border-radius: 999px; color: var(--green); background: rgba(41, 168, 255, 0.1); font-size: 0.7rem; font-weight: 800; }
.empty-state { padding: 30px 22px; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); }

.error-panel { padding: 72px 24px; text-align: center; }
.error-mark { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 18px; border-radius: 50%; color: #071312; background: var(--orange); font-size: 1.4rem; font-weight: 900; }
.error-panel p { color: var(--muted); }

.bottom-nav {
    position: fixed;
    z-index: 50;
    left: 50%;
    bottom: calc(12px + var(--tg-safe-bottom));
    width: min(calc(100% - 28px), 724px);
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    background: rgba(10, 25, 23, 0.88);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.nav-item { display: flex; flex-direction: column; gap: 4px; align-items: center; padding: 8px; border: 0; border-radius: 15px; color: #718783; background: transparent; cursor: pointer; font-size: 0.68rem; }
.nav-item.is-active { color: var(--green); background: rgba(41, 168, 255, 0.07); }
.nav-icon { height: 20px; font-size: 1.35rem; line-height: 17px; }
.grid-icon { display: grid; grid-template-columns: repeat(2, 6px); gap: 3px; align-content: center; }
.grid-icon i { width: 6px; height: 6px; border: 1.5px solid currentColor; border-radius: 2px; }
.user-icon { position: relative; width: 18px; border: 1.5px solid currentColor; border-radius: 9px 9px 5px 5px; border-top-color: transparent; }
.user-icon::before { content: ""; position: absolute; width: 7px; height: 7px; left: 4px; top: -5px; border: 1.5px solid currentColor; border-radius: 50%; }

.skeleton { overflow: hidden; position: relative; border-radius: 20px; background: rgba(255,255,255,.045); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); animation: shimmer 1.4s infinite; }
.product-skeleton { height: 196px; }
.catalog-skeleton { height: 180px; }
.account-skeleton { height: 270px; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

@media (min-width: 640px) {
    .app-shell { padding-left: 28px; padding-right: 28px; }
    .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-row { margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px; }
}

@media (max-width: 390px) {
    .app-shell { padding-left: 14px; padding-right: 14px; }
    .hero { min-height: 350px; padding: 38px 20px 26px; }
    .featured-grid { grid-template-columns: 1fr; }
    .featured-grid .product-card:nth-child(n+3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
