:root {
    --bg-primary: #0a1628;
    --bg-secondary: #0f2035;
    --bg-card: #132a44;
    --bg-card-hover: #173452;
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --accent-dark: #2563eb;
    --text-primary: #ffffff;
    --text-secondary: #8ba3c7;
    --text-muted: #4a6382;
    --border: #1e3a5f;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    padding-top: 56px;
    padding-bottom: 70px;
}

/* ===== HEADER ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-direction: column;
    align-items: flex-start;
}

.header-left .header-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.header-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: -4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.header-btn:active {
    background: var(--bg-card-hover);
}

.flag-ru {
    display: inline-block;
    width: 14px;
    height: 10px;
    background: linear-gradient(180deg, #fff 33%, #0039a6 33% 66%, #d52b1e 66%);
    border-radius: 2px;
}

/* ===== SIDE MENU ===== */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.side-menu {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 201;
    transition: right 0.3s;
    display: flex;
    flex-direction: column;
}

.side-menu.active {
    right: 0;
}

.menu-user {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
}

.menu-avatar {
    width: 48px;
    height: 48px;
    background: var(--bg-card);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-secondary);
}

.menu-user-name {
    font-size: 16px;
    font-weight: 600;
}

.menu-user-username {
    font-size: 13px;
    color: var(--accent-light);
    margin-top: 2px;
}

.menu-items {
    padding: 12px 0;
    flex: 1;
}

.menu-item {
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 15px;
    color: var(--text-primary);
}

.menu-item:active {
    background: var(--bg-card);
}

.menu-item i {
    width: 22px;
    text-align: center;
    color: var(--text-secondary);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    font-size: 11px;
}

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

.nav-item i {
    font-size: 20px;
}

/* ===== CONTENT ===== */
.content {
    padding: 16px;
    max-width: 480px;
    margin: 0 auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

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

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.card-value {
    font-size: 24px;
    font-weight: 700;
}

.card-value-sm {
    font-size: 18px;
    font-weight: 700;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== STAT GRID ===== */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 16px 12px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== STATUS BADGE ===== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

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

.badge-purple {
    background: rgba(139, 92, 246, 0.15);
    color: var(--purple);
}

/* ===== GLOBE SECTION ===== */
.globe-section {
    text-align: center;
    padding: 24px 0;
    position: relative;
}

.globe-container {
    width: 220px;
    height: 220px;
    margin: 0 auto;
    position: relative;
}

.globe-svg {
    width: 100%;
    height: 100%;
}

.globe-status {
    margin-top: 16px;
}

.globe-status-connected {
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
}

.globe-status-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.user-greeting {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.user-role {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ===== SUBSCRIPTION LINK ===== */
.sub-link-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    border: 1px solid var(--border);
}

.sub-link-box code {
    flex: 1;
    font-size: 11px;
    color: var(--text-secondary);
    word-break: break-all;
    line-height: 1.4;
}

.sub-link-box button {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ===== DETAIL ROW ===== */
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* ===== DEVICE LIST ===== */
.device-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

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

.device-icon {
    width: 44px;
    height: 44px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.device-info {
    flex: 1;
}

.device-name {
    font-size: 15px;
    font-weight: 600;
}

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

.device-delete {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
}

/* ===== SECTION HEADER ===== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 22px;
    font-weight: 700;
}

.section-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ===== PROFILE MENU ITEM ===== */
.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: background 0.2s;
}

.profile-menu-item:active {
    background: var(--bg-card-hover);
}

.profile-menu-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.profile-menu-text {
    flex: 1;
}

.profile-menu-text h4 {
    font-size: 15px;
    font-weight: 600;
}

.profile-menu-text p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.profile-menu-arrow {
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== FORM ===== */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

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

.form-input:focus {
    border-color: var(--accent);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

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

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

/* ===== TOGGLE ===== */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.toggle-label {
    font-size: 15px;
    font-weight: 500;
}

.toggle {
    width: 48px;
    height: 26px;
    background: var(--bg-secondary);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: background 0.3s;
}

.toggle.active {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle::after {
    content: '';
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 1px;
    left: 1px;
    transition: left 0.3s;
}

.toggle.active::after {
    left: 23px;
}

/* ===== REFERRAL ===== */
.ref-commission {
    background: var(--purple);
    color: white;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
}

.ref-link-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    margin: 12px 0;
}

.ref-link-box code {
    flex: 1;
    font-size: 11px;
    color: var(--text-secondary);
    word-break: break-all;
}

.ref-link-box button {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ===== NUMBER STEPPER ===== */
.stepper {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}

.stepper-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
}

.stepper-value {
    font-size: 28px;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
}

/* ===== PLAN CARDS (for buying) ===== */
.plan-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 12px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: border-color 0.2s;
}

.plan-card:hover, .plan-card:active {
    border-color: var(--accent);
}

.plan-card.popular {
    border-color: var(--accent);
    position: relative;
}

.plan-card.popular::after {
    content: 'ПОПУЛЯРНЫЙ';
    position: absolute;
    top: -10px;
    right: 16px;
    background: var(--accent);
    color: white;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.plan-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.plan-features {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.plan-price {
    font-size: 24px;
    font-weight: 700;
}

.plan-price span {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 14px;
}

/* ===== NOTIFICATION SETTINGS ===== */
.notif-block {
    margin-bottom: 20px;
}

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

.notif-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
}

.notif-title {
    font-size: 15px;
    font-weight: 600;
}

.notif-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ===== LOADING ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading i {
    font-size: 32px;
    animation: spin 1s linear infinite;
}

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

/* ===== BACK BUTTON ===== */
.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 16px;
    background: none;
    border: none;
}

/* ===== CHART (devices circle) ===== */
.chart-container {
    width: 160px;
    height: 80px;
    margin: 0 auto 20px;
    position: relative;
}

.chart-value {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 28px;
    font-weight: 700;
}

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

/* ===== DELETE ALL BTN ===== */
.btn-danger-text {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* ===== INFO ITEMS ===== */
.info-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

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

.info-item i {
    color: var(--text-secondary);
    margin-top: 3px;
    width: 20px;
    text-align: center;
}

.info-item-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}