:root {
    /* Background */
    --bg-body: #0A0E1A;
    --bg-card: #111827;
    --bg-surface: #1E293B;
    --bg-card-hover: #1a2332;
    --bg-sub-card-start: #131c2e;
    --bg-sub-card-end: #111827;
    /* Text */
    --text-primary: #E5E7EB;
    --text-white: #fff;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --text-dim: #4B5563;
    /* Accent */
    --accent: #2563EB;
    --accent-dark: #1D4ED8;
    --accent-light: #3B82F6;
    /* Semantic */
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-error: #EF4444;
    --color-toggle: #F6821F;
    /* Border */
    --border-subtle: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.08);
    --border-faint: rgba(255,255,255,0.04);
    /* Misc */
    --scrollbar-thumb: #374151;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body-gradient, var(--bg-body));
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

/* Auth page vertical centering */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* === Page loader === */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-body-gradient, var(--bg-body));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #1E293B;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* === Skeleton loading === */
.skeleton {
    background: linear-gradient(90deg, #1E293B 25%, #2a3548 50%, #1E293B 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text-sm {
    height: 12px;
    margin-bottom: 6px;
}

.skeleton-title {
    height: 20px;
    margin-bottom: 12px;
}

.skeleton-block {
    height: 80px;
    margin-bottom: 12px;
    border-radius: 12px;
}

/* === Button loading === */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* === Fade transitions === */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

/* === Toast === */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    z-index: 10000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90%;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: rgba(16,185,129,0.3);
}

.toast.error {
    border-color: rgba(239,68,68,0.3);
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4B5563;
}

/* === Card === */
.card {
    background: var(--bg-card-gradient, var(--bg-card));
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 24px 20px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.logo {
    text-align: center;
    margin-bottom: 24px;
}

.logo img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-white);
    margin-top: 12px;
}

/* === Form === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s ease;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
    background: #1a2332;
}

/* === Buttons === */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--btn-gradient, linear-gradient(135deg, var(--accent), var(--accent-dark)));
    color: var(--text-white);
    box-shadow: 0 2px 12px rgba(37,99,235,0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--btn-hover-gradient, linear-gradient(135deg, var(--accent-light), var(--accent)));
    box-shadow: 0 4px 20px rgba(37,99,235,0.4);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 6px rgba(37,99,235,0.2);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-trial {
    background: linear-gradient(135deg, #10B981, #059669);
    color: var(--text-white);
    margin-bottom: 10px;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgba(16,185,129,0.3);
}

.btn-trial:hover:not(:disabled) {
    background: linear-gradient(135deg, #34D399, #10B981);
    box-shadow: 0 4px 20px rgba(16,185,129,0.4);
    transform: translateY(-1px);
}

.btn-trial:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--scrollbar-thumb);
}

/* === Messages === */
.error-msg {
    color: var(--color-error);
    font-size: 13px;
    margin-top: 8px;
    display: none;
}

.success-msg {
    color: var(--color-success);
    font-size: 13px;
    margin-top: 8px;
    display: none;
}

.link {
    color: var(--accent-light);
    text-decoration: none;
    font-size: 14px;
}

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

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

.text-secondary {
    color: var(--text-secondary);
    font-size: 13px;
}

.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* === Subscription card === */
.sub-card {
    background: var(--sub-card-gradient, linear-gradient(145deg, var(--bg-sub-card-start), var(--bg-sub-card-end)));
    border: 1px solid rgba(37,99,235,0.15);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.sub-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.sub-status .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-active { background: #10B981; box-shadow: 0 0 8px #10B98180; }
.dot-expired { background: #EF4444; box-shadow: 0 0 8px #EF444480; }
.dot-warning { background: #F59E0B; box-shadow: 0 0 8px #F59E0B80; }

.sub-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sub-info-item {
    background: var(--sub-info-gradient, var(--bg-body));
    border-radius: 10px;
    padding: 12px;
}

.sub-info-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.sub-info-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white);
    margin-top: 4px;
}

/* === Key actions === */
.key-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}

.key-actions > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.key-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.key-btn-connect {
    background: var(--btn-gradient, linear-gradient(135deg, var(--accent), var(--accent-dark)));
    color: var(--text-white);
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.key-btn-connect:hover {
    background: var(--btn-hover-gradient, linear-gradient(135deg, var(--accent-light), var(--accent)));
    box-shadow: 0 4px 16px rgba(37,99,235,0.35);
    transform: translateY(-1px);
}

.key-btn-copy {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.key-btn-copy:hover {
    background: var(--bg-card-hover);
    border-color: rgba(37,99,235,0.3);
    transform: translateY(-1px);
}

.key-btn-copy.copied {
    background: rgba(16,185,129,0.15);
    border-color: rgba(16,185,129,0.3);
    color: var(--color-success);
}

.key-btn-devices {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.key-btn-devices:hover {
    background: var(--bg-card-hover);
    border-color: rgba(37,99,235,0.3);
    transform: translateY(-1px);
}

/* === Balance card === */
.balance-card {
    background: var(--bg-card-gradient, var(--bg-card));
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.balance-label { font-size: 14px; color: #9CA3AF; }
.balance-value { font-size: 20px; font-weight: 700; color: #fff; }

/* === Action buttons grid === */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.action-btn {
    background: var(--action-btn-gradient, var(--bg-card));
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.action-btn:hover {
    background: var(--action-btn-hover-gradient, var(--bg-card-hover));
    border-color: rgba(37,99,235,0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn .icon {
    font-size: 26px;
    margin-bottom: 8px;
    display: block;
}

/* === Header === */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.header-logo span {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white);
}

.logout-btn {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    border-color: #EF4444;
    color: var(--color-error);
}

/* === Account bar === */
.account-bar {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card-gradient, var(--bg-card));
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin-bottom: 14px;
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.account-email {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-id {
    font-size: 12px;
    color: var(--text-muted);
}

/* === Loading spinner (legacy) === */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #374151;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

/* === Tariff cards (legacy) === */
.tariff-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.tariff-card:hover {
    border-color: var(--accent);
}

.tariff-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.tariff-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white);
}

.tariff-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-light);
    margin-top: 4px;
}

.tariff-period {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.tariff-details {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* === Tariff groups === */
.tariff-group {
    margin-bottom: 20px;
}

.tariff-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 8px;
}

.tariff-group-icon {
    font-size: 20px;
}

.tariff-group-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white);
}

.tariff-group-list {
    background: var(--bg-card-gradient, var(--bg-card));
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
}

.tariff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid var(--border-faint);
}

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

.tariff-item:hover {
    background: rgba(37,99,235,0.06);
}

.tariff-item.selected {
    background: rgba(37,99,235,0.1);
    border-left: 3px solid var(--accent);
}

.tariff-item-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.tariff-item-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.tariff-item-price {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent-light);
    white-space: nowrap;
}

/* === Presets === */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.preset-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.2s;
}

.preset-btn:hover, .preset-btn.selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* === Payment methods === */
.payment-method {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.payment-method:hover, .payment-method.selected {
    border-color: var(--accent);
}

.payment-method-label {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.payment-method-badge {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-body-gradient, var(--bg-body));
    padding: 2px 8px;
    border-radius: 6px;
}

/* === Steps === */
.step { display: none; }
.step.active { display: block; }

.step-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white);
    margin-bottom: 16px;
}

/* === Back button === */
.back-btn {
    background: none;
    border: none;
    color: var(--accent-light);
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 12px;
}

.back-btn:hover {
    text-decoration: underline;
}

/* === Balance info row === */
.balance-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-body-gradient, var(--bg-body));
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 14px;
}

.balance-info .label { color: #9CA3AF; }
.balance-info .value { color: #fff; font-weight: 600; }

/* === Referral === */
.ref-link-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}

.ref-link-text {
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-all;
    flex: 1;
    min-width: 0;
}

.copy-btn {
    background: var(--accent);
    color: var(--text-white);
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.copy-btn:hover { background: var(--accent-light); }
.copy-btn.copied { background: #10B981; }

.ref-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border-faint);
}

.ref-user:last-child { border-bottom: none; }

.ref-avatar-wrap {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.ref-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--scrollbar-thumb);
    object-fit: cover;
    flex-shrink: 0;
}


.ref-name {
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ref-earned {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-success);
    white-space: nowrap;
    margin-left: auto;
}
.ref-earned.zero {
    color: var(--text-muted);
    font-weight: 400;
}

/* === Terms agreement === */
.terms-agreement {
    margin-bottom: 16px;
}
.terms-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}
.terms-checkbox input[type="checkbox"] {
    display: none;
}
.terms-checkbox .checkmark {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    background: var(--bg-surface);
    transition: all 0.2s ease;
    position: relative;
    margin-top: 2px;
}
.terms-checkbox input:checked + .checkmark {
    background: var(--accent);
    border-color: var(--accent);
}
.terms-checkbox input:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.terms-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.terms-text a {
    color: var(--accent-light);
    text-decoration: none;
}
.terms-text a:hover {
    text-decoration: underline;
}

/* === Stats row === */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-item {
    background: var(--bg-surface);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-white);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Referral bonus info === */
.bonus-info {
    background: var(--bg-card-gradient, var(--bg-card));
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 20px;
    margin-top: 16px;
    margin-bottom: 16px;
}

.bonus-info-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-white);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bonus-level {
    background: var(--bg-body-gradient, var(--bg-body));
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
}

.bonus-level:last-of-type {
    margin-bottom: 0;
}

.bonus-level-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.bonus-level-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.bonus-level-percent {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-light);
}

.bonus-level-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.bonus-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.19);
    border-radius: 8px;
    font-size: 12px;
    color: #93C5FD;
    line-height: 1.5;
}

.bonus-note-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

/* === Section title === */
.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-white);
    margin-bottom: 10px;
}

/* === Condition check === */
.condition-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}

.condition-ok { color: #10B981; }
.condition-no { color: #EF4444; }

/* === Gift card === */
.gift-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.gift-code {
    font-family: monospace;
    font-size: 14px;
    color: var(--accent-light);
    background: var(--bg-body-gradient, var(--bg-body));
    padding: 6px 10px;
    border-radius: 6px;
    display: inline-block;
}

.gift-status-active { color: #10B981; }
.gift-status-used { color: #9CA3AF; }

.gift-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* === Link code display === */
.code-display {
    background: var(--bg-body-gradient, var(--bg-body));
    border: 2px dashed var(--accent);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin: 16px 0;
}

.code-value {
    font-family: monospace;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-light);
    letter-spacing: 6px;
}

.code-timer {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* === Info box === */
.info-box {
    background: var(--bg-surface);
    border-left: 3px solid var(--accent);
    border-radius: 0 10px 10px 0;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* === Delete button === */
.btn-danger {
    background: transparent;
    color: var(--color-error);
    border: 1px solid #EF444440;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #EF444420;
    border-color: #EF4444;
}

/* === Gift links === */
.gift-card.used {
    opacity: 0.5;
}

.gift-links {
    margin-top: 10px;
}

.gift-link-row {
    margin-bottom: 6px;
}

.gift-link-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.gift-link-box {
    background: var(--bg-body-gradient, var(--bg-body));
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gift-link-text {
    font-size: 12px;
    color: var(--text-secondary);
    word-break: break-all;
    flex: 1;
    min-width: 0;
}

.copy-btn-sm {
    background: var(--accent);
    color: var(--text-white);
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-btn-sm:hover { background: var(--accent-light); }
.copy-btn-sm.copied { background: #10B981; }

/* === Compact subscription cards === */
.sub-card-compact {
    background: var(--sub-card-gradient, linear-gradient(145deg, var(--bg-sub-card-start), var(--bg-sub-card-end)));
    border: 1px solid rgba(37,99,235,0.15);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.sub-compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.sub-compact-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-white);
}

.sub-compact-title .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sub-compact-days {
    font-size: 13px;
    color: var(--text-secondary);
}

.sub-compact-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.sub-compact-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.sub-compact-actions > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.key-btn-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.key-btn-sm.connect {
    background: var(--btn-gradient, linear-gradient(135deg, var(--accent), var(--accent-dark)));
    color: var(--text-white);
}

.key-btn-sm.connect:hover {
    background: var(--btn-hover-gradient, linear-gradient(135deg, var(--accent-light), var(--accent)));
}

.key-btn-sm.copy {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.key-btn-sm.copy:hover {
    background: var(--bg-card-hover);
}

.key-btn-sm.copy.copied {
    background: rgba(16,185,129,0.15);
    border-color: rgba(16,185,129,0.3);
    color: var(--color-success);
}

.key-btn-sm.renew {
    background: transparent;
    color: var(--accent-light);
    border: 1px solid rgba(37,99,235,0.3);
}

.key-btn-sm.renew:hover {
    background: rgba(37,99,235,0.1);
}

/* === Auto-renew toggle (Cloudflare style) === */
.auto-renew-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    margin-bottom: 8px;
}

.auto-renew-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 34px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--scrollbar-thumb);
    border-radius: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-slider {
    background: #F6821F;
    box-shadow: 0 0 8px rgba(246,130,31,0.4);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

.toggle-slider::after {
    content: '\2715';
    position: absolute;
    left: 4px;
    top: 2px;
    font-size: 9px;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: bold;
}

.toggle-switch input:checked + .toggle-slider::after {
    content: '\2713';
    left: 20px;
    color: var(--text-white);
}

.toggle-switch.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* === Info tooltip === */
.info-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    font-style: normal;
    cursor: pointer;
    margin-left: 6px;
    flex-shrink: 0;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.info-tip:hover {
    background: rgba(37,99,235,0.15);
    color: var(--accent-light);
}

.info-tip-bubble {
    position: absolute;
    top: calc(100% + 8px);
    left: -20px;
    right: auto;
    transform: scale(0.95);
    background: var(--bg-surface);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 400;
    font-style: normal;
    line-height: 1.5;
    color: #D1D5DB;
    width: max-content;
    max-width: 260px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    pointer-events: none;
}

.info-tip-bubble::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 24px;
    right: auto;
    border: 6px solid transparent;
    border-bottom-color: #1E293B;
}

.info-tip:hover .info-tip-bubble,
.info-tip.active .info-tip-bubble {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
}

/* === Devices modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--bg-card-gradient, var(--bg-card));
    border: 1px solid var(--border-light);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4);
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 16px 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-faint);
    border-radius: 10px;
    margin-bottom: 8px;
}

.device-item:last-child {
    margin-bottom: 0;
}

.device-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.device-info {
    flex: 1;
    min-width: 0;
}

.device-model {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.device-unlink {
    background: transparent;
    color: var(--color-error);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.device-unlink:hover {
    background: rgba(239,68,68,0.12);
    border-color: #EF4444;
}

.device-unlink:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.devices-empty {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.key-btn-sm.devices {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.key-btn-sm.devices:hover {
    background: var(--bg-card-hover);
    border-color: rgba(37,99,235,0.3);
}

/* === TG Link Button (animated gradient) === */
.tg-link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    margin: 10px 0;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-white);
    text-decoration: none;
    background: linear-gradient(
        270deg,
        var(--tg-link-grad-1, #2563EB),
        var(--tg-link-grad-2, #7C3AED),
        var(--tg-link-grad-3, #2563EB)
    );
    background-size: 200% 100%;
    animation: tgLinkShimmer 3s ease infinite;
    transition: opacity .2s;
}
.tg-link-btn:hover { opacity: .88; }
.tg-link-icon { font-size: 16px; }

@keyframes tgLinkShimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* === Responsive === */
@media (max-width: 480px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    body {
        padding: 0;
        align-items: stretch;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .container {
        max-width: 100%;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        padding: 12px;
        overflow-x: hidden;
    }

    .card { padding: 20px 16px; }

    /* Header full width */
    .header {
        margin: 0 -4px 12px;
    }

    /* Account bar */
    .account-bar {
        border-radius: 14px;
    }

    /* Sub card */
    .sub-card {
        border-radius: 16px;
    }

    /* Actions grid — 3 cols on small screens */
    .actions-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .action-btn {
        padding: 14px 6px;
        font-size: 12px;
        border-radius: 14px;
    }

    .action-btn .icon {
        font-size: 20px;
    }

    /* Balance card */
    .balance-card {
        border-radius: 14px;
    }

    /* Key actions */
    .key-actions {
        flex-wrap: wrap;
    }

    .key-btn {
        font-size: 12px;
        padding: 8px 10px;
    }

    /* Panel on mobile — centered */
    .page-panel-overlay {
        align-items: center;
        padding: 12px;
    }

    .page-panel-box {
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: 20px;
    }

    .page-panel-frame {
        border-radius: 0 0 20px 20px;
        max-height: 80vh;
        max-height: 80dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Regular modals on mobile — centered */
    .modal-overlay {
        align-items: center !important;
        padding: 16px !important;
    }

    .modal-box {
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        margin: 0;
        border-radius: 20px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Toast position fix */
    .toast {
        bottom: 20px;
        left: 12px;
        right: 12px;
        max-width: none;
    }
}

/* Small phones */
@media (max-width: 360px) {
    .container { padding: 8px; }
    .actions-grid { gap: 6px; }
    .action-btn { padding: 12px 4px; font-size: 11px; }
    .sub-info { grid-template-columns: 1fr 1fr; gap: 8px; }
}
