/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600;700&display=swap');

/* ===== CSS Variables / Dark Theme (default) ===== */
:root {
    --bg-primary: #0e1219;
    --bg-secondary: #151b25;
    --bg-card: #1a2130;
    --bg-card-hover: #212a3a;
    --bg-sidebar: #0c111a;
    --bg-input: #151b25;
    --border-color: #243044;
    --border-light: #2e3e54;
    --text-primary: #e4e8f0;
    --text-secondary: #8b93a8;
    --text-muted: #5a6478;
    --accent: #8bb41a;
    --accent-hover: #a0cc20;
    --accent-light: rgba(177, 214, 65, 0.15);
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --blue: #027ABB;
    --blue-bg: rgba(2, 122, 187, 0.12);
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --sidebar-width: 240px;
    --transition: 0.2s ease;
    --font: 'Source Code Pro', 'SFMono-Regular', Consolas, monospace;
    --logo-filter: none;
    --sidebar-border: #1a2535;
    --sidebar-text: rgba(255,255,255,0.5);
    --sidebar-text-hover: rgba(255,255,255,0.85);
    --sidebar-item-hover-bg: rgba(255,255,255,0.06);
    --sidebar-active-bg: rgba(177, 214, 65, 0.15);
    --sidebar-active-text: #b1d641;
    --sidebar-logo-color: #e4e8f0;
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    --bg-primary: #f4f6f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f3f8;
    --bg-sidebar: #ffffff;
    --bg-input: #f4f6f9;
    --border-color: #dde2ea;
    --border-light: #c8cfd8;
    --text-primary: #181818;
    --text-secondary: #3f3f46;
    --text-muted: #71717a;
    --accent: #7a9e16;
    --accent-hover: #6b8a12;
    --accent-light: rgba(139, 180, 26, 0.10);
    --green: #16a34a;
    --green-bg: rgba(22, 163, 74, 0.10);
    --red: #dc2626;
    --red-bg: rgba(220, 38, 38, 0.08);
    --yellow: #ca8a04;
    --yellow-bg: rgba(202, 138, 4, 0.10);
    --blue: #027ABB;
    --blue-bg: rgba(2, 122, 187, 0.08);
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --logo-filter: none;
    --sidebar-border: #e2e6ee;
    --sidebar-text: #71717a;
    --sidebar-text-hover: #181818;
    --sidebar-item-hover-bg: rgba(0,0,0,0.04);
    --sidebar-active-bg: rgba(139, 180, 26, 0.08);
    --sidebar-active-text: #7a9e16;
    --sidebar-logo-color: #181818;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== Login Page ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0f18 0%, #162a0c 50%, #0a0f18 100%);
}
[data-theme="light"] .login-body {
    background: linear-gradient(135deg, #eef6e8 0%, #d5f0d0 50%, #eef6e8 100%);
}
[data-theme="light"] .login-card {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: 0 8px 40px rgba(0,0,0,0.08);
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 80px; height: 80px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
}
.login-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.login-form .form-group { margin-bottom: 20px; }

.error-message {
    background: var(--red-bg);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid rgba(239,68,68,0.2);
}

/* ===== Form Elements ===== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea,
.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input::placeholder { color: var(--text-muted); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px; height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border-color);
    border-radius: 26px;
    transition: var(--transition);
}
.slider::before {
    content: '';
    position: absolute;
    height: 20px; width: 20px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }

.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--red); color: white; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-full { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-loader {
    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;
}

.btn-icon {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-card-hover); }

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

/* ===== App Layout ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--sidebar-logo-color);
    text-decoration: none;
}
.sidebar-logo img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: var(--logo-filter);
}
.sidebar-logo span {
    white-space: nowrap;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}
.nav-item:hover { background: var(--sidebar-item-hover-bg); color: var(--sidebar-text-hover); }
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.user-info {
    font-size: 13px;
    color: var(--sidebar-text);
    font-weight: 500;
}
.sidebar-footer .btn {
    color: var(--sidebar-text);
    background: transparent;
}
.sidebar-footer .btn:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-item-hover-bg);
}

/* Sidebar close button */
[data-theme="light"] .sidebar-close {
    color: var(--text-muted);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
}

.topbar-actions { display: flex; gap: 8px; }

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.hamburger span {
    width: 22px; height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

/* ===== Views ===== */
.view { display: none; padding: 24px; }
.view.active { display: block; }
.view-header { margin-bottom: 20px; }

.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-bar .form-select {
    width: auto;
    min-width: 160px;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-total { background: var(--blue-bg); color: var(--blue); }
.stat-up { background: var(--green-bg); color: var(--green); }
.stat-down { background: var(--red-bg); color: var(--red); }
.stat-warning { background: var(--yellow-bg); color: var(--yellow); }

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}
.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Monitor Grid (Dashboard) ===== */
.monitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.monitor-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.monitor-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.monitor-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
}
.monitor-card.status-up::before { background: var(--green); }
.monitor-card.status-down::before { background: var(--red); }
.monitor-card.status-warning::before { background: var(--yellow); }
.monitor-card.status-unknown::before { background: var(--text-muted); }

.monitor-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.monitor-card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.monitor-card-host {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.status-badge.up { background: var(--green-bg); color: var(--green); }
.status-badge.down { background: var(--red-bg); color: var(--red); }
.status-badge.warning { background: var(--yellow-bg); color: var(--yellow); }
.status-badge.unknown { background: rgba(95,99,119,0.15); color: var(--text-muted); }

.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-badge.up .status-dot { animation: pulse-green 2s ease-in-out infinite; }

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.monitor-card-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.meta-item {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.meta-value {
    color: var(--text-primary);
    font-weight: 500;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--accent-light);
    color: var(--accent);
}

/* ===== Monitors Table ===== */
.monitors-table-wrap { overflow-x: auto; }

.monitors-table {
    width: 100%;
    border-collapse: collapse;
}

.monitors-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.monitors-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.monitors-table tr:hover td { background: var(--bg-card); }

.table-actions {
    display: flex;
    gap: 4px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-lg { max-width: 800px; }

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

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Detail View ===== */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.detail-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
}

.detail-item-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-item-value {
    font-size: 20px;
    font-weight: 700;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}
.progress-fill.green { background: var(--green); }
.progress-fill.yellow { background: var(--yellow); }
.progress-fill.red { background: var(--red); }

.services-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.service-tag {
    padding: 3px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    color: var(--text-secondary);
}

.network-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}
.network-table th, .network-table td {
    padding: 8px 12px;
    font-size: 13px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.network-table th {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* History */
.history-section { margin-top: 24px; }
.history-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.history-time {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    min-width: 140px;
}

.history-response {
    color: var(--text-secondary);
    margin-left: auto;
    font-size: 12px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}
.empty-state svg { color: var(--text-muted); margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

/* ===== Settings ===== */
.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 480px;
    margin-bottom: 20px;
}
.settings-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .main-content { margin-left: 0; }
    .hamburger { display: flex; }

    .monitor-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar { padding: 12px 16px; }
    .view { padding: 16px; }

    .modal { margin: 10px; }

    .monitors-table th:nth-child(5),
    .monitors-table td:nth-child(5),
    .monitors-table th:nth-child(7),
    .monitors-table td:nth-child(7) { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }
    .filter-bar { flex-direction: column; }
    .filter-bar .form-select { min-width: 100%; }
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 400px;
}
.toast.success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.toast.error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.toast.info { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== Loading Spinner ===== */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

/* ===== View Toggle (Grid/List) ===== */
.view-toggle {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.toggle-btn {
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.toggle-btn:hover { color: var(--text-secondary); }
.toggle-btn.active {
    background: var(--accent);
    color: white;
}
.toggle-btn + .toggle-btn {
    border-left: 1px solid var(--border-color);
}

/* ===== Monitor List View ===== */
.monitor-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.list-header {
    display: grid;
    grid-template-columns: 110px 1.3fr 70px 1fr 1.2fr 140px 90px 100px;
    gap: 8px;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.list-row {
    display: grid;
    grid-template-columns: 110px 1.3fr 70px 1fr 1.2fr 140px 90px 100px;
    gap: 8px;
    padding: 12px 16px;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}
.list-row::before {
    content: '';
    position: absolute;
    left: 0; top: 0;
    width: 3px; height: 100%;
}
.list-row.status-down::before { background: var(--red); }
.list-row.status-warning::before { background: var(--yellow); }
.list-row.status-up::before { background: var(--green); }
.list-row.status-unknown::before { background: var(--text-muted); }

.list-row:hover { background: var(--bg-card); }

.list-col-host {
    color: var(--text-secondary);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-col-response,
.list-col-last {
    color: var(--text-secondary);
    font-size: 12px;
}

.list-col-actions {
    display: flex;
    gap: 2px;
}

@media (max-width: 1200px) {
    .list-header, .list-row {
        grid-template-columns: 100px 1.2fr 70px 1.2fr 130px 80px;
    }
    .list-col-host, .list-col-actions,
    .list-header > :nth-child(4), .list-header > :nth-child(8) {
        display: none;
    }
}

@media (max-width: 900px) {
    .list-header, .list-row {
        grid-template-columns: 90px 1fr 1.2fr 80px;
    }
    .list-col-type, .list-col-host, .list-col-graph, .list-col-actions,
    .list-header > :nth-child(3), .list-header > :nth-child(4),
    .list-header > :nth-child(6), .list-header > :nth-child(8) {
        display: none;
    }
}

@media (max-width: 600px) {
    .list-header, .list-row {
        grid-template-columns: 90px 1fr 80px;
    }
    .list-col-metrics,
    .list-header > :nth-child(5) {
        display: none;
    }
}

/* ===== Sparkline (mini chart in cards/list) ===== */
.sparkline-container {
    height: 48px;
    margin: 8px 0 4px;
    position: relative;
}

.sparkline-container canvas {
    display: block;
}

.sparkline-list {
    height: 32px;
    margin: 0;
}

/* ===== Detail Chart ===== */
.detail-chart-section {
    margin-bottom: 24px;
}

.chart-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    min-height: 220px;
}

.chart-wrapper canvas {
    display: block;
}

.chart-tooltip {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 10;
    box-shadow: var(--shadow);
    white-space: nowrap;
}

/* ===== Uptime Bar ===== */
.uptime-bar {
    display: flex;
    gap: 2px;
    height: 28px;
    align-items: stretch;
}

.uptime-tick {
    flex: 1;
    border-radius: 3px;
    min-width: 3px;
    transition: opacity var(--transition);
    cursor: default;
}
.uptime-tick:hover {
    opacity: 0.7;
    transform: scaleY(1.15);
}

/* ===== Sensor Charts (per-sensor graphs in detail modal) ===== */
.sensor-charts-section {
    margin: 24px 0;
}

.sensor-charts-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.sensor-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
}

@media (max-width: 700px) {
    .sensor-charts-grid {
        grid-template-columns: 1fr;
    }
}

.sensor-chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
}

.sensor-chart-card:hover {
    border-color: var(--border-light);
}

.sensor-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 6px;
}

.sensor-chart-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sensor-chart-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.sensor-chart-canvas {
    position: relative;
    padding: 4px 8px 8px;
    min-height: 160px;
}

.sensor-chart-canvas canvas {
    display: block;
}

.sensor-chart-empty {
    text-align: center;
    padding: 40px 10px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ===== Inline Card Metrics (CPU/RAM/HDD bars) ===== */
.card-metrics {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 10px 0 4px;
    padding: 10px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.mini-metric {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.mini-metric-label {
    min-width: 42px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.mini-metric-bar {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.mini-metric-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.mini-metric-fill.green { background: var(--green); }
.mini-metric-fill.yellow { background: var(--yellow); }
.mini-metric-fill.red { background: var(--red); }

.mini-metric-val {
    min-width: 36px;
    text-align: right;
    font-weight: 600;
    font-size: 11px;
    color: var(--text-primary);
}

.val-ok { color: var(--green); }
.val-warn { color: var(--yellow); }
.val-err { color: var(--red); }

/* ===== List View Metric Pills ===== */
.list-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.metric-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
}
.metric-pill.pill-green { background: var(--green-bg); color: var(--green); border-color: rgba(34,197,94,0.2); }
.metric-pill.pill-yellow { background: var(--yellow-bg); color: var(--yellow); border-color: rgba(234,179,8,0.2); }
.metric-pill.pill-red { background: var(--red-bg); color: var(--red); border-color: rgba(239,68,68,0.2); }

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: none;
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 16px;
}
.theme-toggle:hover {
    background: var(--sidebar-item-hover-bg);
    color: var(--sidebar-text-hover);
}

/* Light theme login toggle */
.login-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 18px;
    z-index: 10;
    transition: all var(--transition);
}
.login-theme-toggle:hover {
    background: var(--bg-card-hover);
}

/* ===== Threshold Form Section ===== */
.thresholds-section {
    margin-top: 20px;
    padding: 16px;
    background: rgba(177, 214, 65, 0.06);
    border: 1px solid rgba(177, 214, 65, 0.15);
    border-radius: var(--radius);
}

.thresholds-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 14px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.thresholds-section .form-row {
    gap: 10px;
}

.thresholds-section .form-group label {
    font-size: 11px;
}

.thresholds-section input[type="number"] {
    font-size: 13px;
}

/* List: host subtitle under name */
.list-host-sub {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Tag Input ===== */
.tag-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-height: 42px;
    cursor: text;
    transition: border-color var(--transition);
}
.tag-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag-input-field {
    flex: 1;
    min-width: 100px;
    border: none !important;
    background: transparent !important;
    padding: 4px 0 !important;
    font-size: 14px;
    color: var(--text-primary);
    font-family: var(--font);
    outline: none;
    box-shadow: none !important;
}
.tag-input-field::placeholder { color: var(--text-muted); }

.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid rgba(177, 214, 65, 0.25);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.tag-remove {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity var(--transition);
}
.tag-remove:hover { opacity: 1; }

.tag-suggestions {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-top: 4px;
    box-shadow: var(--shadow);
    z-index: 10;
    max-height: 180px;
    overflow-y: auto;
}

.tag-suggestion {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
    color: var(--text-primary);
}
.tag-suggestion:hover {
    background: var(--bg-card-hover);
}

/* ===== Tag Badges (small, for dashboard cards and list) ===== */
.tag-badge-sm {
    display: inline-block;
    padding: 1px 6px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.list-tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 2px;
}

/* ===== Group By Tag ===== */
.monitor-grouped {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.group-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    font-size: 15px;
    font-weight: 600;
}

.group-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.group-dot.up { background: var(--green); }
.group-dot.down { background: var(--red); }
.group-dot.warning { background: var(--yellow); }
.group-dot.unknown { background: var(--text-muted); }

.group-name {
    flex: 1;
    color: var(--text-primary);
}

.group-stats {
    display: flex;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.group-stat-up {
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--green-bg);
    color: var(--green);
}

.group-stat-down {
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--red-bg);
    color: var(--red);
}

.group-stat-warn {
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--yellow-bg);
    color: var(--yellow);
}

.group-section .monitor-grid {
    padding: 16px;
}

.group-section .monitor-list {
    padding: 0;
}

/* Small form select (for group-by dropdown) */
.form-select-sm {
    padding: 6px 10px;
    font-size: 13px;
    min-width: 160px;
    width: auto;
}

/* ===== Disk Selection (Add/Edit Form) ===== */
.disk-selection-section {
    margin-top: 16px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.disk-selection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.disk-selection-header label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.disk-selection-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.disk-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
}

.disk-checkbox-item:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.disk-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.disk-checkbox-label {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 13px;
}

.disk-checkbox-pct {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

/* ===== Per-Disk Chart Cards (full width, vertical stack) ===== */
.sensor-chart-card-full {
    grid-column: 1 / -1;
}

/* ===== Monitored Services (Detail View) ===== */
.monitored-services-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.monitored-service-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.monitored-service-item.svc-stopped {
    border-color: rgba(239, 68, 68, 0.3);
    background: var(--red-bg);
}

.monitored-service-item:hover {
    border-color: var(--border-light);
}

.svc-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.svc-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'SFMono-Regular', Consolas, monospace;
}

.svc-status-text {
    font-size: 12px;
    font-weight: 600;
    min-width: 60px;
    text-align: right;
}

.svc-restart-btn {
    padding: 4px 10px;
    font-size: 11px;
    flex-shrink: 0;
}

/* ===== Compact View - smaller stats ===== */
.compact-mode-active .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.compact-mode-active .stat-card {
    padding: 10px 14px;
}
.compact-mode-active .stat-icon {
    width: 32px;
    height: 32px;
}
.compact-mode-active .stat-icon svg {
    width: 18px;
    height: 18px;
}
.compact-mode-active .stat-value {
    font-size: 20px;
}
.compact-mode-active .stat-label {
    font-size: 11px;
}

/* ===== Compact View ===== */
.monitor-compact {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.compact-row {
    display: grid;
    grid-template-columns: 10px 1.2fr 1fr 1.8fr auto;
    gap: 10px;
    padding: 7px 14px;
    align-items: center;
    font-size: 12px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border-color);
    min-height: 0;
    -webkit-tap-highlight-color: transparent;
}
.compact-row:last-child {
    border-bottom: none;
}
.compact-row:hover {
    background: var(--bg-card);
}
.compact-row:active {
    background: var(--bg-card-hover);
}

.compact-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.compact-dot-up { background: var(--green); }
.compact-dot-down { background: var(--red); }
.compact-dot-warning { background: var(--yellow); }
.compact-dot-unknown { background: var(--text-muted); }
.compact-dot-up { animation: pulse-green 2s ease-in-out infinite; }

.compact-name {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-host {
    color: var(--text-muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-metrics {
    color: var(--text-secondary);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-time {
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
    text-align: right;
    flex-shrink: 0;
}

/* Compact view in groups */
.group-section .monitor-compact {
    border: none;
    border-radius: 0;
}

/* iPad: larger touch targets */
@media (pointer: coarse) {
    .compact-row {
        padding: 10px 14px;
        min-height: 44px;
    }
}

/* Responsive compact */
@media (max-width: 768px) {
    .compact-row {
        grid-template-columns: 10px 1fr 1.5fr auto;
        padding: 8px 12px;
    }
    .compact-host {
        display: none;
    }
}

@media (max-width: 480px) {
    .compact-row {
        grid-template-columns: 10px 1fr auto;
        gap: 8px;
    }
    .compact-metrics {
        display: none;
    }
}

/* ===== Agent Badge (on monitor cards) ===== */
.agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(2, 122, 187, 0.2);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
    margin-bottom: 6px;
}

.agent-badge-inline {
    color: var(--blue);
    font-weight: 600;
}

.agent-badge-mini {
    font-size: 9px;
    font-weight: 600;
    color: var(--blue);
    opacity: 0.8;
}

/* ===== Agents Grid ===== */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: all var(--transition);
}
.agent-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow);
}

.agent-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
}

.agent-card-title {
    font-size: 16px;
    font-weight: 600;
}

.agent-card-location {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.agent-card-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 10px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.agent-card-key {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 14px;
    overflow: hidden;
}

.agent-key-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.agent-key-value {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    user-select: all;
}

.agent-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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