:root {
    /* Светлая тема в духе Antarctic / iOS: сгруппированный фон и белые карточки */
    --bg: #f2f2f7;
    --bg-card: #ffffff;
    --bg-card-hover: #f9f9f9;
    --bg-grouped: #f2f2f7;
    --border: rgba(60, 60, 67, 0.18);
    --separator: rgba(60, 60, 67, 0.12);
    --text: #000000;
    --text-muted: #8e8e93;
    --accent: #007aff;
    --accent-hover: #0062cc;
    --accent-bg: rgba(0, 122, 255, 0.12);
    --radius: 20px;
    --radius-sm: 14px;
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Manrope', system-ui, sans-serif;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.06);
    --bottom-nav-h: 64px;
    --header-h: 56px;
    /* Ширина как у типичного смартфона — на ПК колонка совпадает с мобильной вёрсткой */
    --app-column-max: 430px;
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
}

/* Telegram Mini App: фиксированный светлый фон кошелька, без подстановки тёмного tg theme */
body.tg-miniapp {
    background: var(--bg);
    color: var(--text);
}

html {
    width: 100%;
    overflow-x: hidden;
    background: var(--bg);
    color-scheme: light;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    padding-top: var(--safe-top);
    -webkit-font-smoothing: antialiased;
    width: 100%;
    overflow-x: hidden;
}

/*
 * Каркас: колонка как на телефоне. Ширину задаём .app-shell, не body —
 * иначе position:fixed у таббара привязан к viewport и «уезжает» относительно контента.
 */
.miniapp-body {
    margin: 0;
}

.app-shell {
    width: 100%;
    max-width: var(--app-column-max);
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    box-sizing: border-box;
    background: var(--bg);
    color: var(--text);
    color-scheme: light;
}

/* Верхняя шапка — профиль слева */
.header-top {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-card);
    border-bottom: 1px solid var(--separator);
    padding: 0.75rem 1rem;
    padding-left: calc(1rem + var(--safe-top));
}

.profile-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 1rem;
}

.profile-link:hover {
    opacity: 0.85;
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.header-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
}

.header-app-name {
    flex: 1;
}

.header-arrow {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-user-label {
    margin-left: 0.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Контент на всю ширину колонки (на мобиле = экран, на десктопе = та же 430px) */
.main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding: 1rem max(1rem, env(safe-area-inset-left)) 1rem max(1rem, env(safe-area-inset-right));
    box-sizing: border-box;
    min-height: calc(100vh - var(--header-h) - var(--bottom-nav-h) - var(--safe-bottom));
}

.main-with-bottom-nav {
    padding-bottom: calc(1.5rem + var(--safe-bottom));
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}

.bonus-dev-placeholder {
    text-align: center;
    padding: 2rem 1.25rem 2.35rem;
}

.bonus-dev-placeholder__title {
    margin-bottom: 0.65rem;
}

.bonus-dev-placeholder__text {
    margin: 0 auto;
    max-width: 22rem;
    line-height: 1.55;
}

.card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.card-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.badge-warning {
    background: rgba(234, 179, 8, 0.2);
    color: #ca8a04;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.badge-muted {
    background: var(--bg-card-hover);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.card--expired {
    opacity: 0.92;
    border-style: dashed;
}

.subscriptions-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Страница установки: плитки по платформам */
.install-lead {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.install-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.install-tile {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 0;
}

.install-tile.card.install-tile--accordion {
    padding: 0;
    overflow: hidden;
}

.install-tile__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    width: 100%;
    margin: 0;
    padding: 0.9rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    text-align: left;
    transition: background 0.15s ease;
    box-sizing: border-box;
}

.install-tile__toggle:hover {
    background: var(--bg-grouped);
}

.install-tile__toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.install-tile__head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    min-width: 0;
}

.install-tile__icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--bg-grouped);
    color: var(--accent);
    line-height: 0;
}

.install-tile__icon svg {
    display: block;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Робот Android в исходном path визуально «тяжелее» сверху — лёгкий сдвиг по вертикали */
.install-tile__icon--android svg {
    transform: translateY(1px);
}

.install-tile__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.install-tile__chev-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: #c7c7cc;
}

.install-tile__chev {
    transition: transform 0.25s ease;
}

.install-tile--open .install-tile__chev {
    transform: rotate(180deg);
}

.install-tile__expand {
    border-top: 1px solid var(--separator);
    background: var(--bg-grouped);
}

.install-tile__expand-inner {
    padding: 0.85rem 1rem 1rem;
    box-sizing: border-box;
}

.install-tile__actions {
    margin-bottom: 0.85rem;
}

.install-tile__actions:last-child {
    margin-bottom: 0;
}

.install-tile__download {
    text-decoration: none !important;
}

.install-tile__steps {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.install-tile__steps li {
    margin-bottom: 0.45rem;
}

.install-tile__steps li:last-child {
    margin-bottom: 0;
}

.install-tile__manual {
    margin: 0;
    text-align: left;
}

.install-step {
    margin-bottom: 1rem;
}

.install-step:last-child {
    margin-bottom: 0;
}

.install-step__title {
    font-size: 0.88rem;
    font-weight: 700;
    margin: 0 0 0.45rem;
    color: var(--text);
}

.install-step p {
    margin: 0 0 0.45rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.install-step p:last-child {
    margin-bottom: 0;
}

.install-step__list {
    margin: 0;
    padding-left: 1.15rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.install-step__list li {
    margin-bottom: 0.4rem;
}

.install-step__list li:last-child {
    margin-bottom: 0;
}

.install-step a {
    color: var(--accent);
    font-weight: 500;
}

/* Подписки: белая карточка-аккордеон (стиль Antarctic / iOS) */
.sub-wallet {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 0 0.25rem;
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.sub-wallet__heading {
    margin: 0 1rem 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.sub-wallet__list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.sub-wallet__item {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-top: 1px solid var(--separator);
}

.sub-wallet__item:first-of-type {
    border-top: none;
}

.sub-wallet__row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.85rem 1rem;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: var(--text);
    transition: background 0.15s ease;
}

.sub-wallet__row:hover {
    background: var(--bg-grouped);
}

.sub-wallet__row:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.sub-wallet__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--sub-icon-hue, 210), 72%, 52%);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}

.sub-wallet__label-block {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sub-wallet__name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-wallet__hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-wallet__values {
    flex-shrink: 0;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    align-items: flex-end;
    max-width: 42%;
}

.sub-wallet__val-main {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.sub-wallet__val-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sub-wallet__chev-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: #c7c7cc;
}

.sub-wallet__chev {
    transition: transform 0.25s ease;
}

.sub-wallet__item--open .sub-wallet__chev {
    transform: rotate(180deg);
}

.sub-wallet__item--expired .sub-wallet__val-main {
    color: var(--text-muted);
}

.sub-wallet__expand {
    background: var(--bg-grouped);
    border-top: 1px solid var(--separator);
}

.sub-wallet__expand-inner {
    padding: 0.85rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    box-sizing: border-box;
}

.sub-wallet__badges {
    margin-bottom: 0;
}

.sub-wallet .badge-muted {
    background: rgba(142, 142, 147, 0.12);
    color: var(--text-muted);
    border-color: var(--separator);
}

.sub-wallet__date {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.45;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.sub-wallet__date-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
}

.sub-wallet__date-value,
.sub-wallet__date .code {
    color: var(--text);
    max-width: 100%;
    box-sizing: border-box;
    word-break: break-word;
}

.sub-wallet__date .code {
    font-weight: 600;
}

.sub-wallet__muted {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.sub-wallet .btn-outline {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--bg-card);
}

.sub-wallet .btn-outline:hover {
    background: var(--accent-bg);
    color: var(--accent);
    border-color: var(--accent);
}

.sub-wallet__hint-copy {
    color: #34c759;
}

.sub-wallet__no-link {
    margin: 0;
}

.sub-wallet__btn {
    flex-shrink: 0;
}

.sub-wallet__delete {
    margin-top: 0;
    padding: 0.45rem 0;
    width: 100%;
    border: none;
    background: transparent;
    color: #ff3b30;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.sub-wallet__delete:hover:not(:disabled) {
    background: rgba(255, 59, 48, 0.08);
}

.sub-wallet__delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sub-wallet__empty {
    margin: 0 1rem 1.1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.btn-block {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    cursor: pointer;
}

button.btn {
    font-family: inherit;
}

.copy-subscription-hint {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: var(--accent);
    margin-top: 0.5rem;
    min-height: 1.2em;
}

/* Карточка баланса — белая, как Antarctic Wallet */
.balance-hero {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem 1.15rem;
    margin-bottom: 0.85rem;
    box-shadow: var(--shadow-card);
}

.balance-hero__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.balance-hero__label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.balance-hero__eye {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: -0.35rem -0.35rem -0.35rem 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 10px;
    transition: color 0.15s, background 0.15s;
}

.balance-hero__eye:hover {
    color: var(--text);
    background: var(--bg-grouped);
}

/* Два SVG в одной кнопке — в ряд не ставим, только один слой (иначе видны оба «глаза») */
.balance-hero__eye .balance-hero__icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: block;
    pointer-events: none;
}

.balance-hero__eye .balance-hero__icon--show {
    display: none;
}

.balance-hero--concealed .balance-hero__eye .balance-hero__icon--hide {
    display: none;
}

.balance-hero--concealed .balance-hero__eye .balance-hero__icon--show {
    display: block;
}

.balance-hero__amount-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
}

.balance-hero__digits {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, var(--font-sans);
    line-height: 1.1;
}

.balance-hero__mask {
    display: none;
    letter-spacing: 0.2em;
}

.balance-hero--concealed .balance-hero__value {
    display: none;
}

.balance-hero--concealed .balance-hero__mask {
    display: inline;
}

.balance-hero__rub {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.balance-hero__chevron {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    margin-left: -0.1rem;
}

/* Плитки действий под балансом — на всю ширину блока, как карточка «Общий баланс» */
.action-tiles {
    display: flex;
    justify-content: stretch;
    align-items: stretch;
    gap: 0.5rem;
    margin: 0 0 1.25rem;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.action-tile {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-decoration: none !important;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

/* Telegram Desktop WebView: иначе <a> остаётся «браузерной» синей подчёркнутой ссылкой */
.app-shell nav.action-tiles a.action-tile,
.app-shell nav.action-tiles a.action-tile:link,
.app-shell nav.action-tiles a.action-tile:visited,
.app-shell nav.action-tiles a.action-tile:hover,
.app-shell nav.action-tiles a.action-tile:active {
    color: var(--text) !important;
    -webkit-text-fill-color: currentColor;
    text-decoration: none !important;
}

.app-shell nav.action-tiles button.action-tile {
    color: var(--text) !important;
}

.action-tile__squircle {
    width: 100%;
    box-sizing: border-box;
    min-height: 56px;
    margin: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--separator);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    transition: background 0.2s, transform 0.12s ease, box-shadow 0.2s;
}

.action-tile:hover .action-tile__squircle {
    background: var(--bg-card-hover);
}

.action-tile:active .action-tile__squircle {
    transform: scale(0.97);
}

.action-tile__label {
    display: block;
    margin-top: 0.45rem;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    hyphens: auto;
    color: var(--text);
}

body.dark-theme:not(.miniapp-body) .action-tile__label {
    color: rgba(255, 255, 255, 0.92);
}

.action-tile--btnwrap {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    appearance: none;
    -webkit-appearance: none;
}

.action-tile--btnwrap:hover .action-tile__squircle {
    background: var(--bg-card-hover);
}

.action-tile--btnwrap:active .action-tile__squircle {
    transform: scale(0.97);
}

/* Bottom sheet (подтверждение подписки) */
.bottom-sheet[hidden] {
    display: none !important;
}

.bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 300;
    pointer-events: none;
    visibility: hidden;
}

.bottom-sheet.bottom-sheet--open {
    pointer-events: auto;
    visibility: visible;
}

.bottom-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    opacity: 0;
    transition: opacity 0.28s ease;
}

.bottom-sheet--open .bottom-sheet__backdrop {
    opacity: 1;
}

.bottom-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: min(100%, var(--app-column-max));
    margin: 0 auto;
    box-sizing: border-box;
    background: var(--bg-card);
    color: var(--text);
    border-radius: 16px 16px 0 0;
    padding: 0.25rem 1.2rem calc(1.35rem + var(--safe-bottom));
    transform: translateY(105%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.12);
}

.bottom-sheet--open .bottom-sheet__panel {
    transform: translateY(0);
}

.bottom-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0 0.85rem;
    border-bottom: 1px solid var(--separator);
}

.bottom-sheet__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--text);
}

.bottom-sheet__close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 12px;
    background: var(--bg-grouped);
    color: var(--text-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.bottom-sheet__close:hover {
    background: #e5e5ea;
    color: var(--text);
}

.bottom-sheet__body {
    padding-top: 1.1rem;
}

.bottom-sheet__lead {
    font-size: 0.95rem;
    line-height: 1.45;
    margin: 0 0 0.65rem;
    color: var(--text);
}

.bottom-sheet__lead strong {
    color: var(--text);
    font-weight: 700;
}

.bottom-sheet__muted {
    font-size: 0.82rem;
    line-height: 1.4;
    margin: 0 0 1rem;
    color: var(--text-muted);
}

.bottom-sheet__warn {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.25);
    color: #c00;
    font-size: 0.88rem;
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    margin-bottom: 1rem;
    line-height: 1.35;
}

.bottom-sheet__confirm {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.bottom-sheet__confirm:hover:not(:disabled) {
    background: var(--accent-hover);
}

.bottom-sheet__confirm:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Bottom sheet — продление */
.bottom-sheet--renew .bottom-sheet__panel {
    background: var(--bg-card);
    border: none;
}

.bottom-sheet--renew .bottom-sheet__header {
    border-bottom-color: var(--separator);
}

.renewal-sheet__body {
    padding-top: 0.5rem;
}

.renewal-sheet__hint {
    margin-bottom: 1rem !important;
}

.renewal-sheet__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.renewal-sheet__list > li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.renewal-sheet__option {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
    padding: 0.9rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-grouped);
    color: var(--text);
    cursor: pointer;
    transition: background 0.18s, transform 0.12s;
    -webkit-tap-highlight-color: transparent;
}

.renewal-sheet__option:hover:not(:disabled) {
    background: #e5e5ea;
}

.renewal-sheet__option:active:not(:disabled) {
    transform: scale(0.99);
}

.renewal-sheet__option:disabled {
    opacity: 0.55;
    cursor: wait;
}

.renewal-sheet__opt-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(145deg, #007aff, #0056d6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.renewal-sheet__opt-icon svg {
    opacity: 0.95;
}

.renewal-sheet__opt-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.renewal-sheet__opt-title {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.renewal-sheet__opt-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.renewal-sheet__opt-chev {
    flex-shrink: 0;
    color: #c7c7cc;
    display: flex;
    align-items: center;
}

/* История баланса */
.balance-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.balance-history-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.balance-history-item:last-child {
    border-bottom: none;
}

.balance-history-item__main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.balance-history-item__detail {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.35;
    margin: 0.25rem 0 0.35rem;
}

.balance-history-item__kind {
    font-weight: 600;
    font-size: 0.9rem;
}

.balance-history-item__amount {
    font-family: ui-monospace, monospace;
    font-weight: 600;
    white-space: nowrap;
}

.balance-history-item__amount--credit {
    color: #16a34a;
}

.balance-history-item__amount--debit {
    color: #dc2626;
}

.balance-history-item__amount--neutral {
    color: var(--text-muted);
}

.balance-history-item__meta {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.subscription-flash {
    margin-bottom: 1rem;
}

.subscription-flash--ok {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.08);
}

.subscription-flash--err {
    border-color: rgba(220, 38, 38, 0.35);
    background: rgba(220, 38, 38, 0.06);
}

.code {
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    background: var(--bg-card-hover);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* Нижнее меню — фиксировано к низу экрана, ширина = колонка (десктоп = как на iPhone) */
.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(100%, var(--app-column-max));
    max-width: var(--app-column-max);
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-card);
    border-top: 1px solid var(--separator);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 0.5rem;
    z-index: 100;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    flex: 1;
    padding: 0.25rem;
    transition: color 0.2s;
}

.bottom-nav-item:hover {
    color: var(--text);
}

.bottom-nav-item.active {
    color: var(--accent);
}

.bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.bottom-nav-icon svg {
    width: 22px;
    height: 22px;
}

.bottom-nav-item.active .bottom-nav-icon {
    color: var(--accent);
}

.bottom-nav-label {
    white-space: nowrap;
}

/* Кнопки и ссылки */
a.link {
    color: var(--accent);
    text-decoration: none;
}

a.link:hover {
    text-decoration: underline;
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    font-family: var(--font-sans);
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-outline {
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: transparent;
}

.btn-outline:hover {
    background: var(--bg-card-hover);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.3);
}

.btn-switch-account {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
}

.btn-switch-account:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
}

/* Списки шагов */
ul.step-list {
    list-style: none;
    counter-reset: step;
}

.step-list li {
    position: relative;
    padding-left: 2.75rem;
    margin-bottom: 1rem;
    counter-increment: step;
}

.step-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.step-list .step-title {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.step-list .step-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}

/* Страница входа */
.login-page .main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-h) - var(--bottom-nav-h) - 2rem);
}

/* Страница входа — отдельный layout (не extends base) */
.login-page .nav {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.login-page .nav-logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}

.login-page .nav-logo span {
    color: var(--accent);
}

.login-page.miniapp-body {
    padding-bottom: 0;
}

.login-main .login-card {
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-options {
    text-align: center;
}

.login-option {
    margin-bottom: 1rem;
}

.login-option-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.login-via-bot-link {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.login-error {
    color: #dc2626;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.login-divider {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    text-align: left;
}

.login-form-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: var(--text);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.login-form label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.login-form input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font: inherit;
}

.login-form .btn {
    margin-top: 0.35rem;
}

.login-register-link {
    margin-top: 1rem;
    text-align: center;
}

.login-register-link a {
    color: var(--accent);
    font-weight: 600;
}

/* Страница профиля */
.profile-card .profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-avatar-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1.75rem;
}

.profile-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.profile-username {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.profile-actions {
    padding: 1rem 0;
}

.profile-actions--center {
    text-align: center;
}

/*
 * Тёмная тема — только для страниц БЕЗ личного кабинета (login и т.д.).
 * В Telegram Desktop при тёмном чате на body часто висит .dark-theme — раньше
 * селектор body.tg-miniapp.dark-theme перекрашивал кабинет в тёмный (на iPhone
 * тема светлая — эффекта не было).
 */
body.dark-theme:not(.miniapp-body) {
    --bg: #0d0d0f;
    --bg-card: #18181b;
    --bg-card-hover: #222226;
    --border: #2e2e33;
    --text: #f4f4f5;
    --text-muted: #a1a1aa;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-bg: rgba(59, 130, 246, 0.15);
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

body.dark-theme:not(.miniapp-body) .header-top,
body.dark-theme:not(.miniapp-body) .bottom-nav {
    background: #18181b !important;
    border-color: #2e2e33 !important;
}

body.dark-theme:not(.miniapp-body) .card {
    background: #1f1f23 !important;
    border-color: #2e2e33 !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

body.dark-theme:not(.miniapp-body) .card:hover {
    background: #252529 !important;
    border-color: #3f3f46;
}

body.dark-theme:not(.miniapp-body) .bottom-nav-item {
    color: #a1a1aa;
}

body.dark-theme:not(.miniapp-body) .bottom-nav-item.active {
    color: #3b82f6;
}

body.dark-theme:not(.miniapp-body) .profile-link {
    color: #f4f4f5;
}

body.dark-theme:not(.miniapp-body) .header-arrow {
    color: #a1a1aa;
}

/*
 * Кабинет в Telegram: светлая тема поверх тёмного клиента (селектор по .app-shell).
 */
.tg-miniapp .app-shell {
    background: var(--bg) !important;
    color: var(--text) !important;
}

.tg-miniapp .app-shell .header-top {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--separator) !important;
}

.tg-miniapp .app-shell .profile-link,
.tg-miniapp .app-shell .header-user-label {
    color: var(--text) !important;
}

.tg-miniapp .app-shell .header-arrow {
    color: var(--text-muted) !important;
}

.tg-miniapp .app-shell .bottom-nav {
    background: var(--bg-card) !important;
    border-top: 1px solid var(--separator) !important;
}

.tg-miniapp .app-shell .bottom-nav-item {
    color: var(--text-muted) !important;
}

.tg-miniapp .app-shell .bottom-nav-item.active,
.tg-miniapp .app-shell .bottom-nav-item.active .bottom-nav-icon {
    color: var(--accent) !important;
}

.app-shell .card {
    border: 1px solid var(--separator);
}

.tg-miniapp .app-shell .card {
    background: var(--bg-card) !important;
    box-shadow: var(--shadow-card) !important;
}

.tg-miniapp .app-shell .card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
}

.app-shell .balance-hero {
    border: 1px solid var(--separator);
}

.tg-miniapp .app-shell .balance-hero {
    background: var(--bg-card) !important;
    box-shadow: var(--shadow-card);
}

.app-shell .sub-wallet {
    border: 1px solid var(--separator);
}

.tg-miniapp .app-shell .sub-wallet {
    background: var(--bg-card) !important;
    box-shadow: var(--shadow-card);
}

.tg-miniapp .app-shell .action-tile__squircle {
    background: var(--bg-card) !important;
    border: 1px solid var(--separator) !important;
    box-shadow: var(--shadow) !important;
    color: var(--accent) !important;
}

.tg-miniapp .app-shell .action-tile__label {
    color: var(--text) !important;
}

.tg-miniapp .app-shell .sub-wallet__expand {
    background: var(--bg-grouped) !important;
    border-top: 1px solid var(--separator) !important;
}

.tg-miniapp .app-shell .bottom-sheet__panel {
    background: var(--bg-card) !important;
    color: var(--text) !important;
}

.tg-miniapp .app-shell .bottom-sheet__title {
    color: var(--text) !important;
}

.tg-miniapp .app-shell .bottom-sheet__muted {
    color: var(--text-muted) !important;
}

.tg-miniapp .app-shell .bottom-sheet__lead,
.tg-miniapp .app-shell .bottom-sheet__lead strong {
    color: var(--text) !important;
}

.tg-miniapp .app-shell .renewal-sheet__option {
    background: var(--bg-grouped) !important;
    color: var(--text) !important;
}

.tg-miniapp .app-shell .renewal-sheet__opt-title {
    color: var(--text) !important;
}

.tg-miniapp .app-shell .renewal-sheet__opt-sub {
    color: var(--text-muted) !important;
}

@media (min-width: 768px) {
    .main {
        padding: 1.25rem max(1.25rem, env(safe-area-inset-left)) 1.5rem max(1.25rem, env(safe-area-inset-right));
    }
}
