:root {
    /* Colors */
    --primary-color: #2B4C8C;
    --primary-gradient: linear-gradient(135deg, #2B4C8C 0%, #1E3A5F 100%);
    --secondary-color: #FFD700;
    --secondary-gradient: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    --bg-gradient: linear-gradient(135deg, #2B4C8C 0%, #1E3A5F 50%, #0F1B2E 100%);
    
    --text-main: #2c3e50;
    --text-light: #6c757d;
    --text-white: #ffffff;
    
    --border-light: #e1e8ed;
    --border-focus: #2B4C8C;
    
    --bg-white: rgba(255, 255, 255, 0.95);
    --bg-panel: #f8f9fa;
    
    --success: #28a745;
    --danger: #dc3545;
    --warning: #FFD700;
    --gray: #6c757d;

    /* Spacing & Sizes */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 20px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Select Status Colors */
select.status-select {
    font-weight: 600;
    transition: all 0.3s ease;
}
select.status-select.status-placeholder {
    color: #6c757d;
    border-color: #ced4da;
}
select.status-select.status-normal {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
    font-weight: bold;
}
select.status-select.status-abnormal {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
    font-weight: bold;
}
select.status-select.status-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeeba;
    font-weight: bold;
}
select.status-select.status-error {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
    font-weight: bold;
}
select.status-select.status-non_normal {
    color: #fff;
    background-color: #B3A1A1;
    border-color: #B3A1A1;
    font-weight: bold;
}

/* Site Selection Grid in Modal */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
}

.site-item {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 500;
}

.site-item:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.site-item.selected {
    background-color: #e7f1ff;
    border-color: #2B4C8C;
    color: #2B4C8C;
    position: relative;
}

.site-item.selected::after {
    content: '✓';
    font-weight: bold;
    color: #2B4C8C;
}

/* Selected Tags in Trigger Area */
/* .site-tag moved to form section for better context/override */

.site-tag .remove-tag {
    margin-left: 6px;
    cursor: pointer;
    font-weight: bold;
    color: #adb5bd;
}

.site-tag .remove-tag:hover {
    color: #dc3545;
}

/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-main);
    overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }

/* Layout Utilities */
.container {
    max-width: 1400px;
    width: 95%;
    margin: 2vh auto;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: clamp(15px, 3vw, 30px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.2);
    min-height: auto;
    max-height: 96vh;
    overflow: hidden;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.w-full { width: 100%; }
.text-center { text-align: center; }

/* Components: Header */
header, .header {
    background: var(--bg-white);
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}
.header-title { display: flex; align-items: center; gap: 15px; flex: 1; }
header h1, .header h1 {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    background: linear-gradient(135deg, #1E3A5F 0%, #2B4C8C 50%, #4A90E2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    font-weight: 800;
    letter-spacing: 1px;
    filter: drop-shadow(0 2px 4px rgba(43, 76, 140, 0.1));
}
.logo { width: 60px; height: 60px; transition: transform 0.3s; }
.logo:hover { transform: scale(1.05); }

/* Index Page Specific Header Overrides */
.admin-level2 .header {
    padding: 5px 20px; /* Reduced to match user perception of public page */
    margin-bottom: 5px; 
    margin-top: 0; 
}
.admin-level2 .container {
    padding-top: 0px; /* Remove top padding */
    padding-bottom: 0px; 
}

/* Pager Styles */
.public-pager .icon-btn {
    width: 32px; height: 32px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: #ffffff; color: #1E3A5F;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 6px 16px rgba(0,0,0,0.18); border-radius: 8px;
}
.public-pager .icon-btn:hover { background: #f5f8ff; transform: none; box-shadow: 0 6px 18px rgba(0,0,0,0.22); }
.public-pager .icon-btn:active { transform: none; box-shadow: 0 4px 12px rgba(0,0,0,0.18); }
.public-pager .icon-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.public-pager .icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }

.status-legend {
    display: flex;
    gap: clamp(10px, 2vw, 20px);
    align-items: center;
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

/* Components: Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border-color: rgba(255, 215, 0, 0.3);
}
.btn-secondary {
    background: #ffffff;
    color: var(--primary-color);
    border: 1px solid rgba(43, 76, 140, 0.3);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.btn-secondary:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(43, 76, 140, 0.15);
}
.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}
.btn-danger {
    background: linear-gradient(135deg, #D32F2F 0%, #B71C1C 100%);
    color: white;
}

.btn-danger-outline {
    background: #ffffff;
    color: var(--danger);
    border: 1px solid var(--danger);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.btn-danger-outline:hover {
    background: #fff5f5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.15);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Components: Forms */
.form-group { margin-bottom: 15px; display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-weight: 600; color: var(--text-main); font-size: 14px; }
.form-control, input[type="text"], input[type="number"], input[type="datetime-local"], select, textarea {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.3s;
    background: white;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(43, 76, 140, 0.1);
}

/* Force standard height for inputs and site-trigger */
input[type="text"], input[type="number"], .site-select-trigger {
    height: 38px;
    min-height: 38px;
}
.site-select-trigger {
    display: flex;
    align-items: center;
    overflow: hidden; /* Prevent spill if huge content */
}
/* Adjust site-select-trigger height to be flexible only if needed, but match input normally */
.site-select-trigger {
    height: auto; 
    min-height: 38px;
    padding: 4px 12px; /* Slightly less vertical padding to accommodate tags */
}

/* Site tags inside trigger */
.site-tag {
    background-color: #e9ecef;
    color: #495057;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 0.85em;
    display: inline-flex;
    align-items: center;
    margin: 2px;
    height: 24px; /* Fixed height for tags */
    line-height: 24px;
}
.input-group { display: flex; align-items: center; gap: 8px; }
.input-group .unit { color: var(--text-light); font-size: 13px; white-space: nowrap; }
.input-group .mode-select { width: 110px; flex-shrink: 0; }

/* Components: Cards */
.card {
    background: var(--bg-white);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}
.card-header { 
    border-bottom: 2px solid #3498db; 
    padding-bottom: 10px; 
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: var(--text-main);
    font-weight: 600;
}

/* Components: Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.table, .monitoring-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 14px;
    table-layout: fixed; /* 强制固定列宽，确保截断生效 */
}
.table th, .monitoring-table th {
    background: var(--primary-gradient);
    color: white;
    padding: 12px;
    text-align: center;
    white-space: nowrap;
}
.table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
    vertical-align: middle;
}

.monitoring-table td {
    padding: 8px; /* 稍微减小单元格内边距 */
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    height: 48px; /* 固定行高为 48px */
    font-size: 13px;
    box-sizing: border-box; /* 确保 padding 和 border 包含在 height 内 */
    white-space: nowrap; /* 强制不换行 */
    overflow: hidden; /* 隐藏溢出 */
    text-overflow: ellipsis; /* 显示省略号 */
}
.table tr:hover, .monitoring-table tr:hover { background-color: rgba(43, 76, 140, 0.05); }
.table tr:nth-child(even), .monitoring-table tr:nth-child(even) { background-color: rgba(43, 76, 140, 0.02); }

.instrument-id {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
    word-break: break-word;
}
.instrument-id:hover {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(43, 76, 140, 0.3);
}

/* Components: Control Panel */
.control-panel {
    background: linear-gradient(135deg, #2B4C8C 0%, #1E3A5F 50%, #0F1B2E 100%);
    padding: 8px 12px; /* Reduced padding slightly to save space */
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    margin-bottom: 0px; /* Removed margin to match header spacing consistency */
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 8px;
}
.button-group {
    display: flex;
    gap: clamp(6px, 1.2vw, 10px);
    align-items: center;
    flex-wrap: wrap;
}
.control-panel.compact .compact-row { gap: 10px; }
.control-panel.compact .inline-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}
.control-panel.compact .status-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 6px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Status Switch Group - Custom UI for easier selection */
.status-switch {
    display: flex;
    gap: 5px;
    width: 100%;
    margin-top: 2px;
}

.status-switch-btn {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background-color: #fff;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    outline: none;
    user-select: none;
}

.status-switch-btn:hover {
    background-color: #f8f9fa;
    border-color: #b0b8c1;
    color: var(--text-main);
}

/* Active States for Switch Buttons */
.status-switch-btn.active-normal {
    background: linear-gradient(145deg, #28a745, #218838);
    color: white;
    border-color: #1e7e34;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
    font-weight: 600;
}

.status-switch-btn.active-abnormal {
    background: linear-gradient(145deg, #dc3545, #c82333);
    color: white;
    border-color: #bd2130;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
    font-weight: 600;
}

.status-switch-btn.active-warning {
    background: linear-gradient(145deg, #FFD700, #FFC107);
    color: #856404;
    border-color: #e0a800;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.2);
    font-weight: 600;
}

.status-switch-btn.active-error {
    background: linear-gradient(145deg, #dc3545, #c82333);
    color: white;
    border-color: #bd2130;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
    font-weight: 600;
}

.status-switch-btn.active-na {
    background: linear-gradient(145deg, #6c757d, #5a6268);
    color: white;
    border-color: #545b62;
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
    font-weight: 600;
}

/* Toggle Switch */
.switch-container {
    display: flex;
    align-items: center;
    /* Ensure container takes full width if needed to align content properly */
    /* width: 100%; REMOVED to allow inline layout */
    width: auto;
}

.switch-label {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 10px;
    /* Prevent text selection */
    user-select: none;
    /* Ensure label doesn't exceed container width */
    max-width: 100%;
    margin-bottom: 0; /* Bootstrap label default override */
}

.switch-label input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
    background-color: #ccc;
    border-radius: 24px;
    transition: .4s;
    /* Prevent slider from shrinking */
    flex-shrink: 0;
}

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

input:checked + .slider {
    background-color: #2196F3;
}

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

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.switch-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    /* Ensure text stays on one line */
    white-space: nowrap;
    /* Optional: Move text to left of switch for better right-aligned UI */
    order: -1; 
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .switch-text {
        font-size: 12px; /* Slightly smaller text on mobile */
    }
    .switch-label {
        gap: 8px; /* Slightly smaller gap on mobile */
    }
}

/* Hide original select but keep it accessible for form logic */
select.status-select.hidden-select {
    display: none !important;
}

.control-panel.compact .status-select .status-indicator { margin: 0; align-self: center; }
.control-panel.compact .status-select select {
    height: 22px;
    font-size: 11px;
    border: none;
    background: transparent;
    padding: 0 4px;
}
.control-panel.compact .search-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 12px;
    padding: 0 8px;
    height: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.control-panel.compact .search-input {
    height: 28px;
    padding: 0 8px;
    border: none;
    background: transparent;
    width: clamp(110px, 15vw, 170px);
    font-size: 11px;
    outline: none;
}
.flex-spacer { flex: 1; }

/* Components: Status Indicators */
.status-indicator {
    width: clamp(16px, 2.5vw, 20px);
    height: clamp(16px, 2.5vw, 20px);
    border-radius: 50%;
    display: inline-block;
    margin: 0 auto;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}
.status-indicator:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

.device-indicator {
    width: clamp(14px, 2.1vw, 18px);
    height: clamp(14px, 2.1vw, 18px);
    border-radius: 4px;
}

.status-normal {
    background-color: #28a745;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.4);
}

.status-warning {
    background-color: #FFD700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.status-error {
    background-color: #dc3545;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.4);
}

.status-non_normal {
    background-color: #B3A1A1;
    box-shadow: 0 0 10px rgba(179, 161, 161, 0.4);
}

.status-unknown, .status-not_updated {
    background-color: #6c757d;
    box-shadow: 0 0 10px rgba(108, 117, 125, 0.4);
}

/* Components: Modals */
.modal {
    display: none; /* JS toggles this to block */
    position: fixed;
    z-index: 9999; /* Ensure it's on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    overflow: auto;
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% from top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Modal Header & Elements (restored from backup) */
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}
.modal-header h3 { margin: 0; font-size: 1.25rem; color: var(--text-primary); }
.close {
    color: var(--text-secondary);
    font-size: 28px; font-weight: bold;
    cursor: pointer; line-height: 1;
}
.close:hover { color: var(--text-primary); }

.modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Page: Instrument Detail Specifics */
.detail-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
}
.status-panel { display: flex; flex-direction: column; gap: 20px; }
.status-row { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: var(--bg-panel); border-radius: var(--radius-sm); }

/* Tabs */
.tab-bar { display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; }
.tab-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    background: #f1f3f5;
    cursor: pointer;
    font-weight: 600;
    color: var(--primary-color);
    text-align: center;
    transition: all 0.2s;
}
.tab-btn.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}
.tab-panel { display: none; padding: 20px; background: var(--bg-panel); border-radius: var(--radius-md); border: 1px solid var(--border-light); }
.tab-panel.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Form Grid System */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px 20px;
}

/* History List */
.history-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: white; }
.history-item {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    display: flex; justify-content: space-between;
    cursor: pointer;
}
.history-item:hover { background-color: #f8f9fa; }

/* Responsive */
@media (max-width: 900px) {
    .detail-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .header-title { flex-direction: column; align-items: flex-start; }
    .form-grid { grid-template-columns: 1fr; }
    .modal-content { width: 95%; }
}

/* Legacy/Specific Utility Support */
.d-none { display: none !important; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background-color: #ccc; border-radius: 22px; transition: .4s;
}
.slider:before {
    position: absolute; content: ""; height: 16px; width: 16px;
    left: 3px; bottom: 3px; background-color: white; border-radius: 50%; transition: .4s;
}
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(18px); }

/* Toast */
.toast {
    position: fixed; top: 20px; right: 20px;
    padding: 12px 24px;
    background: white;
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-md);
    border-radius: 4px;
    z-index: 9999;
}

/* Inspection Tabs & Panels */
.inspection-tabbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.5);
    padding: 10px;
    border-radius: var(--radius-md);
    position: relative;
    z-index: 5;
}

.tab-group {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.inspection-tabbar .tab-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-light);
    transition: all 0.3s;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.inspection-tabbar .tab-btn:hover:not(:disabled) {
    color: var(--primary-color);
    background: rgba(43, 76, 140, 0.05);
}

.inspection-tabbar .tab-btn.active {
    background: var(--primary-gradient);
    color: white;
}

.inspection-tabbar .tab-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.switch-wrapper {
    display: flex;
    align-items: center;
    padding: 0 8px;
    border-left: 1px solid var(--border-light);
}

/* Inspection Panels */
.inspection-panel {
    display: none;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease;
}

.inspection-panel.active {
    display: block;
}

.panel-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.panel-section h4 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}/* ... existing code ... */

/* Monitoring Grid & Responsive Table */
.monitoring-grid {
    width: 100%;
    overflow-x: hidden;
    margin-top: 6px;
    border-radius: var(--radius-md);
    /* Ensure it doesn't cause layout shifts */
    min-height: 200px; 
}

/* Ensure table doesn't get too squeezed on small screens/zoom */
.monitoring-table {
    width: 100%;
    /* min-width removed to prevent scrollbar */
}

/* Optimize layout for zoom/small screens */
@media (max-width: 1200px) {
    .container {
        width: 98%;
        padding: 15px;
    }
    
    /* Adjust header font size */
    header h1, .header h1 {
        font-size: 1.5rem;
    }
}


/* Modal Styles (Standardized) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border-radius: var(--radius-md);
    width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    animation: slideDown 0.3s ease-out;
    border: 1px solid var(--border-light);
}

@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-main);
    font-weight: 600;
}

.close {
    color: #aaa;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-light);
    text-align: right;
    background-color: #f8f9fa;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Admin/User Management Styles */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.admin-table th, .admin-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.admin-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}
.admin-table tr:hover {
    background-color: #f8f9fa;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}
.status-active {
    background-color: #e6f4ea;
    color: #1e7e34;
}
.status-inactive {
    background-color: #f8d7da;
    color: #721c24;
}

.action-btn {
    margin-right: 5px;
    cursor: pointer;
    color: #0056b3;
    text-decoration: none;
}
.action-btn:hover {
    text-decoration: underline;
}
.action-btn.delete {
    color: #dc3545;
}

/* Modal Footer (Standardized) */
.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-light);
    text-align: right;
    background-color: #f8f9fa;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* User Management Page Adjustments */
.user-management-page .monitoring-table {
    table-layout: fixed;
    width: 100%;
}

.user-management-page .monitoring-table td:last-child {
    height: 48px;
    white-space: nowrap; 
    vertical-align: middle;
    text-align: center;
    overflow: visible; /* Allow buttons/tooltips to show if needed, but flex container handles it */
}

.user-management-page .monitoring-table .table-actions {
    display: inline-flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.user-management-page .monitoring-table td {
    padding: 0 10px; /* Adjust padding for fixed height */
    font-size: 14px;
    height: 48px;
    line-height: 48px; /* Vertically center text */
    vertical-align: middle;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clickable-status {
    transition: all 0.2s;
}
.clickable-status:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* User Menu Styles */
.user-menu {
    position: relative;
    display: inline-block;
    margin-left: auto;
    min-width: 120px;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
    cursor: pointer; 
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    user-select: none;
}

.user-menu-toggle:hover, .user-menu.open .user-menu-toggle {
    background: rgba(0, 0, 0, 0.05);
}

.user-name {
    font-weight: 600;
    color: var(--text-main);
}

.caret {
    font-size: 10px;
    color: var(--text-light);
    transition: transform 0.2s;
}

.user-menu.open .caret {
    transform: rotate(180deg);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    width: 100%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    z-index: 1001; /* Ensure above other content */
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.user-dropdown.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 0;
    text-align: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-main);
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f8f9fa;
    color: var(--primary-color);
}

/* Ensure public pager is clickable */
.public-pager {
    pointer-events: auto;
}
