/* ========== CSS Variables & Reset ========== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --info: #3b82f6;
    --info-light: #eff6ff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== Container ========== */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 24px;
    width: 100%;
    flex: 1;
}

/* ========== Header ========== */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 48px 20px 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.header h1 {
    font-size: 28px;
    font-weight: 800;
    color: white;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
    position: relative;
}

.header p {
    font-size: 15px;
    color: rgba(255,255,255,0.85);
    font-weight: 400;
    position: relative;
}

/* ========== Cards ========== */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.card-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

/* ========== Status badges ========== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.status-active {
    background: var(--success-light);
    color: var(--success);
}

.status-expired {
    background: var(--danger-light);
    color: var(--danger);
}

.status-none {
    background: var(--gray-100);
    color: var(--gray-500);
}

/* ========== Buttons ========== */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 10px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.btn-success:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16,185,129,0.4);
}

.btn-danger {
    background: white;
    color: var(--danger);
    border: 2px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger-light);
}

.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 2px solid var(--gray-200);
}

.btn-outline:hover {
    border-color: var(--gray-400);
    background: var(--gray-50);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-500);
    border: none;
    padding: 10px;
}

.btn-ghost:hover {
    color: var(--gray-700);
    background: var(--gray-100);
}

/* ========== Subscribe Grid ========== */
.subscribe-grid {
    display: grid;
    gap: 12px;
}

.subscribe-card {
    background: white;
    border: 2px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 24px 20px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.subscribe-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    opacity: 0;
    transition: var(--transition);
}

.subscribe-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.subscribe-card:hover::before {
    opacity: 1;
}

.subscribe-card:active {
    transform: translateY(0);
}

.subscribe-card .name {
    font-size: 17px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.subscribe-card .price {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.subscribe-card .price::after {
    content: ' ₽';
    font-size: 20px;
    font-weight: 600;
}

.subscribe-card .period {
    font-size: 13px;
    color: var(--gray-400);
    font-weight: 500;
}

.subscribe-card .popular {
    position: absolute;
    top: 12px;
    right: -28px;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 32px;
    transform: rotate(45deg);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== Config Box ========== */
.config-box {
    background: var(--gray-900);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #e5e7eb;
    word-break: break-all;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 16px;
    position: relative;
}

.config-box::-webkit-scrollbar {
    width: 6px;
}

.config-box::-webkit-scrollbar-track {
    background: transparent;
}

.config-box::-webkit-scrollbar-thumb {
    background: var(--gray-600);
    border-radius: 3px;
}

/* ========== Alerts ========== */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: var(--info-light);
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ========== Loading ========== */
.loading {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-400);
}

.spinner {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 12px;
}

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

/* ========== Footer ========== */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--gray-400);
    font-size: 12px;
    margin-top: auto;
}

/* ========== Profile Section ========== */
.profile-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 0;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.profile-details {
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

.profile-sub {
    font-size: 13px;
    color: var(--gray-400);
}

/* ========== Divider ========== */
.divider {
    height: 1px;
    background: var(--gray-100);
    margin: 16px 0;
}

/* ========== Menu List ========== */
.menu-list {
    list-style: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: var(--gray-700);
    font-size: 15px;
    font-weight: 500;
}

.menu-item:hover {
    background: var(--gray-50);
}

.menu-item:active {
    background: var(--gray-100);
}

.menu-item .icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.menu-item .icon-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.menu-item .icon-success {
    background: var(--success-light);
    color: var(--success);
}

.menu-item .icon-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.menu-item .icon-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.menu-item .arrow {
    margin-left: auto;
    color: var(--gray-300);
    font-size: 14px;
}

/* ========== Confirm Page ========== */
.confirm-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.confirm-price {
    font-size: 40px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.confirm-price::after {
    content: ' ₽';
    font-size: 24px;
    font-weight: 600;
}

/* ========== Responsive ========== */
@media (max-width: 380px) {
    .header {
        padding: 36px 16px 24px;
    }

    .header h1 {
        font-size: 24px;
    }

    .card {
        padding: 16px;
    }

    .subscribe-card {
        padding: 20px 16px;
    }

    .subscribe-card .price {
        font-size: 28px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }
}

@media (min-width: 481px) {
    .container {
        max-width: 560px;
    }

    .subscribe-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 640px;
        padding: 0 24px 32px;
    }

    .header {
        padding: 56px 24px 36px;
    }

    .header h1 {
        font-size: 32px;
    }
}

/* ========== Dark mode support ========== */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #111827;
        --gray-100: #1f2937;
        --gray-200: #374151;
        --gray-300: #4b5563;
        --gray-400: #9ca3af;
        --gray-500: #d1d5db;
        --gray-600: #e5e7eb;
        --gray-700: #f3f4f6;
        --gray-800: #f9fafb;
        --gray-900: #ffffff;
    }

    body {
        background: #0f172a;
    }

    .card {
        background: #1e293b;
        border-color: #334155;
    }

    .subscribe-card {
        background: #1e293b;
        border-color: #334155;
    }

    .subscribe-card:hover {
        border-color: var(--primary);
    }

    .btn-outline {
        color: var(--gray-300);
        border-color: var(--gray-600);
    }

    .btn-outline:hover {
        background: var(--gray-100);
    }

    .btn-danger {
        background: transparent;
    }

    .btn-danger:hover {
        background: rgba(239,68,68,0.1);
    }

    .menu-item:hover {
        background: var(--gray-100);
    }

    .menu-item:active {
        background: var(--gray-200);
    }

    .divider {
        background: var(--gray-200);
    }

    .config-box {
        background: #0f172a;
    }

    .alert-success {
        background: rgba(16,185,129,0.1);
    }

    .alert-error {
        background: rgba(239,68,68,0.1);
    }

    .alert-info {
        background: rgba(59,130,246,0.1);
    }

    .alert-warning {
        background: rgba(245,158,11,0.1);
    }
}

/* ========== Safe area for notched devices ========== */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: calc(48px + env(safe-area-inset-top));
    }

    .container {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }

    .footer {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}
