:root {
    /* Light Theme - Brand Adherence */
    --bg-main: #FFFFFF;
    --bg-secondary: #F8F5F0;
    --text-primary: #000000;
    --text-secondary: #2B303B;
    --accent-primary: #091C3A;
    --border-subtle: #E5E7EB;
    --card-bg: #FFFFFF;
    --radius: 6px;
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Dark Theme - Brand Adherence */
    --bg-main: #000000;
    --bg-secondary: #000000;
    --text-primary: #FFFFFF;
    --text-secondary: rgba(248, 245, 240, 0.7);
    --accent-primary: #091C3A;
    --border-subtle: #2B303B;
    --card-bg: #2B303B;
}

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

body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, h3, h4, .brand-name, .btn-modern {
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

/* Layout */
.modern-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

@media (max-width: 992px) {
    .modern-layout { grid-template-columns: 1fr; }
}

/* Sidebar Redesign */
.modern-sidebar {
    background: var(--bg-main);
    border-right: 1px solid var(--border-subtle);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 100;
}
@media (max-width: 992px) {
    .modern-sidebar {
        transform: translateX(-100%); /* Hidden by default on mobile */
    }
}

@media (max-width: 992px) {
    .modern-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
}

/* Hamburger menu toggle for mobile */
#menu-toggle {
    display: none; /* Hidden by default on desktop */
}
@media (max-width: 992px) {
    #menu-toggle { display: flex !important; }
    .modern-main {
        padding: 1.5rem;
    }
    .modern-layout.sidebar-open .modern-sidebar {
        transform: translateX(0); /* Show when sidebar-open class is present */
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
    }
}

/* Brand/Logo Layout */
.brand-container {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.logo-svg {
    width: 40px !important;
    height: 40px !important;
    flex-shrink: 0;
}

/* Navigation */
.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius);
    transition: var(--transition);
    border: 1px solid transparent;
    white-space: nowrap; /* Prevents Account Settings from breaking lines */
}

.nav-item:hover, .nav-item.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

/* Content Area */
.modern-main {
    padding: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 992px) {
    .modern-main {
        padding: 1.5rem;
    }
    
    .modern-layout.sidebar-open .modern-sidebar {
        transform: translateX(0);
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
    }
}

/* Components */
.card-modern {
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

/* Table Redesign */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
    text-align: left;
    table-layout: fixed !important; /* Locks column widths */
}

.modern-table th {
    padding: 1rem;
    border-bottom: 2px solid var(--text-primary);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.modern-table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.95rem;
    word-break: break-word;
    white-space: normal !important;
    vertical-align: middle;
}

/* Fixed column widths to prevent jumping when status/buttons change */

.modern-table th:nth-child(1), 
.modern-table td:nth-child(1) {
    width: 180px !important; /* Narrower Organization/Name column */
}

.modern-table th:nth-child(2), 
.modern-table td:nth-child(2) {
    width: 350px !important; /* Tightened Licenses/Dept column */
}

.modern-table th:last-child, 
.modern-table td:last-child {
    width: 260px !important;
}

/* Buttons */
.btn-modern {
    padding: 12px 24px;
    background: var(--accent-primary);
    color: #FFFFFF;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 200px; /* Increased to accommodate "Verify Account" */
    white-space: nowrap;
    gap: 8px;
}

.btn-modern:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

/* Theme Switcher */
.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-main);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
}

/* Hamburger Menu Toggle */
#menu-toggle {
    display: none;
    background: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    width: 44px;
    height: 44px;
    padding: 0;
    min-width: 44px;
}

@media (max-width: 992px) {
    #menu-toggle {
        display: flex !important;
    }
}

/* Custom Select (Native replacement for Materialize) */
.modern-select {
    appearance: none;
    background-color: var(--bg-main);
    border: 1px solid var(--border-subtle);
    padding: 12px 32px 12px 12px;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    cursor: pointer;
    height: 50px;
    width: 100%;
}

/* Global Input Styles - Forced 60px Height */
.modern-input {
    all: unset !important;
    display: block !important;
    width: 100% !important;
    height: 60px !important;
    padding: 0 20px 0 45px !important;
    border: 2px solid var(--border-subtle) !important;
    border-radius: 12px !important;
    background-color: var(--bg-main) !important;
    box-sizing: border-box !important;
    font-size: 1.1rem !important;
    color: var(--text-primary) !important;
    font-family: var(--font-body) !important;
    transition: var(--transition) !important;
}

.modern-input:focus {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 4px rgba(9, 28, 58, 0.05) !important;
}

/* User Greeting Truncation */
#user-greeting {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.visible {
    display: flex;
}

.modal-modern {
    background: var(--bg-main);
    border: 1px solid var(--border-subtle);
    width: 90%;
    max-width: 600px;
    padding: 2.5rem;
    border-radius: var(--radius);
    position: relative;
}

.modal-modern h2 {
    margin-bottom: 1.5rem;
}

/* Standalone App Card/Pill Styles */
.app-item {
    background: var(--bg-main);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    width: 100%;
}

.app-item:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.05);
}

.app-item-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.app-item .app-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    line-height: 1.4;
    word-break: break-word;
}

/* Highlighted Scope Badges as Chips */
.scope-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.scope-badge {
    background: var(--accent-primary);
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    display: inline-block;
}

/* Scope Selector Specific Styles */
.scope-checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.scope-checkbox-item:hover {
    background: var(--bg-secondary);
}

.scope-checkbox-item.checked {
    border-color: var(--accent-primary);
    background: rgba(9, 28, 58, 0.04);
}

.scope-checkbox-label {
    display: flex;
    flex-direction: column;
}

.scope-name {
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.scope-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Modern Switch/Toggle */
.modern-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.modern-switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-subtle);
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px; width: 14px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: #2E7D32; }
input:checked + .slider:before { transform: translateX(20px); }

/* Mobile Responsive Table Transformation */
@media (max-width: 992px) {
    .modern-table.responsive-table {
        display: block;
        table-layout: auto !important;
    }
    
    .modern-table.responsive-table thead {
        display: none;
    }
    
    .modern-table.responsive-table tbody, 
    .modern-table.responsive-table tr, 
    .modern-table.responsive-table td {
        display: block;
        width: 100% !important;
    }
    
    .modern-table.responsive-table tr {
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius);
        background: var(--card-bg);
    }
    
    .modern-table.responsive-table td {
        text-align: right;
        padding: 1rem;
        position: relative;
        border-bottom: 1px solid var(--border-subtle);
    }
    
    .modern-table.responsive-table td::before {
        content: attr(data-label);
        float: left;
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.75rem;
        color: var(--text-secondary);
    }
    
    .modern-table.responsive-table td:last-child {
        border-bottom: none;
    }
}

/* Status Indicators */
.status-pill {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.status-pill.active { background: #E8F5E9; color: #2E7D32; }
.status-pill.inactive { background: #FFEBEE; color: #C62828; }
[data-theme="dark"] .status-pill.active { background: #1B5E20; color: #A5D6A7; }