:root, .theme-light {
    --bg-color: #F2F2F7;
    --card-bg: #FFFFFF;
    --accent-color: #d6a800;
    --green-color: #34C759;
    --red-color: #FF3B30;
    --orange-color: #FF9500;
    --text-primary: #000000;
    --text-secondary: #636366;
    --separator-color: #C6C6C8;
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

.theme-dark {
    --bg-color: #121212;
    --card-bg: #1E1E1E;
    --accent-color: #d6a800;
    --green-color: #30D158;
    --red-color: #FF453A;
    --orange-color: #FF9F0A;
    --text-primary: #FFFFFF;
    --text-secondary: #A0A0A0;
    --separator-color: #2C2C2C;
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4), 0 4px 6px rgba(0,0,0,0.3);
}

*, *::before, *::after { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

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

.app-container {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: calc(1.5rem + env(safe-area-inset-top)) 1rem 2rem 1rem;
    padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

h1 .logo {
    font-size: 2rem;
}

h2 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 1.5rem 0 0.5rem 0.5rem;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0.5rem 0;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1rem;
    transition: background-color 0.3s ease;
}

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

.project-name {
    font-size: 1.25rem;
    font-weight: 600;
}

.status-badge {
    font-size: 0.7rem;
    padding: 0.3em 0.75em;
    border-radius: 99px;
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.status-badge.active {
    background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
    color: white;
    box-shadow: 0 0 15px rgba(52, 199, 89, 0.4);
}

.status-badge.expired {
    background: linear-gradient(135deg, #FF3B30 0%, #FF453A 100%);
    color: white;
}

.status-badge.warning {
    background: linear-gradient(135deg, #FF9500 0%, #FF9F0A 100%);
    color: white;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 122, 255, 0.05);
    border-radius: 10px;
    transition: background 0.2s ease;
}

.detail-emoji {
    font-size: 1.1rem;
}

.detail-info {
    display: flex;
    flex-direction: column;
}

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

.detail-value {
    font-size: 0.9rem;
    font-weight: 600;
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.device-grid.two-col {
    grid-template-columns: repeat(2, 1fr);
}

.device-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 0.75rem;
    background: var(--card-bg);
    border: 2px solid var(--separator-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--text-primary);
    font-family: inherit;
}

.device-btn:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.device-btn .icon {
    font-size: 2rem;
}

.device-btn .label {
    font-size: 0.85rem;
    font-weight: 500;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: white;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-color);
    color: #000000;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--green-color);
}

.btn-success:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-download {
    background: #FFB300;
    color: #000000;
}

.btn-download:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background: var(--separator-color);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--separator-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

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

.btn-large {
    padding: 1.25rem;
    font-size: 1.1rem;
}

.btn + .btn {
    margin-top: 0.75rem;
}

.list-group {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.list-item {
    display: flex;
    align-items: center;
    padding: 0.9rem 1rem;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid var(--separator-color);
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

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

.list-item:hover {
    background: rgba(0, 122, 255, 0.05);
}

.list-item .icon {
    font-size: 1.25rem;
    width: 28px;
    text-align: center;
}

.list-item .text {
    flex: 1;
    font-size: 0.95rem;
}

.list-item .chevron {
    color: var(--text-secondary);
    font-size: 1.25rem;
}

/* Wizard Navigation */
.wizard-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* IMPROVED: Back Button - Circle with centered arrow */
.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: var(--card-bg);
    border: none;
    cursor: pointer;
    color: var(--accent-color);
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    padding: 0;
}

.back-btn:hover {
    transform: scale(1.05);
}

.back-btn:active {
    transform: scale(0.95);
}

.back-btn svg {
    display: block;
}

.wizard-title {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--separator-color);
    transition: all 0.3s ease;
}

.step-dot.active {
    background: var(--accent-color);
    width: 24px;
    border-radius: 4px;
}

.step-dot.done {
    background: var(--green-color);
}

.info-box {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(214, 168, 0, 0.1);
    border-radius: 12px;
    margin: 1rem 0;
}

.info-box .icon {
    font-size: 1.25rem;
}

.info-box .text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.success-icon {
    font-size: 4rem;
    text-align: center;
    margin: 1rem 0;
}

.success-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
}

.success-text {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.screen {
    display: none !important;
}

.screen.active {
    display: block !important;
    animation: fadeIn 0.3s ease;
}

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

.theme-toggle {
    position: fixed;
    top: calc(1rem + env(safe-area-inset-top));
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: var(--shadow-md);
    z-index: 1001;
    transition: transform 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--separator-color);
}

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--separator-color);
    padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.tab-bar-inner {
    display: flex;
    width: 100%;
    max-width: 520px;
    justify-content: space-around;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    font-family: inherit;
}

.tab-item:hover {
    color: var(--accent-color);
}

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

.tab-item .tab-icon {
    font-size: 1.5rem;
}

.tab-item .tab-label {
    font-size: 0.7rem;
    font-weight: 500;
}

.server-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--separator-color);
}

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

.server-name {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
}

.server-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--green-color);
    box-shadow: 0 0 8px var(--green-color), 0 0 16px var(--green-color);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 8px var(--green-color), 0 0 16px var(--green-color); }
    50% { box-shadow: 0 0 12px var(--green-color), 0 0 24px var(--green-color); }
}

.link-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-md);
}

.link-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.9rem;
    background: rgba(214, 168, 0, 0.15);
    color: var(--accent-color);
    border: 1px solid rgba(214, 168, 0, 0.3);
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.link-btn:hover {
    background: rgba(214, 168, 0, 0.25);
    border-color: rgba(214, 168, 0, 0.5);
    transform: translateY(-1px);
}

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

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 1.5rem 0;
}

.processing-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--separator-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--separator-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.plan-item:hover {
    background: rgba(214, 168, 0, 0.05);
}

.payment-method-item:hover {
    background: rgba(214, 168, 0, 0.05);
}

.tv-instruction-placeholder {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 400px) {
    .device-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
}
