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

:root {
    --bg-body: #0f172a;
    --bg-sidebar: #020617;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-heading: #ffffff;
    --text-muted: #64748b;
    --text-bright: #f8fafc;
    --bg-card-solid: #1e293b;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.2);
    --border: rgba(255, 255, 255, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-xl: 20px;
    --status-green: #10b981;
    --status-yellow: #f59e0b;
    --status-red: #ef4444;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

body.light-theme {
    --bg-body: #f1f5f9;
    --bg-main: #f0f2f7;
    --bg-sidebar: #ffffff;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-solid: #ffffff;
    --text-primary: #334155;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-heading: #0f172a;
    --text-main: #334155;
    --text-bright: #0f172a;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-glow: rgba(79, 70, 229, 0.1);
    --border: rgba(0, 0, 0, 0.08);
    --border-subtle: rgba(0, 0, 0, 0.06);
    --status-green: #059669;
    --status-green-bg: rgba(5, 150, 105, 0.1);
    --status-yellow: #d97706;
    --status-yellow-bg: rgba(217, 119, 6, 0.1);
    --status-red: #dc2626;
    --status-red-bg: rgba(220, 38, 38, 0.08);
    --status-critical: #b91c1c;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', system-ui, -apple-system, sans-serif; }
body { background: var(--bg-body); color: var(--text-primary); height: 100vh; overflow: hidden; display: flex; }

.app-container { 
    display: flex; 
    width: 100%; 
    height: 100vh; 
    overflow: hidden; 
}

/* Mobile body override */
@media (max-width: 768px) {
    body {
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
    }
    .app-container {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        flex-direction: column;
    }
}

.sidebar { 
    width: 260px; 
    min-width: 260px;
    background: var(--bg-sidebar); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    box-shadow: 2px 0 12px rgba(0,0,0,0.02);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
}

.brand { 
    padding: 32px 24px; 
    display: flex; 
    align-items: center; 
    gap: 16px; 
}

.brand-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.brand h1 { 
    font-size: 1.5rem; 
    font-weight: 800; 
    color: var(--text-heading); 
    letter-spacing: -0.5px; 
    margin: 0;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: -2px;
}

.nav-menu { padding: 12px; flex: 1; }
.nav-item { 
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm);
    color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; transition: all 0.2s; cursor: pointer; margin-bottom: 4px;
}
.nav-item i, .nav-item svg { 
    width: 18px; 
    height: 18px; 
    stroke-width: 2px;
}

.nav-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }

.main-content { 
    flex: 1; display: flex; flex-direction: column; overflow: hidden; 
    background: var(--bg-body); min-width: 0;
}

.topbar {
    min-height: 72px; height: auto; padding: 12px 40px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-sidebar); backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 500; position: sticky; top: 0;
}

.topbar-inner {
    width: 100%; max-width: 1400px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 16px;
}

.topbar h2 { font-size: 1.3rem; font-weight: 600; color: var(--text-heading); }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-select, .filter-input {
    background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-primary); padding: 6px 12px; border-radius: var(--radius-sm);
    font-size: 0.78rem; font-family: 'Inter', sans-serif; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s; cursor: pointer;
}
.filter-select:focus, .filter-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.filter-select option { background: var(--bg-card-solid); }

/* Unified Premium Select Wrapper */
.filter-select-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: 'Inter', sans-serif;
    height: 32px;
}

.filter-select-wrapper:hover {
    border-color: var(--accent);
}

.filter-select-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-select-wrapper svg, .filter-select-wrapper i {
    width: 13px;
    height: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.filter-select-clean {
    background: transparent !important;
    border: none !important;
    color: var(--text-primary) !important;
    font-size: 0.78rem !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 600 !important;
    outline: none !important;
    cursor: pointer !important;
    padding: 0 16px 0 0 !important;
    margin: 0 !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right center !important;
    background-size: 11px !important;
}

body.light-theme .filter-select-clean {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") !important;
}

.filter-select-clean option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.filter-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.78rem;
    white-space: nowrap;
    margin-right: 2px;
}

/* Custom Checkbox Dropdown (MRQ Checklist Style) */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 170px;
    justify-content: space-between;
    height: 32px;
}

.dropdown-trigger:hover {
    border-color: var(--accent);
}

.dropdown-trigger:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.dropdown-trigger i, .dropdown-trigger svg {
    width: 13px;
    height: 13px;
}

.dropdown-trigger .chevron-icon {
    transition: transform 0.25s ease;
    opacity: 0.8;
}

.custom-dropdown.active .dropdown-trigger .chevron-icon {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 1000;
    width: 280px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.custom-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-items {
    padding: 12px;
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Custom Checkbox Checklist Item */
.dropdown-item-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    user-select: none;
}

.dropdown-item-label:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.dropdown-item-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* MRQ Square checkbox style */
.checkbox-box {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
    background: var(--bg-body);
    flex-shrink: 0;
}

.dropdown-item-label:hover .checkbox-box {
    border-color: var(--accent);
}

.dropdown-item-label input[type="checkbox"]:checked ~ .checkbox-box {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
}

.checkbox-box::after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.dropdown-item-label input[type="checkbox"]:checked ~ .checkbox-box::after {
    display: block;
}

.dropdown-item-label input[type="checkbox"]:checked ~ .checkbox-text {
    color: var(--text-primary);
    font-weight: 600;
}

/* Dropdown Footer inside Menu */
.dropdown-footer {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border);
    background: rgba(16, 23, 42, 0.1);
}

body.light-theme .dropdown-footer {
    background: rgba(0, 0, 0, 0.02);
}

.apply-role-menu-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #ffffff;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.apply-role-menu-btn:hover {
    background: var(--accent-hover, #4f46e5);
    border-color: var(--accent-hover, #4f46e5);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.apply-role-menu-btn:active {
    transform: scale(0.98);
}

.scroll-container { 
    flex: 1; overflow-y: auto; padding: 20px; 
    scroll-behavior: smooth; position: relative; z-index: 1;
    height: 0; min-height: 0;
}

@media (max-width: 768px) {
    .scroll-container { height: auto; min-height: 60vh; overflow-y: visible; }
}


.scroll-container::-webkit-scrollbar { width: 6px; }
.scroll-container::-webkit-scrollbar-track { background: transparent; }
.scroll-container::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 3px; }

/* ── Page Sections ── */
.page-section {
    display: none;
    max-width: 1400px; margin: 0 auto; width: 100%;
    animation: fadeInUp 0.4s ease-out;
}

.page-section.active {
    display: block;
}

.section-header {
    margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-size: 1.3rem; color: var(--text-heading); margin-bottom: 0;
    font-weight: 700; letter-spacing: 0.5px;
}

/* ── Section Titles ── */
.section-title {
    font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 16px;
    text-transform: uppercase; letter-spacing: 2px; font-weight: 600;
    display: flex; align-items: center; gap: 12px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(to right, var(--border), transparent); }

/* ── UI Components ── */
.dashboard-section { margin-bottom: 20px; }
.section-header h2 { font-size: 1.3rem; font-weight: 700; color: var(--text-heading); margin-bottom: 16px; letter-spacing: -0.5px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi-card { 
    background: var(--bg-surface); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius-md);
    transition: transform 0.2s, box-shadow 0.2s; position: relative;
    box-shadow: var(--shadow-sm);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }

/* Accent Borders for Risk */
.kpi-card.risk-high { border-left: 4px solid var(--status-red); }
.kpi-card.risk-medium { border-left: 4px solid var(--status-yellow); }
.kpi-card.risk-low { border-left: 4px solid var(--status-green); }

.kpi-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.kpi-header span { font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-header i, .kpi-header svg { width: 20px; height: 20px; color: var(--accent); opacity: 0.8; }
.kpi-value { font-size: 1.4rem; font-weight: 700; color: var(--text-heading); margin-bottom: 4px; }
.kpi-status { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; }

.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; border: 1px solid transparent; }
.badge-red { background: rgba(239, 68, 68, 0.1); color: var(--status-red); border-color: rgba(239, 68, 68, 0.2); }
.badge-yellow { background: rgba(245, 158, 11, 0.1); color: var(--status-yellow); border-color: rgba(245, 158, 11, 0.2); }
.badge-green { background: rgba(16, 185, 129, 0.1); color: var(--status-green); border-color: rgba(16, 185, 129, 0.2); }
.badge-critical { background: var(--status-red); color: white; }

/* ── Trust Index Special ── */
.trust-index-card { 
    background: radial-gradient(circle at top right, var(--accent-glow), transparent), var(--bg-surface);
    text-align: center; padding: 16px; border: 1px solid var(--border);
}
.trust-ring { 
    width: 110px; height: 110px; border-radius: 50%; margin: 0 auto 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 8px solid var(--border); position: relative;
    background: radial-gradient(circle, var(--accent-glow), transparent);
}
.trust-ring::after {
    content: ''; position: absolute; inset: -8px; border-radius: 50%;
    border: 8px solid var(--accent); 
    border-bottom-color: transparent; border-left-color: transparent;
    transform: rotate(var(--rotation, -45deg));
    transition: transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

/* ── Horizontal Lifecycle Stepper ── */
.stepper-container { 
    display: flex; align-items: center; justify-content: space-between; 
    padding: 16px 20px; background: var(--bg-surface); border-radius: var(--radius-md); border: 1px solid var(--border);
    margin-bottom: 20px; position: relative;
    overflow-x: auto;
}
.stepper-item { 
    flex: 1; min-width: 80px; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 2;
}
.stepper-node { 
    width: 40px; height: 40px; border-radius: 50%; background: var(--bg-body); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center; margin-bottom: 12px; transition: all 0.3s;
}
.stepper-node i, .stepper-node svg { width: 20px; height: 20px; color: var(--text-secondary); transition: color 0.3s; }
.stepper-label { font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.stepper-score { font-size: 1.1rem; font-weight: 800; color: var(--text-heading); margin-top: 4px; }

.stepper-item.risk-high .stepper-node { border-color: var(--status-red); background: rgba(239, 68, 68, 0.15); }
.stepper-item.risk-high .stepper-node svg { color: var(--status-red); }
.stepper-item.risk-medium .stepper-node { border-color: var(--status-yellow); background: rgba(245, 158, 11, 0.15); }
.stepper-item.risk-medium .stepper-node svg { color: var(--status-yellow); }
.stepper-item.risk-low .stepper-node { border-color: var(--status-green); background: rgba(16, 185, 129, 0.15); }
.stepper-item.risk-low .stepper-node svg { color: var(--status-green); }

.stepper-line { 
    position: absolute; top: 56px; left: 10%; right: 10%; height: 2px; background: var(--border); z-index: 1;
}

/* ── Charts & Tables ── */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 16px; margin-bottom: 20px; }
.chart-card { 
    background: var(--bg-surface); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-md); 
    padding: 12px; 
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; 
    box-shadow: var(--shadow-sm); 
    cursor: default;
}
.chart-card.interactive-chart-card:hover,
.chart-card[onclick]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.3);
}
.chart-card canvas {
    cursor: pointer;
}
.chart-card h4 { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.chart-card .chart-wrap { height: 220px; }
.pie-chart-container {
    height: 220px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; overflow-x: auto; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px; font-size: 0.75rem; text-transform: uppercase; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
td { padding: 12px; font-size: 0.9rem; color: var(--text-primary); border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--bg-surface-hover); }

/* ── Alerts ── */
.alerts-container { display: flex; flex-direction: column; gap: 12px; }
.alert-item { 
    display: flex; gap: 16px; padding: 16px; border-radius: var(--radius-sm); 
    background: var(--bg-surface-hover); border: 1px solid var(--border);
    transition: transform 0.2s;
}
.alert-item:hover { transform: translateX(4px); }
.alert-item.critical { border-left: 4px solid var(--status-red); }
.alert-item.medium { border-left: 4px solid var(--status-yellow); }
.alert-item i, .alert-item svg { width: 20px; color: var(--accent); }
.alert-details { display: none; }
.alert-item.expanded .alert-details { display: block; }
.alert-item.expanded i[data-lucide="chevron-down"] { transform: rotate(180deg); }
.alert-title { font-weight: 600; font-size: 0.9rem; color: var(--text-heading); margin-bottom: 4px; }
.alert-meta { font-size: 0.8rem; color: var(--text-secondary); }

/* ── Interactive Components ── */

.interactive-chart-card {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.interactive-chart-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.3);
}
.chart-click-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}
.interactive-chart-card:hover .chart-click-hint {
    color: var(--accent);
}

.chart-formula-toggle {
    transition: all 0.2s ease;
}
.chart-formula-toggle:hover {
    background: rgba(99, 102, 241, 0.1) !important;
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}


.tooltip-container { position: relative; display: inline-block; cursor: help; }
.tooltip-text {
    visibility: hidden; width: 220px; background-color: var(--bg-card);
    color: var(--text-main); text-align: center; border-radius: 6px;
    padding: 10px; position: absolute; z-index: 100; bottom: 125%; left: 50%;
    transform: translateX(-50%); opacity: 0; transition: opacity 0.3s;
    font-size: 0.75rem; border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

@media (max-width: 1024px) {
    .sidebar:not(.collapsed) { width: 80px; min-width: 80px; }
    .sidebar.collapsed { width: 60px !important; min-width: 60px !important; }
    .sidebar span, .logo span { display: none; }
}
.alert-item .alert-content { flex: 1; }
.alert-item .alert-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
.alert-item .alert-meta { font-size: 0.78rem; color: var(--text-muted); }

/* ── Modal ── */
/* ═══ ENHANCED SOC DRILL-DOWN MODAL STYLING ═══ */

/* Modal Backdrop with Modern Glass Blur */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6); /* Deep slate semi-transparent mask */
    backdrop-filter: blur(8px); /* Soft background blur */
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Modal Content Container Card */
.modal-content {
    background-color: var(--bg-surface, #ffffff);
    color: var(--text-primary, #1e293b);
    width: 90%;
    max-width: 850px;
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 
                0 0 0 1px rgba(99, 102, 241, 0.1); /* Subtle glowing accent border */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

/* Modal Header styling */
.modal-header {
    padding: 20px 24px;
    background: var(--bg-surface-hover, #f8fafc);
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-heading, #0f172a);
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Custom Security Icon inside Header */
.modal-header h3::before {
    content: '🛡️';
    font-size: 1.2rem;
}

/* Modernized Circular Close Button */
.close-btn {
    background: transparent;
    border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    color: var(--text-secondary, #64748b);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--status-red, #ef4444);
    border-color: rgba(239, 68, 68, 0.2);
    transform: rotate(90deg);
}

/* Scrollable Modal Body */
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Clean, Balanced Table Layout inside Modal */
#modal-table-container {
    border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    border-radius: 10px;
    overflow-x: auto;
    background-color: var(--bg-surface, #ffffff);
}

#modal-table-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

#modal-table-container th {
    background-color: var(--bg-surface-hover, #f8fafc);
    color: var(--text-secondary, #475569);
    font-weight: 600;
    padding: 14px 16px;
    border-bottom: 2px solid var(--border, rgba(0, 0, 0, 0.08));
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

#modal-table-container td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.05));
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
}

/* Modern Row Hover Effects */
#modal-table-container tbody tr {
    transition: background-color 0.15s ease;
}

#modal-table-container tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.03) !important;
}

/* Custom Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background-color: var(--border, rgba(0, 0, 0, 0.15));
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary, #64748b);
}

/* Custom Scrollbar for Modal Table Container */
#modal-table-container::-webkit-scrollbar {
    height: 6px;
}

#modal-table-container::-webkit-scrollbar-track {
    background: transparent;
}

#modal-table-container::-webkit-scrollbar-thumb {
    background-color: var(--border, rgba(0, 0, 0, 0.15));
    border-radius: 10px;
}

#modal-table-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary, #64748b);
}

/* ── Animations ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.loading-shimmer {
    background: linear-gradient(90deg, transparent, rgba(99,102,241,0.08), transparent);
    background-size: 200% 100%; animation: shimmer 1.5s infinite;
}

/* ══════════════════════════════════════════════
   LIGHT THEME
   ══════════════════════════════════════════════ */

/* ── Light Theme Variable Overrides (Already defined in :root above) ── */
/* This section is now cleaner as it only needs specific element overrides that variables don't catch */
body.light-theme .sidebar { box-shadow: 2px 0 12px rgba(0,0,0,0.04); }
body.light-theme .sidebar::after { background: linear-gradient(to bottom, rgba(99,102,241,0.06), transparent 50%, rgba(99,102,241,0.06)); }
body.light-theme .topbar { background: rgba(255, 255, 255, 0.8); border-bottom: 1px solid rgba(0,0,0,0.05); }
body.light-theme .main-content::before { background: radial-gradient(circle, rgba(99,102,241,0.03), transparent 70%); }
body.light-theme .modal-overlay { background: rgba(0,0,0,0.4); }
body.light-theme .alert-item { background: #f8fafc; }
body.light-theme .toast-notification { background: #ffffff; border-color: rgba(0,0,0,0.1); box-shadow: 0 10px 30px rgba(0,0,0,0.1); }

/* ── Refresh Button ── */
.refresh-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: var(--radius-sm);
    background: var(--accent-glow); border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer; font-family: 'Inter', sans-serif;
    font-size: 0.78rem; font-weight: 600; transition: all 0.25s ease;
    height: 32px;
}
.refresh-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); border-color: var(--accent); }
.refresh-btn svg, .refresh-btn i { width: 13px; height: 13px; transition: transform 0.25s; }

/* ── Toast Notification ── */
.toast-notification {
    position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(80px);
    background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-primary); padding: 12px 24px; border-radius: var(--radius-md);
    font-size: 0.85rem; font-weight: 500; z-index: 200;
    box-shadow: var(--shadow-lg); backdrop-filter: blur(12px);
    display: flex; align-items: center; gap: 10px;
    opacity: 0; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); pointer-events: none;
}
.toast-notification.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-notification svg { width: 18px; height: 18px; color: var(--accent); }

/* Spinner Animation for Refresh and Loading states */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.loading-spin {
    animation: spin 1.2s linear infinite;
    display: inline-block;
}

/* ── Interactive Components ── */
.details-collapse {
    max-height: 0; overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
    background: rgba(16, 23, 42, 0.3); border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.details-collapse.show {
    max-height: 1000px;
    transition: max-height 1s ease-in-out;
    padding-top: 20px;
}

.view-details-btn {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-secondary); padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: 0.8rem; font-weight: 500; cursor: pointer;
    transition: all 0.2s; margin-top: 12px; width: fit-content;
}
.view-details-btn:hover { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }
.view-details-btn svg { width: 14px; height: 14px; transition: transform 0.3s; }
.view-details-btn.active svg { transform: rotate(180deg); }

.progress-container {
    width: 100%; height: 8px; background: rgba(255, 255, 255, 0.05);
    border-radius: 4px; overflow: hidden; margin-top: 12px;
}
.progress-bar { height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.progress-bar.green { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-bar.yellow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-bar.red { background: linear-gradient(90deg, #ef4444, #f87171); }

.tooltip-container { position: relative; display: inline-block; cursor: help; }
.tooltip-text {
    visibility: hidden; width: 220px; background-color: var(--bg-surface);
    color: var(--text-primary); text-align: center; border-radius: 6px;
    padding: 10px; position: absolute; z-index: 100; bottom: 125%; left: 50%;
    transform: translateX(-50%); opacity: 0; transition: opacity 0.3s;
    font-size: 0.75rem; border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    line-height: 1.4;
}
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

/* ── Responsive ── */
/* Base Styles for Mobile Elements */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 12px;
}
.mobile-menu-toggle:hover {
    background: var(--bg-surface-hover);
    border-color: var(--accent);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9998;
    transition: opacity 0.3s ease;
}
.sidebar-backdrop.active {
    display: block;
}

@media (max-width: 1200px) {
    .charts-grid { grid-template-columns: 1fr !important; }
    .alerts-container { grid-template-columns: 1fr !important; }
    .kpi-strip-container { grid-template-columns: repeat(3, 1fr) !important; }
}

@media (max-width: 992px) {
    .kpi-strip-container { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 768px) {
    /* Sidebar becomes a slide-out drawer */
    .sidebar {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 9999;
        width: 260px;
        min-width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--bg-sidebar);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    }
    .sidebar.mobile-active {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: none !important;
    }
    
    /* Main content fills full width */
    .main-content {
        width: 100%;
        overflow-x: hidden;
        overflow-y: visible;
    }
    
    /* Mobile hamburger button */
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Topbar row: hamburger + title + filters */
    .topbar { 
        padding: 12px 16px; 
        height: auto; 
        min-height: 64px; 
    }
    .topbar-inner {
        flex-wrap: nowrap;
        gap: 10px;
    }
    .topbar h2 {
        font-size: 1rem;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .filters {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    /* Scroll container padding */
    .scroll-container { padding: 14px 12px; }
    
    /* KPI strip wraps to 2 columns */
    .kpi-strip-container { grid-template-columns: repeat(2, 1fr) !important; }
    .kpi-grid { grid-template-columns: 1fr 1fr !important; }
    
    /* Cards and tables get horizontal scroll instead of overflow */
    .table-card { overflow-x: auto; }
    table { min-width: 500px; }
    .chart-card { padding: 10px; }
    
    /* Timeline mini-cards: 2 columns */
    .timeline-summary-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Intel drawer full-screen on mobile */
    .intel-drawer {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Modal full-width on mobile */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    /* Brand padding smaller on mobile slide drawer */
    .brand {
        padding: 20px 18px;
    }
    
    /* Page section padding */
    .page-section {
        padding: 0;
    }
}

@media (max-width: 576px) {
    /* Topbar stacks on very small screens */
    .topbar-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .topbar h2 {
        font-size: 1rem;
        text-align: left;
        margin: 0;
        padding-left: 44px; /* avoid hamburger overlap */
        min-height: 36px; /* align vertically with hamburger */
        display: flex;
        align-items: center;
    }
    .topbar-inner .mobile-menu-toggle {
        position: absolute;
        top: 14px;
        left: 14px;
    }
    .filters {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    .filter-select-wrapper {
        border-right: none !important;
        padding-right: 8px !important;
        margin-right: 0 !important;
        width: 100% !important;
    }
    .custom-dropdown, .dropdown-trigger {
        width: 100% !important;
    }
    .filters .refresh-btn {
        width: 100% !important;
        justify-content: center;
    }
    
    /* Single column everything */
    .kpi-grid { grid-template-columns: 1fr !important; }
    .kpi-strip-container { grid-template-columns: 1fr !important; }
    .timeline-summary-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Poisson bar stacks vertically */
    .poisson-stat-bar {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
    }
    .poisson-stat-divider {
        display: none;
    }
    .poisson-stat-item {
        padding: 6px 0;
        border-bottom: 1px solid var(--border);
    }
    .poisson-stat-item:last-child {
        border-bottom: none;
    }
    
    /* Data cleaning bottom control panel responsive stacking */
    .cleaning-controls-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }
    .cleaning-controls-bar div {
        width: 100%;
    }
    .cleaning-controls-bar div:first-child {
        flex-direction: column;
        display: flex;
        gap: 8px;
    }
    .cleaning-controls-bar button {
        width: 100% !important;
        justify-content: center;
    }
    
    /* Section padding */
    .scroll-container { padding: 10px; }
    
    /* Chart fonts smaller */
    .chart-card h4 { font-size: 0.78rem; }
    
    /* Stepper text smaller */
    .stepper-label { font-size: 0.62rem; letter-spacing: 0.5px; }
    .stepper-score { font-size: 0.9rem; }
    .stepper-node { width: 32px; height: 32px; }
    
    /* Table cells smaller text */
    td { font-size: 0.78rem; padding: 8px; }
    th { font-size: 0.68rem; padding: 8px; }
}

/* ── Calculations View ── */
.calc-block {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.calc-block h3 {
    font-size: 1.1rem;
    color: var(--text-heading);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.formula-code {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    padding: 16px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.8;
    white-space: pre-wrap;
}

body.light-theme .formula-code {
    background: #f8fafc;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 32px;
    right: -14px;
    width: 28px;
    height: 28px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 150;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.75rem;
    line-height: 1;
    user-select: none;
    outline: none;
}

.sidebar-toggle:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Collapsed Sidebar Styles */
.sidebar.collapsed {
    width: 60px !important;
    min-width: 60px !important;
}

.sidebar.collapsed .brand-text {
    display: none;
}

.sidebar.collapsed .brand {
    padding: 32px 0;
    justify-content: center;
}

.sidebar.collapsed .nav-label {
    display: none;
}

.sidebar.collapsed .nav-menu {
    padding: 12px 6px;
}

.sidebar.collapsed .nav-item {
    padding: 12px 0;
    justify-content: center;
    gap: 0;
    position: relative;
}

.sidebar.collapsed .nav-item::after {
    content: attr(title);
    position: absolute;
    left: 68px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 200;
    box-shadow: var(--shadow-md);
}

.sidebar.collapsed .nav-item:hover::after {
    opacity: 1;
}

.sidebar.collapsed .sidebar-footer {
    display: none;
}

/* ── Explainable Intelligence Side Drawer ── */
.intel-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 450px;
    max-width: 100%;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.intel-drawer.active {
    transform: translateX(0);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.intel-drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.intel-drawer-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-heading);
}

.intel-drawer-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    line-height: 1.5;
}

.drawer-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.drawer-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-secondary);
}

.drawer-formula-box {
    background: rgba(0, 0, 0, 0.25);
    border-left: 4px solid var(--accent);
    padding: 14px;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.4;
}

body.light-theme .drawer-formula-box {
    background: #f8fafc;
    border-color: var(--accent);
}

.drawer-section-content {
    font-size: 0.88rem;
    color: var(--text-primary);
}

/* ── Threat Matrix Grid Interactivity ── */
.matrix-cell {
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, filter 0.2s ease;
    user-select: none;
}
.matrix-cell:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 12px var(--accent-glow);
    filter: brightness(1.08);
}
.matrix-cell:active {
    transform: scale(0.98);
}




/* ── KPI Strip & Layout Fixes ── */
.kpi-strip-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.kpi-card-mini {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

#card-paper-finalization {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}



@media (max-width: 600px) {
    .kpi-strip-container {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ── Live Indicator Badge ── */
.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--status-red);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(239, 68, 68, 0.08);
    padding: 2px 7px;
    border-radius: 20px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.live-dot {
    width: 6px;
    height: 6px;
    background: var(--status-red);
    border-radius: 50%;
    animation: pulse 1.2s infinite;
    flex-shrink: 0;
}

/* ── Security Event Timeline ── */
.timeline-container {
    position: relative;
    padding-left: 20px;
}

.timeline-container::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent), transparent);
    border-radius: 1px;
}

.timeline-event {
    position: relative;
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.timeline-event:hover {
    transform: translateX(3px);
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -17px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-surface);
    box-shadow: 0 0 0 2px var(--accent);
    transition: all 0.2s;
    z-index: 1;
}

.timeline-event.sev-critical::before { background: var(--status-red); box-shadow: 0 0 0 2px var(--status-red), 0 0 8px rgba(239,68,68,0.4); }
.timeline-event.sev-high::before { background: var(--status-red); box-shadow: 0 0 0 2px var(--status-red); }
.timeline-event.sev-medium::before { background: var(--status-yellow); box-shadow: 0 0 0 2px var(--status-yellow); }
.timeline-event.sev-info::before { background: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

.timeline-event-body {
    background: var(--bg-surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-size: 0.78rem;
    line-height: 1.4;
    transition: all 0.15s;
}

.timeline-event:hover .timeline-event-body {
    border-color: var(--accent);
    background: rgba(99,102,241,0.04);
}

.timeline-event-time {
    font-size: 0.63rem;
    color: var(--text-muted);
    font-family: monospace;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-event-title {
    font-weight: 600;
    color: var(--text-heading);
    font-size: 0.8rem;
}

.timeline-event-desc {
    color: var(--text-secondary);
    margin-top: 2px;
    font-size: 0.72rem;
}


/* ── Enhanced Alert Feed ── */
.alert-feed-item {
    background: var(--bg-surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid var(--border);
}

.alert-feed-item:hover {
    border-color: var(--accent);
    transform: translateX(3px);
}

.alert-feed-item.sev-critical { border-left-color: var(--status-red); background: rgba(239,68,68,0.04); }
.alert-feed-item.sev-high { border-left-color: var(--status-red); }
.alert-feed-item.sev-medium { border-left-color: var(--status-yellow); }
.alert-feed-item.sev-low { border-left-color: var(--status-green); }
.alert-feed-item.sev-info { border-left-color: var(--accent); }

.alert-feed-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 3px;
}

.alert-feed-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-heading);
    flex: 1;
}

.alert-feed-badges {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-items: center;
}

.alert-feed-meta {
    font-size: 0.67rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.alert-feed-stage {
    font-size: 0.62rem;
    font-weight: 600;
    background: rgba(99,102,241,0.1);
    color: var(--accent);
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.alert-feed-details {
    display: none;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-size: 0.73rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.alert-feed-item.expanded .alert-feed-details {
    display: block;
}

/* Light theme adjustments for new components */
body.light-theme .timeline-event-body {
    background: #f8fafc;
}


body.light-theme .alert-feed-item {
    background: #f8fafc;
}

/* ── Data Cleaning Engine Styles ── */
#datasetStatusGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.dataset-tile-card {
    position: relative;
    overflow: hidden;
}

.dataset-tile-card.risk-high {
    border-left: 4px solid var(--status-red);
}

.dataset-tile-card.risk-low {
    border-left: 4px solid var(--status-green);
}

.tile-expansion-details {
    animation: fadeIn 0.25s ease-out;
}

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

.filter-log-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-log-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.filter-log-btn.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* Bottom Controls bar styling */
.cleaning-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    margin-top: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.btn-primary {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

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

.toggle-switch-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}



/* Force dark, high-contrast colors on text to resolve contrast violations */
.matrix-cell[style*="status-red"] div:last-child {
    color: #991b1b !important; /* Rich Dark Crimson over pale pink */
}

.matrix-cell[style*="status-yellow"] div:last-child {
    color: #92400e !important; /* Rich Dark Amber over pale yellow */
}

.matrix-cell[style*="status-green"] div:last-child {
    color: #065f46 !important; /* Rich Dark Emerald over pale green */
}



/* Modern, high-contrast count badge */
.matrix-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background-color: rgba(15, 23, 42, 0.85); /* Deep slate contrast backdrop */
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    line-height: 1;
    pointer-events: none; /* Prevents badge from blocking click events */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── Poisson Stat Bar ── */
.poisson-stat-bar {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.poisson-stat-item {
    flex: 1;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2px 8px;
}

.poisson-stat-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    line-height: 1.2;
    margin-bottom: 2px;
}

.poisson-stat-value {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.3;
}

.poisson-stat-divider {
    width: 1px;
    background: var(--border);
    align-self: stretch;
    margin: 2px 0;
}

/* ── Modern Premium Device Pill Select ── */
.device-select-pill {
    background: rgba(16, 185, 129, 0.08) !important;
    color: var(--status-green) !important;
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
    padding: 6px 28px 6px 12px !important;
    border-radius: 20px !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px;
    outline: none !important;
    cursor: pointer !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2310b981' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: calc(100% - 10px) center !important;
    background-size: 10px !important;
    display: inline-flex;
    align-items: center;
}

.device-select-pill:hover {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: var(--status-green) !important;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.15);
}

.device-select-pill:focus {
    border-color: var(--status-green) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.device-select-pill option {
    background: var(--bg-surface, #1e293b) !important;
    color: var(--text-primary, #f8fafc) !important;
    font-weight: 600;
    text-transform: none;
    padding: 8px;
}
