/* ===========================
   Dashboard Layout
   =========================== */

.navbar-dashboard {
    position: sticky;
    top: 0;
    z-index: 100;
    background: transparent;
    border-bottom: 0;
}

.dashboard-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: calc(100vh - 70px);
    background: transparent;
}

/* ===========================
   Sidebar
   =========================== */

.sidebar {
    background: linear-gradient(180deg, rgba(255,255,255,.78), rgba(248,251,255,.72));
    border-right: 1px solid rgba(148,163,184,.18);
    padding: 2rem 0;
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
    backdrop-filter: blur(18px);
}

.sidebar-section {
    padding: 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section h3 {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-lighter);
    margin-bottom: 1rem;
    letter-spacing: 0.55px;
}

.sidebar-menu,
.project-list,
.stats-list {
    list-style: none;
}

.sidebar-menu a,
.project-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-dark);
    border-radius: 10px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover,
.project-item:hover {
    background: rgba(255,255,255,.85);
    color: #1e3a8a;
}

.sidebar-menu a.active,
.project-item.active {
    background: linear-gradient(90deg, rgba(43,108,176,.12), rgba(56,178,172,.10));
    color: #1e3a8a;
    border-left-color: #2b6cb0;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(43,108,176,.12);
}

.project-list {
    list-style: none;
}

.project-list li {
    margin-bottom: 0.5rem;
}

.stats-list li {
    padding: 0.5rem 0;
    color: var(--text-light);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}

/* ===========================
   Dashboard Content
   =========================== */

.dashboard-content {
    padding: 2rem;
    overflow-y: auto;
}

/* Keep dashboard actions visually consistent and high-contrast. */
.dashboard-content .btn-primary,
.modal-footer .btn-primary {
    background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
    color: #ffffff !important;
    border-color: #1e3a8a !important;
    box-shadow: 0 4px 15px rgba(29, 78, 216, 0.28);
}

.dashboard-content .btn-secondary,
.modal-footer .btn-secondary {
    background: linear-gradient(135deg, #0f766e, #115e59) !important;
    color: #ffffff !important;
    border-color: #134e4a !important;
}

.dashboard-content .btn-danger,
.modal-footer .btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    color: #ffffff !important;
    border-color: #991b1b !important;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,251,255,.98));
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(148,163,184,.18);
    box-shadow: 0 18px 36px rgba(15,23,42,.08);
    position: relative;
    overflow: hidden;
}

.dashboard-header::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #2b6cb0 0%, #38b2ac 35%, #dd6b20 100%);
}

.dashboard-header h1 {
    margin: 0;
    color: var(--text-dark);
    letter-spacing: -0.03em;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    cursor: pointer;
}

.dashboard-section {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.dashboard-section h2 {
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

/* ===========================
   Metrics Grid
   =========================== */

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

.metric-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    text-align: center;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-lighter);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.metric-status {
    font-size: 0.8rem;
    color: var(--success-color);
    font-weight: 500;
}

/* ===========================
   Sensors Table
   =========================== */

.sensors-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

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

.sensors-table thead {
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}

.sensors-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sensors-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s ease;
}

.sensors-table tbody tr:hover {
    background: var(--bg-light);
}

.sensors-table td {
    padding: 1rem;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.temp-value {
    font-weight: 600;
    color: var(--primary-color);
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
}

.progress-bar.large {
    height: 32px;
}

.progress-fill {
    background: linear-gradient(90deg, var(--success-color), var(--primary-color));
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    transition: width 0.3s ease;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-online {
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
}

.status-warning {
    background: rgba(237, 137, 54, 0.1);
    color: var(--warning-color);
}

.status-offline {
    background: rgba(245, 101, 101, 0.1);
    color: var(--danger-color);
}

.heat-tape-on {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
    font-weight: 600;
    font-size: 0.85rem;
}

.heat-tape-off {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    background: rgba(158, 158, 158, 0.15);
    color: #9e9e9e;
    font-weight: 600;
    font-size: 0.85rem;
}

.view-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.view-link:hover {
    color: var(--primary-dark);
}

/* ===========================
   Charts Grid
   =========================== */

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

.chart-container {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.chart-container h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-dark);
}

.chart-container canvas {
    max-height: 300px;
}

/* ===========================
   Projects Grid
   =========================== */

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.project-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.project-location {
    color: var(--text-lighter);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.project-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-lighter);
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.project-info {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.project-info p {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.project-info p strong {
    color: var(--text-dark);
}

.project-card .btn {
    width: 100%;
    text-align: center;
}

/* ===========================
   Projects List (Detailed)
   =========================== */

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.project-detail-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.project-detail-header {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-detail-header h3 {
    margin-bottom: 0.25rem;
}

.project-status-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.project-status-badge.active {
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
}

.project-status-badge.monitoring {
    background: rgba(66, 153, 225, 0.1);
    color: var(--info-color);
}

.project-status-badge.completed {
    background: rgba(160, 174, 192, 0.1);
    color: var(--text-lighter);
}

.project-detail-body {
    padding: 2rem;
}

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

.info-item {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius-md);
}

.info-item label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-lighter);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.info-item span {
    display: block;
    color: var(--text-dark);
    font-weight: 500;
}

.project-history-source-badge {
    display: inline-block;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

button.project-history-source-badge {
    appearance: none;
    background-clip: padding-box;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.project-history-source-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.modal-container .btn-primary {
    background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
    color: #ffffff !important;
    border-color: #1e3a8a !important;
    box-shadow: 0 4px 15px rgba(29, 78, 216, 0.28);
}

.modal-container .btn-secondary {
    background: linear-gradient(135deg, #0f766e, #115e59) !important;
    color: #ffffff !important;
    border-color: #134e4a !important;
}

.modal-container .btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    color: #ffffff !important;
    border-color: #991b1b !important;
}

.project-history-source-badge.active-only {
    background: rgba(72, 187, 120, 0.12);
    border-color: rgba(72, 187, 120, 0.22);
    color: #22543d;
}

.project-history-source-badge.includes-removed {
    background: rgba(66, 153, 225, 0.12);
    border-color: rgba(66, 153, 225, 0.25);
    color: #1a365d;
}

.project-history-source-badge.none-assigned {
    background: rgba(160, 174, 192, 0.16);
    border-color: rgba(160, 174, 192, 0.3);
    color: #4a5568;
}

.project-sensors {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.project-sensors h4 {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.sensor-list {
    list-style: none;
}

.sensor-list li {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.sensor-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    margin-right: 0.5rem;
    font-size: 0.8rem;
}

.status-online {
    color: var(--success-color);
    font-weight: 600;
    font-size: 0.85rem;
}

.project-progress {
    margin-bottom: 1.5rem;
}

.project-progress label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-dark);
}

.project-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.project-actions .btn {
    flex: 1;
    min-width: 150px;
}

/* Danger/Delete button */
.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
}
.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-container {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
    max-width: 660px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--text-dark, #1e293b);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #94a3b8;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.modal-close:hover {
    background: #f1f5f9;
    color: #334155;
}

.status-banner {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(255, 255, 255, 0.82);
    color: var(--text-dark);
    font-weight: 600;
}

.status-banner.error {
    background: rgba(245, 101, 101, 0.1);
    border-color: rgba(245, 101, 101, 0.22);
    color: #9b2c2c;
}

.status-banner.success {
    background: rgba(72, 187, 120, 0.12);
    border-color: rgba(72, 187, 120, 0.22);
    color: #276749;
}

.project-units {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.project-units h4 {
    margin-bottom: 0.35rem;
}

.project-units-subtitle {
    margin-bottom: 1rem;
    color: var(--text-light);
    font-size: 0.92rem;
}

.assigned-units-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.assigned-unit-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(43,108,176,0.12), rgba(56,178,172,0.10));
    color: #1e3a8a;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
}

.assigned-unit-chip:hover {
    background: linear-gradient(90deg, rgba(30, 64, 175, 0.2), rgba(15, 118, 110, 0.2));
    color: #0f172a;
}

.assigned-unit-open-indicator {
    font-size: 0.82rem;
    color: #1d4ed8;
    font-weight: 800;
}

.assigned-unit-chip small {
    color: var(--text-light);
    font-weight: 600;
}

.project-unit-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.project-unit-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.95rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,251,255,0.96));
}

.project-unit-option input {
    margin-top: 0.2rem;
}

.project-unit-option-label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.project-unit-option-name {
    color: var(--text-dark);
    font-weight: 700;
}

.project-unit-option-meta {
    color: var(--text-light);
    font-size: 0.84rem;
}

.project-unit-empty {
    padding: 1rem;
    border-radius: 12px;
    background: var(--bg-light);
    color: var(--text-light);
    font-size: 0.92rem;
}

.project-assignment-actions {
    display: flex;
    justify-content: flex-end;
}

.project-assignment-actions .btn {
    min-width: 180px;
}

/* ===========================
   Calibrations
   =========================== */

.calibrations-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.calibration-card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.calibration-card h3 {
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.calibration-params {
    background: var(--bg-white);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.param {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.param:last-child {
    border-bottom: none;
}

.param label {
    color: var(--text-lighter);
    font-weight: 500;
}

.param span {
    color: var(--text-dark);
    font-weight: 600;
}

.mix-calibrations-table td {
    vertical-align: middle;
}

.mix-calibrations-table .mix-math {
    font-family: "Consolas", "Monaco", monospace;
    font-size: 0.9rem;
    white-space: nowrap;
}

.mix-calibrations-table td:last-child {
    white-space: nowrap;
}

/* ===========================
   Forms
   =========================== */

.project-form {
    background: var(--bg-light);
    padding: 2rem;
    border-radius: var(--radius-lg);
    max-width: 600px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions .btn {
    flex: 1;
}

/* ===========================
   Export Controls
   =========================== */

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

.export-option {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.export-option h3 {
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.export-option p {
    color: var(--text-light);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.export-option .btn {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.export-option input {
    margin-bottom: 1rem;
}

/* ===========================
   Responsive Dashboard
   =========================== */

@media (max-width: 1024px) {
    .dashboard-container {
        grid-template-columns: 200px 1fr;
    }
    
    .sidebar {
        width: 200px;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    
    .sidebar {
        display: none;
        position: fixed;
        left: 0;
        top: 70px;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
        z-index: 99;
    }
    
    .sidebar.show {
        display: block;
    }
    
    .dashboard-content {
        padding: 1rem;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .sensors-table th,
    .sensors-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .project-info-grid {
        grid-template-columns: 1fr;
    }
    
    .project-actions {
        flex-direction: column;
    }
    
    .project-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .sensors-table {
        font-size: 0.8rem;
    }
    
    .sensors-table th,
    .sensors-table td {
        padding: 0.5rem;
    }
    
    .status-badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .project-detail-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .export-controls {
        grid-template-columns: 1fr;
    }
}

/* ===========================
   Sensor Detail Modal
   =========================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

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

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.modal-body {
    padding: 2rem;
}

.detail-section {
    margin-bottom: 2.5rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-dark);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

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

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    margin-bottom: 0.4rem;
    letter-spacing: 0.5px;
}

.detail-item span {
    font-size: 1rem;
    color: var(--text-dark);
    word-break: break-word;
}

.temp-value {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.1rem;
}

.readings-table {
    width: 100%;
    overflow-x: auto;
}

.readings-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.readings-table th {
    background: var(--bg-light);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid var(--border-color);
}

.readings-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

.alerts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid;
    font-size: 0.95rem;
}

.alert-success {
    background: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.alert-warning {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.alert-danger {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ===========================
   Overseer Controls
   =========================== */

.overseer-controls {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.overseer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    cursor: pointer;
    user-select: none;
}

.overseer-header h4 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.05rem;
}

.overseer-toggle {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.overseer-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.overseer-panel {
    padding: 1.5rem;
    background: var(--bg-white);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        overflow: hidden;
    }
    to {
        opacity: 1;
        max-height: 2000px;
    }
}

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

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.control-group label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.control-group small {
    color: var(--text-lighter);
    font-size: 0.8rem;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.control-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.control-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.control-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.control-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.slider-value {
    min-width: 50px;
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.control-select {
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    color: var(--text-dark);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.control-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
    border-radius: var(--radius-md);
    border-top: 1px solid var(--border-color);
}

.control-actions .btn {
    flex: 1;
    min-width: 150px;
}

/* Mobile Overseer Controls */
@media (max-width: 768px) {
    .controls-grid {
        grid-template-columns: 1fr;
    }
    
    .overseer-header {
        padding: 1rem;
    }
    
    .overseer-panel {
        padding: 1rem;
    }
    
    .control-group {
        padding: 0.75rem;
    }
    
    .control-actions {
        flex-direction: column;
    }
    
    .control-actions .btn {
        width: 100%;
    }
}
@media (max-width: 768px) {
    .modal {
        padding: 1rem;
    }
    
    .modal-content {
        width: 100%;
        max-height: 95vh;
        border-radius: 16px;
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    }
    
    .modal-header {
        padding: 1.5rem;
        gap: 1rem;
        flex-wrap: wrap;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
        order: 1;
        width: 100%;
    }
    
    .modal-close {
        order: 2;
        font-size: 2rem;
        padding: 0.25rem;
    }
    
    .modal-body {
        padding: 1.25rem;
        max-height: calc(95vh - 140px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .detail-section {
        margin-bottom: 2rem;
        padding-bottom: 1.5rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .detail-section:last-child {
        border-bottom: none;
    }
    
    .detail-section h3 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .detail-item {
        padding: 0.75rem;
        background: var(--bg-light);
        border-radius: var(--radius-md);
    }
    
    .detail-item label {
        font-size: 0.75rem;
        margin-bottom: 0.35rem;
    }
    
    .detail-item span {
        font-size: 0.95rem;
    }
    
    .temp-value {
        font-size: 1rem;
    }
    
    .readings-table {
        font-size: 0.85rem;
    }
    
    .readings-table th,
    .readings-table td {
        padding: 0.6rem 0.4rem;
    }
    
    .readings-table thead {
        position: sticky;
        top: 0;
        background: var(--bg-light);
        z-index: 10;
    }
    
    .alerts-container {
        gap: 0.75rem;
    }
    
    .alert {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .modal-footer {
        padding: 1.25rem;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.95rem;
        border-radius: 8px;
    }
    
    /* Improve touch targets */
    .modal-footer .btn-secondary {
        order: 2;
    }
    
    .modal-footer .btn-primary {
        order: 1;
    }
}

/* Extra small screens (mobile phones) */
@media (max-width: 480px) {
    .modal-header {
        padding: 1.25rem 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .detail-item {
        padding: 0.65rem;
    }
    
    .detail-item label {
        font-size: 0.7rem;
    }
    
    .detail-section h3 {
        font-size: 0.95rem;
        margin-bottom: 0.65rem;
    }
    
    .readings-table th,
    .readings-table td {
        padding: 0.5rem 0.3rem;
        font-size: 0.8rem;
    }
    
    .modal-footer {
        padding: 1rem;
        gap: 0.5rem;
    }
}
