:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #2481cc;
    --tg-theme-button-text-color: #ffffff;
    --primary-color: #2481cc;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    padding: 0;
    margin: 0;
    overflow-x: hidden;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 0 0 30px 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;
}

.header p {
    font-size: 16px;
    opacity: 0.9;
}

.device-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.device-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.device-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px rgba(36, 129, 204, 0.2);
}

.device-card.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.device-icon {
    font-size: 60px;
    margin-bottom: 15px;
}

.device-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--tg-theme-text-color);
}

.key-list {
    margin-bottom: 30px;
}

.key-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    border: 2px solid #f0f0f0;
    transition: all 0.3s ease;
}

.key-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.key-status {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.key-status.active {
    background: #e8f5e9;
    color: #4CAF50;
}

.key-status.expired {
    background: #ffebee;
    color: #f44336;
}

.key-info {
    margin-bottom: 15px;
}

.key-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.key-info-label {
    color: var(--tg-theme-hint-color);
    font-size: 14px;
}

.key-info-value {
    font-weight: 600;
    font-size: 14px;
}

.btn {
    display: block;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    margin-bottom: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.instructions {
    background: white;
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.instructions h2 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--tg-theme-text-color);
}

.step {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
}

.step-number {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 15px;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 5px;
}

.step-description {
    color: var(--tg-theme-hint-color);
    font-size: 14px;
    line-height: 1.5;
}

.app-links {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.app-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: #000;
    color: white;
    border-radius: 12px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.app-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.config-display {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    word-break: break-all;
    font-family: monospace;
    font-size: 12px;
    max-height: 150px;
    overflow-y: auto;
}

.loading {
    text-align: center;
    padding: 50px 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
}

.empty-state-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state-text {
    color: var(--tg-theme-hint-color);
    font-size: 16px;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #323232;
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
}

@media (max-width: 480px) {
    .device-selector {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 24px;
    }
}
