/* ===== CSS VARIABLES ===== */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #0f172a;
    --background: #ffffff;
    --background-alt: #f8fafc;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

/* ===== RESET & BASE ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }

/* ===== UTILITIES ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}
.text-center { text-align: center; }
.hidden { display: none !important; }
.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
    border: 2px solid transparent;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}
.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== HEADER ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--secondary);
}
.nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}
.nav-link {
    color: var(--text-muted);
    font-weight: 500;
}
.nav-link:hover,
.nav-link.active {
    color: var(--primary);
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-auth { display: flex; gap: 0.75rem; }
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--background-alt);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
}
.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}
.nav-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.nav-username {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}
.nav-status {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.nav-status.active { color: var(--success); }
.nav-status.inactive { color: var(--text-muted); }
.nav-status.expired { color: var(--danger); }

/* ===== HERO ===== */
.hero {
    padding: 4rem 0;
    background: linear-gradient(135deg, var(--background-alt) 0%, var(--background) 100%);
    text-align: center;
}
.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--secondary);
}
.hero p {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2rem;
}
.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== FEATURES ===== */
.features {
    padding: 3rem 0;
    background: var(--background);
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Жёстко 2 колонки на ПК */
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .features-grid {
        grid-template-columns: 1fr; /* На телефоне автоматически в столбик */
    }
}
.feature-card {
    padding: 1.5rem;
    background: var(--background-alt);
    border-radius: var(--radius);
    text-align: center;
}
.feature-card h3 {
    margin: 0.75rem 0 0.5rem;
    font-size: 1.125rem;
}
.feature-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ===== PRICING ===== */
.pricing {
    padding: 4rem 0;
    background: var(--background-alt);
}
.pricing h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.pricing-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}
.pricing-card {
    background: var(--background);
    padding: 2rem;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    text-align: center;
    transition: var(--transition);
    position: relative;
}
.pricing-card:hover,
.pricing-card.selected {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.pricing-card.featured {
    border-color: var(--primary);
}
.pricing-card .badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 0.25rem 1rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.pricing-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}
.pricing-card .price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--secondary);
    margin: 1rem 0;
}
.pricing-card .price span {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
}
.pricing-card .price small {
    display: block;
    font-size: 0.875rem;
    color: var(--success);
    margin-top: 0.25rem;
}
.pricing-card ul {
    list-style: none;
    margin: 1.5rem 0;
    text-align: left;
}
.pricing-card li {
    padding: 0.5rem 0;
    color: var(--text-muted);
    border-bottom: 1px dashed var(--border);
}
.pricing-card li:last-child { border-bottom: none; }

/* ===== AUTH ===== */
.auth-section {
    padding: 3rem 0;
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    background: var(--background-alt);
}
.auth-card {
    max-width: 420px;
    margin: 0 auto;
    background: var(--background);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--background-alt);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}
.auth-tab {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
}
.auth-tab.active {
    background: var(--background);
    color: var(--primary);
    box-shadow: var(--shadow);
}
.auth-card h2 {
    text-align: center;
    margin-bottom: 0.25rem;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}
.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}
.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}
.auth-switch a {
    font-weight: 500;
    color: var(--primary);
}

/* ===== DASHBOARD ===== */
.dashboard { padding: 3rem 0; }
.dashboard h1 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.75rem;
}
.status-card {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 2px solid var(--border);
}
.status-card.active { border-color: var(--success); }
.status-card.expired { border-color: var(--danger); }
.status-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
}
.status-dot.active { background: var(--success); }
.status-dot.expired { background: var(--danger); }
.status-badge {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--background-alt);
}
.status-badge.active { background: var(--success); color: white; }
.status-badge.expired { background: var(--danger); color: white; }

/* Timer */
.timer-section { margin: 1.5rem 0; }
.timer-label {
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}
.timer-display {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.timer-block {
    background: var(--background-alt);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    min-width: 70px;
    text-align: center;
}
.timer-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
}
.timer-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Progress bar */
.progress-section { margin: 1.5rem 0; }
.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}
.progress-bar {
    height: 8px;
    background: var(--background-alt);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: inherit;
    transition: width 0.3s ease;
}
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }
.progress-fill.red { background: var(--danger); }

/* Info grid */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
}
.info-card {
    background: var(--background-alt);
    padding: 1rem;
    border-radius: var(--radius-sm);
    text-align: center;
}
.info-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.info-value {
    font-weight: 600;
    color: var(--secondary);
}

/* Config section */
.config-section {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 2px solid var(--border);
}
.config-section h3 { margin-bottom: 1rem; }
.config-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.config-info p {
    margin: 0.5rem 0;
    color: var(--text-muted);
}
.config-info strong { color: var(--text); }

.btn-renew {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
}
.btn-renew:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgb(0 0 0 / 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--background);
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 420px;
    width: 100%;
    position: relative;
    animation: modalSlide 0.2s ease;
}
@keyframes modalSlide {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-close {
    position: absolute;
    top: 1rem; right: 1rem;
    font-size: 1.5rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.qr-image {
    width: 100%;
    max-width: 300px;
    margin: 1rem auto;
    border-radius: var(--radius-sm);
}

/* ===== FOOTER ===== */
.footer {
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}
/* --- УСТРОЙСТВА --- */
.devices-section {
    background: var(--background-alt);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    margin-top: 1.5rem;
}
.devices-section h3 { margin-bottom: 1rem; font-size: 1.2rem; }

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #1e293b; /* Твой фон */
    border-radius: 8px;
    margin-bottom: 0.5rem;
    color: #ffffff; /* 🔥 Важно: делаем текст белым, иначе на тёмном фоне его не видно */
}
.device-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.device-info span { font-weight: 500; }
.device-ip { font-size: 0.85rem; opacity: 0.7; }

.btn-download {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-download:hover { background: #2563eb; }

.btn-create-device {
    background: var(--success);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 1rem;
}
.btn-create-device:hover:not(:disabled) { background: #22c55e; }
.btn-create-device:disabled { background: var(--text-muted); cursor: not-allowed; }
/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .device-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .btn-download {
        align-self: flex-end;
    }
}
/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; }
    .nav { order: 3; width: 100%; justify-content: center; padding-top: 1rem; }
    .nav-right { margin-left: auto; }
    .hero h1 { font-size: 2rem; }
    .hero p { font-size: 1rem; }
    .pricing-card .price { font-size: 1.75rem; }
    .timer-display { flex-wrap: wrap; }
    .timer-block { min-width: 60px; padding: 0.5rem 0.75rem; }
    .timer-number { font-size: 1.25rem; }
    .info-grid { grid-template-columns: 1fr; }
    .config-actions { flex-direction: column; }
    .config-actions .btn { width: 100%; }
}

@media (max-width: 480px) {
    .hero { padding: 2.5rem 0; }
    .pricing, .features, .dashboard { padding: 2rem 0; }
    .auth-card { padding: 1.5rem; }
    .modal-content { padding: 1.5rem; }
}
