@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    /* Brand Palette */
    --primary-red: #EB0A1E;
    --red-hover: #D0021B;
    --primary-blue: #0A1633;
    --secondary-blue: #162B55;
    --accent-blue: #2563EB;
    --dark-bg: #070D1E;
    --dark-surface: #0E1A38;
    
    /* Light Mode Variables */
    --text-dark: #1E293B;
    --text-muted: #64748B;
    --text-light: #F8FAFC;
    --bg-light: #F1F5F9;
    --bg-card: #FFFFFF;
    --card-header-bg: linear-gradient(90deg, #0A1633 0%, #162B55 100%);
    --card-header-text: #FFFFFF;
    --border-color: #E2E8F0;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --table-header-bg: #F8FAFC;
    --table-row-hover: #F1F5F9;
    --topbar-bg: #FFFFFF;
    --metric-border: #EDF2F7;
    --metric-val-color: var(--primary-blue);
    --circle-health-bg: #F0FDF4;
    --circle-alarm-bg: #FEF2F2;

    /* Status Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #06B6D4;

    /* Dimensions */
    --sidebar-width: 255px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

/* ================= COMPREHENSIVE HIGH-CONTRAST DARK MODE ================= */
body.dark-mode {
    --text-dark: #F8FAFC;
    --text-muted: #94A3B8;
    --bg-light: #070D1E;
    --bg-card: #0D1935;
    --card-header-bg: linear-gradient(90deg, #112248 0%, #1A346C 100%);
    --card-header-text: #FFFFFF;
    --border-color: #1E293B;
    --border-subtle: rgba(255, 255, 255, 0.1);
    --table-header-bg: #0F1E40;
    --table-row-hover: #162850;
    --topbar-bg: #0A152E;
    --metric-border: #1E2E52;
    --metric-val-color: #38BDF8;
    --circle-health-bg: rgba(16, 185, 129, 0.12);
    --circle-alarm-bg: rgba(239, 68, 68, 0.12);
}

/* Force bright legible text in Dark Mode */
body.dark-mode,
body.dark-mode p,
body.dark-mode span,
body.dark-mode div,
body.dark-mode td,
body.dark-mode b,
body.dark-mode strong {
    color: #E2E8F0;
}
body.dark-mode .text-muted,
body.dark-mode p[style*="color:#666"],
body.dark-mode p[style*="color: #666"],
body.dark-mode p[style*="color:#888"],
body.dark-mode p[style*="color: #888"],
body.dark-mode span[style*="color:#666"],
body.dark-mode span[style*="color: #666"],
body.dark-mode span[style*="color:#888"],
body.dark-mode span[style*="color: #888"],
body.dark-mode div[style*="color:#666"],
body.dark-mode div[style*="color: #666"],
body.dark-mode div[style*="color:#888"],
body.dark-mode div[style*="color: #888"],
body.dark-mode div[style*="color:#555"],
body.dark-mode div[style*="color: #555"],
body.dark-mode div[style*="color:#718096"] {
    color: #94A3B8 !important;
}
body.dark-mode .topbar-title h2 {
    color: #FFFFFF !important;
}
body.dark-mode .topbar-title p {
    color: #94A3B8 !important;
}

/* Bright contrast colored texts in Dark Mode */
body.dark-mode .text-success,
body.dark-mode [style*="color:var(--success)"] {
    color: #34D399 !important;
}
body.dark-mode .text-danger,
body.dark-mode [style*="color:var(--danger)"],
body.dark-mode [style*="color:#D0021B"] {
    color: #F87171 !important;
}
body.dark-mode .text-warning,
body.dark-mode [style*="color:var(--warning)"],
body.dark-mode [style*="color:#F5A623"] {
    color: #FBBF24 !important;
}

/* Topbar & Headers in Dark Mode */
body.dark-mode .topbar {
    background: var(--topbar-bg) !important;
    border-color: #1E2E52 !important;
}
body.dark-mode .topbar-main-header {
    border-color: #1E2E52 !important;
}
body.dark-mode .topbar-sub-header {
    background: #081126 !important;
    border-color: #1E2E52 !important;
}

/* Cards & Bodies in Dark Mode */
body.dark-mode .card {
    background: var(--bg-card) !important;
    border-color: #1E2E52 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
}
body.dark-mode .card-body {
    background: var(--bg-card) !important;
    color: #F8FAFC !important;
}

/* Metrics in Dark Mode */
body.dark-mode .metric-box {
    border-color: var(--metric-border) !important;
}
body.dark-mode .metric-box .title {
    color: #94A3B8 !important;
}
body.dark-mode .metric-box .value {
    color: #38BDF8 !important;
}
body.dark-mode .metric-box .value.red {
    color: #F87171 !important;
}
body.dark-mode .metric-box .value.green {
    color: #34D399 !important;
}
body.dark-mode .metric-box:hover {
    background: rgba(255,255,255,0.04) !important;
}

/* Circles */
body.dark-mode .health-circle {
    background: var(--circle-health-bg) !important;
    color: #34D399 !important;
}
body.dark-mode .alarm-circle {
    background: var(--circle-alarm-bg) !important;
    color: #F87171 !important;
}
body.dark-mode .gauge-circle-chiller {
    background: rgba(16, 185, 129, 0.12) !important;
}
body.dark-mode .gauge-circle-chiller div {
    color: #34D399 !important;
}

/* Tables & Special Rows in Dark Mode */
body.dark-mode .table th {
    background: var(--table-header-bg) !important;
    color: #94A3B8 !important;
    border-color: #1E2E52 !important;
}
body.dark-mode .table td {
    border-color: #1E2E52 !important;
    color: #E2E8F0 !important;
}
body.dark-mode .table tbody tr:hover td {
    background-color: var(--table-row-hover) !important;
}

/* Total Row & Cyber Alert Row in Dark Mode (High contrast, bright text) */
body.dark-mode .total-row,
body.dark-mode tr.total-row td,
body.dark-mode tr[style*="background:#f8fafc"] td {
    background-color: #132347 !important;
    color: #F8FAFC !important;
    border-color: #1E3A8A !important;
}
body.dark-mode .cyber-alert-row,
body.dark-mode tr.cyber-alert-row td,
body.dark-mode tr[style*="background:#fff1f2"] td {
    background-color: rgba(239, 68, 68, 0.18) !important;
    color: #FECACA !important;
    border-color: rgba(239, 68, 68, 0.35) !important;
}

/* Dark mode custom container boxes & machine elements */
body.dark-mode div[style*="background:#f8fafc"],
body.dark-mode div[style*="background: #f8fafc"],
body.dark-mode div[style*="background:#fafbfc"],
body.dark-mode div[style*="background: #fafbfc"],
body.dark-mode div[style*="background:#f9f9f9"],
body.dark-mode div[style*="background: #f9f9f9"],
body.dark-mode div[style*="background:#edf2f7"],
body.dark-mode div[style*="background: #edf2f7"],
body.dark-mode .eq-card-item,
body.dark-mode .chiller-unit-box {
    background: #112040 !important;
    border-color: #1E3460 !important;
    color: #F1F5F9 !important;
}
body.dark-mode .chiller-unit-box b,
body.dark-mode .eq-card-item b {
    color: #38BDF8 !important;
}
body.dark-mode .chiller-unit-box.active-run {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: var(--success) !important;
}
body.dark-mode div[style*="background:#eff6ff"],
body.dark-mode div[style*="background:#f0fdf4"],
body.dark-mode div[style*="background:#fef2f2"] {
    background: #132347 !important;
    border-color: #1E3A8A !important;
    color: #F1F5F9 !important;
}
body.dark-mode div[style*="border-right: 1px solid #edf2f7"],
body.dark-mode div[style*="border-right:1px solid #edf2f7"],
body.dark-mode div[style*="border-right:1px solid #eee"],
body.dark-mode div[style*="border-top:1px solid #eee"],
body.dark-mode div[style*="border-bottom: 1px solid #eee"],
body.dark-mode div[style*="border-top:1px dashed #cbd5e1"],
body.dark-mode div[style*="border-bottom:1px dashed #cbd5e1"] {
    border-color: #1E2E52 !important;
}

/* Form Controls in Dark Mode */
body.dark-mode .control-item select,
body.dark-mode input[type="text"],
body.dark-mode input[type="password"],
body.dark-mode textarea {
    background-color: #132347 !important;
    color: #F8FAFC !important;
    border-color: #1E3A8A !important;
}
body.dark-mode .theme-toggle-btn {
    background: #132347 !important;
    color: #F8FAFC !important;
    border-color: #1E3A8A !important;
}
body.dark-mode .theme-toggle-btn:hover {
    background: #1A346C !important;
}

/* ================= DARK MODE EXHAUSTIVE CONTRAST OVERRIDES ================= */
/* Brighten all text with inline dark colors in Dark Mode */
body.dark-mode [style*="color:#0A1C3E"],
body.dark-mode [style*="color: #0A1C3E"],
body.dark-mode [style*="color:#1C3364"],
body.dark-mode [style*="color: #1C3364"],
body.dark-mode [style*="color:#1e40af"],
body.dark-mode [style*="color: #1e40af"],
body.dark-mode [style*="color:#1e3a8a"],
body.dark-mode [style*="color: #1e3a8a"],
body.dark-mode [style*="color:#166534"],
body.dark-mode [style*="color: #166534"],
body.dark-mode [style*="color:#14532d"],
body.dark-mode [style*="color: #14532d"],
body.dark-mode [style*="color:#7f1d1d"],
body.dark-mode [style*="color: #7f1d1d"],
body.dark-mode [style*="color:#991b1b"],
body.dark-mode [style*="color: #991b1b"],
body.dark-mode [style*="color:var(--primary-blue)"] {
    color: #38BDF8 !important;
}

body.dark-mode [style*="color:#15803d"],
body.dark-mode [style*="color: #15803d"] {
    color: #34D399 !important;
}

body.dark-mode [style*="color:#b91c1c"],
body.dark-mode [style*="color: #b91c1c"] {
    color: #F87171 !important;
}

body.dark-mode [style*="color:#3b82f6"],
body.dark-mode [style*="color: #3b82f6"] {
    color: #60A5FA !important;
}

/* Dark mode inline borders: Turn all gray/dark lines into bright cyan/navy visible lines */
body.dark-mode [style*="border: 1px solid #e2e8f0"],
body.dark-mode [style*="border:1px solid #e2e8f0"],
body.dark-mode [style*="border: 1px solid #bfdbfe"],
body.dark-mode [style*="border:1px solid #bfdbfe"],
body.dark-mode [style*="border: 1px solid #bbf7d0"],
body.dark-mode [style*="border:1px solid #bbf7d0"],
body.dark-mode [style*="border: 1px solid #fecaca"],
body.dark-mode [style*="border:1px solid #fecaca"],
body.dark-mode [style*="border: 1px solid #fee2e2"],
body.dark-mode [style*="border:1px solid #fee2e2"],
body.dark-mode [style*="border: 1px solid #CBD5E1"],
body.dark-mode [style*="border:1px solid #CBD5E1"] {
    border-color: #1E3A8A !important;
}

/* Progress track in dark mode */
body.dark-mode .progress-track {
    background: #1E2E52 !important;
}

/* SVG Line / Polylines / Paths in Dark Mode */
body.dark-mode svg line,
body.dark-mode svg polyline,
body.dark-mode svg path {
    stroke: #38BDF8 !important;
}
body.dark-mode svg text {
    fill: #E2E8F0 !important;
}

/* ================= GLOBAL BASE STYLES ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-size: 13px;
    overflow-x: hidden;
    height: 100vh;
    letter-spacing: -0.01em;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #e2e8f0; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ================= DASHBOARD LAYOUT ================= */
.dashboard-wrapper {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-light);
}

/* FLOATING SIDEBAR WITH LOGOUT AT BOTTOM */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: linear-gradient(180deg, #070D1E 0%, #0B152E 100%);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100vh;
    border-right: 1px solid rgba(255,255,255,0.06);
    justify-content: space-between;
    padding: 12px 0;
}

.sidebar-header {
    height: 55px;
    min-height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    text-align: center;
}
.sidebar-header h2 { 
    font-size: 16px; 
    font-weight: 800; 
    color: var(--text-light); 
    line-height: 1.2; 
    letter-spacing: 0.5px; 
    text-align: center;
}
.sidebar-header h2 span {
    color: var(--primary-red);
    text-shadow: 0 0 10px rgba(235, 10, 30, 0.4);
}

.sidebar-menu-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4px 14px;
    margin: auto 0;
}

.sidebar-menu {
    list-style: none;
    padding: 6px;
    margin: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.sidebar-menu li {
    margin: 2px 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 7px 12px;
    color: #94A3B8;
    text-decoration: none;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    transition: all 0.2s ease;
    border-radius: 8px;
    position: relative;
}

.sidebar-menu a i { 
    width: 22px; 
    font-size: 13px; 
    margin-right: 10px; 
    text-align: center; 
    transition: transform 0.2s;
}
.sidebar-menu a small { 
    display: block; 
    text-transform: none; 
    color: #64748B; 
    font-size: 9.5px; 
    margin-top: 1px; 
    font-weight: 400; 
    letter-spacing: 0;
}
.sidebar-menu a:hover { 
    background: rgba(255,255,255,0.06); 
    color: #F8FAFC; 
    transform: translateX(3px);
}
.sidebar-menu a:hover i {
    transform: scale(1.15);
    color: #38BDF8;
}

.sidebar-menu li.active a {
    background: linear-gradient(135deg, var(--primary-red) 0%, #C80818 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(235, 10, 30, 0.35);
    font-weight: 700;
}
.sidebar-menu li.active a small { color: rgba(255,255,255,0.85); }
.sidebar-menu li.active a i { color: #FFFFFF; }

/* SIDEBAR FOOTER WITH LOGOUT BUTTON */
.sidebar-footer {
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #F87171;
    font-size: 11.5px;
    font-weight: 700;
    text-decoration: none;
    text-transform: uppercase;
    transition: all 0.2s ease;
}
.sidebar-logout-btn:hover {
    background: var(--danger);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.sidebar-version {
    font-size: 9px;
    color: #64748B;
    text-align: center;
    letter-spacing: 0.3px;
}

/* MAIN CONTENT */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-light);
    height: 100vh;
    min-width: 0;
}

/* ================= 2-TIER CLEAN TOPBAR SYSTEM ================= */
.topbar {
    background: var(--topbar-bg);
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-color);
    z-index: 90;
    flex-shrink: 0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    transition: background 0.2s ease;
}

/* TIER 1: HEADER UTAMA (JUDUL DI TENGAH) */
.topbar-main-header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav-toggle {
    display: none;
    position: absolute;
    left: 14px;
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    font-size: 15px;
    color: var(--primary-blue);
    cursor: pointer;
    padding: 5px 8px;
}

.topbar-title {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.topbar-title h2 {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--primary-blue);
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-title p {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* TIER 2: HEADER ADEK / SUB-HEADER (KONTROL TOMBOL DIBAWAH JUDUL) */
.topbar-sub-header {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    background: #FAFBFD;
}

.topbar-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: nowrap;
    width: 100%;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid #CBD5E1;
    background: #F8FAFC;
    color: #1E293B;
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.theme-toggle-btn:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
}

.control-item { display: flex; flex-direction: row; align-items: center; gap: 6px; }
.control-item label { 
    font-size: 10px; 
    font-weight: 700; 
    color: #64748B; 
    text-transform: uppercase; 
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.control-item select {
    padding: 4px 24px 4px 8px;
    border: 1px solid #CBD5E1;
    border-radius: 6px;
    background-color: #FFFFFF;
    font-size: 11px;
    font-weight: 600;
    color: #1E293B;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
    cursor: pointer;
}

.btn-export {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #1E293B 100%);
    color: var(--text-light);
    border: none;
    padding: 5px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 10.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s ease;
}
.btn-export:hover { 
    background: var(--secondary-blue); 
    box-shadow: var(--shadow-md); 
    transform: translateY(-1px);
}

/* CONTENT AREA (Scrollable) */
.content-area {
    padding: 14px 16px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ================= MODERN CARDS ================= */
.card {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    min-width: 0;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-header {
    background: var(--card-header-bg);
    color: var(--card-header-text);
    padding: 9px 14px;
    font-size: 11.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.card-header span.badge {
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(4px);
    padding: 2px 7px;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255,255,255,0.15);
}

.card-body {
    padding: 12px 14px;
    flex-grow: 1;
    position: relative;
    min-height: 120px;
    overflow-x: auto;
    background: var(--bg-card);
}

/* ================= GRID SYSTEM ================= */
.dashboard-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
    width: 100%;
}
.col-1 { grid-template-columns: 1fr; }
.col-2 { grid-template-columns: repeat(2, 1fr); }
.col-3 { grid-template-columns: repeat(3, 1fr); }
.col-4 { grid-template-columns: repeat(4, 1fr); }
.col-5 { grid-template-columns: repeat(5, 1fr); }

/* Nested Grid Helpers */
.grid-nested-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; }
.grid-nested-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.grid-nested-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.grid-nested-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: 100%; }
.grid-nested-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; width: 100%; }

/* Proportional Grid Row Layouts */
.grid-layout-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-layout-3-1 { display: grid; grid-template-columns: 3fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-layout-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; margin-bottom: 12px; }
.grid-layout-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-bottom: 12px; }
.grid-layout-1-1-1 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.grid-layout-1-1 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
.grid-layout-2-1-1-1 { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-layout-1-1-08-1 { display: grid; grid-template-columns: 1.1fr 1.1fr 0.9fr 1.1fr; gap: 12px; margin-bottom: 12px; }

/* ================= METRIC BOXES ================= */
.metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    width: 100%;
    height: 100%;
}
.metric-box {
    border-right: 1px solid var(--metric-border);
    padding: 6px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    transition: background 0.15s;
}
.metric-box:last-child { border-right: none; }
.metric-box .title { 
    font-size: 10px; 
    font-weight: 700; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    margin-bottom: 4px; 
    text-align: center;
    letter-spacing: 0.3px;
}
.metric-box .value { 
    font-size: 22px; 
    font-weight: 800; 
    color: var(--metric-val-color); 
    margin-bottom: 2px;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.03em;
}
.metric-box .value.red { color: var(--danger); }
.metric-box .value.green { color: var(--success); }
.metric-box .subtitle { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; font-weight: 500; }
.metric-box .trend { font-size: 10px; font-weight: 700; }

/* SPARKLINE */
.sparkline {
    width: 100%;
    height: 16px;
    margin-top: 4px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 100 20"><path d="M0,15 L20,10 L40,18 L60,5 L80,12 L100,2" fill="none" stroke="%2310B981" stroke-width="2.5"/><circle cx="100" cy="2" r="2.5" fill="%2310B981"/></svg>') no-repeat center;
    background-size: 100% 100%;
}

/* CIRCLES */
.health-circle {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    border: 5px solid var(--success);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-blue);
    font-family: 'JetBrains Mono', monospace;
    margin: 6px auto;
    background: var(--circle-health-bg);
}

.alarm-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 5px solid var(--danger);
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    background: var(--circle-alarm-bg);
    font-family: 'JetBrains Mono', monospace;
}

/* PROGRESS BARS */
.progress-bar-container { display: flex; align-items: center; margin-bottom: 6px; }
.progress-label { width: 90px; font-size: 11px; flex-shrink: 0; font-weight: 500; color: var(--text-dark); }
.progress-track { flex: 1; height: 7px; background: #E2E8F0; border-radius: 4px; margin: 0 8px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #10B981 0%, #059669 100%); border-radius: 4px; }
.progress-value { width: 34px; font-size: 11px; font-weight: 700; text-align: right; flex-shrink: 0; font-family: 'JetBrains Mono', monospace; }

/* UTILS */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.text-center { text-align: center; }

/* TABLES */
.table-responsive { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; }
.table th, .table td { padding: 7px 10px; border-bottom: 1px solid var(--border-color); text-align: left; }
.table th { 
    font-weight: 700; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    font-size: 10px; 
    background: var(--table-header-bg); 
    letter-spacing: 0.3px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.table tbody tr:hover td {
    background-color: var(--table-row-hover);
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; }
.status-dot.green { background-color: var(--success); box-shadow: 0 0 6px rgba(16, 185, 129, 0.5); }
.status-dot.red { background-color: var(--danger); box-shadow: 0 0 6px rgba(239, 68, 68, 0.5); }
.status-dot.yellow { background-color: var(--warning); box-shadow: 0 0 6px rgba(245, 158, 11, 0.5); }

/* SIDEBAR OVERLAY FOR MOBILE */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(7, 13, 30, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99;
}

/* ================= RESPONSIVE MEDIA QUERIES (ANDROID, IOS, TABLET, DESKTOP) ================= */
@media (max-width: 1024px) {
    .grid-layout-2-1,
    .grid-layout-3-1,
    .grid-layout-3-2,
    .grid-layout-1-2,
    .grid-layout-1-1-1,
    .grid-layout-1-1-08-1,
    .grid-layout-2-1-1-1,
    .dashboard-grid.col-4,
    .dashboard-grid.col-5 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
    }
    .dashboard-wrapper {
        height: auto;
        min-height: 100vh;
    }
    .main-content {
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
    }
    .content-area {
        overflow-y: visible;
        padding: 10px;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1000;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    
    .mobile-nav-toggle {
        display: inline-block;
    }
    
    .topbar-main-header {
        padding: 0 45px;
        height: auto;
        min-height: 48px;
        padding-top: 6px;
        padding-bottom: 6px;
    }
    .topbar-title h2 {
        white-space: normal;
        font-size: 12.5px;
    }
    .topbar-title p {
        white-space: normal;
        font-size: 9.5px;
    }

    .topbar-sub-header {
        height: auto;
        padding: 6px 12px;
    }
    .topbar-controls {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 6px;
        justify-content: flex-start;
    }
    .control-item {
        flex: 1 1 calc(50% - 6px);
    }
    .btn-export {
        width: 100%;
        justify-content: center;
        margin-top: 4px;
    }

    .grid-layout-2-1,
    .grid-layout-3-1,
    .grid-layout-3-2,
    .grid-layout-1-2,
    .grid-layout-1-1,
    .grid-layout-1-1-1,
    .grid-layout-1-1-08-1,
    .grid-layout-2-1-1-1,
    .dashboard-grid.col-2,
    .dashboard-grid.col-3,
    .dashboard-grid.col-4,
    .dashboard-grid.col-5,
    .grid-nested-2,
    .grid-nested-3,
    .grid-nested-4,
    .grid-nested-5,
    .grid-nested-6 {
        grid-template-columns: 1fr !important;
    }

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

/* Extra Mobile Screens (iPhone SE, Android 375px - 480px) */
@media (max-width: 480px) {
    .content-area {
        padding: 6px;
    }
    .card {
        margin-bottom: 8px;
    }
    .card-header {
        font-size: 11px;
        padding: 8px 10px;
    }
    .metric-row {
        grid-template-columns: 1fr;
    }
    .control-item {
        flex: 1 1 100%;
    }
    .table th, .table td {
        padding: 6px 8px;
        font-size: 10px;
    }
    .role-hint-box, .login-card {
        padding: 16px;
        width: 92%;
    }
}

