:root {
    --font-ui: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}

body {
    font-family: var(--font-ui);
    margin: 0;
    padding: 0;
    background: #f0f0f0;
}

/* Hide the control; it's just a state carrier */
.nav-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    top: -9999px;
    left: -9999px;
    opacity: 0;
}

/* Shell & layout */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    border-left: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    background: #fff;
    box-sizing: border-box;
}

.topbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
}

    .topbar .left {
        display: flex;
        align-items: center;
        gap: .5rem;
    }

    .topbar .brand {
        display: flex;
        align-items: center;
        gap: .5rem;
        text-decoration: none;
        color: inherit;
        font-weight: 600;
    }

        .topbar .brand img {
            height: 32px;
            width: auto;
            display: block;
            object-fit: contain;
        }

.topnav {
    display: flex;
    gap: 1rem;
    margin-left: 1rem;
}

    .topnav a {
        color: #6b7280;
        text-decoration: none;
    }

        .topnav a.active {
            color: #2563eb;
            font-weight: 600;
        }

.right {
    margin-left: auto;
}

.content-row {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
}

.sidebar {
    width: 180px;
    border-right: 1px solid #e5e7eb;
    background: transparent;
    padding: .5rem;
    overflow: auto;
    transition: width .2s ease, padding .2s ease;
    flex-shrink: 0;
}

/* Collapsed sidebar - icon-only mode */
.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar {
    width: 56px !important;
    padding: 0.75rem 0.25rem !important;
    overflow: hidden !important;
    border-right: 1px solid #e5e7eb;
}

/* Hide text labels when collapsed */
.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar .text {
    display: none;
}

/* Hide expand icon when collapsed */
.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar .expand-icon {
    display: none;
}

/* Hide nav group items when collapsed */
.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar .nav-group-items {
    display: none;
}

/* Center icons when collapsed */
.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar .tree-link {
    justify-content: center;
    padding: 0.5rem;
}

/* Make nav-group-header look like a regular link when collapsed */
.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar .nav-group-header {
    justify-content: center;
    padding: 0.5rem;
}

/* Adjust icon box size when collapsed for better fit */
.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar .icon {
    border: none;
    inline-size: auto;
    block-size: auto;
    font-size: 1.25rem;
}

/* Add tooltip on hover when collapsed */
.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar .nav-item {
    position: relative;
}

.nav-toggle:not(:checked) ~ .app-shell .content-row .sidebar .nav-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #1f2937;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    margin-left: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.main {
    flex: 1;
    padding: 1rem 1.25rem;
    min-width: 0;
    overflow: auto;
}

.breadcrumbs {
    color: #6b7280;
    font-size: .9rem;
    margin-bottom: .5rem;
}

/* Tree content */
.tree-label {
    display: block;
    padding: .35rem .5rem;
    margin: .15rem 0;
    color: #374151;
    font-weight: 600;
}

.tree-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin: 0;
    border-radius: 0.375rem;
    text-decoration: none;
    color: #111827;
    transition: background-color 0.1s ease, color 0.1s ease;
    position: relative;
}

    .tree-link:hover {
        background: #f3f4f6;
        color: #111827;
    }

    .tree-link:active {
        background: #e5e7eb;
        transform: scale(0.98);
    }

    /* Fluent active/selected state */
    .tree-link.active {
        background: #e0e7ff;
        color: #1e40af;
        font-weight: 600;
    }

        .tree-link.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 3px;
            height: 70%;
            background: #2563eb;
            border-radius: 0 2px 2px 0;
        }

    /* Focus state for accessibility */
    .tree-link:focus-visible {
        outline: 2px solid #0078d4;
        outline-offset: 2px;
    }

.icon {
    display: inline-grid;
    place-items: center;
    inline-size: 2.25rem;
    block-size: 2.25rem;
    border: 1px solid #e5e7eb;
    border-radius: .5rem;
    cursor: pointer;
    user-select: none;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", emoji, system-ui, sans-serif;
    line-height: 1;
}

    .icon:hover {
        background: #f8fafc;
    }

/* Account dropdown menu */
.acct-menu {
    position: relative;
}

    .acct-menu > summary {
        list-style: none;
        cursor: pointer;
        padding: .35rem .6rem;
        border: 1px solid #e5e7eb;
        border-radius: .5rem;
    }

    .acct-menu[open] > summary {
        background: #f8fafc;
    }

    .acct-menu .menu {
        position: absolute;
        right: 0;
        margin-top: .25rem;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: .5rem;
        min-width: 220px;
        padding: .25rem;
        box-shadow: 0 6px 16px rgba(0,0,0,.08);
        display: flex;
        flex-direction: column;
        z-index: 1000;
    }

        .acct-menu .menu a {
            padding: .45rem .6rem;
            text-decoration: none;
            color: #111827;
            border-radius: .35rem;
        }

            .acct-menu .menu a:hover {
                background: #f3f4f6;
            }

/* Footer */
.footer {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    padding: 0.75rem 1.5rem;
    font-size: small;
    color: #444;
    margin-top: auto;
    width: 100%;
    box-sizing: border-box;
}

    .footer > div {
        max-width: 100%;
    }

    .footer .container {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
    }

        .footer .container span:nth-child(1) {
            justify-self: start;
            text-align: left;
        }

        .footer .container span:nth-child(2) {
            justify-self: center;
            text-align: center;
        }

        .footer .container span:nth-child(3) {
            justify-self: end;
            text-align: right;
        }

/* Fluent Design Navigation Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    flex-direction: column;
}

/* Fluent-style button for forms in nav */
.nav-button {
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 1rem;
    text-align: left;
    padding: 0;
}

    .nav-button:focus-visible {
        outline: 2px solid #0078d4;
        outline-offset: 2px;
        border-radius: .375rem;
    }

.acct-menu {
    position: relative;
    display: inline-block;
}

.menu-flyout {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    z-index: 1000;
}

    /* Optional: Add a backdrop that closes the menu when clicked */
    .menu-flyout::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: -1;
    }

.account-info-section {
    display: grid;
    gap: 4px; /* Reduced from 12px for tighter spacing */
    margin: 16px 0;
}

.info-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    align-items: center;
    gap: 16px;
}

.info-label {
    text-align: right;
    font-weight: 600;
    color: var(--neutral-foreground-rest);
}

/* User Management Table Styling */
.user-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.user-table thead {
    background: var(--neutral-layer-2);
}

.user-table th {
    text-align: left;
    padding: 12px;
    font-weight: 600;
    border-bottom: 2px solid var(--neutral-stroke-rest);
}

.user-table td {
    padding: 12px;
    border-bottom: 1px solid var(--neutral-stroke-rest);
}

.user-table tbody tr:hover {
    background: var(--neutral-layer-1);
}

/* Ultra-Compact FluentDataGrid Styling - Windows-native density */
.compact-grid {
    font-size: 0.75rem;
    line-height: 1.1;
    --data-grid-cell-padding: 1px 4px;
}

/* Target FluentDataGrid table elements directly */
.compact-grid table {
    border-collapse: collapse;
    font-size: 0.75rem;
}

.compact-grid thead th,
.compact-grid th {
    padding: 1px 6px !important;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background-color: #e9ecef;
    border-bottom: 1px solid #ced4da;
}

.compact-grid tbody td,
.compact-grid td {
    padding: 1px 6px !important;
    font-size: 0.75rem;
    line-height: 1.1;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
}

/* Striped rows - targeting table rows */
.compact-grid tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.compact-grid tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

/* Hover effect */
.compact-grid tbody tr:hover {
    background-color: #cfe2ff !important;
}

/* FluentUI web component specific overrides */
.compact-grid fluent-data-grid-row {
    min-height: 16px !important;
    --rowHeight: 16px;
}

.compact-grid fluent-data-grid-cell {
    padding: 1px 6px !important;
    min-height: 16px !important;
    font-size: 0.75rem;
    line-height: 1.1;
}

.compact-grid fluent-data-grid-row:nth-child(even) {
    background-color: #f8f9fa;
}

.compact-grid fluent-data-grid-row:nth-child(odd) {
    background-color: #ffffff;
}

.compact-grid fluent-data-grid-row:hover {
    background-color: #cfe2ff !important;
}

/* Column headers for web components */
.compact-grid .column-header,
.compact-grid [role="columnheader"] {
    padding: 1px 6px !important;
    font-weight: 600;
    font-size: 0.7rem;
    background-color: #e9ecef;
    line-height: 1.1;
    text-align: left;
}

/* RowClass-based striping (works with FluentDataGrid RowClass parameter) */
.compact-grid .row-even,
.compact-grid tr.row-even,
.compact-grid fluent-data-grid-row.row-even {
    background-color: #f8f9fa !important;
}

.compact-grid .row-odd,
.compact-grid tr.row-odd,
.compact-grid fluent-data-grid-row.row-odd {
    background-color: #ffffff !important;
}

.compact-grid .row-even:hover,
.compact-grid .row-odd:hover,
.compact-grid tr.row-even:hover,
.compact-grid tr.row-odd:hover,
.compact-grid fluent-data-grid-row.row-even:hover,
.compact-grid fluent-data-grid-row.row-odd:hover {
    background-color: #cfe2ff !important;
}