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

:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --hint-color: #999999;
    --border-color: #e0e0e0;
    --input-bg: #f5f5f5;
    --primary-color: #2481cc;
    --primary-text: #ffffff;
    --telegram-color: #0088cc;
    --header-bg: #2a2a2a;
    --header-text: #ffffff;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --hint-color: #999999;
    --border-color: #333333;
    --input-bg: #2a2a2a;
    --primary-color: #2481cc;
    --primary-text: #ffffff;
    --telegram-color: #0088cc;
    --header-bg: #1a1a1a;
    --header-text: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

#app {
    position: relative;
    min-height: 100vh;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* App Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: var(--header-bg);
    color: var(--header-text);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

.app-logo {
    font-size: 20px;
}

/* Login Content */
.login-content {
    padding: 32px 24px;
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* App Main Logo */
.app-main-logo {
    width: 120px;
    height: 120px;
    margin: 16px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon {
    font-size: 80px;
    line-height: 1;
}

/* Main Title */
.main-title {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    margin: 0;
    color: var(--text-color);
}

/* Login Form */
.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    position: relative;
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--hint-color);
    pointer-events: none;
}

.input-group input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-color);
    transition: border-color 0.2s, background-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.input-group input::placeholder {
    color: var(--hint-color);
}

/* Primary Login Button */
.primary-login-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-text);
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.primary-login-btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

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

/* Separator */
.separator {
    text-align: center;
    color: var(--hint-color);
    font-size: 14px;
    position: relative;
    width: 100%;
    margin: 8px 0;
}

.separator::before,
.separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 20px);
    height: 1px;
    background: var(--border-color);
}

.separator::before {
    left: 0;
}

.separator::after {
    right: 0;
}

/* Telegram Login Button */
.telegram-login-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-text);
    background: var(--telegram-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.1s;
}

.telegram-login-btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

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

.telegram-icon {
    font-size: 18px;
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    width: 100%;
    background: var(--input-bg);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    margin-top: 16px;
}

.theme-btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--hint-color);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.theme-btn.active {
    background: var(--bg-color);
    color: var(--text-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .theme-btn.active {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.theme-icon {
    font-size: 16px;
}

/* Loading Screen */
#loading-screen {
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

#loading-screen.active {
    display: flex; /* Show as flex when active */
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-content p {
    color: var(--hint-color);
    font-size: 14px;
}

/* Cabinet Header */
.cabinet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center {
    flex: 1;
    text-align: center;
}

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

.menu-btn, .notifications-btn, .more-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    color: var(--text-color);
    transition: opacity 0.2s;
}

.menu-btn:active, .notifications-btn:active, .more-btn:active {
    opacity: 0.6;
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Dashboard Content */
.dashboard-content {
    padding: 20px 16px;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* User Identity Section */
.user-identity-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

.user-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.username-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.username {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.vpn-icon {
    font-size: 16px;
}

.user-email {
    font-size: 14px;
    color: var(--hint-color);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-connect-vpn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--bg-color);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-connect-vpn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

.btn-buy {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-text);
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-buy:active {
    opacity: 0.8;
    transform: scale(0.98);
}

.btn-trial {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.btn-trial:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Tariff Section */
.tariff-section {
    margin-top: 8px;
}

.tariff-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 12px;
}

.tariff-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tariff-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.tariff-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tariff-label {
    font-size: 14px;
    color: var(--hint-color);
    font-weight: 500;
}

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

.tariff-info-banner {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: white;
}

.info-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-label {
    font-size: 12px;
    opacity: 0.9;
}

.info-value {
    font-size: 16px;
    font-weight: 600;
}

.info-center {
    flex: 1;
    text-align: center;
}

.support-message {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.95;
}

/* Profile Card (legacy, keep for compatibility) */
.profile-card {
    background: var(--input-bg);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
}

.profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.profile-item .label {
    font-weight: 500;
    color: var(--hint-color);
    font-size: 14px;
}

.profile-item .value {
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
}

/* Subscribe URL Section */
.subscribe-url-section {
    margin-top: 8px;
}

.subscribe-url-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-color);
}

.url-box {
    background: var(--input-bg);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.url-box code {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    word-break: break-all;
    font-family: 'Courier New', monospace;
    color: var(--text-color);
}

[data-theme="dark"] .url-box code {
    background: rgba(255, 255, 255, 0.1);
}

.copy-btn {
    background: var(--primary-color);
    color: var(--primary-text);
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
}

.copy-btn:active {
    opacity: 0.8;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-color);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--hint-color);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--input-bg);
    color: var(--text-color);
}

.modal-close:active {
    transform: scale(0.9);
}

.modal-body {
    padding: 20px;
}

.modal-description {
    margin: 0 0 20px 0;
    color: var(--hint-color);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.modal-body .input-group {
    margin-bottom: 16px;
}

.modal-body .input-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-color);
    transition: border-color 0.2s;
}

.modal-body .input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid #fcc;
}

.success-message {
    background: #efe;
    color: #3c3;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid #cfc;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn-cancel {
    flex: 1;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-color);
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:active {
    opacity: 0.8;
    transform: scale(0.98);
}

.btn-submit {
    flex: 1;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-text);
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-submit:active {
    opacity: 0.8;
    transform: scale(0.98);
}

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

/* Responsive */
@media (max-width: 480px) {
    .login-content {
        padding: 24px 16px;
    }
    
    .dashboard-content {
        padding: 16px;
    }
    
    .main-title {
        font-size: 28px;
    }
    
    .app-main-logo {
        width: 100px;
        height: 100px;
    }
    
    .logo-icon {
        font-size: 60px;
    }
    
    .tariff-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .tariff-info-banner {
        flex-direction: column;
        text-align: center;
    }
    
    .info-left {
        width: 100%;
    }
    
    .modal-content {
        max-width: 100%;
        margin: 10px;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-body {
        padding: 16px;
    }
}
