/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

:root {
    --primary: #2c3e50;
    --primary-dark: #1a252f;
    --secondary: #3498db;
    --accent: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --gray: #95a5a6;
    --gray-light: #bdc3c7;
    --border: #dfe6e9;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --radius: 8px;
}

body {
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    background: var(--primary);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-logo i {
    color: var(--accent);
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-menu a {
    color: var(--light);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.logout-btn {
    background: var(--danger);
    color: white !important;
}

.logout-btn:hover {
    background: #c0392b !important;
}

.badge {
    background: var(--accent);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    flex: 1;
}

.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

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

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 1rem;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.table tr:hover {
    background: #f8f9fa;
}

.status-active {
    color: var(--accent);
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    font-size: 0.95rem;
}

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

.btn-primary:hover {
    background: #2980b9;
}

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.alert-success {
    background: #d4edda;
    border-color: var(--accent);
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border-color: var(--danger);
    color: #721c24;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border-top: 4px solid;
}

.stat-card:nth-child(1) { border-color: var(--secondary); }
.stat-card:nth-child(2) { border-color: var(--accent); }
.stat-card:nth-child(3) { border-color: var(--warning); }
.stat-card:nth-child(4) { border-color: var(--danger); }

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.stat-label {
    color: var(--gray);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.footer {
    background: var(--primary-dark);
    color: var(--light);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary);
}

.login-container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
}

.sms-message {
    background: white;
    border-left: 4px solid var(--secondary);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.sms-sender {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.sms-body {
    color: #555;
    line-height: 1.5;
}

.sms-time {
    font-size: 0.85rem;
    color: var(--gray);
}

@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== НОВЫЙ ДИЗАЙН DASHBOARD ===== */

/* Статистика в строку */
.stats-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.stat-box {
    flex: 1;
    min-width: 180px;
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    border-left: 4px solid var(--secondary);
}

.stat-box:nth-child(2) { border-color: var(--accent); }
.stat-box:nth-child(3) { border-color: var(--warning); }
.stat-box:nth-child(4) { border-color: var(--danger); }

.stat-icon {
    font-size: 2rem;
    color: var(--secondary);
}

.stat-box:nth-child(2) .stat-icon { color: var(--accent); }
.stat-box:nth-child(3) .stat-icon { color: var(--warning); }
.stat-box:nth-child(4) .stat-icon { color: var(--danger); }

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Фильтр бар */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.filter-group {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: #f8f9fa;
}

.filter-btn.active {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-label {
    color: var(--gray);
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.view-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--gray);
}

.view-btn.active {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

/* Карточки устройств */
.devices-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.device-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    border: 1px solid var(--border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.device-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

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

.device-id {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--dark);
    font-weight: 600;
}

.device-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: 600;
}

.status-valid {
    background: #d4edda;
    color: #155724;
}

.status-invalid {
    background: #f8d7da;
    color: #721c24;
}

.device-info {
    margin-bottom: 1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.info-label {
    color: var(--gray);
}

.info-value {
    font-weight: 500;
    color: var(--dark);
}

.device-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-sms {
    background: var(--secondary);
    color: white;
}

.btn-sms:hover {
    background: #2980b9;
}

.btn-info {
    background: var(--gray-light);
    color: var(--dark);
}

.btn-info:hover {
    background: #95a5a6;
}

/* Пустое состояние */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--gray);
}

.empty-state i {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--dark);
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
}

.modal-close:hover {
    color: var(--dark);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

/* SMS сообщения в модалке */
.sms-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

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

.sms-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray);
}

.sms-body {
    line-height: 1.5;
}

/* Форма смены пароля */
#password-form .form-group {
    margin-bottom: 1rem;
}

#password-form label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

#password-form input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

#password-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius);
}

#password-message.success {
    background: #d4edda;
    color: #155724;
}

#password-message.error {
    background: #f8d7da;
    color: #721c24;
}

/* Адаптивность */
@media (max-width: 768px) {
    .stats-row {
        flex-direction: column;
    }
    
    .devices-container {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .filter-group {
        flex-wrap: wrap;
    }
}
