:root {
    --bg-color: #f4f6f9;
    --sidebar-bg: #2c3e50;
    --sidebar-width: 250px; /* Master width variable */
    --header-bg: #ffffff;
    --card-bg: #ffffff;
    --status-online: #28a745;
    --status-degraded: #fd7e14;
    --status-offline: #dc3545;
    --text-main: #333;
    --text-muted: #6c757d;
}

/* ——— Global Layout (Grid System) ——— */
body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    height: 100vh;
    display: grid;
    /* Define the grid areas explicitly */
    grid-template-areas: 
        "menu header"
        "menu main";
    /* Column 1 is sidebar width, Column 2 is the rest */
    grid-template-columns: var(--sidebar-width) 1fr;
    /* Row 1 is header height, Row 2 is the rest */
    grid-template-rows: 60px 1fr;
}

/* ——— Login Page Override ——— */
body.login-page {
    /* Override the global grid */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--sidebar-bg); /* A dark background makes the login card pop */
    grid-template-areas: none; /* Neutralizes the global grid */
}

/* ——— Login Card Styling ——— */
.login-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    box-sizing: border-box;
    text-align: center;
}

.login-header {
    margin-bottom: 25px;
}

.login-header h2 {
    margin: 0 0 10px 0;
    color: var(--text-main);
    font-size: 1.8rem;
}

.login-header p {
    margin: 0;
    color: var(--text-muted);
}

/* ——— Alert Messages (Used in Login) ——— */
.alert {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: left;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ——— Sidebar (Left Column) ——— */
.sidebar {
    grid-area: menu; /* Places this in the 'menu' grid area */
    background: var(--sidebar-bg);
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Scroll sidebar independently if needed */
    z-index: 100;
}

/* Sidebar Menu Items */
.menu-wrapper ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    color: #bdc3c7;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s, color 0.2s;
}

.menu-link:hover, .menu-link.active {
    background: #34495e;
    color: #fff;
}

.submenu-arrow { font-size: 0.8em; }

/* ——— Flyout Submenus (Desktop) ——— */
/* These pop OUT of the grid, so they need fixed positioning */
.sub-menu {
    display: none;
    position: fixed;
    width: 200px;
    background: #34495e;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    border-left: 2px solid #3498db;
}

/* ——— Header (Top Right) ——— */
header {
    grid-area: header;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid #dee2e6;
    z-index: 10;
}

.brand { font-weight: bold; font-size: 1.2rem; color: #2c3e50; }
.user-info { font-size: 0.9rem; color: var(--text-muted); }

/* ——— Main Content (Bottom Right) ——— */
main {
    grid-area: main;
    padding: 20px;
    overflow-y: auto; /* Main content scrolls while sidebar stays put */
}

/* ——— Dashboard Cards ——— */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
}

.card {
    background: var(--card-bg);
    border-radius: 5px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-top: 4px solid #ccc;
    transition: transform 0.2s;
}

.card:hover { transform: translateY(-2px); }
.card.online { border-top-color: var(--status-online); }
.card.degraded { border-top-color: var(--status-degraded); }
.card.offline { border-top-color: var(--status-offline); }

.school-name { font-weight: bold; font-size: 1rem; margin-bottom: 5px; display: block;}
.ip-address { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 10px; display: block;}
.metrics { display: flex; justify-content: space-between; font-size: 0.85rem; }

/* ——— Admin Tables & Forms ——— */
table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.data-table th, .data-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #ddd; }
.data-table th { background-color: #f8f9fa; font-weight: bold; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; }
.form-group input, .form-group select { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; }

/* ——— Buttons ——— */
.btn { padding: 8px 15px; border: none; border-radius: 4px; cursor: pointer; color: white; }
.btn-primary { background-color: #007bff; }
.btn-primary:hover { background-color: #0056b3; }
.btn-edit { background-color: #3498db; margin-right: 5px; }
.btn-danger { background-color: #e74c3c; }
.btn-small { padding: 4px 8px; font-size: 0.8em; }

/* ——— Mobile Responsiveness ——— */
@media (max-width: 768px) {
    body {
        /* Stack the header and main content vertically */
        display: flex;
        flex-direction: column;
        grid-template-areas: none;
        grid-template-columns: 1fr; 
    }

    /* Sidebar - Hides off-screen to the left by default */
    .sidebar {
        position: fixed;
        left: -250px; 
        top: 0;
        bottom: 0;
        width: 250px;
        height: 100vh;
        transition: left 0.3s ease;
        display: flex; 
        z-index: 9999;
        box-shadow: 5px 0 15px rgba(0,0,0,0.3);
    }

    /* Class toggled by JavaScript in header.php */
    .sidebar.active {
        left: 0;
    }

    /* Top Navigation Bar */
    header {
        width: 100%;
        padding: 0 15px;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        position: sticky;
        top: 0;
    }

    /* Show the hamburger lines (id from the header.php update) */
    #mobile-toggle {
        display: block !important;
        margin-right: 10px;
    }

    /* Sub-menus: Stack them vertically inside the sidebar instead of flying out */
/* Sub-menus: Hidden by default on mobile until toggled */
    .sub-menu {
        position: static !important;
        width: 100% !important;
        display: none; /* Changed from block to none */
        box-shadow: none !important;
        border-left: none !important;
        background: #1a252f !important;
        padding-left: 15px; /* Indent sub-items so they look nested */
    }

    /* This class will be toggled via JS */
    .sub-menu.open {
        display: block !important;
    }

    /* Main Grid Overrides: Force single column for cards */
    .ping-dashboard-grid, 
    .dashboard-grid, 
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    /* Prevent wide tables and containers from breaking the layout */
    .container-wide, 
    .container-full,
    .container-full-dashboard {
        padding: 10px;
        width: 100%;
        box-sizing: border-box;
        overflow-x: auto; /* Adds horizontal scroll to the container if table is too wide */
    }
    
    table.data-table {
        font-size: 0.85rem; 
        display: block; /* Allows the table itself to overflow-x properly */
        overflow-x: auto;
    }

    /* Adjust Modals for small screens */
    .modal-content,
    .chart-modal-content, 
    .zoom-modal-content,
    .history-modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 15px;
        margin: 5% auto;
        box-sizing: border-box;
    }

    /* Ensure images in cards don't exceed screen width */
    .ping-card img, .card img {
        width: 100%;
        height: auto;
    }
}

/* ——— Modals & Overlays ——— */
.modal {
    display: none; /* Crucial: Hides it by default */
    position: fixed; 
    z-index: 2000; /* High number to sit on top of menu/header */
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); /* Dimmed background */
    backdrop-filter: blur(2px); /* Nice blur effect */
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% from top, centered horizontally */
    padding: 20px;
    border: 1px solid #888;
    width: 400px;
    max-width: 90%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    position: relative;
}

/* Close 'X' Button */
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover, .close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

/* ——— Success Message Toast ——— */
#success-msg {
    visibility: hidden; /* Crucial: Hides it by default */
    min-width: 250px;
    background-color: #28a745; /* Green */
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed; /* Floats above content */
    z-index: 2001; /* On top of modal */
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%); /* Centers it perfectly */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
}

#success-msg.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px; /* Slight slide-up animation */
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block; /* Makes the link wrap the div properly */
}
.card-link:hover .card {
    transform: translateY(-5px); /* Nice little hover effect */
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* --- Pagination & Search UI --- */
.search-wrapper { 
    display: flex; 
    justify-content: center; 
    margin-bottom: 25px; 
}

.search-container { 
    display: flex; 
    gap: 10px; 
    background: var(--card-bg); 
    padding: 15px; 
    border-radius: 8px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.search-input { 
    padding: 8px 12px; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    width: 350px; 
}

.pagination { 
    margin-top: 20px; 
    display: flex; 
    gap: 5px; 
    justify-content: center; 
    align-items: center; 
}

.page-link { 
    padding: 8px 12px; 
    border: 1px solid #ddd; 
    text-decoration: none; 
    color: var(--text-main); 
    border-radius: 4px; 
    background: #fff; 
}

.page-link.active { 
    background: var(--sidebar-bg); 
    color: white; 
    border-color: var(--sidebar-bg); 
}

.btn-clear { 
    background-color: var(--status-degraded); 
    color: white; 
    text-decoration: none; 
    display: inline-flex; 
    align-items: center; 
}

.badge-history { 
    padding: 3px 7px; 
    border-radius: 4px; 
    font-size: 0.7rem; 
    font-weight: bold; 
}

.school-link { 
    font-weight: bold; 
    color: #007bff; 
    text-decoration: none; 
}

/* --- Edit School & Pill UI --- */
.form-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
    min-height: 80vh;
}

.edit-card {
    width: 100%;
    max-width: 500px;
    background: var(--card-bg);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.pill-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 6px;
    border: 1px solid #ddd;
    min-height: 45px;
}

.tech-pill {
    background-color: var(--sidebar-bg);
    color: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tech-pill .remove-pill {
    cursor: pointer;
    font-weight: bold;
    color: #ff8a8a;
}

.tech-pill .remove-pill:hover { color: #ff3333; }

.hidden-checkbox { display: none; }

.custom-select {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-bottom: 5px;
}

.readonly-input {
    background: #eee !important;
    cursor: not-allowed;
}

/* ——— Bulk Management UI ——— */
.tech-badge { 
    background-color: var(--sidebar-bg); 
    color: #fff; 
    padding: 2px 8px; 
    border-radius: 4px; 
    font-size: 0.75rem; 
    margin-right: 4px; 
    display: inline-block; 
}

.modal-overlay-bulk { 
    display: none; 
    position: fixed; 
    z-index: 9999; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.7); 
    backdrop-filter: blur(2px); 
}

.user-scroll { 
    max-height: 250px; 
    overflow-y: auto; 
    border: 1px solid #ddd; 
    padding: 10px; 
    margin: 15px 0; 
    border-radius: 6px; 
    background: #fafafa; 
}

.user-row { 
    display: flex; 
    align-items: center; 
    padding: 8px; 
    border-bottom: 1px solid #eee; 
    gap: 10px; 
    cursor: pointer; 
}

.user-row:hover { background: #f0f4f8; }

.error-msg-inline { 
    color: #dc3545; 
    background: #f8d7da; 
    padding: 10px; 
    border-radius: 4px; 
    margin-bottom: 15px; 
    display: none; 
    font-weight: bold; 
    font-size: 0.9rem; 
}

.modal-btns { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 15px; 
    margin-top: 20px; 
}

.btn-add { background: var(--status-online); color: white; border: none; padding: 12px; cursor: pointer; border-radius: 6px; font-weight: bold; }
.btn-remove { background: var(--status-offline); color: white; border: none; padding: 12px; cursor: pointer; border-radius: 6px; font-weight: bold; }
.btn-ghost { background: #eee; border: none; padding: 8px; cursor: pointer; border-radius: 4px; font-size: 0.8rem; margin-bottom: 5px; }

/* --- Header Link Styling --- */
.logout-link {
    color: var(--status-offline); /* Using your existing red variable */
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
}

.logout-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* --- RRD Ping Dashboard --- */
.ping-dashboard-grid {
    display: grid;
    /* This ensures it fills the width and creates as many columns as fit (min 500px each) */
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

.ping-card {
    background: var(--card-bg);
    border-radius: 5px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-top: 4px solid var(--sidebar-bg);
    /* Ensure the card itself doesn't shrink */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ping-card img {
    width: 100%; /* Make the RRD image fill the card width */
    height: auto;
    margin-top: 10px;
}

.page-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    width: 100%;
}

/* --- Bandwidth Leaderboard Specifics --- */
.rank-badge {
    background: var(--sidebar-bg);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    margin-right: 10px;
}

.bandwidth-value {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 1.1rem;
}

.download-text { color: var(--status-online); }
.upload-text { color: #007bff; }

.progress-bar-bg {
    background: #e9ecef;
    border-radius: 4px;
    height: 8px;
    width: 100%;
    margin-top: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    background: var(--status-online);
    height: 100%;
}

/* Status Indicators for Table */
.status-indicator { font-size: 0.85rem; font-weight: bold; text-transform: uppercase; }
.status-online { color: var(--status-online); }
.status-degraded { color: var(--status-degraded); }
.status-offline { color: var(--status-offline); }

/* Unified Large Chart Modal */
.chart-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
}

.chart-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 90vw;
    max-width: 1100px;
    position: relative;
}

/* --- School Link Styling (Leaderboard) --- */
.school-link-alt {
    text-decoration: none; 
    color: var(--sidebar-bg); /* Dark slate color from your vars */
    font-weight: bold; 
    border-bottom: 1px dotted var(--sidebar-bg);
    transition: all 0.2s ease;
}

.school-link-alt:hover {
    color: #007bff; /* Bright blue only on hover */
    border-bottom: 1px solid #007bff;
    text-decoration: none;
}

/* Helper for muted text in the table */
.text-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* --- Traffic Focus Page --- */
.focus-container {
    max-width: 1000px;
    margin: 40px auto;
    text-align: center;
}

.graph-large {
    width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    background: #fff;
    padding: 10px;
}

.back-nav {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Standardizing the Back Button and Group toggles */
.btn-back {
    background: #eee; 
    color: #333 !important; 
    text-decoration: none; 
    padding: 8px 15px; 
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-back:hover {
    background: #e0e0e0;
}

.btn-group {
    display: flex;
    gap: 5px;
}

.btn-group .btn {
    background: #fff;
    color: var(--sidebar-bg);
    border: 1px solid #ddd;
    padding: 6px 12px;
}

.btn-group .btn.active {
    background: var(--sidebar-bg);
    color: #fff;
    border-color: var(--sidebar-bg);
}

/* --- Traffic Zoom & History View --- */
.zoom-container { 
    position: relative; 
    display: inline-block; 
    cursor: crosshair; 
    user-select: none; 
    -webkit-user-drag: none; 
}

.zoom-box { 
    position: absolute; 
    border: 1px solid #007bff; 
    background: rgba(0, 123, 255, 0.2); 
    pointer-events: none; 
    display: none; 
}

/* Specific Modal for Zooming */
.zoom-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); 
    align-items: center;
    justify-content: center;
}

.zoom-modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    position: relative;
    width: 90vw; 
    max-width: 1200px; 
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.close-modal-circle {
    position: absolute;
    top: -15px;
    right: -15px;
    background: var(--status-offline);
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    text-align: center;
    cursor: pointer;
    line-height: 30px;
    font-weight: bold;
    font-size: 20px;
    border: 2px solid white;
}

/* Small helper for inline forms */
.w-auto { width: auto !important; }
.d-inline { display: inline-block !important; }

/* --- Outage History Modal Specifics --- */
.history-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
}

.history-modal.show { display: flex; }

.history-modal-content {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    position: relative;
    width: 800px;
    max-width: 95%;
}

.history-close {
    position: absolute;
    top: 10px; right: 15px;
    font-size: 28px; font-weight: bold;
    cursor: pointer; color: #aaa;
}
.history-close:hover { color: #000; }

/* --- Stats & Badges --- */
.ack-container { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.btn-ack { background: #dc3545; color: white; border: none; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 0.75rem; font-weight: bold; }
.btn-ack:hover { background: #b02a37; }

.ack-status { font-size: 0.75rem; color: #666; font-style: italic; background: #eee; padding: 3px 8px; border-radius: 4px; }
.badge-history { padding: 3px 7px; border-radius: 4px; font-size: 0.7rem; font-weight: bold; display: inline-block; }

.custom-scrollbar::-webkit-scrollbar { width: 8px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* --- Details Page & Utility Helpers --- */
.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-center { text-align: center; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }
.mt-0 { margin-top: 0; }

.card-stats {
    max-width: 600px;
    margin: 0 auto 30px auto;
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

.ath-label { color: #d9534f; }
.timestamp-muted { color: #888; font-size: 0.8em; }

.btn-back-details {
    background: #6c757d; 
    color: #FFFFFF; 
    text-decoration: none; 
    padding: 8px 15px; 
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}

.ping-card-large {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-top: 6px solid var(--sidebar-bg);
    max-width: 1200px;
    margin: 0 auto 30px auto; /* centers and adds bottom space */
}

.ping-card-large img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain; /* Keeps aspect ratio, fills width */
}
.ping-card-large .zoom-container {
    width: 100%;
    overflow: hidden; /* Prevents overflow issues */
}

.traffic-card-large {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-top: 6px solid var(--sidebar-bg);
    max-width: 1200px;
    margin: 0 auto 30px auto;
}

.traffic-card-large img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    object-fit: contain;
}

.traffic-card-large .zoom-container {
    width: 100%;
    overflow: hidden;
}

.ping-card-large img,
.traffic-card-large img {
    width: 100%;
    max-height: 500px; /* or 400px, adjust to taste */
    height: auto;
    display: block;
    object-fit: contain;
}

        /* List View Overrides */
/* --- View Mode Container --- */
/* Triggers when user toggles OR when head script applies forced class */
.list-view, 
.forced-list-view #statusGrid {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    max-width: 1400px;
    margin: 0 auto;
}

.list-view .card-link,
.forced-list-view #statusGrid .card-link { 
    width: 100%; 
    text-decoration: none; 
}

/* Updated Grid: 5 Columns (Name, Status, IP, Last Check, Metrics) */
.list-view .card,
.forced-list-view #statusGrid .card {
    display: grid;
    grid-template-columns: 2.2fr 100px 1.8fr 1.5fr 180px; 
    align-items: center;
    padding: 8px 15px;
    border-radius: 4px;
    gap: 15px;
}

/* List View Element Styling */
.list-view .school-name,
.forced-list-view #statusGrid .school-name { 
    font-weight: bold; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.list-view .ip-address,
.forced-list-view #statusGrid .ip-address { 
    font-family: monospace; 
    color: #555; 
    font-size: 0.9rem; 
}

/* Visibility Control */
.last-check-col { display: none; } 
.list-view .last-check-col,
.forced-list-view #statusGrid .last-check-col { 
    display: inline-block; 
    font-size: 0.85rem; 
    color: #666; 
}

.status-label { display: none; }
.list-view .status-label,
.forced-list-view #statusGrid .status-label { 
    display: inline-block; 
    font-weight: 900; 
    font-size: 0.85rem; 
}

/* Metrics Row */
.list-view .metrics,
.forced-list-view #statusGrid .metrics { 
    display: flex; 
    gap: 15px; 
    margin: 0; 
    justify-content: flex-end;
    font-size: 0.9rem;
}

/* Global Status Colors */
.status-label.online { color: #2ecc71; }
.status-label.offline { color: #e74c3c; }
.status-label.degraded { color: #f1c40f; }

/* Toggle Button */
.view-toggle-btn {
    background: #444;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Climate Controller List View Fixes - OVERRIDE VERSION */
/* These selectors are MORE specific to win the cascade battle */

/* Target the climate grid cards specifically */
.list-view.climate-grid .card,
.forced-list-view .climate-grid .card,
#statusGrid.climate-grid.list-view .card,
#statusGrid.climate-grid.forced-list-view .card {
    /* Adjust row height to accommodate two lines of text */
    min-height: 55px;
    /* Slightly larger gap for readability */
    gap: 12px;
    /* Align items to top so both name lines sit together */
    align-items: start !important;
    padding-top: 10px;
    padding-bottom: 10px;
    /* Ensure single row layout */
    grid-template-rows: auto;
}

/* Stack the two names as a unit - first column */
.list-view.climate-grid .school-name,
.forced-list-view .climate-grid .school-name,
#statusGrid.climate-grid.list-view .school-name,
#statusGrid.climate-grid.forced-list-view .school-name {
    /* Allow school name to take full width of its cell */
    grid-column: 1;
    line-height: 1.2;
    white-space: normal !important; /* Override the nowrap */
    overflow: visible;
    margin-bottom: 0;
}

/* Controller name sits below school name in the same grid cell */
.list-view.climate-grid .controller-name,
.forced-list-view .climate-grid .controller-name,
#statusGrid.climate-grid.list-view .controller-name,
#statusGrid.climate-grid.forced-list-view .controller-name {
    display: block;
    font-size: 0.75em;
    color: #666;
    margin-top: 2px;
    line-height: 1.2;
    grid-column: 1;
    /* Hide in grid view, show in list view */
    display: block;
}

/* Ensure metrics stay on one line and align properly */
.list-view.climate-grid .metrics,
.forced-list-view .climate-grid .metrics,
#statusGrid.climate-grid.list-view .metrics,
#statusGrid.climate-grid.forced-list-view .metrics {
    white-space: nowrap;
    flex-wrap: nowrap;
    align-items: center;
    height: 100%;
}

/* Hide controller name in GRID view (cards) */
.dashboard-grid:not(.list-view).climate-grid .controller-name,
.dashboard-grid:not(.forced-list-view).climate-grid .controller-name {
    display: block; /* Actually keep it visible but styled differently */
    font-size: 0.85em;
    color: #666;
    margin-top: 3px;
}

/* NVR-specific card layout - won't affect ping/traffic/other cards */
.nvr-card {
    min-height: 140px; /* breathing room */
    padding: 20px 15px; /* a bit more vertical space */
    display: flex;
    align-items: center;
    justify-content: center;
}

.nvr-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px; /* nice spacing between lines */
}

.nvr-model {
    font-size: 1rem;
    color: var(--text-muted);
}

.nvr-hours {
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 4px;
}

/* Optional: make hours stand out more */
.nvr-hours.status-online { color: var(--status-online); }
.nvr-hours.status-degraded { color: var(--status-degraded); }
.nvr-hours.status-offline { color: var(--status-offline); }



/* --- Network Overview Page --- */
.overview-page main {
    max-width: none;
    padding: 20px;
}

/* Summary bar stays full width */
.summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Problem sections grid - 2 per row on desktop, 1 on mobile */
.problems-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(550px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
    align-items: stretch; /* Prevent stretching to match tallest card */
}

/* Ensure cards don't get too wide on large screens */
@media (min-width: 1400px) {
    .problems-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.summary-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-top: 5px solid #667eea;
}

.summary-card.healthy { border-top-color: var(--status-online); }
.summary-card.warning { border-top-color: var(--status-degraded); }
.summary-card.danger { border-top-color: var(--status-offline); }

.summary-number {
    font-size: 3em;
    font-weight: bold;
    color: var(--text-main);
    margin: 10px 0;
}

.summary-label {
    color: var(--text-muted);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-sub {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 5px;
}

.problem-section {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 450px; /* Fixed max height for all cards */
}

.section-header {
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.section-header.schools { background: linear-gradient(135deg, #dc3545 0%, #c82333 100%); color: white; }
.section-header.heat { background: linear-gradient(135deg, #fd7e14 0%, #e8590c 100%); color: white; }
.section-header.nvr { background: linear-gradient(135deg, #6f42c1 0%, #5a32a3 100%); color: white; }
.section-header.server { background: linear-gradient(135deg, #0dcaf0 0%, #0aa2c0 100%); color: white; }

.section-title {
    font-size: 1.3em;
    font-weight: bold;
    margin: 0;
}

.section-count {
    background: rgba(255,255,255,0.2);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
}

/* Scrollable content area */
.problem-list-container {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 100px;
    max-height: 350px; /* Leaves room for header */
    /* Styled scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #6c757d #f1f1f1;
}

.problem-list-container::-webkit-scrollbar {
    width: 8px;
}

.problem-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.problem-list-container::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 4px;
}

.problem-list-container::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

.problem-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.problem-item {
    padding: 18px 25px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.problem-item:hover {
    background: #f8f9fa;
}

.problem-item:last-child {
    border-bottom: none;
}

.problem-info h4 {
    margin: 0 0 5px 0;
    color: var(--text-main);
}

.problem-meta {
    font-size: 0.85em;
    color: var(--text-muted);
}

.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-badge.offline { background: #dc3545; color: white; }
.status-badge.degraded { background: #ffc107; color: #212529; }
.status-badge.warning { background: #fd7e14; color: white; }
.status-badge.critical { background: #dc3545; color: white; }

.hdd-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.hdd-bar {
    width: 80px;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.hdd-fill {
    height: 100%;
    border-radius: 4px;
}

.hdd-fill.warning { background: #fd7e14; }
.hdd-fill.critical { background: #dc3545; }

/* Server grid stays within card */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 25px;
    overflow-y: auto;
    max-height: 350px;
    scrollbar-width: thin;
    scrollbar-color: #6c757d #f1f1f1;
}

.server-grid::-webkit-scrollbar {
    width: 8px;
}

.server-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.server-grid::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 4px;
}

.server-grid::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

.server-metric {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.server-metric h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 0.9em;
    text-transform: uppercase;
}

.server-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #212529;
}

.progress-bar {
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s;
}

.service-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.service-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
}

.service-badge.up { background: #d4edda; color: #155724; }
.service-badge.down { background: #f8d7da; color: #721c24; }

.empty-state {
    padding: 40px;
    text-align: center;
    color: #6c757d;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.empty-state-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.quick-links {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.quick-link {
    background: var(--card-bg);
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    color: #495057;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.quick-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Mobile: stack everything */
@media (max-width: 768px) {
    .problems-grid {
        grid-template-columns: 1fr;
    }
    
    .problem-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .hdd-indicator {
        justify-content: flex-start;
        width: 100%;
    }
    
    .problem-section {
        max-height: none; /* Remove height constraint on mobile */
    }
    
    .problem-list-container,
    .server-grid {
        max-height: 300px;
    }
}

/* Acknowledge button on Overview.php page and status styles */
.ack-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
    cursor: pointer;
    margin-left: 10px;
    text-transform: uppercase;
}

.ack-btn:hover {
    background: #c82333;
}

.ack-status-inline {
    background: #28a745;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75em;
    margin-left: 10px;
}

.ack-info {
    color: #6c757d;
    font-size: 0.8em;
    margin-top: 5px;
}

/* --- Radius Page Specific Styles --- */
.radius-stats-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 20px; 
    margin-bottom: 20px; 
}
.radius-stat-card { 
    text-align: center; 
    padding: 20px; 
}
.radius-stat-value { 
    font-size: 2.5rem; 
    font-weight: bold; 
    margin: 10px 0; 
}
.radius-stat-label { 
    color: #666; 
    font-size: 0.9rem; 
}
.radius-stat-sub { 
    color: #999; 
    font-size: 0.8rem; 
    margin-top: 5px; 
}
.radius-success-rate { 
    font-size: 0.85rem; 
    color: #666; 
}
.radius-rate-badge { 
    font-size: 0.7rem; 
    color: #888; 
    font-weight: normal; 
}
.radius-view-all-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}
.radius-school-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}
.radius-school-link { 
    color: inherit; 
    text-decoration: none; 
    display: block;
    transition: opacity 0.2s;
}
.radius-school-link:hover { 
    opacity: 0.7;
    text-decoration: underline;
}

/* Mobile for radius page */
@media (max-width: 768px) {
    .radius-stats-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px;
    }
    .radius-stat-value { 
        font-size: 1.8rem; 
    }
}