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

:root {
    --bg-primary: #f0f8ff;
    --bg-secondary: #e3f2fd;
    --bg-card: #ffffff;
    --bg-input: #f5f9ff;
    --text-primary: #0d47a1;
    --text-secondary: #1565c0;
    --text-muted: #64b5f6;
    --border-color: #90caf9;
    --shadow: 0 4px 20px rgba(13, 71, 161, 0.08);
    --shadow-hover: 0 8px 30px rgba(13, 71, 161, 0.15);
    --gradient-start: #2196f3;
    --gradient-end: #64b5f6;
    --sub-bg: #f5f9ff;
    --sub-active-bg: #e3f2fd;
    --toast-bg: #0d47a1;
    --toast-success: #0d47a1;
    --toast-error: #c62828;
    --modal-overlay: rgba(13, 71, 161, 0.6);
}

[data-theme="dark"] {
    --bg-primary: #0a0a1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #1a1a2e;
    --bg-input: #0a0a1a;
    --text-primary: #e8e8ff;
    --text-secondary: #a8b5ff;
    --text-muted: #6b7fc8;
    --border-color: #2a2a4e;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.5);
    --gradient-start: #4a6cf7;
    --gradient-end: #7b9aff;
    --sub-bg: #0a0a1a;
    --sub-active-bg: #1a1a2e;
    --toast-bg: #1a1a2e;
    --toast-success: #4a6cf7;
    --toast-error: #ff6b6b;
    --modal-overlay: rgba(0,0,0,0.8);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: all 0.3s ease;
}

.main-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 8px;
}

.profile-btn-top {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 12px;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.profile-btn-top:hover {
    background: var(--bg-secondary);
}

.top-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.top-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}
.badge.active { background: rgba(33, 150, 243, 0.15); color: #0d47a1; }
.badge.expired { background: rgba(244, 67, 54, 0.15); color: #c62828; }
[data-theme="dark"] .badge.active { background: rgba(74, 108, 247, 0.2); color: #7b9aff; }
[data-theme="dark"] .badge.expired { background: rgba(244, 67, 54, 0.2); color: #ff6b6b; }

.lang-selector { display: flex; gap: 4px; }
.lang-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}
.lang-btn:hover { background: var(--bg-secondary); border-color: var(--gradient-start); }
.lang-btn.active { background: var(--gradient-start); border-color: var(--gradient-start); color: white; }

.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    width: 100%;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.card-header h3 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--text-primary); }
.btn-refresh {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    transition: all 0.3s ease;
}
.btn-refresh:hover { color: var(--text-primary); transform: rotate(180deg); }

.subscription-item {
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--sub-bg);
    border-radius: 12px;
    border-left: 4px solid var(--gradient-start);
    cursor: pointer;
    transition: all 0.3s ease;
}
.subscription-item:hover { transform: translateX(4px); box-shadow: var(--shadow); }
.subscription-item:last-child { margin-bottom: 0; }
.subscription-item.active {
    border-left-color: #ff9800;
    background: var(--sub-active-bg);
}
.subscription-item .sub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.subscription-item .sub-name { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.subscription-item .sub-days { font-size: 13px; color: var(--text-muted); }
.subscription-item .sub-key { font-size: 11px; color: var(--text-muted); font-family: monospace; }
.subscription-item .sub-status {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(33, 150, 243, 0.1);
    color: var(--text-secondary);
}
.subscription-item .sub-status.active { background: rgba(76, 175, 80, 0.15); color: #2e7d32; }
.subscription-item .sub-status.expired { background: rgba(244, 67, 54, 0.15); color: #c62828; }

.loading-subscriptions { text-align: center; padding: 20px 0; color: var(--text-muted); }
.loading-spinner-small {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--gradient-start);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 8px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.info-item { background: var(--bg-input); padding: 12px; border-radius: 12px; }
.info-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.info-value { font-size: 18px; font-weight: 700; color: var(--text-primary); }

.traffic-section { margin-top: 8px; }
.traffic-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.progress-bar { width: 100%; height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
}
.progress-fill.warning { background: linear-gradient(90deg, #ff9800, #ffc107); }
.progress-fill.danger { background: linear-gradient(90deg, #f44336, #e91e63); }

.expiry-info {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    flex-wrap: wrap;
}
.expiry-info i { color: var(--text-muted); }

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 16px;
}
.action-btn {
    background: var(--bg-input);
    border: none;
    border-radius: 12px;
    padding: 14px 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}
.action-btn:hover { background: var(--bg-secondary); border-color: var(--border-color); }
.action-btn:active { transform: scale(0.95); }
.action-btn i { font-size: 20px; color: var(--gradient-start); }
.action-btn span { font-size: 11px; color: var(--text-muted); }

.server-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.server-item {
    background: var(--bg-input);
    padding: 14px;
    border-radius: 12px;
    text-align: center;
}
.server-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.server-value { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.server-value.ping { color: var(--gradient-start); }

.footer { text-align: center; padding: 20px 0 10px; font-size: 14px; color: var(--text-muted); font-weight: 500; }

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    backdrop-filter: blur(10px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow-hover);
}
@keyframes slideUp {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.modal-header h3 { color: var(--text-primary); }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.modal-close:hover { color: var(--text-primary); transform: rotate(90deg); }
.modal-body { text-align: center; }

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: white;
    margin: 0 auto 12px;
    overflow: hidden;
}
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}
.profile-id {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.profile-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.profile-btn:hover { background: var(--bg-secondary); }
.profile-btn.theme-btn { background: var(--bg-secondary); }

#qrCode { display: flex; flex-direction: column; align-items: center; margin: 16px 0; }
#qrCode img { border-radius: 12px; background: white; padding: 16px; max-width: 100%; height: auto; }
.modal-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

.link-copy-area {
    background: var(--bg-input);
    border-radius: 12px;
    padding: 12px 16px;
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-wrap: wrap;
}
.link-copy-area:hover { border-color: var(--gradient-start); background: var(--bg-secondary); }
.link-copy-area p { font-size: 12px; color: var(--text-secondary); word-break: break-all; flex: 1; font-family: monospace; }
.copy-link-btn {
    background: var(--gradient-start);
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.copy-link-btn:hover { background: var(--text-primary); transform: scale(1.02); }
.copy-link-btn:active { transform: scale(0.95); }

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toast-bg);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 3000;
    animation: slideUp 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    max-width: 90%;
    text-align: center;
}
.toast.success { background: var(--toast-success); }
.toast.error { background: var(--toast-error); }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

@media (max-width: 480px) {
    .main-content { padding: 10px; }
    .topbar { padding: 10px 14px; flex-wrap: wrap; }
    .topbar-right { flex-wrap: wrap; gap: 6px; }
    .profile-btn-top { padding: 2px 6px; }
    .top-username { font-size: 13px; }
    .top-avatar { width: 34px; height: 34px; font-size: 14px; }
    .card { padding: 16px; }
    .info-grid { grid-template-columns: 1fr 1fr; }
    .server-grid { grid-template-columns: 1fr 1fr; }
    .action-grid { grid-template-columns: 1fr 1fr; }
    .subscription-item .sub-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 360px) {
    .info-grid { grid-template-columns: 1fr; }
    .server-grid { grid-template-columns: 1fr; }
    .action-grid { grid-template-columns: 1fr; }
    .lang-selector { gap: 2px; }
    .lang-btn { padding: 3px 8px; font-size: 12px; }
}
