/* ============================================================
   app.css  —  Global design tokens & base styles
   ============================================================ */

:root {
    /* Brand accent — dull orange */
    --accent:          #B86A0F;
    --accent-light:    #FDF4E7;
    --accent-mid:      #EF9F27;
    --accent-hover:    #A05C0A;
    --accent-dark:     #633806;
    --accent-bg:       #FAEEDA;

    /* Neutrals */
    --gray-900: #2C2C2A;
    --gray-800: #444441;
    --gray-600: #5F5E5A;
    --gray-400: #888780;
    --gray-200: #D3D1C7;
    --gray-100: #F1EFE8;
    --gray-50:  #F7F6F2;

    /* Semantic */
    --color-danger:       #A32D2D;
    --color-danger-bg:    #FCEBEB;
    --color-danger-border:#F09595;
    --color-warn:         #854F0B;
    --color-warn-bg:      #FAEEDA;
    --color-success:      #3B6D11;
    --color-success-bg:   #EAF3DE;
    --color-info:         #185FA5;
    --color-info-bg:      #E6F1FB;

    /* Layout */
    --sidebar-width:      180px;
    --sidebar-collapsed:  48px;
    --topbar-height:      38px;
    --globalbar-height:   40px;
    --panel-width:        320px;
    --radius-sm:          4px;
    --radius-md:          6px;
    --radius-lg:          8px;

    /* Surfaces */
    --surface:            #ffffff;
    --surface-secondary:  #F7F6F2;
    --surface-tertiary:   #F1EFE8;
    --border:             rgba(0,0,0,0.10);
    --border-mid:         rgba(0,0,0,0.18);
    --text-primary:       #2C2C2A;
    --text-secondary:     #5F5E5A;
    --text-tertiary:      #888780;
}

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

html, body {
    height: 100%;
    font-family: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--surface-secondary);
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }


/* ============================================================
   GLOBAL BAR  (always on top, dark)
   ============================================================ */
.global-bar {
    height: var(--globalbar-height);
    background: var(--gray-900);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.gb-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.gb-logomark {
    width: 26px;
    height: 26px;
    background: var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gb-logomark svg { width: 14px; height: 14px; }

.gb-appname {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.gb-sep {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.12);
    flex-shrink: 0;
}

.gb-module-crumb {
    font-size: 11px;
    color: rgba(255,255,255,0.38);
}

.gb-module-active {
    font-size: 11px;
    color: var(--accent-mid);
    font-weight: 500;
}

.gb-home-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(255,255,255,0.07);
    border: 0.5px solid rgba(255,255,255,0.14);
    border-radius: var(--radius-md);
    color: rgba(255,255,255,0.55);
    font-size: 11px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.gb-home-btn:hover {
    background: rgba(255,255,255,0.13);
    color: #fff;
}

.gb-home-btn svg { width: 12px; height: 12px; }

.gb-search {
    flex: 1;
    max-width: 260px;
    margin: 0 8px;
}

.gb-search input {
    width: 100%;
    background: rgba(255,255,255,0.07);
    border: 0.5px solid rgba(255,255,255,0.13);
    border-radius: var(--radius-md);
    padding: 5px 10px 5px 28px;
    font-size: 11px;
    color: rgba(255,255,255,0.75);
    outline: none;
    transition: background 0.15s;
}

.gb-search input::placeholder { color: rgba(255,255,255,0.28); }
.gb-search input:focus { background: rgba(255,255,255,0.11); }
.gb-search-wrap { position: relative; }
.gb-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.3);
    pointer-events: none;
}
.gb-search-icon svg { width: 12px; height: 12px; }

.gb-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.gb-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.45);
    cursor: pointer;
    transition: color 0.15s;
    background: none;
    border: none;
    padding: 0;
}

.gb-icon-btn:hover { color: rgba(255,255,255,0.85); }
.gb-icon-btn svg { width: 16px; height: 16px; }

.gb-badge {
    width: 7px;
    height: 7px;
    background: #E24B4A;
    border-radius: 50%;
    position: absolute;
    top: -1px;
    right: -2px;
    border: 1.5px solid var(--gray-900);
}

.gb-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.gb-user-info { display: flex; flex-direction: column; line-height: 1.3; }
.gb-user-name { font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.85); }
.gb-user-role { font-size: 10px; color: rgba(255,255,255,0.38); }


/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}


/* ============================================================
   MODULE LAYOUT SHELL
   ============================================================ */
.module-shell {
    display: flex;
    flex: 1;
    /* overflow must NOT be hidden — MudPopover teleports outside this
       container and needs to be visible above the module shell */
    overflow: visible;
    min-height: 0;
}

/* MODULE SIDEBAR */
.module-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ms-header {
    padding: 10px 14px 8px;
    border-bottom: 0.5px solid var(--border);
    flex-shrink: 0;
}

.ms-module-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-dark);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--accent-bg);
    padding: 3px 7px;
    border-radius: var(--radius-sm);
}

.ms-module-tag svg { width: 11px; height: 11px; }

.ms-nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.ms-section { padding: 0 0 6px; }

.ms-section-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 8px 14px 4px;
}

.ms-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    position: relative;
    text-decoration: none;
}

.ms-item:hover {
    background: var(--surface-secondary);
    color: var(--text-primary);
}

.ms-item.active {
    background: var(--accent-bg);
    color: var(--accent-dark);
    font-weight: 500;
}

.ms-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2.5px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.ms-item svg { width: 14px; height: 14px; flex-shrink: 0; }

.ms-badge {
    margin-left: auto;
    background: var(--color-danger-bg);
    color: var(--color-danger);
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 8px;
}

.ms-badge.warn {
    background: var(--accent-bg);
    color: var(--accent-dark);
}

.ms-footer {
    padding: 10px 14px;
    border-top: 0.5px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ms-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-dark);
    flex-shrink: 0;
}

.ms-user-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.ms-user-role { font-size: 10px; color: var(--text-tertiary); }

/* MODULE CONTENT AREA */
.module-content-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* overflow:hidden would clip MudPopover dropdowns — use min-height instead */
    min-height: 0;
}

/* MODULE TOPBAR */
.module-topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    flex-shrink: 0;
    /* Must be visible so MudSelect popover can render below the topbar */
    overflow: visible;
    position: relative;
    z-index: 10;
}

.mt-breadcrumb {
    font-size: 11px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.mt-breadcrumb span { color: var(--text-primary); font-weight: 500; }
.mt-breadcrumb svg { width: 11px; height: 11px; }

.mt-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    font-size: 11px;
    border-radius: var(--radius-md);
    border: 0.5px solid var(--border-mid);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}

.btn:hover { background: var(--surface-secondary); color: var(--text-primary); }
.btn svg { width: 12px; height: 12px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.filter-select {
    padding: 4px 8px;
    font-size: 11px;
    border: 0.5px solid var(--border-mid);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
}

/* MODULE PAGE CONTENT */
.page-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.page-main {
    flex: 1;
    min-width: 0; /* ← prevents flex child from overflowing */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* PAGE HEADER */
.page-hdr { display: flex; align-items: flex-start; justify-content: space-between; }
.page-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.page-subtitle { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* KPI ROW */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.kpi-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.kpi-card.accent-left-warn { border-left: 2.5px solid var(--accent-mid); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.kpi-card.accent-left-danger { border-left: 2.5px solid var(--color-danger); border-radius: 0 var(--radius-md) var(--radius-md) 0; }

.kpi-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.kpi-value { font-size: 24px; font-weight: 600; line-height: 1; color: var(--text-primary); }
.kpi-value.ok { color: var(--color-success); }
.kpi-value.warn { color: var(--color-warn); }
.kpi-value.danger { color: var(--color-danger); }

.kpi-delta {
    font-size: 10px;
    margin-top: 4px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 3px;
}

.kpi-delta.up { color: var(--color-success); }
.kpi-delta.down { color: var(--color-danger); }

/* SECTION HEADER */
.section-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.section-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.section-link {
    font-size: 11px;
    color: var(--accent);
    cursor: pointer;
}

.section-link:hover { color: var(--accent-hover); }

/* DATA TABLE */
.data-table-wrap {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    overflow-x: auto; /* ← table scrolls horizontally inside its box */
    overflow-y: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

.data-table th {
    background: var(--surface-secondary);
    padding: 6px 10px;
    text-align: left;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 0.5px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 7px 10px;
    border-bottom: 0.5px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover td { background: var(--surface-secondary); }
.data-table tbody tr.row-selected td { background: var(--accent-bg); }

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
}

.badge-dot { width: 5px; height: 5px; border-radius: 50%; }

.badge-online { background: var(--color-success-bg); color: var(--color-success); }
.badge-online .badge-dot { background: var(--color-success); }
.badge-offline { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-offline .badge-dot { background: var(--color-danger); }
.badge-warn { background: var(--color-warn-bg); color: var(--color-warn); }
.badge-warn .badge-dot { background: var(--color-warn); }

/* SIGNAL BARS */
.signal-bar { display: flex; align-items: flex-end; gap: 2px; height: 13px; }
.sig-b { width: 3px; background: var(--gray-200); border-radius: 1px; }
.sig-b.on { background: var(--accent); }

/* SPARKLINE CHARTS */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.mini-chart-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.mini-chart-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.sparkline { width: 100%; height: 44px; }

.spark-axis {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* RIGHT DETAIL PANEL */
.right-panel {
    width: 320px;
    flex-shrink: 0;
    background: var(--surface);
    border-left: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rp-header {
    padding: 10px 14px;
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-shrink: 0;
}

.rp-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.rp-subtitle { font-size: 10px; color: var(--text-tertiary); margin-top: 2px; }

.rp-close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    font-size: 14px;
    flex-shrink: 0;
}

.rp-close-btn:hover { color: var(--text-primary); }

.rp-tabs {
    display: flex;
    border-bottom: 0.5px solid var(--border);
    flex-shrink: 0;
}

.rp-tab {
    flex: 1;
    padding: 7px 4px;
    font-size: 11px;
    text-align: center;
    color: var(--text-tertiary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -0.5px;
    transition: color 0.12s;
}

.rp-tab:hover { color: var(--text-secondary); }

.rp-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

.rp-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rp-empty {
    text-align: center;
    padding: 50px 16px;
    color: var(--text-tertiary);
    font-size: 12px;
    line-height: 1.8;
}

.rp-section-title {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 7px;
    border-bottom: 0.5px solid var(--border);
    margin-bottom: 8px;
}

.rp-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 3px 0;
    gap: 8px;
}

.rp-key {
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.rp-val {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
    word-break: break-all;
    min-width: 0;
}
.rp-val.ok { color: var(--color-success); }
.rp-val.warn { color: var(--color-warn); }
.rp-val.danger { color: var(--color-danger); }

.rp-mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.rp-mini-kpi {
    background: var(--surface-secondary);
    border-radius: var(--radius-md);
    padding: 8px 10px;
}

.rp-mini-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rp-mini-val { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.rp-mini-unit { font-size: 9px; color: var(--text-tertiary); }

.rp-gauge-wrap { margin: 4px 0 8px; }
.rp-gauge { background: var(--surface-secondary); border-radius: 3px; height: 5px; overflow: hidden; }
.rp-gauge-fill { height: 100%; border-radius: 3px; }

.rp-alert-item {
    display: flex;
    gap: 8px;
    padding: 7px 9px;
    border-radius: var(--radius-md);
    margin-bottom: 5px;
}

.rp-alert-item.danger { background: var(--color-danger-bg); }
.rp-alert-item.warn { background: var(--color-warn-bg); }

.rp-alert-icon { font-size: 12px; flex-shrink: 0; margin-top: 1px; }
.danger .rp-alert-icon { color: var(--color-danger); }
.warn .rp-alert-icon { color: var(--color-warn); }

.rp-alert-msg { font-size: 11px; line-height: 1.4; }
.danger .rp-alert-msg { color: #791F1F; }
.warn .rp-alert-msg { color: var(--accent-dark); }

.rp-alert-time { font-size: 10px; margin-top: 2px; }
.danger .rp-alert-time { color: var(--color-danger); }
.warn .rp-alert-time { color: var(--color-warn); }

.rp-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.rp-btn {
    flex: 1;
    min-width: 80px;
    padding: 5px 8px;
    font-size: 11px;
    border: 0.5px solid var(--border-mid);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: background 0.12s;
}

.rp-btn:hover { background: var(--surface-secondary); color: var(--text-primary); }
.rp-btn.danger { border-color: var(--color-danger-border); color: var(--color-danger); background: var(--color-danger-bg); }
.rp-btn.danger:hover { background: #F7C1C1; }


/* ============================================================
   HOME PAGE
   ============================================================ */
.home-wrap {
    flex: 1;
    overflow-y: auto;
    background: var(--surface-secondary);
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.home-greeting { display: flex; align-items: flex-end; justify-content: space-between; }
.home-greeting-text { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.home-greeting-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

.home-date-badge {
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--surface);
    border: 0.5px solid var(--border);
    padding: 4px 10px;
    border-radius: var(--radius-md);
}

/* CROSS-MODULE KPI BAR */
.home-kpi-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.home-kpi {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.home-kpi-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.home-kpi-val { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.home-kpi-module { font-size: 9px; color: var(--text-tertiary); margin-top: 3px; }
.home-kpi-module span { color: var(--accent); font-weight: 500; }

/* MODULE GRID */
.module-grid-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 8px;
}

.module-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.module-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.module-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.module-card-top { display: flex; align-items: flex-start; justify-content: space-between; }

.module-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.module-icon svg { width: 17px; height: 17px; }

.module-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-top: 3px;
}

.dot-ok { background: var(--color-success); }
.dot-warn { background: var(--accent-mid); }
.dot-muted { background: var(--gray-300); }

.module-card-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.module-card-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.4; }

.module-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 0.5px solid var(--border);
}

.module-card-stat { font-size: 10px; color: var(--text-tertiary); }
.module-card-stat strong { font-weight: 600; color: var(--text-primary); }

.module-card-arrow { color: var(--text-tertiary); font-size: 13px; }
.module-card:hover .module-card-arrow { color: var(--accent); }

/* BOTTOM ROW — activity + quick access */
.home-bottom { display: grid; grid-template-columns: 1fr 280px; gap: 10px; }

.activity-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.activity-header {
    padding: 10px 14px;
    border-bottom: 0.5px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 0.5px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-top: 3px;
    flex-shrink: 0;
}

.activity-text { font-size: 11px; color: var(--text-primary); line-height: 1.4; flex: 1; }
.activity-module { font-size: 10px; color: var(--accent); font-weight: 500; }
.activity-time { font-size: 10px; color: var(--text-tertiary); white-space: nowrap; }

.quick-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.quick-header {
    padding: 10px 14px;
    border-bottom: 0.5px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.quick-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 0.5px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
    font-size: 12px;
    color: var(--text-secondary);
}

.quick-item:last-child { border-bottom: none; }
.quick-item:hover { background: var(--accent-light); color: var(--accent-dark); }
.quick-item svg { width: 13px; height: 13px; color: var(--text-tertiary); flex-shrink: 0; }
.quick-item:hover svg { color: var(--accent); }

/* ============================================================
   DARK MODE OVERRIDES
   Triggered by theme.js adding 'dark-mode' class to <html>
   Mirrors the pattern in your existing theme.css
   ============================================================ */

html.dark-mode {

    /* ── Our own design tokens ── */
    --surface:           #1E293B;
    --surface-secondary: #0F172A;
    --surface-tertiary:  #0A1220;
    --border:            rgba(255,255,255,0.08);
    --border-mid:        rgba(255,255,255,0.14);
    --text-primary:      #F1F5F9;
    --text-secondary:    #94A3B8;
    --text-tertiary:     #64748B;
    --gray-900: #F1F5F9;
    --gray-800: #CBD5E1;
    --gray-600: #94A3B8;
    --gray-400: #64748B;
    --gray-200: #334155;
    --gray-100: #1E293B;
    --gray-50:  #0F172A;
    --color-danger:       #F87171;
    --color-danger-bg:    rgba(248,113,113,0.12);
    --color-danger-border:rgba(248,113,113,0.25);
    --color-warn:         #FBB840;
    --color-warn-bg:      rgba(251,184,64,0.12);
    --color-success:      #4ADE80;
    --color-success-bg:   rgba(74,222,128,0.12);
    --color-info:         #60A5FA;
    --color-info-bg:      rgba(96,165,250,0.12);
    --accent:          #EF9F27;
    --accent-light:    rgba(239,159,39,0.15);
    --accent-mid:      #F5B942;
    --accent-hover:    #D4891A;
    --accent-dark:     #FCD88A;
    --accent-bg:       rgba(239,159,39,0.12);

    /* ── Shared --sh-* tokens used by theme.css and site.css ──
       These must also be overridden here so MudBlazor components
       and any legacy styles that reference --sh-* go dark too.   */
    --sh-bg:              #0F172A;
    --sh-bg-secondary:    #1E293B;
    --sh-card:            #1E293B;
    --sh-card-hover:      #334155;
    --sh-text:            #F1F5F9;
    --sh-text-secondary:  #94A3B8;
    --sh-text-muted:      #64748B;
    --sh-border:          #334155;
    --sh-border-light:    #475569;
    --sh-input-bg:        #1E293B;
    --sh-table-stripe:    #1E293B;
    --sh-shadow:          0 4px 6px -1px rgba(0,0,0,0.4);
    --sh-navbar:          #080E1A;
    --sh-navbar-text:     #F1F5F9;
    --sh-navbar-border:   #1E293B;

    /* SafeHouse inline-style aliases (from _Layout.cshtml <style> block) */
    --safehouse-surface:      #1E293B;
    --safehouse-background:   #0F172A;
    --safehouse-text-primary: #F1F5F9;
    --safehouse-text-secondary:#94A3B8;
    --safehouse-border:       #334155;
    --sh-surface:             #1E293B;
    --sh-background:          #0F172A;
    --sh-text-primary:        #F1F5F9;
    --sh-text-secondary:      #94A3B8;
}

/* ── Force body + app backgrounds dark ──
   theme.css uses !important on .mud-main-content so we match it  */
html.dark-mode body,
html.dark-mode .app-shell,
html.dark-mode .app-body,
html.dark-mode .home-wrap,
html.dark-mode .mud-main-content,
html.dark-mode main,
html.dark-mode .main-content {
    background-color: #0F172A !important;
    color: #F1F5F9 !important;
}

/* ── Global bar stays dark in both modes (intentional brand element) ── */
html.dark-mode .global-bar {
    background: #080E1A;
}

/* ── Module sidebar ── */
html.dark-mode .module-sidebar {
    background: #1E293B;
    border-right-color: rgba(255,255,255,0.06);
}

html.dark-mode .ms-header {
    border-bottom-color: rgba(255,255,255,0.06);
}

html.dark-mode .ms-item:hover {
    background: rgba(255,255,255,0.05);
}

html.dark-mode .ms-item.active {
    background: rgba(239,159,39,0.15);
    color: #FCD88A;
}

html.dark-mode .ms-item.active::before {
    background: #EF9F27;
}

html.dark-mode .ms-footer {
    border-top-color: rgba(255,255,255,0.06);
}

html.dark-mode .ms-user-avatar {
    background: rgba(239,159,39,0.15);
    color: #FCD88A;
}

/* ── Module topbar ── */
html.dark-mode .module-topbar {
    background: #1E293B;
    border-bottom-color: rgba(255,255,255,0.06);
}

html.dark-mode .filter-select {
    background: #0F172A;
    border-color: rgba(255,255,255,0.12);
    color: #94A3B8;
}

html.dark-mode .btn {
    background: #1E293B;
    border-color: rgba(255,255,255,0.12);
    color: #94A3B8;
}

html.dark-mode .btn:hover {
    background: #334155;
    color: #F1F5F9;
}

html.dark-mode .btn-primary {
    background: #B86A0F;
    border-color: #B86A0F;
    color: #fff;
}

html.dark-mode .btn-primary:hover {
    background: #A05C0A;
}

/* ── KPI cards ── */
html.dark-mode .kpi-card {
    background: #1E293B;
    border-color: rgba(255,255,255,0.07);
}

html.dark-mode .kpi-card.accent-left-warn {
    border-left-color: #FBB840;
}

html.dark-mode .kpi-card.accent-left-danger {
    border-left-color: #F87171;
}

/* ── Data table ── */
html.dark-mode .data-table-wrap {
    background: #1E293B;
    border-color: rgba(255,255,255,0.07);
}

html.dark-mode .data-table th {
    background: #0F172A;
    border-bottom-color: rgba(255,255,255,0.07);
    color: #64748B;
}

html.dark-mode .data-table td {
    border-bottom-color: rgba(255,255,255,0.05);
    color: #CBD5E1;
}

html.dark-mode .data-table tbody tr:hover td {
    background: rgba(255,255,255,0.04);
}

html.dark-mode .data-table tbody tr.row-selected td {
    background: rgba(239,159,39,0.12);
}

/* ── Section link ── */
html.dark-mode .section-link {
    color: #EF9F27;
}

/* ── Mini chart cards ── */
html.dark-mode .mini-chart-card {
    background: #1E293B;
    border-color: rgba(255,255,255,0.07);
}

html.dark-mode .chart-row .mini-chart-card polygon {
    opacity: 0.4;
}

/* ── Right panel ── */
html.dark-mode .right-panel {
    background: #1E293B;
    border-left-color: rgba(255,255,255,0.06);
}

html.dark-mode .rp-header {
    border-bottom-color: rgba(255,255,255,0.06);
}

html.dark-mode .rp-tabs {
    border-bottom-color: rgba(255,255,255,0.06);
}

html.dark-mode .rp-tab {
    color: #64748B;
}

html.dark-mode .rp-tab:hover { color: #94A3B8; }

html.dark-mode .rp-tab.active {
    color: #EF9F27;
    border-bottom-color: #EF9F27;
}

html.dark-mode .rp-section-title {
    border-bottom-color: rgba(255,255,255,0.06);
    color: #64748B;
}

html.dark-mode .rp-key { color: #64748B; }
html.dark-mode .rp-val { color: #CBD5E1; }
html.dark-mode .rp-val.ok    { color: #4ADE80; }
html.dark-mode .rp-val.warn  { color: #FBB840; }
html.dark-mode .rp-val.danger{ color: #F87171; }

html.dark-mode .rp-mini-kpi {
    background: #0F172A;
}

html.dark-mode .rp-gauge {
    background: #0F172A;
}

html.dark-mode .rp-alert-item.danger {
    background: rgba(248,113,113,0.10);
}

html.dark-mode .rp-alert-item.warn {
    background: rgba(251,184,64,0.10);
}

html.dark-mode .rp-btn {
    background: #1E293B;
    border-color: rgba(255,255,255,0.12);
    color: #94A3B8;
}

html.dark-mode .rp-btn:hover {
    background: #334155;
    color: #F1F5F9;
}

html.dark-mode .rp-btn.danger {
    background: rgba(248,113,113,0.10);
    border-color: rgba(248,113,113,0.25);
    color: #F87171;
}

html.dark-mode .rp-close-btn { color: #64748B; }
html.dark-mode .rp-close-btn:hover { color: #F1F5F9; }

/* ── Badges ── */
html.dark-mode .badge-online  { background: rgba(74,222,128,0.12);  color: #4ADE80; }
html.dark-mode .badge-offline { background: rgba(248,113,113,0.12); color: #F87171; }
html.dark-mode .badge-warn    { background: rgba(251,184,64,0.12);  color: #FBB840; }
html.dark-mode .badge-dot.bd-online  { background: #4ADE80; }
html.dark-mode .badge-dot.bd-offline { background: #F87171; }
html.dark-mode .badge-dot.bd-warn    { background: #FBB840; }

html.dark-mode .ms-badge {
    background: rgba(248,113,113,0.15);
    color: #F87171;
}

html.dark-mode .ms-badge.warn {
    background: rgba(251,184,64,0.15);
    color: #FBB840;
}

html.dark-mode .ms-module-tag {
    background: rgba(239,159,39,0.15);
    color: #FCD88A;
}

/* ── Home page ── */
html.dark-mode .home-wrap {
    background: #0F172A;
}

html.dark-mode .home-kpi {
    background: #1E293B;
    border-color: rgba(255,255,255,0.07);
}

html.dark-mode .home-kpi-label { color: #64748B; }
html.dark-mode .home-kpi-val   { color: #F1F5F9; }
html.dark-mode .home-kpi-module span { color: #EF9F27; }
html.dark-mode .home-date-badge {
    background: #1E293B;
    border-color: rgba(255,255,255,0.08);
    color: #64748B;
}

html.dark-mode .module-grid-label { color: #64748B; }

html.dark-mode .module-card {
    background: #1E293B;
    border-color: rgba(255,255,255,0.07);
}

html.dark-mode .module-card:hover {
    border-color: #EF9F27;
    background: rgba(239,159,39,0.08);
}

html.dark-mode .module-card-name  { color: #F1F5F9; }
html.dark-mode .module-card-desc  { color: #64748B; }
html.dark-mode .module-card-footer{ border-top-color: rgba(255,255,255,0.06); }
html.dark-mode .module-card-stat  { color: #64748B; }
html.dark-mode .module-card-stat strong { color: #CBD5E1; }
html.dark-mode .module-card-arrow { color: #64748B; }
html.dark-mode .module-card:hover .module-card-arrow { color: #EF9F27; }

html.dark-mode .activity-card,
html.dark-mode .quick-card {
    background: #1E293B;
    border-color: rgba(255,255,255,0.07);
}

html.dark-mode .activity-header,
html.dark-mode .quick-header {
    color: #64748B;
    border-bottom-color: rgba(255,255,255,0.06);
}

html.dark-mode .activity-item {
    border-bottom-color: rgba(255,255,255,0.05);
}

html.dark-mode .activity-text   { color: #CBD5E1; }
html.dark-mode .activity-time   { color: #475569; }

html.dark-mode .quick-item {
    border-bottom-color: rgba(255,255,255,0.05);
    color: #94A3B8;
}

html.dark-mode .quick-item:hover {
    background: rgba(239,159,39,0.08);
    color: #FCD88A;
}

html.dark-mode .quick-item svg { color: #475569; }
html.dark-mode .quick-item:hover svg { color: #EF9F27; }

html.dark-mode .home-greeting-text { color: #F1F5F9; }
html.dark-mode .home-greeting-sub  { color: #64748B; }

/* ── Signal bars in dark mode ── */
html.dark-mode .sig-b     { background: #334155; }
html.dark-mode .sig-b.on  { background: #EF9F27; }

/* ── Scrollbar in dark mode ── */
html.dark-mode ::-webkit-scrollbar-thumb { background: #334155; }
html:not(.dark-mode) .global-bar {
    background: var(--sh-secondary, #1e293b); /* keep dark bar in light mode - it's a design choice */
}
/* ── Shared Right-Panel utility classes (Energy, Finance, etc.) ── */
.rp-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 5px 0;
    border-bottom: 0.5px solid var(--border);
    font-size: 11px;
    gap: 8px;
}

.rp-key {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.rp-val {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

.rp-section-title {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-tertiary);
    margin: 12px 0 4px;
}

    .rp-section-title:first-child {
        margin-top: 4px;
    }

.rp-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

    .rp-form-group label {
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--text-secondary);
    }

    .rp-form-group input,
    .rp-form-group select,
    .rp-form-group textarea {
        width: 100%;
        padding: 6px 9px;
        font-size: 12px;
        border: 0.5px solid var(--border);
        border-radius: 5px;
        background: var(--surface-secondary);
        color: var(--text-primary);
        outline: none;
        box-sizing: border-box;
    }

        .rp-form-group input:focus,
        .rp-form-group select:focus,
        .rp-form-group textarea:focus {
            border-color: var(--accent);
        }

        .rp-form-group input:disabled,
        .rp-form-group select:disabled {
            opacity: .55;
            cursor: not-allowed;
        }

.rp-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 4px;
}

.rp-btn {
    width: 100%;
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 500;
    border: 0.5px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: block;
    transition: border-color .12s, background .12s;
}

    .rp-btn:hover {
        border-color: var(--accent);
        background: var(--accent-bg);
        color: var(--accent);
    }

.rp-btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

    .rp-btn-primary:hover {
        opacity: .88;
    }

.rp-msg {
    font-size: 11px;
    padding: 5px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

    .rp-msg.success {
        background: var(--color-success-bg, #d1fae5);
        color: var(--color-success, #065f46);
    }

    .rp-msg.error {
        background: #fee2e2;
        color: var(--color-danger, #b91c1c);
    }

.rp-mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 10px;
}

.rp-mini-kpi {
    background: var(--surface-secondary);
    border: 0.5px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}

.rp-mini-label {
    font-size: 9px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.rp-mini-val {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.rp-mini-unit {
    font-size: 9px;
    color: var(--text-tertiary);
}
.home-inline-search {
    flex: 0 0 220px;
    margin: 0 16px;
}

.home-inline-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.home-inline-search-icon {
    position: absolute;
    left: 9px;
    color: var(--text-tertiary);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.home-inline-search-input {
    width: 100%;
    padding: 6px 28px 6px 28px;
    background: var(--surface);
    border: 0.5px solid var(--border-mid);
    border-radius: var(--radius-md);
    font-size: 11px;
    color: var(--text-primary);
    outline: none;
    transition: border-color .15s, background .15s;
}

    .home-inline-search-input::placeholder {
        color: var(--text-tertiary);
    }

    .home-inline-search-input:focus {
        border-color: var(--accent);
        background: var(--surface);
    }

.home-inline-search-clear {
    position: absolute;
    right: 7px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    display: flex;
    align-items: center;
}

    .home-inline-search-clear:hover {
        color: var(--text-primary);
    }

/* ── Tab Bar ── */
.home-tab-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.home-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    border: 0.5px solid var(--border-mid);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    position: relative;
}

    .home-tab:hover {
        border-color: var(--accent);
        color: var(--accent);
        background: rgba(239,159,39,.05);
    }

.home-tab--active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(239,159,39,.08);
}

.home-tab-search-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

/* ── Tab Content Container ── */
.home-tab-content {
    min-height: 200px;
}

.home-tab-hidden {
    display: none;
}

/* ── Shared Tab Loading Spinner ── */
.htab-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 48px 0;
    color: var(--text-tertiary);
    font-size: 11px;
}

    .htab-loading .spinner {
        width: 24px;
        height: 24px;
        border: 2px solid var(--border-mid);
        border-top-color: var(--accent);
        border-radius: 50%;
        animation: spin .7s linear infinite;
    }

/* ── Dark mode additions ── */
html.dark-mode .home-inline-search-input {
    background: #1E293B;
    border-color: rgba(255,255,255,.1);
    color: #F1F5F9;
}

    html.dark-mode .home-inline-search-input:focus {
        border-color: var(--accent);
        background: #1E293B;
    }

html.dark-mode .home-tab {
    border-color: rgba(255,255,255,.1);
    color: #94A3B8;
}

    html.dark-mode .home-tab:hover,
    html.dark-mode .home-tab--active {
        border-color: #EF9F27;
        color: #EF9F27;
        background: rgba(239,159,39,.08);
    }