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

:root {
    --primary: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --secondary: #6b7280;

    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #374151;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
}

body[data-theme="dark"] {
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #374151;
    --text-primary: #f3f4f6;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Navbar */
.navbar {
    background: var(--bg-primary);
    border-bottom: 2px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px var(--shadow);
    transition: background 0.3s;
}

/* Mobile Navigation */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
}

/* Hide mobile-only menu items on desktop */
.nav-menu-mobile-only {
    display: none !important;
}

.theme-toggle-menu {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 1rem;
    text-align: left;
    width: 100%;
    border-radius: 0.375rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.theme-toggle-menu:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .navbar {
        flex-wrap: wrap;
        position: relative;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border-bottom: 2px solid var(--border-color);
        flex-direction: column;
        padding: 1rem;
        display: none !important;
        box-shadow: 0 4px 6px var(--shadow);
        z-index: 1000;
    }

    .nav-menu.active {
        display: flex !important;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a,
    .nav-menu button {
        display: block;
        width: 100%;
        text-align: left;
        padding: 0.75rem 1rem;
    }

    /* Show mobile-only items */
    .nav-menu-mobile-only {
        display: block !important;
        border-top: 1px solid var(--border-color);
        margin-top: 0.5rem;
        padding-top: 0.5rem;
    }

    /* Hide desktop nav-user */
    .nav-user {
        display: none !important;
    }
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

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

.nav-menu a {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: var(--bg-tertiary);
    color: var(--primary);
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    margin-left: 0.5rem;
}

.theme-toggle:hover {
    background: var(--bg-primary);
    transform: scale(1.1);
}

.nav-menu a.alarm-alert {
    background: var(--danger);
    color: white;
    font-weight: 600;
    animation: pulse-bg 2s ease-in-out infinite;
    position: relative;
}

.nav-menu a.alarm-ok {
    background: var(--success);
    color: white;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes pulse-bg {
    0%, 100% {
        background: var(--danger);
    }
    50% {
        background: #dc2626;
    }
}

.alarm-badge {
    display: inline-block;
    background: #fff;
    color: var(--danger);
    font-size: 0.7rem;
    font-weight: bold;
    padding: 3px 7px;
    border-radius: 12px;
    margin-left: 6px;
    vertical-align: middle;
    box-shadow: 0 0 0 2px var(--danger), 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: badge-pulse 2s ease-in-out infinite;
    min-width: 20px;
    text-align: center;
}

@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 2px var(--danger), 0 2px 8px rgba(239, 68, 68, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 3px var(--danger), 0 3px 12px rgba(239, 68, 68, 0.6);
    }
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Cards */
.card {
    background: var(--bg-primary);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px var(--shadow);
    transition: background 0.3s;
}

.card h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

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

.stat-card {
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary);
    box-shadow: 0 1px 3px var(--shadow);
    transition: background 0.3s;
}

.stat-card.stat-success {
    border-left-color: var(--success);
}

.stat-card.stat-danger {
    border-left-color: var(--danger);
}

.stat-card.stat-warning {
    border-left-color: var(--warning);
}

.stat-card.stat-info {
    border-left-color: var(--info);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

/* Mobile responsive stats */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-label {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
        margin-bottom: 0.75rem;
    }

    .stat-card {
        padding: 0.5rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 1rem;
    }
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 1rem;
    }
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.table tr:hover {
    background: var(--bg-tertiary);
}

/* Mobile responsive tables */
@media (max-width: 768px) {
    .table {
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.4rem 0.25rem;
    }

    /* Hide "Last Seen" and "Watchdog" columns on mobile */
    .table th:nth-child(3),
    .table td:nth-child(3),
    .table th:nth-child(4),
    .table td:nth-child(4) {
        display: none;
    }

    .card {
        padding: 1rem;
    }
}

/* Extra small screens - more compact */
@media (max-width: 480px) {
    .table {
        font-size: 0.7rem;
    }

    .table th,
    .table td {
        padding: 0.35rem 0.2rem;
    }

    .card {
        padding: 0.75rem;
    }
}

.table tr.disabled {
    opacity: 0.5;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.2s, background 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.checkbox-label input {
    width: auto;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn:hover {
    background: var(--bg-tertiary);
}

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

.btn-primary:hover {
    background: #2563eb;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #cffafe;
    color: #155e75;
}

.badge-secondary {
    background: var(--light);
    color: #4b5563;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* Alarm List */
.alarm-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.alarm-list li {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--bg-primary);
    transition: all 0.2s;
}

.alarm-list li:hover {
    box-shadow: 0 2px 4px var(--shadow);
}

.alarm-list li.acknowledged {
    opacity: 0.6;
    border-left: 4px solid var(--info);
}

.alarm-list li:not(.acknowledged) {
    border-left: 4px solid var(--danger);
}

.alarm-message {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.alarm-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .alarm-list li {
        padding: 0.75rem;
    }

    .alarm-message {
        font-size: 0.875rem;
        margin-bottom: 0.4rem;
    }

    .alarm-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        font-size: 0.8rem;
    }
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

/* Watchdog Status Box */
.watchdog-status {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    transition: background 0.3s;
    gap: 1rem 1.5rem;
}

.watchdog-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.watchdog-main strong {
    color: var(--text-primary);
    font-weight: 600;
}

.watchdog-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    color: var(--text-secondary);
}

.watchdog-info span {
    white-space: nowrap;
}

.watchdog-time {
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .watchdog-status {
        padding: 0.875rem;
        font-size: 0.85rem;
        gap: 0.75rem;
    }

    .watchdog-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
    }

    .watchdog-time {
        width: 100%;
    }
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}
