/* ==========================================================================
   TABLE OF CONTENTS
   1.  VARIABLES & RESET
   2.  NAVIGATION & MOBILE MENU (Base)
   3.  AUTH SCREEN
   4.  DASHBOARD LAYOUT (Sidebar + Main Base)
   7.  MODALS & FORMS
   12. RESPONSIVE BEHAVIOR & MEDIA QUERIES (Layout Shell)
   ========================================================================== */

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    /* Tool Colors */
    --fep-blue: #007bff; --fep-bg: #F0FDFA;
    --analytics-amber: #F59E0B; --analytics-bg: #FFFBEB;
    --simulator-green: #10B981; --simulator-bg: #ECFDF5;
    --diagnostics-purple: #8b5cf6; --diagnostics-bg: #f5f3ff;
    --amp-rose: #E11D48; --amp-bg: #FFF1F2;
    --locked-gray: #64748B;
    
    /* Brand & UI Colors */
    --bg: #F8FAFC;
    --panel: #ffffff;
    --edge: #E2E8F0;
    --edge-strong: #CBD5E1;
    --muted: #64748B;
    --text: #0F172A;
    --accent: #0F766E;        /* Teal 700 */
    --accent-light: #14B8A6;  /* Teal 500 */
    --accent-dark: #134E4A;   /* Teal 900 */
    
    --radius: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05);

    /* Missing Compat Vars */
    --bg-secondary: #ffffff;
    --text-main: #0F172A;
    --text-muted: #64748B;
    
    /* Typography Global */
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    
    --hover-bg: #F1F5F9; /* Light mode hover */
    
    /* Asset Table Compat */
    --bg-sub: #F8FAFC;
    --text-secondary: #64748B;
    
    color-scheme: light;
}

[data-theme="dark"] {
    /* Brand & UI Colors - Dark Mode (Slate Palette) */
    --bg: #0F172A;        /* Slate 900 */
    --panel: #1E293B;     /* Slate 800 */
    --edge: #334155;      /* Slate 700 */
    --edge-strong: #475569; /* Slate 600 */
    --muted: #94A3B8;     /* Slate 400 */
    --text: #F8FAFC;      /* Slate 50 */
    
    /* Adjust Accents for Dark Mode */
    --accent: #14B8A6;    /* Teal 500 (Brighter for dark bg) */
    --accent-light: #2DD4BF; /* Teal 400 */
    --accent-dark: #CCFBF1;  /* Teal 100 (Used for text on light bg, but maybe need check) */

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);

    /* Tool Colors - Dark Mode Adjustments */
    --fep-bg: #1e3a8a; /* Darker Blue highlight */
    --analytics-bg: #451a03; /* Darker Amber */
    --simulator-bg: #064e3b; /* Darker Green */
    --diagnostics-bg: #4c1d95; /* Darker Purple */
    --amp-bg: #881337; /* Darker Rose */
    
    --bg-secondary: #1E293B;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    
    --hover-bg: #334155; /* Dark mode hover (Slate 700) */
    
    --bg-sub: #0F172A; /* Slate 900 for sub-headers */
    --text-secondary: #94A3B8; /* Slate 400 for secondary text */

    color-scheme: dark;
}

/* Theme Toggle Switch */
.theme-toggle {
    position: fixed;
    bottom: 3rem;
    right: 3rem; /* Left of the sidebar toggle if present, or just top right */
    z-index: 2000;
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: 99px;
    padding: 0.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--muted);
    transition: color 0.3s;
}

.theme-toggle:hover svg {
    color: var(--text);
}

[data-theme="dark"] .theme-toggle {
    background: #334155;
    border-color: #475569;
}

[data-theme="dark"] .theme-toggle svg.moon {
    color: #F8FAFC;
    display: block;
}

[data-theme="dark"] .theme-toggle svg.sun {
    display: none;
}

[data-theme="light"] .theme-toggle svg.moon {
    display: none;
}


[data-theme="light"] .theme-toggle svg.sun {
    color: #F59E0B;
    display: block;
}

/* Global Helper Classes */
.mobile-only {
    display: none;
}

html, body { height: 100%; margin: 0; }
body {
    display: flex; flex-direction: column; min-height: 100vh;
    background-color: var(--bg); overflow-x: hidden;
    font-family: var(--font-body, sans-serif);
}
main { flex: 1 0 auto; display: flex; flex-direction: column; width: 100%; padding: 0; }
footer {
    flex-shrink: 0; margin-top: auto; padding: 4rem 0; 
    border-top: 1px solid var(--edge); text-align: center; 
    color: var(--muted); font-size: 1.4rem; background: var(--bg);
}

.close-modal-btn {
    font-size: 2rem;
    cursor: pointer;
    color: var(--muted);
    background: none;
    border: none;
    line-height: 1;
    padding: 0 5px;
}

.btn.primary {
    font-size: 1.5rem;
    padding: 1rem;
    /* border-radius: var(--radius); */
    /* width: 50%; */
}
#btn-add-asset {
    width: auto;
    text-align: center;
    font-size: 1.2rem;
}

/* =========================================
   2. NAVIGATION & MOBILE MENU (Base)
   ========================================= */
/* Toggle Button */
.nav-toggle {
    display: none; /* Hidden by default, shown in media queries */
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    z-index: 1001;
}
.nav-toggle span {
    display: block; width: 24px; height: 2px;
    background-color: var(--text); border-radius: 2px;
    transition: all 0.3s ease;
}

/* Mobile Overlay (Container) */
.nav-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 9999; visibility: hidden; transition: visibility 0.3s;
}
.nav-overlay.open { visibility: visible; }

/* Dark Backdrop */
.nav-overlay__backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.5); opacity: 0;
    transition: opacity 0.3s ease;
}
.nav-overlay.open .nav-overlay__backdrop { opacity: 1; }

/* The Drawer */
.nav-overlay__card {
    position: absolute; top: 0; right: 0; bottom: 0;
    max-height: 25vh; width: 280px; max-width: 80%;
    background: #fff; padding: 2rem;
    box-shadow: -5px 0 20px rgba(0,0,0,0.15);
    transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
}
.nav-overlay.open .nav-overlay__card { transform: translateX(0); }

.nav-overlay__header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2rem; border-bottom: 1px solid var(--edge); padding-bottom: 1rem;
}
.close-icon {
    position: absolute; top: 0; right: 0;
    background: none; border: none; font-size: 2rem; line-height: 1;
    color: var(--muted); cursor: pointer; padding: 0 5px;
}
.nav-menu { list-style: none; padding: 0; margin: 0; }
.nav-menu li { margin-bottom: 0.5rem; }
.nav-menu a {
    display: block; padding: 0.8rem 0;
    font-size: 1.2rem; color: var(--text);
    text-decoration: none; font-weight: 600;
}
.nav-menu a:hover { color: var(--accent); }

/* =========================================
   3. AUTH SCREEN
   ========================================= */
.auth-wrapper {
    flex: 1; width: 100%; display: flex; align-items: center;     
    justify-content: center; padding: 2rem;
    background: radial-gradient(circle at 50% 50%, #f8fafc 0%, #e2e8f0 100%);
}
.auth-card {
    background: var(--panel); width: 100%; max-width: 400px;
    padding: 4rem 3rem; border-radius: var(--radius-lg);
    border: 1px solid var(--edge); box-shadow: var(--shadow-lg);
}
.auth-logo-wrapper {position: absolute; top: 0; left: 0; padding: 1rem 2rem;}
.auth-header { text-align: center; margin-bottom: 2.4rem; }
.auth-header h2 { font-size: 2.2rem; color: var(--text); margin-bottom: 0.5rem; }
.auth-header p { font-size: 1.4rem; color: var(--muted); }
.lock-ring {
    background: #F1F5F9; color: var(--muted); width: 50px; height: 50px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.5rem;
}
.auth-form { display: flex; flex-direction: column; gap: 1.6rem; }
.is-hidden { display: none !important; }

.input {
  width: 100%; padding: 1.2rem 1.4rem; border-radius: var(--radius);
  border: 1px solid var(--edge); background: var(--panel); color: var(--text); font-size: 1.5rem;
}
.input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}
.input-row { display: flex; gap: 0.8rem; align-items: stretch; }
.input-action { border-radius: var(--radius); padding: 0 1.2rem; white-space: nowrap; }
.check-row { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-weight: 600; font-size: 1.4rem; }
.field-hint { margin-top: 0.6rem; font-size: 1.3rem; color: var(--muted); }

.info-banner {
  border: 1px solid rgba(20,184,166,0.35); background: rgba(20,184,166,0.08);
  color: var(--text); padding: 1.2rem 1.2rem; border-radius: var(--radius);
}
.banner-row { font-weight: 700; font-size: 1.4rem; }
.banner-actions { display: flex; gap: 1rem; margin-top: 1rem; }

.error-banner {
    background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B;
    padding: 1rem; border-radius: 8px; font-size: 1.3rem; text-align: center;
    margin-top: 1rem; font-weight: 600;
}
.auth-logo { margin-top: 0.6rem; opacity: 0.95; }
html.auth-pending body { visibility: hidden; }

.form-group label { display: block; font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 1rem 0 0.5rem; }
.form-group input {
    width: 100%; padding: 1.2rem; border: 1px solid var(--edge-strong); border-radius: 8px;
    font-family: inherit; font-size: 1.6rem; transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1); }
#member-list {
    margin-bottom: 0 !important;
    padding-left: 0 !important;
}
/* =========================================
   4. DASHBOARD LAYOUT (Sidebar + Main)
   ========================================= */
.full-width-container { min-width: 100%; padding: 0 2rem; height: 100%; }
.dashboard-wrapper { flex: 1; width: 100%; padding: 0; background: var(--panel); }
.dashboard-layout { display: flex; align-items: flex-start; height: 100%; }
.dashboard-wrapper .container { padding: 0; width: 100%; margin: auto; height: 100%;}

/* --- Sidebar Base --- */
#sidebar-container { width: 100%; padding: 0 1rem; position:sticky; top: 2rem; }
.dashboard-sidebar {
    flex-shrink: 0;
    background: var(--panel);
    padding: 0rem 1.5rem 1.5rem 1.5rem;
    position: sticky;
    top: 0;
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
    /* box-shadow: var(--shadow-sm); */
    transition: width 0.3s ease, padding 0.3s ease;
    z-index: 90;
    scrollbar-width: thin;
}

/* Sidebar Toggle Button (Desktop) */
.sidebar-collapse-toggle {
    position: sticky; top: 0rem; left: 0rem;
    width: 100%; height: 50px;
    background: var(--bg-secondary); border: none; border-bottom: 1px solid var(--edge-strong);
    color: var(--muted); cursor: pointer;
    display: flex; align-items: center; justify-content: end;
    transition: all 0.2s; z-index: 100; margin-bottom: 1rem; padding: 0;
}
.sidebar-collapse-toggle:hover {
   color: var(--text);
}

.mobile-sidebar-chevron { display: none; }
.sidebar-welcome {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--edge);
    position: sticky;
    top: 4.5rem;
    margin-bottom: 6rem;
}
.avatar-circle {
    width: 40px; height: 40px; background: var(--accent); color: white;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.4rem;
}
.sidebar-welcome .name { text-transform: capitalize; }
.welcome-text { display: flex; flex-direction: column; }
.welcome-text .sub { font-size: 1.1rem; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.welcome-text .name { font-size: 1.4rem; font-weight: 700; color: var(--text); }

/* Sidebar Menu Items */
.sidebar-menu { display: flex; flex-direction: column; gap: 0.8rem; }
.menu-item {
    background: transparent; border: none; width: 100%; text-align: left;
    padding: 1.2rem 1.6rem; font-family: var(--font-body, sans-serif);
    font-size: 1.5rem; font-weight: 600; color: var(--muted);
    border-radius: 8px; cursor: pointer; display: flex; align-items: center;
    gap: 1.2rem; transition: all 0.2s;
}
.menu-item svg { opacity: 0.7; }
.menu-item:hover:not([disabled]) { background: var(--bg); color: var(--text); }
.menu-item.active { background: var(--fep-bg); color: var(--accent); font-weight: 700; }
.menu-item.active svg { opacity: 1; color: var(--accent); }
.menu-item.action-item { color: var(--accent); }
.menu-item.action-item svg { color: var(--accent); opacity: 1; }
.menu-item.action-item:hover { background: #F0FDFA; }

/* Logout Button Special Styling */
.menu-item.logout-item {
    color: #DC2626; /* Red text */
}
.menu-item.logout-item svg {
    color: #DC2626;
    opacity: 0.7;
}
.menu-item.logout-item:hover {
    background: #FEF2F2; /* Light red bg */
    color: #DC2626;
}
.menu-item.logout-item:hover svg {
    opacity: 1;
}

/* Sidebar Theme Toggle */
.theme-icon-container {
    display: flex; align-items: center; justify-content: center;
}
.dashboard-sidebar.collapsed .theme-label {
    display: none;
}
.dashboard-sidebar.collapsed .theme-icon-container {
    margin: 0 auto; /* Center icon when collapsed */
}
/* Ensure regular menu items also center their icons/content when collapsed if needed, 
   but specific fix for theme toggle ensures correct behavior */
.dashboard-sidebar.collapsed .menu-item {
    justify-content: center;
    padding-left: 0; padding-right: 0;
}
.dashboard-sidebar.collapsed .menu-item span:not(.theme-icon-container), 
.dashboard-sidebar.collapsed .menu-item svg + span { /* target text labels */
    display: none;
}

/* Sidebar Project List Dropdown */
.justify-between { justify-content: space-between; }
.chevron-icon { transition: transform 0.2s ease; opacity: 0.5; }
.projects-nav-section.open .chevron-icon { transform: rotate(180deg); }
.projects-list { overflow: hidden; transition: max-height 0.3s ease-out; padding-left: 1.5rem; margin-bottom: 0.5rem; scrollbar-width: none;}
.projects-list.collapsed { max-height: 0; }
.projects-list.expanded { max-height: 300px; overflow-y: auto; }
.project-link-item {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 0.8rem 1rem; font-size: 1.4rem;
    color: var(--muted); background: transparent; border: none; text-align: left;
    cursor: pointer; border-radius: 6px; margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-link-item:hover { color: var(--text); background: var(--hover-bg); }
.project-link-item.active { color: var(--accent); background: var(--fep-bg); font-weight: 700; }

/* Sidebar Tools List Dropdown */
.tools-nav-section.open .chevron-icon { transform: rotate(180deg); }
.tools-list { display: flex; flex-direction: column; overflow: hidden; transition: max-height 0.3s ease-out; padding-left: 1.5rem; margin-bottom: 0.5rem; scrollbar-width: none; }
.tools-list.collapsed { max-height: 0; }
.tools-list.expanded { max-height: 300px; overflow-y: auto; }


/* Sidebar Back Nav */
.sidebar-header-nav {
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--edge);
}
.back-nav-btn {
    background: var(--panel); border: 1px solid var(--edge); border-radius: 8px;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    color: var(--muted); cursor: pointer; transition: all 0.2s;
}
.back-nav-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--fep-bg); }
.sidebar-welcome.condensed { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.sidebar-welcome.condensed .avatar-circle.small { width: 32px; height: 32px; font-size: 1.1rem; }
.sidebar-welcome.condensed .name { font-size: 1.2rem; }
.sidebar-welcome.condensed .sub { font-size: 0.85rem; }

/* --- Main Content Panel --- */
.dashboard-main-panel {     
    flex: 1;
    min-width: 0;
    margin: 0 auto;
    background-color: var(--bg); 
    height:100%;
}
.dashboard-header {
    background: var(--panel);
    border-bottom: 1px solid var(--edge);
    padding: 2.5rem;
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
    position: sticky;
    top: 0;
    min-height: 120px;
    z-index:500;
}
.status-eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 1rem;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #16A34A;
}
.pulse-dot {
    width: 6px; height: 6px; background: #16A34A; border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
.header-left {
    display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
}
.header-left h1 { font-size: 2.4rem; line-height: 1; margin: 0; color: var(--text); }
.system-toolbar {
    display: flex; align-items: center; background: #F8FAFC;
    border: 1px solid var(--edge); border-radius: 8px; padding: 0.4rem; gap: 0.5rem;
}
.toolbar-item {
    display: flex; align-items: center; gap: 8px; padding: 0 1rem;
    font-size: 0.9rem; font-weight: 600; color: var(--muted); user-select: none;
}
.db-indicator { width: 6px; height: 6px; background: #16A34A; border-radius: 50%; }
.db-label { font-size: 1rem !important; }
.toolbar-divider { width: 1px; height: 24px; background: var(--edge); }
.toolbar-btn {
    background: var(--panel); border: 1px solid var(--edge); color: var(--muted);
    width: 36px; height: 36px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s ease;
}
.toolbar-btn:hover {
    border-color: var(--accent); color: var(--accent); background: var(--fep-bg);
    transform: translateY(-1px); box-shadow: var(--shadow-sm);
}

/* =========================================
   7. MODALS & FORMS
   ========================================= */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000;
    display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px);
    padding: 1rem;
}
.modal-card {
    background: var(--panel); width: 100%; max-width: 600px; 
    max-height: 90vh;
    display: flex; flex-direction: column;
    border-radius: 16px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: scaleIn 0.2s ease-out; position: relative;
    padding: 2rem;
    scrollbar-width:none;
}
/* Scrollable areas */
.modal-card form, .settings-scroll-area { overflow-y: auto; padding: 1rem; flex: 1; scrollbar-width:none; }
/* Fixed Header */
.modal-header { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 0 0 2rem !important; flex-shrink: 0;
}
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.close-modal { background: none; border: none; font-size: 2.4rem; cursor: pointer; color: var(--muted); line-height: 1; }
.close-modal:hover { color: var(--text); }
.settings-section-title {
    font-size: 1.2rem; color: var(--muted); text-transform: uppercase;
    font-weight: 700; letter-spacing: 0.05em; margin-bottom: 1.2rem;
}
#scenario-list {
    padding: 0;
    margin: 0;
}
/* Tool Cards in Modal */
.tool-select-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem; margin-top: 0.5rem;
}
.tool-select-card {
    display: flex; align-items: flex-start; gap: 12px; padding: 1rem;
    border: 1px solid var(--edge); border-radius: 10px; background: var(--panel);
    cursor: pointer; transition: all 0.2s ease; position: relative;
}
.tool-select-card:hover { border-color: var(--accent); background-color: #F0FDFA; }
.tool-select-card input[type="checkbox"] { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.tool-select-card:has(input:checked) { margin-bottom: 0; border-color: var(--accent); background-color: #F0FDFA; box-shadow: 0 0 0 1px var(--accent); }
.tool-select-icon {
    width: 32px; height: 32px; background: #F1F5F9; color: var(--muted);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.2s;
}
.tool-select-card:has(input:checked) .tool-select-icon { background: var(--accent); color: #fff; }
.tool-content strong { display: block; font-size: 1rem; color: var(--text); margin-bottom: 2px; font-weight: 600;}
.tool-content p { font-size: 0.85rem; color: var(--muted); line-height: 1.3; margin: 0; }

/* Team Roles */
/* Team Roles */
.role-badge { display: inline-block; font-size: 1rem; font-weight: 700; padding: 0.3rem 0.8rem; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.6rem; border: 1px solid transparent; width: fit-content; }
.role-badge.admin { background: #E0E7FF; color: #4338CA; border-color: #C7D2FE; } /* Indigo */
.role-badge.partner { background: #CCFBF1; color: #0F766E; border-color: #99F6E4; } /* Teal */
.role-badge.operator { background: #F1F5F9; color: #475569; border-color: #E2E8F0; } /* Slate */
.role-badge.owner { background: #FFFBEB; color: #D97706; border-color: #FCD34D; } /* Gold */
.role-badge.viewer { background: #F1F5F9; color: #64748B; border-color: #E2E8F0; } /* Gray */
.role-badge.editor { background: #E0F2FE; color: #0284C7; border-color: #BAE6FD; } /* Sky */
.role-badge.analyst { background: #F3E8FF; color: #7E22CE; border-color: #D8B4FE; } /* Purple */
.role-badge.field { background: #EFF6FF; color: #1D4ED8; border-color: #93C5FD; } /* Blue */

.remove-icon-btn { background: transparent; border: none; cursor: pointer; padding: 8px; border-radius: 6px; color: #CBD5E1; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; }
.remove-icon-btn:hover { background-color: #FEF2F2; color: #DC2626; }
.remove-icon-btn svg { width: 18px; height: 18px; display: block; }

.add-member-box { background: #F8FAFC; padding: 1.5rem; border-radius: 12px; border: 1px solid var(--edge); margin-top: 1rem; box-shadow: inset 0 1px 2px rgba(0,0,0,0.02); }
.add-member-label { display: block; font-size: 1.1rem; font-weight: 700; color: var(--muted); margin-bottom: 1.2rem; text-transform: uppercase; letter-spacing: 0.05em; }
.add-member-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }

.styled-input { width: 100%; padding: 1rem; border: 1px solid var(--edge-strong); border-radius: 8px; background: var(--panel); font-family: inherit; font-size: 1.4rem; color: var(--text); transition: all 0.2s ease; appearance: none; }
select.styled-input { appearance: auto; cursor: pointer; background-color: var(--panel); }
.styled-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1); }
.styled-input::placeholder { color: #94A3B8; }
.icon-btn { display: flex; align-items: center; justify-content: center; gap: 0.8rem; font-weight: 700; }

.pending-members-area { background: #F8FAFC; border: 1px solid var(--edge); border-radius: 8px; padding: 1rem; margin-top: 1rem; }
.pending-list { list-style: none; padding: 0; margin: 0; }
.pending-item { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem; background: #fff; border: 1px solid var(--edge); border-radius: 6px; margin-bottom: 0.5rem; }
.pending-info { display: flex; gap: 10px; align-items: center; }
.pending-email { font-weight: 600; color: var(--text); font-size: 0.95rem; }
.pending-role { font-size: 0.8rem; text-transform: uppercase; font-weight: 700; color: var(--muted); background: #F1F5F9; padding: 2px 6px; border-radius: 4px; }
/* Override width for Create Modal specifically to be wider */
#project-modal .modal-card,
#settings-modal .modal-card { max-width: 800px; }

/* Custom Alert Modal Styles (uiUtils.js) */
.alert-card {
    padding: 3rem 2.5rem; /* Explicit padding for content */
    text-align: center;
    max-width: 420px !important; /* Focused width */
    gap: 1.5rem;
    align-items: center; /* Center flex children horizontally */
}

.alert-icon-box {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 0.5rem auto;
    flex-shrink: 0;
}
.alert-icon-box svg { width: 32px; height: 32px; }
.alert-icon-box.info { background: #E0F2FE; color: #0284C7; }
.alert-icon-box.success { background: #DCFCE7; color: #16A34A; }
.alert-icon-box.warning { background: #FEF3C7; color: #D97706; }
.alert-icon-box.danger { background: #FEE2E2; color: #DC2626; }

#alert-title { 
    font-size: 1.4rem; 
    font-weight: 700; 
    margin: 0 0 0.8rem 0; 
    color: var(--text); 
}
#alert-message { 
    font-size: 1rem; 
    color: var(--muted); 
    margin: 0 0 2rem 0; 
    line-height: 1.6; 
}

.modal-actions {
    display: grid; 
    gap: 1.2rem; 
    width: 100%; 
    margin-top: 1rem;
}

/* Ensure global buttons in modal are consistent & Modern (RDA-like) */
.modal-card .btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.8rem 1.5rem; 
    border-radius: 8px; 
    font-weight: 600; 
    font-size: 1rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid transparent;
}

.modal-card .btn.primary {
    /* background: #0F172A; */
    color: #fff;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.modal-card .btn.primary:hover {
    /* background: #1E293B; */
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(0, 0, 0, 0.15);
}

.modal-card .btn.secondary, .modal-card .btn.ghost {
    background: var(--panel);
    border: 1px solid var(--edge);
    color: var(--text);
}
.modal-card .btn.secondary:hover, .modal-card .btn.ghost:hover {
    background: var(--hover-bg);
    border-color: var(--muted);
}
.modal-card .btn.danger {
    background: #DC2626;
    color: white;
    margin: 0 !important;
    width: fit-content !important;
}
.modal-card .btn.danger:hover {
    background: #B91C1C;
}
.modal-footer {
    display: flex;
    justify-content: space-between !important;
}


/* ==========================================================================
   12. RESPONSIVE BEHAVIOR & MEDIA QUERIES (Layout Shell)
   ========================================================================== */

/* --- A. Desktop Logic (Large Screens > 1024px & > 901px) --- */
@media (min-width: 901px) {
    /* .dashboard-main-panel {
        padding: 0 5rem 0 0;
    } */
    #view-products { 
        padding: 2rem;
        background-color: var(--bg);
        height: auto;
    }
    #view-hub {
        padding: 2rem;
        display: block;
    }
    #portfolio-summary-banner{
        display: flex;
        width: 100%;
        /* justify-content: center; */
    }
    #sidebar-container { width: auto; padding: auto; }
    .dashboard-sidebar { width: 260px; }
    
    .dashboard-sidebar.collapsed { width: 80px; padding: 0rem 1rem 2rem 1rem; }
    .dashboard-sidebar.collapsed .sidebar-collapse-toggle {justify-content:center; }
    .dashboard-sidebar.collapsed .sidebar-collapse-toggle svg {transform: rotate(180deg);}
    .dashboard-sidebar.collapsed .welcome-text { display: none; }
    .dashboard-sidebar.collapsed .sidebar-welcome { justify-content: center; border-bottom: none; padding-bottom: 2rem; top: 6rem; }
    .dashboard-sidebar.collapsed .avatar-circle { width: 32px; height: 32px; font-size: 1rem; }
    .dashboard-sidebar.collapsed .sidebar-menu .menu-item { font-size: 0 !important; justify-content: end; padding: 1.2rem 0.5rem; }
    .dashboard-sidebar.collapsed .menu-item svg { margin: 0; opacity: 1; width: 24px; height: 24px; }
    .dashboard-sidebar.collapsed .projects-nav-section .chevron-icon,
    .dashboard-sidebar.collapsed .projects-nav-section #projects-toggle-btn span { display: none !important; }
    .dashboard-sidebar.collapsed #projects-toggle-btn { justify-content: center; }
    .dashboard-sidebar.collapsed #projects-toggle-btn svg:first-child { display: block; margin: 0; }
    .dashboard-sidebar.collapsed .projects-list { display: none; }
    .dashboard-sidebar.collapsed .projects-nav-section { display: none !important; }
    .dashboard-sidebar.collapsed #project-context-nav div[style*="height: 1px"] { margin: 0.8rem 0.5rem !important; }

    /* Tools List Collapsed Overrides */
    .dashboard-sidebar.collapsed .tools-nav-section .chevron-icon,
    .dashboard-sidebar.collapsed .tools-nav-section #tools-toggle-btn span { display: none !important; }
    .dashboard-sidebar.collapsed #tools-toggle-btn { justify-content: center; }
    .dashboard-sidebar.collapsed #tools-toggle-btn svg:first-child { display: block; margin: 0; }
    .dashboard-sidebar.collapsed .tools-list { display: none; }
    .dashboard-sidebar.collapsed .tools-nav-section { display: none !important; }
}

/* --- B. Laptop/Tablet Logic (Max Width 1024px) --- */
@media (max-width: 1024px) {
    /* (Moved content to hub.css) */
}

/* --- C. Tablet/Mobile Logic (Max Width 900px) --- */
@media (max-width: 900px) {
    /* 1. Layout Flow */
    .dashboard-layout { flex-direction: column; gap: 0; }
    .dashboard-header { top: 8rem; }
    /* 2. Sticky Nav & Sidebar Offset */
    .site-nav { position: static; top: 0; z-index: 1000; }
    .dashboard-wrapper { padding-top: 0; }
    .dashboard-main-panel { width: 100%;}

    /* Sticky Sidebar Accordion */
    .dashboard-sidebar {
        width: 100%; position: sticky; top: 0; z-index: 900;
        height: auto; min-height: auto; max-height: 80px; /* Collapsed Height matches header size */
        overflow: hidden; transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
        padding: 0 1.5rem; margin: 0; cursor: pointer;
        background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(8px);
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-bottom-left-radius: var(--radius);
        border-bottom-right-radius: var(--radius);
    }
    /* #spa-tool-container {
        padding: 2rem;
    } */
    
    /* Mobile Sidebar Dark Mode Override */
    [data-theme="dark"] .dashboard-sidebar {
        background: rgba(15, 23, 42, 0.95) !important; /* Slate-900 with opacity */
        border-color: var(--edge);
    }
    
    /* Hide Desktop Toggle on Mobile */
    .sidebar-collapse-toggle { display: none !important; }
    
    /* Expanded State */
    .dashboard-sidebar.mobile-expanded {
        max-height: 85vh; padding: 1rem 1.5rem; overflow-y: auto;
        box-shadow: 0 20px 40px -5px rgba(0,0,0,0.2); border-color: var(--accent);
        background: #fff;
    }
    
    /* Sidebar Header */
    .sidebar-welcome {
        margin-bottom: 0; border-bottom: 1px solid transparent;
        padding: 1.2rem 0; transition: all 0.3s;
        display: flex; align-items: center; justify-content: space-between;
    }
    .dashboard-sidebar.mobile-expanded .sidebar-welcome { margin-bottom: 1rem; border-bottom-color: var(--edge); }
    
    /* Chevron Animation */
    .mobile-sidebar-chevron { display: block; color: var(--muted); transition: transform 0.3s ease; }
    .dashboard-sidebar.mobile-expanded .mobile-sidebar-chevron { transform: rotate(180deg); color: var(--accent); }
    
    /* Menu Fade In */
    .sidebar-menu { opacity: 0; transition: opacity 0.2s ease 0.1s; pointer-events: none; }
    .dashboard-sidebar.mobile-expanded .sidebar-menu { opacity: 1; pointer-events: auto; }

        /* Sidebar */
    .sidebar-welcome { height: 80px; padding: 0; z-index: 50; background-color: var(--panel); top: 0;}
    .dashboard-sidebar.collapsed .theme-icon-container { margin: 0;}
    #tool-sidebar { padding:0rem 1.5rem 1.5rem}
    .dashboard-sidebar.collapsed .menu-item { justify-content: start;}
    /* .dashboard-sidebar.mobile-expanded {
        padding:0rem 1.5rem 1.5rem
    } */
    /* Dashboard Header Hide */
    /* .dashboard-header { display: none; } */
}

/* --- D. Mobile Specific Logic (Max Width 768px) --- */
@media (max-width: 768px) {
    /* Hide Desktop Nav */
    .nav-links { display: none; }
    .nav-toggle { display: flex; }

    /* Container Padding */
    .full-width-container { padding: 1.5rem 1rem; }
    
    /* Content Widths */
    #sidebar-container, .dashboard-sidebar { top: 0;}
    .dashboard-main-panel { width: 100%; }
    /* Sidebar */
    .sidebar-welcome { height: 80px; padding: 0; z-index: 50; background-color: var(--panel); top: 0;}
    .dashboard-sidebar.collapsed .theme-icon-container { margin: 0;}
    #tool-sidebar { padding:0rem 1.5rem 1.5rem}
    .dashboard-sidebar.collapsed .menu-item { justify-content: start;}
    /* .dashboard-sidebar.mobile-expanded {
        padding:0rem 1.5rem 1.5rem
    } */

    /* Modals */
    .modal-card { width: 95%; padding: 1.5rem; max-height: 85vh; }
    
    .tool-select-grid {
        grid-template-columns: 1fr;
    }

    #portfolio-summary-banner {
      display: flex;
      flex-direction: column;
    }
}

/* ==========================================
   MOBILE RESPONSIVENESS: OOR PROJECT INDEX
   ========================================== */
@media (max-width: 768px) {
    #oor-recent-index-container table, 
    #oor-recent-index-container thead, 
    #oor-recent-index-container tbody, 
    #oor-recent-index-container th, 
    #oor-recent-index-container td, 
    #oor-recent-index-container tr { 
        display: block; 
    }

    #oor-recent-index-container thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    #oor-recent-index-container tr {
        border: 1px solid var(--edge);
        border-radius: 8px;
        margin-bottom: 1rem;
        padding: 0; /* Removed padding to allow full-width header */
        overflow: hidden; /* Encapsulate header corners */
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        background: var(--bg-card);
        cursor: pointer; 
    }
    
    #oor-recent-index-container tr:active {
        background-color: var(--bg-main);
    }
    
    #oor-recent-index-container td { 
        border: none;
        border-bottom: 1px dashed var(--edge); 
        position: relative;
        padding: 0.8rem 1rem; /* Added horizontal padding */
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }
    
    #oor-recent-index-container td:last-child {
        border-bottom: 0;
    }

    #oor-recent-index-container td::before { 
        content: attr(data-label);
        font-weight: 500;
        color: var(--text-secondary);
        font-size: 0.85rem;
    }
    
    /* Hide the action button cell as the whole card is clickable */
    #oor-recent-index-container td.cell-action {
        display: none; 
    }
    
    /* Project Name Styling (Header of the Card) */
    #oor-recent-index-container td[data-label="Project"] {
        display: block;
        text-align: left;
        font-size: 1.1rem;
        font-weight: 500;
        color: var(--text-main);
        background-color: var(--bg); /* Header Background */
        padding: 1rem;
        margin-bottom: 0;
        border-bottom: 1px solid var(--edge);
    }
    
    #oor-recent-index-container td[data-label="Project"]::before {
        display: none;
    }

    /* Model Used Specifics */
    #oor-recent-index-container td[data-label="Model Used"] {
        flex-direction: column;
        align-items: flex-end;
    }
    
    #oor-recent-index-container td[data-label="Model Used"]::before {
        align-self: flex-start;
        margin-bottom: 0.25rem;
    }
}

/* ==========================================================================
   DARK MODE COMPONENT OVERRIDES
   ========================================================================== */

/* Sidebar */
[data-theme="dark"] .menu-item.logout-item:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #F87171;
}

/* Modals & Inputs */
[data-theme="dark"] .add-member-box {
    background: var(--bg);
    border-color: var(--edge);
}

[data-theme="dark"] .pending-item {
    background: var(--bg);
    border-color: var(--edge);
}
[data-theme="dark"] .pending-role {
    background: var(--hover-bg);
    color: var(--muted);
}

/* Tool Select Cards */
[data-theme="dark"] .tool-select-card {
    background: var(--panel);
    border-color: var(--edge);
}
[data-theme="dark"] .tool-select-card:hover,
[data-theme="dark"] .tool-select-card:has(input:checked) {
    background-color: rgba(20, 184, 166, 0.1);
    border-color: var(--accent);
}
[data-theme="dark"] .tool-select-icon {
    background: var(--bg);
    color: var(--muted);
}
[data-theme="dark"] .tool-select-card:has(input:checked) .tool-select-icon {
    background: var(--accent);
    color: #fff;
}

/* Team List */
[data-theme="dark"] .team-list-item {
    border-bottom-color: var(--edge);
}
[data-theme="dark"] .team-avatar {
    background: var(--hover-bg);
    color: var(--text);
}

/* Sidebar Action Items (New Project, Settings) */
[data-theme="dark"] .menu-item.action-item:hover {
    background: rgba(20, 184, 166, 0.15); /* Dark Transparent Teal */
    color: var(--accent);
}

/* =========================================
   8. DROPDOWNS & POPOVERS (Global Standard)
   ========================================= */
.dropdown-item {
    display: flex; /* Flex for icon alignment, behaves like block */
    width: 100%;
    padding: 0.8rem 1.2rem;
    clear: both;
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--text);
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
    border-radius: 0;
    
    /* Internal Layout */
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0.5rem 0;
}

.dropdown-item:hover {
    background: var(--hover-bg);
    color: var(--accent);
    text-decoration: none;
}

.dropdown-divider {
    height: 1px;
    background: var(--edge);
    /* margin: 0.5rem 0; */
    overflow: hidden;
}

.dropdown-item.logout { color: #DC2626; }
.dropdown-item.logout:hover { background: #FEF2F2; }