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

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #12131a;
    color: #ecf1f3;
    font-size: 10px;
}

h1, h2, h3, h4, h5, h6, .nav-brand, .nav-brand-text, .page-header h1, .stat-value, .btn {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
}

.navbar {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-brand img {
    height: 24px;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    flex: 1;
}

.nav-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
}

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

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: rgba(255,255,255,0.9);
    font-size: 0.9rem;
}

.btn-logout {
    background: #e74c3c;
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-actions {
    display: flex;
    gap: 0.75rem;
}

button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    transition: all 0.2s;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary { background: #f04158; color: white; }
.btn-primary:hover { background: #d63649; }

button[type="submit"].btn-primary {
    margin-top: 1rem;
    font-size: 12px;
}

.btn-secondary { background: #95a5a6; color: white; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-success { background: #2ecc71; color: white; }
.btn-success:hover { background: #27ae60; }
.btn-warning { background: #f39c12; color: white; }
.btn-warning:hover { background: #e67e22; }
.btn-danger { background: #e74c3c; color: white; }
.btn-danger:hover { background: #c0392b; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #95a5a6;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0 2px;
}
.icon-btn:hover { transform: scale(1.1); }
.icon-btn-success { background: #2ecc71; }
.icon-btn-success:hover { background: #27ae60; }
.icon-btn-warning { background: #f39c12; }
.icon-btn-warning:hover { background: #e67e22; }
.icon-btn-danger { background: #e74c3c; }
.icon-btn-danger:hover { background: #c0392b; }
.icon-btn-info { background: #3498db; }
.icon-btn-info:hover { background: #2980b9; }

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

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

.stat-card {
    background: #1c1e26;
    padding: 1.25rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.stat-icon.devices { background: linear-gradient(135deg, #3498db 0%, #2980b9 100%); }
.stat-icon.signals { background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%); }
.stat-icon.readings { background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%); }
.stat-icon.alarms { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); }

.stat-info { flex: 1; }
.stat-value { font-size: 1.75rem; font-weight: 700; display: block; }
.stat-label { color: #7f8c8d; font-size: 0.85rem; }
.stat-sub { color: #95a5a6; font-size: 0.75rem; display: block; margin-top: 0.25rem; }

.table-container {
    background: #1c1e26;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid #4a4f6a; font-size: 12px; color: #ecf1f3; }
th { background: #252838; font-weight: 600; color: #ecf1f3; }
tr:hover { background: #3d4259; }
.row-inactive { opacity: 0.6; }
.row-alarm { background: #fee; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filters input, .filters select {
    padding: 0.5rem 1rem;
    border: 2px solid #4a4f6a;
    border-radius: 8px;
    font-size: 12px;
    background: #252838;
    color: #ecf1f3;
}

.form-container {
    background: #1c1e26;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-width: 800px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 12px;
    color: #ecf1f3;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #4a4f6a;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #252838;
    color: #ecf1f3;
}
.form-group input:focus { border-color: #3498db; outline: none; }

.login-card .form-group input {
    background: #252838;
    color: #ecf1f3;
    font-size: 12px;
}
.login-card .form-group input::placeholder {
    color: #7f8c8d;
    font-size: 12px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #ecf0f1;
    align-items: stretch;
}

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

.detail-card {
    background: #1c1e26;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.detail-card h3 { margin-bottom: 1rem; font-size: 1rem; color: #ecf1f3; }
.detail-card dl { display: grid; grid-template-columns: 1fr 2fr; gap: 0.5rem; }
.detail-card dt { color: #95a5a6; }
.detail-card dd { margin: 0; color: #ecf1f3; }

.detail-section {
    background: #1c1e26;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.detail-section h2 { margin-bottom: 1rem; font-size: 1.1rem; }

.alarms-list { display: flex; flex-direction: column; gap: 1rem; }

.alarm-card {
    background: #1c1e26;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid #95a5a6;
}

.alarm-warning { border-left-color: #f39c12; }
.alarm-critical { border-left-color: #e74c3c; }
.alarm-info { border-left-color: #3498db; }

.alarm-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.alarm-type { font-weight: 600; text-transform: uppercase; font-size: 0.85rem; }
.alarm-severity { font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 4px; background: #f8f9fa; }
.alarm-message { margin-bottom: 0.5rem; }
.alarm-meta, .alarm-time { font-size: 0.85rem; color: #7f8c8d; display: flex; gap: 1rem; }
.alarm-actions { margin-top: 0.75rem; }

.logs-container {
    background: #1c1e26;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
}

.log-entry {
    display: grid;
    grid-template-columns: 70px 150px 120px 1fr;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #4a4f6a;
    color: #ecf1f3;
}

.log-DEBUG { background: #f8f9fa; }
.log-INFO { background: white; }
.log-WARNING { background: #fff8e1; }
.log-ERROR { background: #ffebee; }

.log-level { font-weight: 600; }
.log-DEBUG .log-level { color: #95a5a6; }
.log-INFO .log-level { color: #3498db; }
.log-WARNING .log-level { color: #f39c12; }
.log-ERROR .log-level { color: #e74c3c; }

.log-time { color: #7f8c8d; }
.log-message { word-break: break-word; }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.text-center { text-align: center; }
.p-4 { padding: 1rem; }
.mb-2 { margin-bottom: 1rem; }

.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #12131a;
}

.login-card {
    background: #1c1e26;
    padding: 1.25rem;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 320px;
}

.login-header { text-align: center; margin-bottom: 1rem; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.login-header img { margin-bottom: 0.4rem; height: 50px; }
.login-header h1 { margin: 0; color: #ecf1f3; }
.login-header p { color: #95a5a6; font-size: 0.9rem; margin: 0; }

.error-alert {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

.stats-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.mini-stat {
    background: #1c1e26;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    min-width: 100px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.mini-value { font-size: 1.5rem; font-weight: 700; display: block; color: #ecf1f3; }
.mini-label { font-size: 0.75rem; color: #95a5a6; }
.mini-stat.critical { border-bottom: 3px solid #e74c3c; }
.mini-stat.warning { border-bottom: 3px solid #f39c12; }
.mini-stat.info { border-bottom: 3px solid #3498db; }

.app-footer {
    text-align: center;
    padding: 2rem;
    color: #95a5a6;
    font-size: 0.85rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2ecc71;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    backdrop-filter: blur(8px);
}

.toast-visible {
    transform: translateX(0);
}

.toast-hiding {
    transform: translateX(120%);
}

.toast-icon {
    flex-shrink: 0;
    display: flex;
}

.toast-success { background: rgba(46, 204, 113, 0.95); }
.toast-error { background: rgba(231, 76, 60, 0.95); }
.toast-warning { background: rgba(243, 156, 18, 0.95); }
.toast-info { background: rgba(52, 152, 219, 0.95); }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

button[type="submit"]:disabled .spinner {
    margin-right: 0.5rem;
}
