/* ============================================
   TAKUMI PROXY — PERSONAL DASHBOARD
   ============================================ */

/* ---- Help and FAQ ---- */
.faq-entry { margin-top: 16px; }
.guide-entry { margin-top: 20px; }
.home-qr-button { margin-top: 12px; }
.qr-dialog { margin: auto; width: min(380px, calc(100% - 32px)); max-height: 90dvh; padding: 22px; overflow: auto; background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); }
.qr-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.qr-dialog__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qr-dialog__header h2 { font-size: 1.1rem; }
.qr-dialog img { display: block; width: 100%; height: auto; padding: 12px; background: white; border-radius: 10px; }
.qr-dialog img[hidden] { display: none; }
.help-topics, .guide-downloads, .guide-imports { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.help-topics .btn, .guide-downloads .btn, .guide-imports .btn { flex: 1 1 140px; }
.help-report { margin-top: 28px; display: grid; gap: 10px; }
.help-report[hidden], .guide-qr[hidden] { display: none; }
.help-report select, .help-report textarea, #guideDevice { width: 100%; padding: 12px; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-primary); font: inherit; }
.help-report textarea { resize: vertical; font-size: 0.85rem; line-height: 1.6; }
.help-report label, #screen-connect > label { color: var(--text-secondary); font-size: 0.85rem; }
.guide-steps { padding-left: 24px; display: grid; gap: 24px; }
.guide-steps li::marker { color: var(--accent-secondary); font-weight: 700; }
.guide-steps h3 { font-size: 1rem; margin-bottom: 6px; }
.guide-steps p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.7; }
#guidePrivateActions > .btn { margin-top: 10px; }
.guide-qr { text-align: center; margin-top: 16px; }
.guide-qr p { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.6; margin-bottom: 12px; }
.guide-qr img { max-width: 100%; width: 280px; height: auto; background: white; padding: 12px; border-radius: 12px; }
.history__actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: 52%; }
.history__resume { padding: 8px 10px; border: 1px solid var(--border-accent); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: 0.75rem; cursor: pointer; }
.history__resume:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
.history__item-status--activating { background: var(--bg-glass); color: var(--warning); }
.history__item { width: 100%; text-align: left; font: inherit; color: var(--text-primary); cursor: pointer; }
.history__item:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
.history__details-hint { color: var(--text-secondary); font-size: 0.75rem; }
.payment-details { display: grid; gap: 16px; text-align: left; }
.payment-details dt { color: var(--text-secondary); font-size: 0.8rem; margin-bottom: 4px; }
.payment-details dd { margin: 0; overflow-wrap: anywhere; }
.header__avatar, .auth__avatar, .tabbar__avatar { display: block; object-fit: contain; border-radius: 50%; flex-shrink: 0; }
.header__avatar { width: 48px; height: 48px; }
.auth__avatar { width: 72px; height: 72px; margin: 0 auto 20px; }
.tabbar__avatar { width: 36px; height: 36px; }
.header__help { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 12px; margin-left: 12px; border: 1px solid var(--border-accent); border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.header__help:hover { background: var(--bg-card-hover); }
.header__help:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
@media (max-width: 360px) {
    .header__help { padding: 0 10px; }
    .header__help span { display: none; }
    .header .header__logo { gap: 10px; }
}
.faq-list { display: grid; gap: 10px; }
.faq-item { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.faq-item summary { padding: 18px; cursor: pointer; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.faq-item summary::marker { color: var(--accent-primary); }
.faq-item summary:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 3px; border-radius: var(--radius-md); }
.faq-item[open] { border-color: var(--border-accent); }
.faq-answer { padding: 0 18px 18px; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.7; overflow-wrap: anywhere; }
.faq-answer p + p { margin-top: 10px; }
.faq-answer ul, .faq-answer ol { padding-left: 22px; }
.faq-answer li + li { margin-top: 6px; }
.faq-answer a { color: var(--accent-secondary); }
.faq-answer strong { color: var(--text-primary); }
.faq-note { margin: 20px 0; color: var(--text-secondary); font-size: 0.85rem; line-height: 1.6; }

/* ---- Reset & Base ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #111216;
    --bg-secondary: #191a20;
    --bg-card: #1b1c23;
    --bg-card-hover: #22232c;
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.07);

    --text-primary: #f3f2f7;
    --text-secondary: #b0b0bf;
    --text-tertiary: #9393a5;

    --accent-primary: #9585f5;
    --accent-secondary: #b9afff;
    --accent-gradient: var(--accent-primary);

    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;

    --border-color: rgba(255, 255, 255, 0.09);
    --border-accent: rgba(149, 133, 245, 0.4);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 0 transparent;

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}

body.tg-webapp {
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    min-height: var(--tg-viewport-stable-height, 100vh);
}

/* ---- Animated Background ---- */
.bg-grid {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none; z-index: 0;
}

.bg-glow {
    position: fixed; border-radius: 50%; filter: blur(80px);
    pointer-events: none; z-index: 0;
    animation: floatGlow 15s ease-in-out infinite;
}
.bg-glow--1 { width: 300px; height: 300px; background: rgba(108, 92, 231, 0.12); top: -80px; right: -60px; }
.bg-glow--2 { width: 250px; height: 250px; background: rgba(0, 210, 255, 0.08); bottom: 20%; left: -80px; animation-delay: -5s; }
.bg-glow--3 { width: 200px; height: 200px; background: rgba(108, 92, 231, 0.06); bottom: -40px; right: 20%; animation-delay: -10s; }

@keyframes floatGlow {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-10px, 20px) scale(0.9); }
}

/* ---- App Container ---- */
.app {
    position: relative; z-index: 1;
    max-width: 520px; margin: 0 auto;
    padding: 24px 20px; padding-bottom: 104px;
    animation: fadeInUp 0.6s var(--ease-out) both;
    will-change: transform, opacity;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Screens ---- */
.screen {
    animation: fadeInUp 0.4s var(--ease-out) both;
    will-change: transform, opacity;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.screen__header {
    display: flex; align-items: center; gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.screen__title {
    font-size: 1.25rem; font-weight: 700;
    background: var(--text-primary);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.screen__desc {
    font-size: 0.85rem; color: var(--text-secondary);
    margin-bottom: var(--space-lg); line-height: 1.6;
}

.back-btn {
    width: 36px; height: 36px; border-radius: var(--radius-md);
    background: var(--bg-glass); border: 1px solid var(--border-color);
    color: var(--text-primary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--duration-normal) var(--ease-out);
}
.back-btn:hover { background: var(--bg-glass-hover); border-color: var(--border-accent); }

/* ---- Loading ---- */
.loading {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 60vh; gap: var(--space-lg);
}

.loading__spinner {
    width: 40px; height: 40px; border-radius: 50%;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading__text { color: var(--text-tertiary); font-size: 0.9rem; }

/* ---- Auth Screen ---- */
.auth {
    display: flex; flex-direction: column; align-items: center;
    min-height: 80vh; justify-content: center; padding: var(--space-lg) 0;
}

.auth__logo { text-align: center; margin-bottom: var(--space-xl); }

.auth__logo-icon {
    width: 56px; height: 56px; margin: 0 auto 20px;
    display: grid; place-items: center; color: var(--accent-secondary);
    background: var(--bg-glass); border: 1px solid var(--border-accent); border-radius: 18px;
}

.auth__title {
    font-size: 1.85rem; font-weight: 750; letter-spacing: -0.05em;
    background: var(--accent-gradient);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth__subtitle { color: var(--text-tertiary); font-size: 0.9rem; margin-top: var(--space-xs); }

.auth__tabs {
    display: flex; width: 100%; background: var(--bg-glass);
    border-radius: var(--radius-md); padding: 3px;
    margin-bottom: var(--space-lg); border: 1px solid var(--border-color);
}

.auth__tab {
    flex: 1; padding: 10px; border: none; background: none;
    color: var(--text-tertiary); font-family: inherit;
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    border-radius: calc(var(--radius-md) - 2px);
    transition: all var(--duration-normal) var(--ease-out);
}

.auth__tab--active {
    background: var(--accent-gradient);
    color: white; box-shadow: var(--shadow-md);
}

.auth__form {
    width: 100%; display: flex; flex-direction: column;
    gap: var(--space-md);
}

.input-group {
    display: flex; flex-direction: column; gap: var(--space-xs);
}

.input-label {
    font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
    padding-left: 2px;
}

.input {
    width: 100%; padding: 14px var(--space-md);
    background: var(--bg-glass); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-family: inherit; font-size: 0.95rem;
    transition: all var(--duration-normal) var(--ease-out);
    outline: none;
}

.input::placeholder { color: var(--text-tertiary); }
.input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15); }

.auth__message {
    width: 100%; padding: var(--space-md); border-radius: var(--radius-md);
    font-size: 0.85rem; text-align: center; margin-top: var(--space-md);
}
.auth__message--success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.auth__message--error { background: rgba(239, 68, 68, 0.1); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }

.auth__footer {
    margin-top: var(--space-xl); color: var(--text-tertiary);
    font-size: 0.8rem; text-align: center; line-height: 1.6;
}
.auth__footer a { color: var(--accent-secondary); text-decoration: none; font-weight: 600; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--space-sm); padding: 14px var(--space-lg);
    border-radius: var(--radius-md); font-family: inherit;
    font-size: 0.9rem; font-weight: 700; cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    border: none; position: relative; overflow: hidden;
}

.btn--primary {
    background: var(--accent-gradient); color: #161224;
    box-shadow: none;
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--primary:active { transform: translateY(0) scale(0.98); }

.btn--outline {
    background: transparent; color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn--outline:hover { border-color: var(--border-accent); background: var(--bg-glass); }

.btn--full { width: 100%; }

.btn--loading .btn__text { opacity: 0; }
.btn--loading .btn__spinner { opacity: 1; visibility: visible; }

.btn__spinner {
    opacity: 0; visibility: hidden; width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
    animation: spin 0.6s linear infinite;
    position: absolute; left: 50%; top: 50%;
    margin-left: -10px; margin-top: -10px;
}

/* ---- Header ---- */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-md) 0; margin-bottom: var(--space-md);
}

.header__logo { display: flex; align-items: center; gap: var(--space-md); }

.header__icon {
    width: 42px; height: 42px; display: flex;
    align-items: center; justify-content: center;
    background: var(--bg-glass); border: 1px solid var(--border-accent);
    border-radius: var(--radius-md); box-shadow: var(--shadow-glow);
}
.header__icon svg { width: 24px; height: 24px; }

.header__title {
    font-size: 1.25rem; font-weight: 700;
    background: var(--text-primary);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; letter-spacing: -0.02em;
}

.header__subtitle { font-size: 0.75rem; color: var(--text-tertiary); font-weight: 500; }

.header__status {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-full); font-size: 0.75rem;
    font-weight: 600; color: var(--success);
}

.status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--success); animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-xl); overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s var(--ease-out) 0.1s both;
}

.card--subscription { position: relative; }
.card--subscription::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 1px; background: var(--border-accent);
}

.card__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-lg); padding-bottom: 0;
}

.card__badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 14px; border-radius: var(--radius-full);
    font-size: 0.8rem; font-weight: 600;
}
.card__badge--active { background: rgba(16, 185, 129, 0.12); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.card__badge--expired { background: rgba(239, 68, 68, 0.12); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }
.card__badge--warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }

.card__badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-in-out infinite; }

.card__plan {
    font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
    padding: 5px 14px; background: var(--bg-glass);
    border-radius: var(--radius-full); border: 1px solid var(--border-color);
}

.card__body { padding: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-lg); }

/* ---- Battery Widget ---- */
.battery { display: flex; flex-direction: column; gap: var(--space-md); }

.battery__body { display: flex; align-items: center; gap: 0; padding: 0 var(--space-xs); }

.battery__shell {
    flex: 1; height: 80px; background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.08); border-radius: 14px;
    position: relative; overflow: hidden; transition: border-color 0.5s ease;
}
.battery--high .battery__shell { border-color: rgba(16, 185, 129, 0.25); }
.battery--mid .battery__shell { border-color: rgba(245, 158, 11, 0.25); }
.battery--low .battery__shell { border-color: rgba(239, 68, 68, 0.3); }

.battery__fill {
    position: absolute; top: 4px; left: 4px; bottom: 4px;
    width: 0%; border-radius: 10px;
    transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.5s ease;
    overflow: hidden;
}
.battery--high .battery__fill {
    background: linear-gradient(90deg, #059669, #10B981, #34D399);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}
.battery--mid .battery__fill {
    background: linear-gradient(90deg, #D97706, #F59E0B, #FBBF24);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}
.battery--low .battery__fill {
    background: linear-gradient(90deg, #DC2626, #EF4444, #F87171);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3), inset 0 1px 0 rgba(255,255,255,0.15);
    animation: batteryPulse 1.5s ease-in-out infinite;
}

@keyframes batteryPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

.battery__fill-shimmer {
    position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: batteryShimmer 3s ease-in-out infinite;
}
@keyframes batteryShimmer { 0% { left: -120%; } 100% { left: 200%; } }

.battery__segments {
    position: absolute; top: 4px; left: 4px; right: 4px; bottom: 4px;
    display: flex; gap: 3px; pointer-events: none; z-index: 2;
}
.battery__segment { flex: 1; border-right: 1px solid rgba(255, 255, 255, 0.04); }
.battery__segment:last-child { border-right: none; }

.battery__center-info {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    display: flex; align-items: baseline; gap: 5px; z-index: 3;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.battery__days-value { font-size: 2rem; font-weight: 900; color: #fff; line-height: 1; font-variant-numeric: tabular-nums; }
.battery__days-label { font-size: 0.8rem; font-weight: 600; color: rgba(255, 255, 255, 0.8); }

.battery__cap {
    width: 8px; height: 32px; background: rgba(255, 255, 255, 0.1);
    border-radius: 0 4px 4px 0; border: 2px solid rgba(255, 255, 255, 0.08);
    border-left: none; flex-shrink: 0; transition: background 0.5s ease;
}
.battery--high .battery__cap { background: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.25); }
.battery--mid .battery__cap { background: rgba(245, 158, 11, 0.2); border-color: rgba(245, 158, 11, 0.25); }
.battery--low .battery__cap { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.3); }

.battery__details { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-sm) var(--space-xs); justify-content: center; }
.battery__detail { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.battery__detail-label { font-size: 0.7rem; color: var(--text-tertiary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; text-align: center; }
.battery__detail-value { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); text-align: center; }
.battery__detail-value--unlimited { display: flex; align-items: center; gap: 5px; color: var(--accent-secondary); }
.battery__detail-value--unlimited svg { opacity: 0.8; }
.battery__detail-divider { width: 1px; height: 32px; background: var(--border-color); flex-shrink: 0; }

/* ---- No Subscription Banner ---- */
.no-sub {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-xl); padding: var(--space-xl);
    text-align: center; animation: fadeInUp 0.6s var(--ease-out) 0.1s both;
}
.no-sub__icon { font-size: 2.5rem; margin-bottom: var(--space-md); }
.no-sub__title { font-size: 1.1rem; font-weight: 700; margin-bottom: var(--space-sm); }
.no-sub__text { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: var(--space-lg); }

/* ---- Sections ---- */
.section { margin-top: var(--space-lg); animation: fadeInUp 0.6s var(--ease-out) 0.2s both; }

.section__title {
    display: flex; align-items: center; gap: var(--space-sm);
    font-size: 1rem; font-weight: 700; color: var(--text-primary);
    margin-bottom: var(--space-md);
}
.section__title svg { color: var(--accent-secondary); flex-shrink: 0; }

/* ---- Connect Grid ---- */
.connect-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }

.connect-btn {
    display: flex; flex-direction: column; align-items: flex-start;
    gap: 18px; padding: 18px 14px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative; overflow: hidden;
    color: var(--text-primary); min-width: 0;
    text-align: left; font-family: inherit;
}
.connect-btn:hover { transform: translateY(-2px); border-color: var(--border-accent); background: var(--bg-card-hover); }
.connect-btn:active { transform: translateY(0) scale(0.98); }

.connect-btn__icon {
    width: 40px; height: 40px; display: flex;
    align-items: center; justify-content: center;
    border-radius: var(--radius-md);
}
.connect-btn--v2ray .connect-btn__icon { background: rgba(108, 92, 231, 0.15); color: var(--accent-primary); }
.connect-btn--happ .connect-btn__icon { background: rgba(0, 210, 255, 0.15); color: var(--accent-secondary); }
.connect-btn__icon svg { width: 22px; height: 22px; }

.connect-btn__text { display: flex; flex-direction: column; }
.connect-btn__name { font-size: 0.95rem; font-weight: 700; }
.connect-btn__desc { font-size: 0.7rem; color: var(--text-tertiary); font-weight: 500; }

/* ---- Copy Button ---- */
.copy-btn {
    width: 100%; display: flex; align-items: center; gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-glass); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); cursor: pointer;
    font-family: inherit; font-size: 0.9rem; font-weight: 700;
    color: white; transition: all var(--duration-normal) var(--ease-out);
    position: relative; overflow: hidden;
    box-shadow: none;
}
.copy-btn:hover { background: var(--bg-glass-hover); border-color: var(--border-accent); }
.copy-btn:active { transform: translateY(0) scale(0.98); }

.copy-btn__icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.copy-btn__icon svg { width: 20px; height: 20px; }
.copy-btn__text { flex: 1; text-align: left; }
.copy-btn__success { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; opacity: 0; transform: scale(0); transition: all var(--duration-normal) var(--ease-spring); }
.copy-btn__success svg { width: 20px; height: 20px; }

.copy-btn.copied .copy-btn__icon { opacity: 0; transform: scale(0); transition: all var(--duration-normal) var(--ease-spring); }
.copy-btn.copied .copy-btn__success { opacity: 1; transform: scale(1); }
.copy-btn.copied { background: linear-gradient(135deg, var(--success), #059669); box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3); }

/* ---- Plans ---- */
.plans { display: flex; flex-direction: column; gap: var(--space-md); }

.plan-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: var(--space-md);
    transition: all var(--duration-normal) var(--ease-out);
    cursor: pointer; position: relative; overflow: hidden;
}
.plan-card:hover { transform: translateY(-2px); border-color: var(--border-accent); box-shadow: var(--shadow-md), var(--shadow-glow); }
.plan-card:active { transform: scale(0.98); }

.plan-card--popular { border-color: var(--accent-primary); }
.plan-card--popular::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 1px; background: var(--border-accent);
}

.plan-card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-sm); }

.plan-card__name { font-size: 0.95rem; font-weight: 800; }

.plan-card__tag {
    padding: 3px 8px; border-radius: var(--radius-full);
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    background: var(--accent-gradient); color: white;
}

.plan-card__price {
    display: flex; align-items: baseline; gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}
.plan-card__amount { font-size: 1.4rem; font-weight: 900; }
.plan-card__currency { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.plan-card__period { font-size: 0.75rem; color: var(--text-tertiary); margin-left: var(--space-xs); }

.plan-card__features { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-card__feature {
    display: flex; align-items: center; gap: 3px;
    font-size: 0.7rem; color: var(--text-secondary);
    padding: 3px 8px; background: var(--bg-glass);
    border-radius: var(--radius-full); border: 1px solid var(--border-color);
}

.plan-skeleton {
    height: 100px; background: var(--bg-glass);
    border-radius: var(--radius-lg); border: 1px solid var(--border-color);
    animation: skeletonPulse 1.5s ease-in-out infinite;
}
@keyframes skeletonPulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.8; } }

/* ---- Payment ---- */
.payment-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-xl); padding: var(--space-xl);
    text-align: center; display: flex; flex-direction: column;
    gap: var(--space-md);
}
.payment-card__plan { font-size: 1rem; color: var(--text-secondary); font-weight: 600; }
.payment-card__price {
    font-size: 2.5rem; font-weight: 900;
    background: var(--accent-gradient);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.payment-card__status {
    padding: var(--space-md); border-radius: var(--radius-md);
    font-size: 0.85rem; font-weight: 600;
}
.payment-card__status--success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.payment-card__status--error { background: rgba(239, 68, 68, 0.1); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }
.payment-card__status--pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }

/* ---- History ---- */
.history { display: flex; flex-direction: column; gap: var(--space-sm); }

.history__empty {
    text-align: center; padding: var(--space-2xl);
    color: var(--text-tertiary);
}
.history__empty-icon { font-size: 2rem; margin-bottom: var(--space-md); }

.history__item {
    display: flex; align-items: center; gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--duration-fast) ease;
}
.history__item:hover { background: var(--bg-card-hover); }

.history__item-icon { font-size: 1.2rem; flex-shrink: 0; }
.history__item-left { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.history__item-amount { font-size: 1rem; font-weight: 700; }
.history__item-date { font-size: 0.75rem; color: var(--text-tertiary); }

.history__item-status {
    padding: 4px 10px; border-radius: var(--radius-full);
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
    flex-shrink: 0;
}
.history__item-status--succeeded { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.history__item-status--pending { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.history__item-status--canceled { background: rgba(239, 68, 68, 0.12); color: var(--error); }

.history__skeleton {
    height: 56px; background: var(--bg-glass);
    border-radius: var(--radius-lg); border: 1px solid var(--border-color);
    animation: skeletonPulse 1.5s ease-in-out infinite;
}
.history__skeleton:nth-child(2) { animation-delay: 0.15s; }
.history__skeleton:nth-child(3) { animation-delay: 0.3s; }

/* ---- Tab Bar ---- */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(17, 18, 22, 0.96);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex; justify-content: center; z-index: 1000;
    padding: var(--space-sm) 0;
    padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom, 8px));
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.tabbar__item {
    flex: 1; max-width: 120px; display: flex; flex-direction: column;
    align-items: center; gap: 2px; padding: var(--space-sm) 0;
    background: none; border: none; color: var(--text-tertiary);
    font-family: inherit; font-size: 0.65rem; font-weight: 600;
    cursor: pointer; transition: all var(--duration-normal) var(--ease-out);
}
.tabbar__item:hover { color: var(--text-secondary); }
.tabbar__item--active { color: var(--accent-secondary); }
.tabbar__item--active svg { stroke-width: 2; }

/* ---- Toast ---- */
.toast {
    position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
    display: flex; align-items: center; gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: rgba(17, 24, 39, 0.95); border: 1px solid var(--border-accent);
    border-radius: var(--radius-full); font-size: 0.85rem;
    color: var(--text-primary); white-space: nowrap;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    opacity: 0; pointer-events: none;
    transition: all var(--duration-normal) var(--ease-out); z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast__icon { color: var(--success); display: flex; }
.toast__icon svg { width: 18px; height: 18px; }

/* ---- Responsive ---- */
@media (max-width: 400px) {
    .app { padding: 20px 16px 104px; }
    .card__body { padding: var(--space-md); }
    .battery__days-value { font-size: 1.5rem; }
    .connect-btn { padding: var(--space-md); }
}

/* ---- Profile Screen ---- */
.profile-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-lg);
}

.profile-card__avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: 2px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: var(--shadow-glow);
}

.profile-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-card__name {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}

.profile-card__subtext {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.profile-email-card {
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.profile-email-card__status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

/* ---- Telegram Theme Integration ---- */
body.tg-webapp {
    --bg-primary: var(--tg-theme-bg-color, #0a0e1a);
    --text-primary: var(--tg-theme-text-color, #f1f5f9);
    --text-secondary: var(--tg-theme-hint-color, #94a3b8);
    --text-tertiary: var(--tg-theme-hint-color, #64748b);

    --bg-secondary: var(--tg-theme-secondary-bg-color, color-mix(in srgb, var(--bg-primary) 93%, var(--text-primary) 7%));
    --bg-card: var(--tg-theme-section-bg-color, var(--tg-theme-secondary-bg-color, color-mix(in srgb, var(--bg-primary) 95%, var(--text-primary) 5%)));
    --bg-card-hover: var(--tg-theme-section-bg-color, var(--tg-theme-secondary-bg-color, color-mix(in srgb, var(--bg-primary) 90%, var(--text-primary) 10%)));
    --bg-glass: color-mix(in srgb, var(--bg-primary) 97%, var(--text-primary) 3%);
    --bg-glass-hover: color-mix(in srgb, var(--bg-primary) 93%, var(--text-primary) 7%);

    --accent-primary: var(--tg-theme-button-color, #6C5CE7);
    --accent-secondary: var(--tg-theme-link-color, #00D2FF);
    --accent-gradient: linear-gradient(135deg, var(--tg-theme-button-color, #6C5CE7) 0%, var(--tg-theme-link-color, #00D2FF) 100%);

    --border-color: color-mix(in srgb, var(--bg-primary) 90%, var(--text-primary) 10%);
    --border-accent: var(--tg-theme-button-color, rgba(108, 92, 231, 0.3));

    background: var(--bg-primary);
    color: var(--text-primary);
}

body.tg-webapp .bg-grid,
body.tg-webapp .bg-glow {
    display: none !important;
}

body.tg-webapp .input {
    background: var(--bg-secondary);
}

body.tg-webapp .tabbar {
    background: var(--bg-secondary);
}

body.tg-webapp .btn--primary {
    background: var(--accent-gradient);
    color: var(--tg-theme-button-text-color, white);
}

body.tg-webapp .battery__shell {
    background: color-mix(in srgb, var(--bg-primary) 85%, var(--text-primary) 15%);
    border-color: color-mix(in srgb, var(--bg-primary) 80%, var(--text-primary) 20%);
}

body.tg-webapp .battery__cap {
    background: color-mix(in srgb, var(--bg-primary) 80%, var(--text-primary) 20%);
    border-color: color-mix(in srgb, var(--bg-primary) 78%, var(--text-primary) 22%);
}

/* ---- Desktop Sidebar Layout ---- */
.tabbar__logo {
    display: none;
}

@media (min-width: 768px) {
    body:not(.tg-webapp) {
        display: grid;
        grid-template-columns: 200px minmax(0, 680px);
        justify-content: center;
        gap: clamp(24px, 4vw, 56px);
        align-items: flex-start;
        padding: var(--space-2xl) var(--space-xl);
    }

    body:not(.tg-webapp) .app {
        grid-column: 2;
        grid-row: 1;
        width: 100%; max-width: none; min-width: 0;
        margin: 0; padding: 0;
        padding-bottom: var(--space-2xl);
    }

    body:not(.tg-webapp) .tabbar {
        grid-column: 1;
        grid-row: 1;
        position: sticky;
        top: var(--space-2xl);
        left: auto;
        bottom: auto;
        width: 100%;
        height: calc(100vh - var(--space-2xl) * 2);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border-top: none;
        border-right: 1px solid rgba(255, 255, 255, 0.03); /* Softer divider */
        padding: 0 var(--space-lg) var(--space-xl) 0;
    }

    body:not(.tg-webapp) .tabbar__logo {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        padding: 0 var(--space-sm) var(--space-xl) var(--space-sm);
        margin-bottom: var(--space-md);
        border-bottom: 1px solid var(--border-color);
    }

    body:not(.tg-webapp) .tabbar__logo-icon {
        font-size: 1.8rem;
    }

    body:not(.tg-webapp) .tabbar__logo-text {
        font-size: 1.25rem;
        font-weight: 800;
        background: var(--accent-gradient);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    body:not(.tg-webapp) .tabbar__item {
        max-width: none;
        flex-direction: row;
        justify-content: flex-start;
        padding: var(--space-md) var(--space-lg);
        gap: var(--space-md);
        font-size: 1rem;
        border-radius: var(--radius-md);
        margin-bottom: var(--space-xs);
        flex: none;
    }

    body:not(.tg-webapp) .tabbar__item:hover {
        background: var(--bg-glass-hover);
    }

    body:not(.tg-webapp) .tabbar__item--active {
        background: var(--bg-glass);
    }

    body:not(.tg-webapp) .plans {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
        gap: var(--space-md);
    }

    body:not(.tg-webapp) .history {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
        gap: var(--space-md);
    }
}

/* ---- Referrals ---- */
.referral-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.referral-stats__item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.referral-stats__value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    line-height: 1;
}

.referral-stats__label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.referral-link-box {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.referral-link-box__input {
    width: 100%;
    text-align: center;
    background: var(--bg-card);
    font-size: 0.85rem;
    color: var(--accent-secondary);
    font-weight: 600;
    cursor: default;
}

.referral-guide {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.referral-guide__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

.referral-guide__list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.referral-guide__list li {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    position: relative;
    padding-left: var(--space-xs);
}

/* ---- Quiet surfaces and accessible controls ---- */
.bg-grid, .bg-glow { display: none; }
.auth__logo-icon svg { width: 28px; height: 28px; }
.tabbar__logo-icon { display: grid; place-items: center; flex: 0 0 32px; color: var(--accent-secondary); }
.tabbar__logo-icon svg { width: 26px; height: 26px; }
body:not(.tg-webapp) .tabbar__logo-text { font-size: 1rem; white-space: nowrap; }
.auth { max-width: 380px; margin: 0 auto; }
.auth__title { background: none; color: var(--text-primary); -webkit-text-fill-color: currentColor; }
.auth__subtitle { color: var(--text-secondary); }
.auth__tabs { padding: 4px; }
.auth__tab--active { background: var(--bg-card-hover); box-shadow: none; color: var(--text-primary); }
.input { min-height: 48px; background: var(--bg-secondary); }
.btn { min-height: 46px; font-weight: 650; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent-secondary); outline-offset: 4px; }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.header { padding: 8px 0 24px; margin-bottom: 8px; }
.header__subtitle { margin-top: 3px; font-size: 0.8rem; }
.header__icon { background: var(--bg-card); border-color: var(--border-color); }
.section__title { margin-bottom: 6px; letter-spacing: -0.02em; }
.section__desc { color: var(--text-secondary); font-size: 0.8rem; line-height: 1.6; margin-bottom: 16px; }
.connect-btn__name { font-size: 0.9rem; }
.connect-btn__desc { margin-top: 3px; font-size: 0.7rem; line-height: 1.5; }
.connect-btn--incy .connect-btn__icon { background: var(--bg-glass); color: var(--accent-secondary); }
.copy-btn { color: var(--text-secondary); font-size: 0.8rem; padding: 15px 18px; }
.copy-btn__icon { color: var(--accent-secondary); }
.plan-card { padding: 20px; }
.plan-card__tag { color: #161224; text-transform: none; }
#subscriptionNotice { border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--bg-card); margin-bottom: 20px; font-size: 0.85rem; }
#subscriptionNotice .btn { margin-top: 12px; }
#startupError { position: relative; z-index: 2; max-width: 480px; margin: 48px auto; line-height: 1.7; }
#startupError .btn { margin-top: 16px; }
body.auth-page { display: block; }
body.auth-page .app { margin: 0 auto; padding: 24px 20px; }
@media (max-width: 359px) {
    .connect-grid { grid-template-columns: 1fr; }
    .connect-btn { flex-direction: row; align-items: center; gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* Public incident notices remain visible on every screen, including login. */
.service-status {
    margin: 16px 0;
    padding: 16px 18px;
    border: 1px solid rgba(245, 182, 66, .35);
    border-radius: 16px;
    background: rgba(245, 182, 66, .08);
    color: var(--text-primary, #f4f4f6);
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.service-status[hidden] { display: none; }
.service-status p { margin: 4px 0 0; }
.service-status > div + div { margin-top: 12px; }
.service-status [data-state="outage"] { padding: 12px 14px; border-left: 3px solid #ff6b7a; border-radius: 8px; background: rgba(255, 82, 107, .1); }
.service-status [data-state="outage"] strong { color: #ff8c98; }
.service-status small { display: block; opacity: .8; }
.service-status button {
    margin-top: 8px;
    padding: 6px 12px;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.notification-setting { padding: 20px; margin: 20px 0; }
.notification-setting h3 { font-size: 1rem; margin-bottom: 16px; }
.notification-setting label { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.notification-setting input { width: 18px; height: 18px; accent-color: #8b76ed; }
.notification-setting [hidden] { display: none; }
