/**
 * Navigation System - ResponseReady
 * Sidebar navigation with topbar layout
 *
 * Dependencies: tokens.css (must be loaded first)
 *
 * Structure:
 * 1. (Legacy - removed, replaced by sidebar)
 * 2. (Legacy - removed, replaced by sidebar)
 * 3. User Menu (shared between topbar dropdown)
 * 4. (Legacy - removed, replaced by sidebar)
 * 5. (Legacy - removed)
 * 6. Responsive Styles
 * 7. Accessibility & Animation
 * 8. Print Styles
 * 9. App Sidebar
 * 10. App Topbar
 * 11. Sidebar Collapsed State
 * 12. Sidebar Mobile Styles
 * 13. Sidebar Desktop Styles
 * 14. Sidebar Focus Styles
 * 15. Sidebar Print Styles
 */

/* ==========================================================================
   1. (Legacy Site Header - removed, replaced by sidebar + topbar)
   ========================================================================== */

/* ==========================================================================
   2. (Legacy Primary Navigation - removed, replaced by sidebar)
   ========================================================================== */

/* ==========================================================================
   3. User Menu
   ========================================================================== */

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--color-neutral-600);
    font-family: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-default);
}

.user-menu-trigger:hover {
    background-color: var(--color-neutral-100);
}

.user-menu-trigger:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* User Avatar */
.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--avatar-sm);
    height: var(--avatar-sm);
    background-color: var(--color-primary-700);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
}

.user-avatar svg {
    width: var(--icon-md);
    height: var(--icon-md);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.user-name {
    font-weight: var(--font-medium);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-trigger .icon-chevron {
    width: 14px;
    height: 14px;
    opacity: 0.8;
    transition: transform var(--duration-fast) var(--ease-default);
}

.user-menu-trigger[aria-expanded="true"] .icon-chevron {
    transform: rotate(180deg);
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 220px;
    padding: var(--space-2) 0;
    background-color: var(--surface-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(calc(-1 * var(--space-2)));
    transition: opacity var(--duration-fast) var(--ease-default), 
                transform var(--duration-fast) var(--ease-default), 
                visibility var(--duration-fast) var(--ease-default);
    z-index: var(--z-dropdown);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* User Info in Dropdown */
.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    margin-bottom: var(--space-2);
}

.dropdown-user-info .user-avatar {
    background-color: var(--color-primary-600);
    color: white;
}

.dropdown-user-details {
    flex: 1;
    min-width: 0;
}

.dropdown-user-name {
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    color: var(--color-neutral-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-user-role {
    font-size: var(--text-xs);
    color: var(--color-neutral-500);
}

/* Dropdown Item */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--color-neutral-700);
    font-size: var(--text-sm);
    text-decoration: none;
    transition: background-color var(--duration-fast) var(--ease-default);
}

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

.dropdown-item svg {
    width: var(--icon-md);
    height: var(--icon-md);
    color: var(--color-neutral-500);
    flex-shrink: 0;
}

.dropdown-item--danger {
    color: var(--color-primary-600);
}

.dropdown-item--danger svg {
    color: var(--color-primary-600);
}

.dropdown-item--danger:hover {
    background-color: var(--color-primary-50);
}

/* Dropdown Divider */
.dropdown-divider {
    height: 1px;
    margin: var(--space-2) 0;
    background-color: var(--border-default);
}

.dropdown-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: calc(var(--z-dropdown) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-fast) var(--ease-default),
                visibility var(--duration-fast) var(--ease-default);
    -webkit-tap-highlight-color: transparent;
}

.dropdown-backdrop.show {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 641px) {
    .dropdown-backdrop {
        display: none;
    }
}

/* ==========================================================================
   4. (Legacy Mobile Navigation - removed, replaced by sidebar mobile drawer)
   ========================================================================== */

/* ==========================================================================
   5. (Legacy Responsive Task Navigation - removed)
   ========================================================================== */

/* ==========================================================================
   6. Responsive Styles
   ========================================================================== */

/* Mobile - below 768px */
@media (max-width: 640px) {
    /* User dropdown adjustments for mobile */
    .user-dropdown {
        position: fixed;
        top: auto;
        bottom: var(--space-2);
        right: var(--space-2);
        left: var(--space-2);
        min-width: auto;
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* ==========================================================================
   7. Accessibility & Animation
   ========================================================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible styles for keyboard navigation */
.user-menu-trigger:focus-visible,
.dropdown-item:focus-visible {
    outline: 2px solid var(--color-primary-400);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dropdown-item {
        border: 1px solid transparent;
    }

    .dropdown-item:focus-visible {
        border-color: currentColor;
    }
}

/* ==========================================================================
   8. Print Styles
   ========================================================================== */

@media print {
    .has-sidebar .main-content,
    .has-sidebar .main-footer {
        margin-left: 0;
    }
}

/* ==========================================================================
   9. App Sidebar
   ========================================================================== */

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width, 280px);
    background-color: var(--sidebar-bg, #FFFFFF);
    border-right: 1px solid var(--sidebar-border, var(--border-default));
    z-index: var(--z-sticky);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--duration-normal) var(--ease-default),
                visibility var(--duration-normal) var(--ease-default);
}

/* Sidebar Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2-5) var(--space-5);
    border-bottom: 1px solid var(--sidebar-border, var(--border-default));
    text-decoration: none;
    color: var(--color-neutral-900);
    flex-shrink: 0;
    height: var(--topbar-height, 56px);
}

.sidebar-brand:hover {
    text-decoration: none;
    color: var(--color-neutral-900);
}

.sidebar-brand-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.sidebar-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: var(--leading-tight);
    overflow: hidden;
}

.sidebar-brand-title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    letter-spacing: var(--tracking-tight);
    color: var(--color-neutral-900);
    white-space: nowrap;
}

.sidebar-brand-subtitle {
    font-size: var(--text-xs);
    color: var(--color-neutral-500);
    white-space: nowrap;
}

/* ============================================================================
   Sidebar Brigade Switcher
   ----------------------------------------------------------------------------
   Native <details>/<summary> dropdown for multi-brigade users. Lives between
   the brand and the nav so it's the first thing a user sees when they open
   the sidebar — important on mobile, where this is the only way to change
   brigade context.
   ============================================================================ */
.sidebar-brigade-switcher {
    margin: var(--space-3);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--surface-primary);
    flex-shrink: 0;
}

/* Hide native disclosure marker; we render our own chevron. */
.sidebar-brigade-switcher > summary {
    list-style: none;
}
.sidebar-brigade-switcher > summary::-webkit-details-marker {
    display: none;
}

.sidebar-brigade-switcher-summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    border-radius: var(--radius-md);
    user-select: none;
    transition: background-color var(--duration-fast);
}

.sidebar-brigade-switcher-summary:hover {
    background: var(--color-neutral-50);
}

.sidebar-brigade-switcher-summary:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.sidebar-brigade-switcher-label {
    font-size: 10px;
    font-weight: var(--font-semibold);
    color: var(--color-neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}

.sidebar-brigade-switcher-value {
    flex: 1;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-neutral-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.sidebar-brigade-switcher-chevron {
    flex-shrink: 0;
    color: var(--color-neutral-500);
    transition: transform var(--duration-fast);
}

.sidebar-brigade-switcher[open] .sidebar-brigade-switcher-chevron {
    transform: rotate(180deg);
}

.sidebar-brigade-switcher-list {
    list-style: none;
    margin: 0;
    padding: var(--space-1);
    border-top: 1px solid var(--border-default);
    max-height: 260px;
    overflow-y: auto;
}

.sidebar-brigade-switcher-list form {
    margin: 0;
}

.sidebar-brigade-switcher-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-2-5);
    border: none;
    background: transparent;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-neutral-800);
    font: inherit;
    transition: background-color var(--duration-fast);
}

.sidebar-brigade-switcher-item:hover {
    background: var(--color-neutral-50);
}

.sidebar-brigade-switcher-item:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.sidebar-brigade-switcher-item.is-active {
    background: var(--color-primary-light, rgba(220, 38, 38, 0.08));
    color: var(--color-primary);
}

.sidebar-brigade-switcher-item-name {
    flex: 1;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brigade-switcher-item-code {
    font-size: 10px;
    font-weight: var(--font-semibold);
    color: var(--color-neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    padding: 1px var(--space-1-5);
    background: var(--color-neutral-100);
    border-radius: var(--radius-sm);
}

.sidebar-brigade-switcher-item.is-active .sidebar-brigade-switcher-item-code {
    background: rgba(255, 255, 255, 0.6);
    color: var(--color-primary);
}

/* When the sidebar is collapsed (icon-only), hide the switcher's label
   and brigade name — keep only the chevron/icon visible. Clicking it
   should still expand the list. */
.app-sidebar.is-collapsed .sidebar-brigade-switcher-label,
.app-sidebar.is-collapsed .sidebar-brigade-switcher-value,
.app-sidebar.is-collapsed .sidebar-brigade-switcher-item-name {
    display: none;
}

.app-sidebar.is-collapsed .sidebar-brigade-switcher {
    margin: var(--space-2);
}

.app-sidebar.is-collapsed .sidebar-brigade-switcher-summary {
    justify-content: center;
    padding: var(--space-2);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-3) 0;
}

.sidebar-section {
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}

.sidebar-section-label {
    display: block;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--color-neutral-500);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Sidebar Link */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 44px;
    padding: var(--space-2-5) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-neutral-700);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default);
}

.sidebar-link:hover {
    background-color: var(--color-neutral-100);
    color: var(--color-neutral-900);
    text-decoration: none;
}

.sidebar-link[aria-current="page"],
.sidebar-link.active {
    background-color: var(--color-primary-50);
    color: var(--color-primary-600);
    border-left: 3px solid var(--color-primary-600);
    padding-left: calc(var(--space-3) - 3px);
}

.sidebar-link[aria-current="page"] .sidebar-icon,
.sidebar-link.active .sidebar-icon {
    color: var(--color-primary-600);
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--color-neutral-500);
}

.sidebar-icon svg {
    width: 100%;
    height: 100%;
}

.sidebar-link-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Submenu (collapsible groups) */
.sidebar-submenu {
    margin-bottom: var(--space-1);
}

.sidebar-submenu-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    min-height: 44px;
    padding: var(--space-2-5) var(--space-3);
    border: none;
    border-radius: var(--radius-md);
    background: none;
    color: var(--color-neutral-700);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-default);
}

.sidebar-submenu-toggle:hover {
    background-color: var(--color-neutral-100);
}

.sidebar-submenu-toggle .sidebar-icon {
    flex-shrink: 0;
}

.sidebar-submenu-chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    color: var(--color-neutral-400);
    transition: transform var(--duration-fast) var(--ease-default);
    flex-shrink: 0;
}

.sidebar-submenu-chevron svg {
    width: 100%;
    height: 100%;
}

.sidebar-submenu.is-expanded > .sidebar-submenu-toggle > .sidebar-submenu-chevron {
    transform: rotate(90deg);
}

.sidebar-submenu-items {
    display: none;
    padding: var(--space-1) 0 var(--space-1) calc(var(--space-3) + 20px + var(--space-3));
}

.sidebar-submenu.is-expanded > .sidebar-submenu-items {
    display: block;
}

.sidebar-submenu-items .sidebar-link {
    padding-left: var(--space-3);
    min-height: 38px;
    font-size: var(--text-sm);
}

/* Nested-item icons are a touch smaller than the top-level 20px, matching the
   submenu-toggle, so the compact rows stay tidy. */
.sidebar-submenu-items .sidebar-icon {
    width: 16px;
    height: 16px;
}

/* Nested module submenu (third level) — reduce indentation */
.sidebar-submenu-items .sidebar-submenu .sidebar-submenu-toggle {
    padding-left: var(--space-3);
    font-size: var(--text-sm);
    min-height: 38px;
}

.sidebar-submenu-items .sidebar-submenu-items {
    padding-left: var(--space-4);
}

.sidebar-submenu-items .sidebar-submenu-items .sidebar-link {
    padding-left: var(--space-3);
    min-height: 34px;
    font-size: var(--text-xs);
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-border, var(--border-default));
    padding: var(--space-3) var(--space-4);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.sidebar-user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--avatar-sm);
    height: var(--avatar-sm);
    background-color: var(--color-primary-600);
    border-radius: var(--radius-full);
    color: white;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-neutral-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: var(--text-xs);
    color: var(--color-neutral-500);
}


/* Sidebar Close Button (mobile) */
.sidebar-close {
    display: none;
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-neutral-500);
    cursor: pointer;
    z-index: 1;
}

.sidebar-close:hover {
    background-color: var(--color-neutral-100);
    color: var(--color-neutral-900);
}

.sidebar-close svg {
    width: 20px;
    height: 20px;
}

/* Sidebar Collapse Toggle */
.sidebar-collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: auto;
    background: none;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--color-neutral-500);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default);
    flex-shrink: 0;
}

.sidebar-collapse-toggle:hover {
    background-color: var(--color-neutral-100);
    color: var(--color-neutral-900);
}

.sidebar-collapse-toggle svg {
    width: 18px;
    height: 18px;
}

/* Sidebar Overlay (mobile backdrop) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--surface-overlay, rgba(15, 23, 42, 0.5));
    z-index: calc(var(--z-sticky) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) var(--ease-default),
                visibility var(--duration-normal) var(--ease-default);
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   10. App Topbar
   ========================================================================== */

.app-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width, 280px);
    right: 0;
    height: var(--topbar-height, 56px);
    background-color: var(--surface-primary);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    padding: 0 var(--space-5);
    gap: var(--space-4);
    z-index: calc(var(--z-sticky) - 1);
    transition: left var(--duration-normal) var(--ease-default);
}

.topbar-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    padding: 0;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-neutral-600);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-default);
    flex-shrink: 0;
}

.topbar-hamburger:hover {
    background-color: var(--color-neutral-100);
}

.topbar-hamburger svg {
    width: var(--icon-lg);
    height: var(--icon-lg);
}

.topbar-context {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}

.topbar-page-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--color-neutral-900);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* ==========================================================================
   10a. Environment Banner
   Shown for non-production environments (staging, development).
   ========================================================================== */

.env-banner {
    position: fixed;
    top: var(--topbar-height, 56px);
    left: var(--sidebar-width, 280px);
    right: 0;
    height: 32px;
    background-color: var(--color-warning);
    color: white;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-align: center;
    line-height: 32px;
    z-index: calc(var(--z-sticky) - 2);
    transition: left var(--duration-normal) var(--ease-default);
}

/* Push main content down when banner is present. The bare `padding-top:32px`
   previously set here clobbered the .has-sidebar/.main-content base which
   already accounts for the topbar height — so on staging/dev the env banner
   visually overlapped the page h1. Re-compute the full top inset:
   topbar + banner + breathing room.

   Specificity note: main.css's `.has-sidebar .main-content` rule loads later
   in the cascade and has the same specificity (0,2,0) as `.has-env-banner
   .main-content` — so the later rule would win on a tie. Bump specificity
   here by combining both body classes (.has-sidebar.has-env-banner) which
   yields (0,3,0) and decisively overrides main.css regardless of source
   order. The pure `.has-env-banner .main-content` fallback covers the
   no-sidebar layout (e.g. login/error). */
.has-env-banner .main-content,
.has-sidebar.has-env-banner .main-content {
    padding-top: calc(var(--topbar-height, 56px) + 32px + var(--space-3, 0.75rem));
}
@media (max-width: 640px) {
    .has-env-banner .main-content,
    .has-sidebar.has-env-banner .main-content {
        padding-top: calc(var(--topbar-height, 56px) + 32px + var(--space-4, 1rem));
    }
}

/* ==========================================================================
   11. Sidebar Collapsed State (Desktop)
   Sidebar hides completely; topbar expands full-width with hamburger to reopen.
   ========================================================================== */

.app-sidebar.is-collapsed {
    transform: translateX(-100%);
    visibility: hidden;
}

/* Topbar and env banner go full-width when sidebar is collapsed */
.sidebar-collapsed .app-topbar,
.sidebar-collapsed .env-banner {
    left: 0;
}

/* Show hamburger when sidebar is collapsed on desktop */
.sidebar-collapsed .topbar-hamburger {
    display: flex;
}

/* ==========================================================================
   12. Sidebar Mobile Styles
   ========================================================================== */

@media (max-width: 640px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width, 280px);
        z-index: calc(var(--z-sticky) + 1);
        box-shadow: none;
        transition: transform var(--duration-normal) var(--ease-default);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .app-sidebar .sidebar-close {
        display: flex;
    }

    .app-sidebar .sidebar-collapse-toggle {
        display: none;
    }

    .app-topbar,
    .env-banner {
        left: 0;
    }

    .topbar-hamburger {
        display: flex;
    }

}

/* ==========================================================================
   13. Sidebar Desktop Styles
   ========================================================================== */

@media (min-width: 641px) {
    .app-sidebar .sidebar-close {
        display: none;
    }
}

/* ==========================================================================
   14. Sidebar Focus Styles
   ========================================================================== */

.sidebar-link:focus-visible,
.sidebar-submenu-toggle:focus-visible,
.sidebar-close:focus-visible,
.sidebar-collapse-toggle:focus-visible,
.topbar-hamburger:focus-visible {
    outline: 2px solid var(--color-primary-400);
    outline-offset: 2px;
}

/* ==========================================================================
   15. Topbar FDR Chip
   Persistent operational status — rendered by components/topbar.ejs from
   res.locals.fdrChip (cache-only lookup; hidden when feature off / no data).
   Rating colours mirror FdrService RATING_COLORS.
   ========================================================================== */

.topbar-fdr-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1-5);
    padding: var(--space-1) var(--space-3);
    background: var(--surface-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--text-secondary);
    white-space: nowrap;
}

.topbar-fdr-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--color-neutral-300);
    flex-shrink: 0;
}

.fdr-rating-moderate .topbar-fdr-dot { background: #64BF30; }
.fdr-rating-high .topbar-fdr-dot { background: #FEDD3A; }
.fdr-rating-extreme .topbar-fdr-dot { background: #F78100; }
.fdr-rating-catastrophic .topbar-fdr-dot { background: #AD0909; }

@media (max-width: 640px) {
    /* Save topbar space on phones */
    .topbar-fdr-prefix {
        display: none;
    }
}

/* ==========================================================================
   16. Mobile Bottom Tab Bar
   Rendered by components/tabbar.ejs from the unified brigade nav.
   Desktop: hidden (sidebar covers navigation). ≤640px: fixed bottom bar
   with Dashboard + first nav leaves + More (opens the sidebar drawer).
   ========================================================================== */

.app-tabbar {
    display: none;
}

@media (max-width: 640px) {
    .app-tabbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: var(--z-sticky);
        display: flex;
        background: var(--surface-primary);
        border-top: 1px solid var(--border-default);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .tabbar-item {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 56px;
        padding: var(--space-1);
        border: none;
        background: none;
        color: var(--text-secondary);
        text-decoration: none;
        font-family: inherit;
        font-size: 0.6875rem;
        font-weight: var(--font-weight-medium);
        cursor: pointer;
    }

    .tabbar-item svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .tabbar-item span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tabbar-item.is-active {
        color: var(--color-primary);
    }

    .tabbar-item:focus-visible {
        outline: 2px solid var(--color-primary-400);
        outline-offset: -2px;
    }

    /* Keep page content and footer clear of the fixed bar */
    .has-sidebar .main-content {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .has-sidebar .main-footer {
        margin-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }
}

/* ==========================================================================
   17. Sidebar Print Styles
   ========================================================================== */

@media print {
    .app-sidebar,
    .app-topbar,
    .env-banner,
    .sidebar-overlay,
    .app-tabbar {
        display: none !important;
    }
}
