*, *::before, *::after {
    box-sizing: border-box;
}

.osm-dark-map .leaflet-tile-pane {
    filter: none;
}

.osm-dark-map .leaflet-tile-pane::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: rgba(2, 28, 49, 0.58);
    mix-blend-mode: multiply;
}

:root {
    color-scheme: dark;
    --visual-viewport-height: 100dvh;
    --keyboard-height: 0px;
    /* Base Colors - Stitch Dark Theme */
    --bg-primary: #0c0e12;
    --bg-secondary: #15181e;
    --bg-surface: #20242b;
    --bg-card: #181b21;
    
    --text-primary: #f0f1f3;
    --text-secondary: #b4b8c1;
    --text-muted: #a1a6b1;
    --accent-gold: #e0c49a;
    
    /* EVP Amber -> Stitch Red */
    --accent-evp: #d41111;
    --accent-evp-glow: rgba(212, 17, 17, 0.25);
    
    /* Spirit Teal - Subtle cold accent */
    --accent-spirit: #14b8a6;
    --accent-blue-light: #60a5fa;
    
    --accent-red: #d41111;
    --accent-red-glow: rgba(212, 17, 17, 0.3);

    --accent: var(--accent-evp);
    --accent-glow: var(--accent-evp-glow);
    
    /* Functional Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #d41111;
    --status-red: #d41111;
    --border-color: #34383f;
    --input-border: #44434a;

    /* Layout - Modern & Readable */
    --sidebar-width: 240px;
    --header-height: 64px;
    --bottom-nav-height: 60px;
    --bottom-clearance: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    --border-radius-lg: 8px;
    --border-radius-md: 8px;
    --border-radius-sm: 8px;
    --touch-target: 44px;
    
    --font-ui: 'Geist', sans-serif;
    --font-tech: 'JetBrains Mono', monospace;
    
    --transition-standard: 0.2s ease;

    /* Modern Glassmorphism with proper contrast */
    --glass-bg: rgba(18, 20, 24, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    --glass-blur: blur(10px);

    --panel-glow: 0 0 25px rgba(0, 0, 0, 0.3);
}

/* Native Feel Enhancements */
body {
    overscroll-behavior: none; /* Disable pull-to-refresh and rubber banding */
    -webkit-tap-highlight-color: transparent; /* Remove the blue overlay on tap in mobile Safari/Chrome */
    user-select: none; /* Prevent accidental text selection during rapid interactions */
    -webkit-user-drag: none; /* Prevent image dragging which feels like a web-page */
}

/* Premium Cursor Control */
body, button, .btn, .nav-item, .stitch-case-card, .location-item, .audit-entry {
    cursor: default;
}

/* Allow text selection only where it makes sense */
input, textarea, [contenteditable="true"], .entry-note, .audit-log-row, .card-title, .form-section-title {
    user-select: text;
    -webkit-user-select: text;
}

/* Visual Active States for Buttons & Cards */
.btn:active,
.nav-item:active,
.stitch-case-card:active,
.location-item:active,
.audit-entry:active,
.card:active {
    transform: scale(0.985);
    opacity: 0.9;
    filter: brightness(1.1);
    transition: transform 0.1s cubic-bezier(0, 0, 0.2, 1);
}

.btn-primary:active {
    background: var(--accent-red);
    box-shadow: 0 0 15px var(--accent-red-glow);
}

.nav-item {
    transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}

/* Smooth Scrolling Container */
.main-content {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
}

.modern-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

.icon-outline-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--text-muted);
    cursor: pointer;
    width: 44px;
    height: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    flex-shrink: 0;
    box-sizing: border-box;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-standard);
    padding: 0;
}
.icon-outline-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
}
.icon-outline-btn:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
}

.control-group-header {
    font-family: var(--font-tech);
    font-size: 0.65rem;
    color: var(--accent-red) !important; /* Force red color */
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
}

.audio-controls-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
    margin-bottom: 24px;
    background: rgba(0,0,0,0.2);
    padding: 24px;
    border-radius: var(--border-radius-md);
}

.audio-control-cluster {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.workspace-main {
    min-width: 0;
    width: 100%;
}

.audio-lab-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px !important;
}

@media screen and (max-width: 768px) {
    /* Explicitly hide redundant nav items in the mobile drawer */
    .stitch-sidebar .nav-item.mobile-hide,
    .stitch-sidebar .tools-nav-group.mobile-hide,
    .stitch-sidebar .tools-nav-group {
        display: none !important;
    }
    .audio-lab-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
    }
}

.status-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.6rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

[data-theme="red"] {
    --bg-primary: #000000;
    --bg-secondary: #080000;
    --bg-surface: #100000;
    --bg-card: rgba(16, 0, 0, 0.6);
    --text-primary: #D41111;
    --text-secondary: #C7D0DE;
    --text-muted: #D98D8D;
    --accent: #D41111;
    --accent-glow: var(--accent-red-glow);
    --border-color: rgba(212, 17, 17, 0.2);
    --input-border: rgba(212, 17, 17, 0.45);
}

[data-theme="red"] .btn-secondary, body.red-mode .btn-secondary {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

[data-theme="red"] .btn-ghost {
    border-color: rgba(212, 17, 17, 0.2);
    color: var(--text-muted);
}

/* --- Field Event Logger & Audit Entry Desktop Layout --- */
.event-log-header {
    display: grid;
    grid-template-columns: 140px 110px 1fr 70px;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.5);
    font-size: 0.7rem;
    color: var(--text-muted);
    align-items: center;
}

.event-log-row {
    display: grid;
    grid-template-columns: 140px 110px 1fr 70px;
    gap: 12px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    align-items: start;
    user-select: none;
    -webkit-user-select: none;
    width: 100%;
    box-sizing: border-box;
}

.event-log-meta-wrap {
    display: contents;
}

.event-log-meta-wrap .audit-time,
.event-log-row .audit-time {
    font-family: var(--font-tech);
    font-size: 0.7rem;
    color: var(--warning);
    white-space: normal;
    word-break: break-word;
}

.event-log-category-pill {
    font-family: var(--font-tech);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-transform: uppercase;
}

.event-log-row .entry-note {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}

.event-log-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.event-log-actions .log-action-btn {
    padding: 4px 8px;
    font-size: 1.1rem;
    min-height: 0;
    line-height: 1;
    border: none;
    opacity: 0.9;
    cursor: pointer;
    filter: brightness(1.4);
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 16px; }

html, body {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden !important;
    overflow-x: hidden !important;
    position: relative;
    margin: 0;
    padding: 0;
    box-sizing: border-box !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
    overscroll-behavior: none;
}

input, textarea, [contenteditable="true"] {
    user-select: text;
}

h1, h2, h3, .tech-text {
    font-family: var(--font-tech);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Layout */
.app-container {
    display: grid;
    grid-template-areas: 
        "sidebar header"
        "sidebar quicklog"
        "sidebar main";
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: var(--header-height) auto 1fr;
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

@media (min-width: 769px) {
    .app-container.desktop-sidebar-closed {
        grid-template-columns: 0 minmax(0, 1fr) !important;
    }
    .app-container.desktop-sidebar-closed .sidebar,
    .app-container.desktop-sidebar-closed .stitch-sidebar {
        display: none !important;
    }
    .app-container.desktop-sidebar-closed .sidebar-toggle {
        display: flex !important;
    }
}

/* Mobile-only / Mobile-hide utilities */
.mobile-only { display: none; }
.mobile-hide { display: block; }

.header {
    grid-area: header;
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    height: var(--header-height, 60px);
    z-index: 1000;
    box-sizing: border-box;
}

.header-left, .header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Unified Action Button System (All 36px height) */
#header-notification-btn,
.header-notification-btn,
.mobile-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--accent-blue-light, #60a5fa);
    cursor: pointer;
    position: relative;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

#header-notification-btn:hover,
.header-notification-btn:hover,
.mobile-action-btn:hover {
    background: rgba(96, 165, 250, 0.12);
    border-color: var(--accent-blue-light, #60a5fa);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.3);
}

.mobile-action-btn {
    color: var(--text-primary, #e2e8f0);
}

.mobile-action-btn svg {
    pointer-events: none;
    width: 18px;
    height: 18px;
}

#header-notification-btn svg,
.header-notification-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* Header Red Mode Button */
#theme-toggle.header-action-theme-btn,
.header-action-theme-btn {
    height: 36px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--accent-red, #d41111);
    background: rgba(212, 17, 17, 0.08);
    border: 1px solid rgba(212, 17, 17, 0.35);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

#theme-toggle.header-action-theme-btn:hover,
.header-action-theme-btn:hover {
    background: rgba(212, 17, 17, 0.18);
    border-color: rgba(212, 17, 17, 0.55);
    box-shadow: 0 0 12px rgba(212, 17, 17, 0.3);
}

/* Header Brand & Subtitle Responsive Utilities */
.header-brand-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-tablet-view {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Desktop workstation (> 1024px and not native) */
@media screen and (min-width: 1025px) {
    html:not([data-is-native="true"]) .header-brand-wrap {
        display: none !important;
    }
    html:not([data-is-native="true"]) .header-tablet-view {
        display: none !important;
    }
    html:not([data-is-native="true"]) .mobile-header-actions {
        display: none !important;
    }
    html:not([data-is-native="true"]) .header-breadcrumb {
        display: flex !important;
    }
    html:not([data-is-native="true"]) #header-notification-btn {
        display: inline-flex !important;
    }
}

@media screen and (max-width: 1024px) {
    .sidebar-toggle.desktop-only {
        display: none !important;
    }
    .header-breadcrumb {
        display: none !important;
    }
    .adsense-header-container {
        display: none !important;
    }
    #header-notification-btn {
        display: none !important;
    }
    .header-brand-wrap {
        display: flex !important;
    }
    .mobile-header-actions {
        display: flex !important;
    }
}

[data-is-native="true"] .sidebar-toggle.desktop-only {
    display: none !important;
}
[data-is-native="true"] .header-breadcrumb {
    display: none !important;
}
[data-is-native="true"] .adsense-header-container {
    display: none !important;
}
[data-is-native="true"] #header-notification-btn {
    display: none !important;
}
[data-is-native="true"] .header-brand-wrap {
    display: flex !important;
}
[data-is-native="true"] .mobile-header-actions {
    display: flex !important;
}

/* Hide tablet subtitle on narrow phone screens (< 600px) */
@media screen and (max-width: 599px) {
    .header-tablet-view {
        display: none !important;
    }
}

/* Extra tight fit for small mobile headers (< 480px) */
@media screen and (max-width: 480px) {
    .theme-btn-text-suffix {
        display: none !important;
    }
    #theme-toggle.header-action-theme-btn,
    .header-action-theme-btn {
        padding: 0 8px !important;
        font-size: 0.65rem !important;
        letter-spacing: 0.5px !important;
    }
    .header-actions {
        gap: 6px !important;
    }
    .mobile-header-actions {
        gap: 4px !important;
    }
}

.sidebar {
    grid-area: sidebar;
    background-color: var(--bg-secondary);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    padding: 0 0 24px 0;
    gap: 0;
    overflow-y: auto;
    z-index: 500;
}

.brand { padding: 0 24px; }
.brand-logo { font-size: 1rem; color: var(--accent); padding-left: 8px; margin: 0; line-height: 1; }

.sidebar-header { 
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px 0 16px; 
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.nav-item {
    padding: 10px 20px 10px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition-standard);
}
.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}
.nav-item.active { border-left: 3px solid var(--accent); }
.nav-item .material-symbols-outlined { text-transform: none !important; }
.nav-item.logout-item {
    border-left: 2px solid rgba(212, 17, 17, 0.7);
    background: rgba(212, 17, 17, 0.08);
    color: var(--accent-red);
    box-shadow: inset 0 0 0 1px rgba(212, 17, 17, 0.25);
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.nav-item.logout-item:hover {
    background: rgba(212, 17, 17, 0.16);
    border-left-color: rgba(212, 17, 17, 0.95);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(212, 17, 17, 0.5), 0 0 10px rgba(212, 17, 17, 0.35);
}
.nav-icon {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
}
.nav-text { font-family: var(--font-tech, monospace); letter-spacing: 0.03em; }

/* ---- Filter Tooltip System ---- */
.filter-label-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}
.filter-help {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(96, 165, 250, 0.12);
    border: 1px solid rgba(96, 165, 250, 0.35);
    color: var(--accent-blue-light, #60a5fa);
    font-size: 0.72rem;
    font-weight: bold;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(96, 165, 250, 0.25);
    user-select: none;
    flex-shrink: 0;
    font-style: normal;
    line-height: 1;
    transition: all 0.15s ease;
}
.filter-help::before {
    content: '';
    position: absolute;
    inset: -8px; /* Expand touch target to 40px */
}
.filter-help:hover, .filter-help.active {
    background: rgba(96, 165, 250, 0.28);
    border-color: var(--accent-blue-light, #60a5fa);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.4);
}
@media (hover: hover) {
    .filter-help::after {
        display: none !important;
    }
}

.main-content {
    grid-area: main;
    padding: 8px 32px 32px 32px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 32px;
    width: 100%;
}

/* Dashboard Information Density */
.dashboard-grid-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    align-items: flex-start;
}

.stats-overview-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stats-group {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    flex-direction: row;
    gap: 16px;
    align-items: stretch;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.stats-group .stat-card {
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 12px;
    min-height: 100px;
    flex: 1;
    box-shadow: none;
}

.stats-group .stat-card:nth-child(2) {
    margin-left: 0;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 8px;
    line-height: 1.4;
    min-height: 120px;
}

.stat-value,
.stat-label,
.stat-help {
    line-height: 1.45;
}

.stat-help {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.9;
}

.stat-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    min-height: 24px;
    padding: 2px 6px;
    color: var(--accent-blue-light, #60a5fa);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-tech, monospace);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(96, 165, 250, 0.25);
    user-select: none;
    border-radius: 4px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.28);
    transition: all 0.15s ease;
    vertical-align: middle;
    margin-left: 5px;
    line-height: 1;
}

.stat-tooltip::before {
    content: '';
    position: absolute;
    inset: -8px; /* Expand touch target to 40px+ */
}

.stat-tooltip:hover, .stat-tooltip:focus, .stat-tooltip.active {
    background: rgba(96, 165, 250, 0.24);
    border-color: var(--accent-blue-light, #60a5fa);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.4);
}

/* stat-tooltip-text is now a hidden data-carrier; actual rendering is done by
   the JS tooltip engine in core.js which appends #hll-tooltip to <body> */
.stat-tooltip-text {
    display: none;
}

/* Global JS-driven tooltip bubble — rendered on <body>, position: fixed */
#hll-tooltip {
    position: fixed;
    z-index: 2147483647; /* max possible z-index */
    max-width: min(320px, calc(100vw - 28px));
    padding: 10px 14px;
    background: rgba(8, 12, 18, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #f1f5f9;
    border: 1px solid rgba(96, 165, 250, 0.45);
    border-radius: 6px;
    font-size: 0.72rem;
    font-family: var(--font-tech, monospace);
    line-height: 1.5;
    white-space: normal;
    box-shadow: 0 8px 32px rgba(0,0,0,0.85), 0 0 15px rgba(96, 165, 250, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform: translateY(4px);
    letter-spacing: 0.03em;
    pointer-events: none !important;
    word-break: break-word;
}

#hll-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.stat-value {
    font-family: var(--font-tech);
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 2px;
    margin-bottom: 4px;
    display: block;
}

/* Data-source attribution badge — shown under auto-fetched fields */
.data-source-badge {
    display: block;
    font-size: 0.55rem;
    color: var(--text-muted);
    font-family: var(--font-tech);
    letter-spacing: 0.04em;
    opacity: 0.65;
    margin-top: 3px;
}

/* Pre-Sweep sub-section group headers */
.env-subsection-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.env-subsection-header .env-subsection-title {
    font-family: var(--font-tech);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.env-subsection-header .env-subsection-source {
    font-family: var(--font-tech);
    font-size: 0.55rem;
    letter-spacing: 0.04em;
    opacity: 0.6;
    margin-left: auto;
}

/* Sections */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-title {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.investigations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Compact Investigation Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.card:hover { 
    border-color: rgba(255, 255, 255, 0.15); 
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    transform: translateY(-2px);
}

#investigation-intake-view .card:hover {
    transform: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.05);
}

.card-media {
    height: 140px;
    background: #000;
    position: relative;
    overflow: hidden;
}

.card-content { padding: 16px; }
.card-title { font-size: 1rem; margin-bottom: 4px; }
.card-location { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 12px; }

.card-metadata {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-tech);
    font-size: 0.7rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

/* Team Panel */
.team-panel {
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    padding: 24px;
}

.team-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.team-member {
    display: flex;
    align-items: center;
    gap: 12px;
}

.member-avatar {
    width: 32px;
    height: 32px;
    background: var(--bg-surface);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--accent);
}

.member-info { display: flex; flex-direction: column; }
.member-name { font-size: 0.85rem; font-weight: 600; }
.member-role { font-size: 0.7rem; color: var(--text-muted); }

/* Storage Sidebar */
.storage-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.storage-card, .processing-card {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.storage-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.storage-bar {
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
}
.storage-fill { background: var(--accent); height: 100%; box-shadow: 0 0 8px var(--accent-glow); }

/* Buttons & UI */
.btn {
    padding: 12px 24px;
    border-radius: 6px !important;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:active:not(:disabled) {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--accent-red);
    color: #fff;
    border: 1px solid var(--accent-red);
}
.btn-primary:hover:not(:disabled) {
    background: #b30e0e;
    border-color: #b30e0e;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-cancel {
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.btn-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning, #f59e0b);
    color: var(--warning, #f59e0b);
}

.btn-warning:hover:not(:disabled) {
    background: var(--warning, #f59e0b);
    color: #0b0f17;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
}

.btn-mic-sample {
    font-size: 0.65rem;
    height: 32px;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(96, 165, 250, 0.12);
    border: 1px solid var(--accent-blue-light);
    color: var(--accent-blue-light);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.5px;
}

.btn-mic-sample:hover:not(:disabled) {
    background: rgba(96, 165, 250, 0.24);
    border-color: #93c5fd;
    color: #fff;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.35);
}

.btn-mic-sample:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-mic-sample.sampling {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4) !important;
    animation: pulse-sampling 1s infinite alternate;
}

@keyframes pulse-sampling {
    0% { opacity: 0.8; transform: scale(0.99); }
    100% { opacity: 1; transform: scale(1.01); }
}

[data-theme="red"] .btn-mic-sample {
    background: rgba(220, 38, 38, 0.15);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

[data-theme="red"] .btn-mic-sample:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.3);
    border-color: #fca5a5;
    color: #fff;
}

.btn:disabled, .btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
    pointer-events: none;
}

.hardware-banner {
    background: rgba(212, 17, 17, 0.1);
    border: 1px solid var(--status-red);
    color: var(--status-red);
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    display: none; /* Hidden by default */
    align-items: center;
    gap: 12px;
    font-family: var(--font-tech);
    font-size: 0.8rem;
    box-shadow: 0 0 20px rgba(212, 17, 17, 0.15);
}

.hardware-banner i {
    font-size: 1.2rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--success);
    animation: pulse-sync 2.5s infinite ease-in-out;
}

@keyframes pulse-sync {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

/* Red Mode Vignette */
/* Investigations List View */
.investigations-list-full {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    grid-auto-rows: min-content;
    align-items: start;
    gap: 20px;
    margin-top: 20px;
}

.investigations-list-full .card {
    height: auto !important;
    align-self: start !important;
}

/* Investigation Detail View (Modular & Tactical) */
.investigation-detail-page {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 32px;
    min-height: calc(100vh - 120px);
}

/* Detail Sidebar */
.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.case-info-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
}

.case-id-badge {
    font-family: var(--font-tech);
    font-size: 0.6rem;
    color: var(--accent);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    display: block;
}

.case-title-large {
    font-family: var(--font-tech);
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 8px 0;
}

.telemetry-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    margin-top: 16px;
}

.telemetry-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.telemetry-label { color: var(--text-muted); font-family: var(--font-tech); }
.telemetry-value { color: var(--text-primary); font-family: var(--font-tech); }

.metadata-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-label {
    font-family: var(--font-tech);
    font-size: 0.6rem;
    color: var(--text-muted);
}

.meta-value {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Evidence Folders */
.evidence-section {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.folder-group {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

.folder-header {
    background: var(--bg-surface);
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.folder-content {
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.evidence-thumb-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition-standard);
}

.evidence-thumb-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.evidence-thumb-visual {
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    position: relative;
}

.evidence-thumb-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
}

.evidence-thumb-info {
    padding: 10px;
    font-size: 0.65rem;
}

.evidence-name {
    display: block;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.evidence-type-tag {
    font-family: var(--font-tech);
    color: var(--accent);
    font-size: 0.55rem;
}


#red-mode-vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 100px rgba(212, 17, 17, 0.2);
    opacity: 0;
    transition: opacity 0.5s;
    z-index: 9999;
}

/* Review Console Styles */
.view {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
}

#investigation-intake-view {
    padding: 24px;
}
#investigation-intake-view .card {
    padding: 24px;
}
#investigation-intake-view {
    position: relative;
    z-index: 1;
    background: transparent;
    padding: 0;
}

#investigation-intake-view > .card {
    max-width: 1200px;
    margin: 0 auto;
}

.review-grid-layout {
    display: grid;
    grid-template-columns: 1fr 380px; /* Slightly narrower right col */
    gap: 24px;
    align-items: start;
}

.media-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    grid-auto-rows: max-content;
    gap: 16px;
    width: 100%;
}

.media-grid-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: var(--transition-standard);
    min-height: 180px;
}

.media-grid-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.media-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    transition: var(--transition-standard);
}

.media-grid-item:hover img {
    opacity: 0.9;
}

/* Media Detail Styles */
.media-detail-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.media-viewer {
    background: #000;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.media-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Technical Overlay */
.viewer-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: radial-gradient(circle, transparent 70%, rgba(0,0,0,0.3) 100%);
}

.overlay-top, .overlay-bottom {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-tech);
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

.overlay-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
}
.overlay-crosshair::before { content: ''; position: absolute; height: 100%; width: 1px; background: rgba(255, 255, 255, 0.1); left: 50%; }
.overlay-crosshair::after { content: ''; position: absolute; width: 100%; height: 1px; background: rgba(255, 255, 255, 0.1); top: 50%; }

/* Audit Log */
.audit-log {
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.audit-entry {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.audit-time { font-family: var(--font-tech); color: var(--accent); white-space: normal; word-break: break-word; }

.annotation-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-input {
    width: 100%;
    background: rgba(10, 12, 16, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 12px 18px;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    transition: var(--transition-standard);
    box-sizing: border-box;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
    appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

select.form-input {
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23999%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 10px auto;
    padding-right: 32px;
}

/* Cyber-Command Dark Theme Dropdown Menu Styling */
select option,
select.form-input option,
.intake-select option {
    background-color: #0d131d !important;
    color: #f3f6fb !important;
    padding: 10px 14px;
    font-family: inherit;
}

select option:hover,
select option:focus,
select option:active,
select option:checked,
select.form-input option:hover,
select.form-input option:focus,
select.form-input option:checked,
.intake-select option:hover,
.intake-select option:focus,
.intake-select option:checked {
    background-color: #1e293b !important;
    color: var(--accent-blue-light, #60a5fa) !important;
}

label {
    display: block;
    font-family: var(--font-tech);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.form-group label,
.grid-2 > div > label,
.grid-3 > div > label {
    margin-bottom: 2px !important;
}

.tech-text-label {
    font-family: var(--font-tech);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
    margin-bottom: 16px; /* Doubled from 8px */
    display: block;
}

.telemetry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.anomaly-toggles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.anomaly-toggles .btn {
    padding: 10px 6px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 2px solid transparent; /* slightly thicker border visually when active */
    white-space: normal;
    line-height: 1.2;
    height: auto;
    min-height: 54px;
}

.anomaly-toggles .btn[data-val="Found"].active {
    background: rgba(212, 17, 17, 0.15) !important;
    color: var(--danger) !important;
    border-color: var(--danger) !important;
    box-shadow: 0 0 16px rgba(212, 17, 17, 0.2);
}

.anomaly-toggles .btn[data-val="None"].active {
    background: rgba(16, 185, 129, 0.15) !important;
    color: var(--success) !important;
    border-color: var(--success) !important;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.2);
}

/* --- AUTH UI: REALM SSO & FIELD LAB THEME --- */
:root {
    --color-primary: #d41111;
    --color-primary-hover: #990d0d;
    --color-gold: #b08d57;
    --color-gold-soft: #e0c49a;
    --color-bg-dark: #080808;
    --color-surface-dark: #121212;
    --color-surface-card: #181818;
    --color-border: rgba(255, 255, 255, 0.1);
}

.auth-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--color-bg-dark);
    background-image: radial-gradient(circle at 50% 25%, #1f0606 0%, #080808 80%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 130000;
    backdrop-filter: blur(14px);
    padding: max(36px, env(safe-area-inset-top, 36px)) 16px max(24px, env(safe-area-inset-bottom, 24px));
    overflow-y: auto;
    box-sizing: border-box;
}

[data-is-native="true"] .auth-overlay {
    padding-top: max(48px, env(safe-area-inset-top, 48px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
}

.login-layout-wrapper {
    width: 100%;
    max-width: 920px;
    display: flex;
    align-items: stretch;
    background: linear-gradient(180deg, rgba(22, 22, 22, 0.96), rgba(12, 12, 12, 0.98));
    border: 1px solid rgba(212, 17, 17, 0.38);
    border-radius: 20px;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.9), 0 0 50px rgba(212, 17, 17, 0.15);
    overflow: hidden;
    backdrop-filter: blur(14px);
    margin: auto;
}

.login-card-shell {
    flex: 1 1 52%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: rgba(14, 14, 14, 0.65);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.realm-info-shell {
    flex: 1 1 48%;
    min-width: 0;
    background: radial-gradient(circle at top right, rgba(212, 17, 17, 0.14) 0%, rgba(10, 10, 10, 0.92) 70%);
    padding: 36px 32px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.realm-info-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 100% 0%, rgba(176, 141, 87, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.realm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(212, 17, 17, 0.15);
    border: 1px solid rgba(212, 17, 17, 0.4);
    color: #ff9b9b;
    font-family: 'Oswald', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 600;
    width: fit-content;
    margin-bottom: 20px;
}

.realm-badge .material-symbols-outlined {
    font-size: 0.95rem;
    color: var(--color-primary);
}

.realm-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
    color: #ffffff;
    margin-bottom: 12px;
}

.realm-title span {
    color: var(--color-gold-soft);
}

.realm-desc {
    color: #a3a3a3;
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 24px;
}

.realm-perks {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 28px;
}

.realm-perk-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.realm-perk-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(176, 141, 87, 0.1);
    border: 1px solid rgba(176, 141, 87, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gold-soft);
}

.realm-perk-icon .material-symbols-outlined {
    font-size: 1.15rem;
}

.realm-perk-content h4 {
    font-family: 'Oswald', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ffffff;
    margin-bottom: 2px;
}

.realm-perk-content p {
    font-size: 0.8rem;
    color: #8e8e8e;
    line-height: 1.35;
}

.realm-footer-note {
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    color: #737373;
    line-height: 1.4;
}

.realm-footer-note .material-symbols-outlined {
    font-size: 1.1rem;
    color: var(--color-gold);
    flex-shrink: 0;
}

.login-header {
    text-align: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-logo-link {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.site-brand-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #ffffff;
    line-height: 1;
}

.site-brand-title span {
    color: var(--color-primary);
}

.site-brand-subtitle {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: #9ca3af;
}

.auth-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
}

.auth-tab-btn {
    flex: 1 1 0%;
    min-width: 0;
    padding: 12px 6px;
    background: transparent;
    border: none;
    color: #9ca3af;
    font-family: 'Oswald', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
    text-align: center;
    box-sizing: border-box;
}

.auth-tab-btn:hover {
    color: #ffffff;
}

.auth-tab-btn.active {
    color: #ffffff;
    background: rgba(212, 17, 17, 0.14);
}

.auth-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-primary);
}

.login-card-shell .card-body {
    padding: 26px 24px;
}

.field-group {
    margin-bottom: 18px;
}

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Oswald', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-gold-soft);
    margin-bottom: 6px;
}

.field-input {
    width: 100%;
    background: #0d0d0d;
    border: 1px solid rgba(176, 141, 87, 0.28);
    border-radius: 8px;
    padding: 12px 14px;
    color: #ffffff;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.field-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
    background: #111111;
}

.field-input::placeholder {
    color: #555555;
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--color-primary) 0%, #b30f0f 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #ffffff;
    font-family: 'Oswald', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 13px 20px;
    min-height: 46px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(212, 17, 17, 0.35);
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.submit-btn:hover {
    background: linear-gradient(135deg, #e01b1b 0%, var(--color-primary-hover) 100%);
    box-shadow: 0 6px 20px rgba(212, 17, 17, 0.5);
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.realm-mobile-footer {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.7rem;
    color: #888888;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .login-layout-wrapper {
        flex-direction: column;
        max-width: 440px;
        width: 100%;
        border-radius: 16px;
        margin: auto;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9), 0 0 30px rgba(212, 17, 17, 0.2);
    }
    .login-card-shell {
        border-right: none;
        border-bottom: 1px solid rgba(212, 17, 17, 0.25);
        width: 100%;
    }
    .login-header {
        padding: 12px 16px 8px;
    }
    .site-brand-title {
        font-size: 1.3rem;
    }
    .login-card-shell .card-body {
        padding: 12px 16px 12px;
    }
    .field-group {
        margin-bottom: 10px;
    }
    .field-label {
        font-size: 0.72rem;
        margin-bottom: 3px;
    }
    .field-input {
        padding: 8px 12px;
        font-size: 0.85rem;
        height: 38px;
    }
    .submit-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
        min-height: 40px;
        margin-top: 2px;
    }
    .auth-tabs {
        height: 38px;
    }
    .auth-tab-btn {
        padding: 8px 4px;
        font-size: 0.76rem;
    }

    /* Sleek, Compact Mobile Realm Info Shell */
    .realm-info-shell {
        display: flex !important;
        padding: 14px 16px 12px;
        background: radial-gradient(circle at top right, rgba(212, 17, 17, 0.16) 0%, rgba(10, 10, 10, 0.96) 80%);
    }
    .realm-badge {
        margin-bottom: 6px;
        padding: 3px 8px;
        font-size: 0.62rem;
    }
    .realm-title {
        font-size: 1.05rem;
        margin-bottom: 2px;
    }
    .realm-desc {
        font-size: 0.74rem;
        margin-bottom: 10px;
        line-height: 1.3;
    }
    .realm-perks {
        gap: 6px;
        margin-bottom: 10px;
    }
    .realm-perk-item {
        gap: 8px;
        align-items: center;
    }
    .realm-perk-icon {
        width: 26px;
        height: 26px;
        min-width: 26px;
        min-height: 26px;
        border-radius: 6px;
    }
    .realm-perk-icon .material-symbols-outlined {
        font-size: 0.9rem;
    }
    .realm-perk-content h4 {
        font-size: 0.74rem;
        margin-bottom: 0px;
    }
    .realm-perk-content p {
        font-size: 0.68rem;
        line-height: 1.2;
    }
    .realm-footer-note {
        padding-top: 8px;
        font-size: 0.65rem;
        gap: 6px;
        margin-top: 2px;
    }
}

.auth-subtitle {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-family: var(--font-tech);
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 60px 48px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px; /* Slightly softer for native app feel */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Corner HUD accents */
.auth-card::before, .auth-card::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent);
    opacity: 0.5;
}
.auth-card::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.auth-card::after { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

.auth-card h2 {
    font-size: 1.8rem;
    margin-bottom: 4px;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
    font-weight: 800;
    letter-spacing: 0.1em;
}

.auth-subtitle {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 40px;
    font-family: var(--font-tech);
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.input-group {
    margin-bottom: 24px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 0.65rem;
    font-family: var(--font-tech);
    color: var(--text-muted);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.auth-card .form-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 14px;
    color: #fff;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.auth-card .form-input:focus {
    background: rgba(0, 0, 0, 0.5);
    border-bottom-color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
    outline: none;
}

/* TOOLTIP SYSTEM */
[data-tooltip] {
    position: relative;
    cursor: help;
    z-index: 1;
}

[data-tooltip]:hover {
    z-index: 9999;
}

[data-tooltip]::before,
[data-tooltip]:hover::before {
    display: none !important;
}

.btn-block {
    width: 100%;
    padding: 18px;
    margin-top: 15px;
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 800;
    transition: 0.3s;
}

.btn-block:hover {
    letter-spacing: 0.2em;
    filter: brightness(1.2);
}

/* Form Styles */
/* Handled by .form-input above */

textarea.form-input {
    resize: vertical;
}

.telemetry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}


.auth-toggle {
    margin-top: 32px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: var(--font-tech);
}

.auth-toggle a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    margin-left: 8px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
}

/* --- Mobile Responsiveness --- */
@media screen and (max-width: 1100px) {
    .main-with-sidebar {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 992px) {
    .dashboard-grid-layout,
    .review-grid-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

.desktop-hide { display: none !important; }

@media screen and (max-width: 768px) {
    /* Explicitly hide redundant nav items in the mobile drawer */
    .stitch-sidebar .nav-item.mobile-hide,
    .stitch-sidebar .tools-nav-group.mobile-hide,
    .stitch-sidebar .tools-nav-group {
        display: none !important;
    }
    /* Show / hide utilities */
    .mobile-only { display: block !important; }
    .mobile-hide { display: none !important; }
    .mobile-show-flex { display: flex !important; }
    .desktop-hide { display: flex !important; }

    /* Make stitch-sidebar an overlay on mobile */
    .stitch-sidebar {
        position: fixed;
        top: 0;
        bottom: 0; /* Cover entire height */
        right: 0;
        width: min(85vw, 320px);
        z-index: 100120;
        background: #0f172a;
        border-left: 1px solid rgba(255, 255, 255, 0.08);
        transform: translateX(110%);
        visibility: hidden;
        pointer-events: none;
        box-shadow: none !important;
        opacity: 0;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s ease, opacity 0.3s ease;
        display: flex;
        flex-direction: column;
        padding: 0;
        overflow-y: auto;
    }

    .stitch-sidebar.active {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        box-shadow: -20px 0 50px rgba(0, 0, 0, 0.6) !important;
        opacity: 1;
    }

    .stitch-sidebar-logo {
        margin-bottom: 20px;
        align-self: flex-start;
    }

    .stitch-sidebar-logo svg {
        width: 30px;
        height: 30px;
    }

    .stitch-sidebar-nav {
        gap: 10px;
        align-items: stretch;
    }

    .stitch-nav-item {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        width: 100%;
        min-height: 48px;
        padding: 12px 12px;
        border-left: none;
        border-radius: 14px;
        border: 1px solid rgba(255, 255, 255, 0.12);
        background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.02));
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03), 0 6px 14px rgba(0,0,0,0.28);
        box-sizing: border-box;
    }

    .stitch-nav-item svg {
        flex: 0 0 auto;
        width: 18px;
        height: 18px;
    }

    .stitch-nav-item span {
        font-size: 0.68rem;
        letter-spacing: 0.08em;
        text-align: left;
        flex: 1;
    }

    .stitch-nav-item.active {
        color: #fff;
        border-left-color: transparent;
        border-color: rgba(212, 17, 17, 0.42);
        background: linear-gradient(180deg, rgba(212, 17, 17, 0.24), rgba(212, 17, 17, 0.09));
        box-shadow: inset 0 0 0 1px rgba(212, 17, 17, 0.24), 0 10px 22px rgba(0,0,0,0.32);
    }

    .stitch-sidebar-bottom {
        justify-content: stretch;
        margin-top: 10px;
        width: 100%;
    }

    .mobile-action-btn {
        background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: #f0f4ff;
        width: 38px;
        height: 38px;
        border-radius: 14px;
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05), 0 8px 18px rgba(0,0,0,0.3);
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .btn {
        border: 1px solid rgba(255, 255, 255, 0.18);
        background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
        color: #f0f4ff;
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 8px 18px rgba(0,0,0,0.3);
    }

    .btn-primary {
        border-color: rgba(212, 17, 17, 0.75);
        background: linear-gradient(180deg, #d41111, #8f0c0c);
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 10px 22px rgba(212, 17, 17, 0.45);
    }

    .btn-secondary,
    .btn-ghost {
        border-color: rgba(255, 255, 255, 0.22);
        background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
    }

    .btn:active:not(:disabled) {
        transform: translateY(1px) scale(0.98);
    }
    
    .mobile-action-btn svg {
        pointer-events: none;
    }

    .mobile-action-btn .icon-close {
        display: none;
    }

    .mobile-action-btn.is-open .icon-menu {
        display: none;
    }

    .mobile-action-btn.is-open .icon-close {
        display: block;
    }
    
    .mobile-action-btn:active {
        background: rgba(255, 255, 255, 0.12);
        transform: scale(0.95);
    }
    
    .sidebar-backdrop {
        background: rgba(0, 0, 0, 0.65) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
    }

    /* Force app-like fixed height with no body scroll */
    html {
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    body {
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        overflow-x: hidden !important;
        position: fixed !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    .app-container {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        overflow-x: hidden !important;
        background: var(--bg-primary);
        box-sizing: border-box !important;
    }

    .main-content {
        flex: 1 !important;
        padding: 12px !important;
        padding-left: calc(12px + env(safe-area-inset-left, 0px)) !important;
        padding-right: calc(12px + env(safe-area-inset-right, 0px)) !important;
        padding-bottom: var(--bottom-clearance) !important;
        scroll-padding-bottom: var(--bottom-clearance);
        overflow-y: auto !important;
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        -webkit-overflow-scrolling: touch;
        display: block !important;
    }

    .view {
        padding: 0 !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
    }

    .case-details-layout {
        padding: 0 !important;
        margin: 0 auto !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .card,
    .stitch-card,
    .stitch-case-card {
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Fixed Header with Robust Notch Support */
    .header {
        flex-shrink: 0 !important;
        padding-top: env(safe-area-inset-top, 0) !important;
        height: calc(var(--header-height) + env(safe-area-inset-top, 0)) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding-left: calc(16px + env(safe-area-inset-left, 0px)) !important;
        padding-right: calc(16px + env(safe-area-inset-right, 0px)) !important;
        background: var(--bg-secondary) !important;
        border-bottom: 1px solid var(--border-color) !important;
        z-index: 1000 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        position: sticky !important;
        top: 0 !important;
    }

    /* Testing Banner Responsive */
    #testing-tools-banner {
        margin: 8px 12px !important;
        flex-shrink: 0 !important;
    }

    .header-left {
        gap: 12px !important;
    }

    /* Reset ALL grids to 1 column and prevent horizontal growth */
    .grid-2, .grid-3, .stats-overview-row, .metadata-grid, .telemetry-grid,
    .dashboard-grid-layout, .review-grid-layout,
    .investigation-detail-page, .responsive-grid, .main-with-sidebar {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 16px !important;
        overflow-x: hidden !important;
        height: auto !important; /* Allow growing */
    }

    /* Ensure Map in Locations View has height when stacked */
    #locations-view .main-with-sidebar > div:last-child {
        height: 400px !important;
        min-height: 400px;
        flex-shrink: 0;
    }

    /* Ensure Site Directory in Locations View doesn't take too much space before map */
    #locations-view .main-with-sidebar > div:first-child {
        max-height: 300px;
        overflow-y: auto;
    }

    .stat-card, .card {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .auth-card {
        padding: 40px 24px !important;
    }

    .form-footer { position: sticky; bottom: -24px; background: rgba(10, 14, 20, 0.98); z-index: 100; box-shadow: 0 -10px 20px rgba(0,0,0,0.5); margin-left: -24px; margin-right: -24px; padding: 20px 24px; 
        justify-content: center !important;
        margin-bottom: 20px !important;
    }

    .form-footer button {
        width: 100% !important;
        margin-bottom: 8px !important;
    }

    /* Mobile Navigation — Bottom Bar */
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: calc(64px + env(safe-area-inset-bottom, 0));
        z-index: 15000;
        background: var(--bg-secondary);
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        border-right: none;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-top: 0;
        overflow: hidden;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        padding: 0;
    }

    .sidebar-nav .nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 0;
        gap: 6px;
        min-height: auto;
    }
    
    .sidebar-nav .nav-item:hover, .sidebar-nav .nav-item.active {
        border-left: none;
        border-bottom: 2px solid var(--accent);
        background: transparent;
    }
    
    .nav-icon {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .nav-text {
        font-size: 0.6rem;
        letter-spacing: 0;
    }

    .sidebar-header, .sidebar-footer {
        display: none !important;
    }

    .sidebar.active {
        left: 0;
        box-shadow: 4px 0 30px rgba(0,0,0,0.6);
    }

    /* Dim overlay when sidebar is open */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 100110;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .sidebar-backdrop.active {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-toggle {
        display: none !important;
    }

    .main-content {
        padding: 16px;
        padding-bottom: var(--bottom-clearance);
        scroll-padding-bottom: var(--bottom-clearance);
    }

    .stats-overview-row {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 20px;
    }

    /* Collapse all two-column grids */
    .grid-2,
    .grid-3,
    .stats-overview-row,
    .metadata-grid,
    .telemetry-grid,
    .anomaly-toggles,
    .dashboard-grid-layout,
    .review-grid-layout,
    .investigation-detail-page {
        grid-template-columns: 1fr !important;
    }

    /* Keep two-column for very compact checkbox lists */
    .checkbox-grid-2 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Intake view */
    #investigation-intake-view {
        left: auto;
        top: auto;
    }

    /* Investigation log — collapse sidebar to top */
    #investigation-log-view > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Log sticky panel: un-stick on mobile */
    #investigation-log-view [style*="position: sticky"] {
        position: relative !important;
        top: unset !important;
    }

    /* Case detail hero */
    .case-main-content,
    .case-sidebar {
        width: 100% !important;
    }

    /* Investigation card header actions — wrap */
    .card-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .stats-group {
        flex-direction: column;
    }

    /* Touch-friendly targets */
    .btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    .form-input,
    select.form-input {
        min-height: 44px;
        font-size: 1rem; /* Prevent iOS auto-zoom */
    }

    textarea.form-input {
        font-size: 1rem;
    }

    .nav-item {
        min-height: 48px;
        padding: 12px 20px;
    }

    /* Section header wraps on narrow screens */
    .section-header {
        flex-wrap: wrap;
        gap: 10px;
    }
}

@media screen and (max-width: 480px) {
    html { font-size: 16px; }

    .stats-overview-row {
        grid-template-columns: 1fr;
    }

    .investigations-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .auth-card {
        padding: 40px 24px;
    }

    /* Log category+input row stacks */
    #investigation-log-view [style*="grid-template-columns: auto 1fr auto"] {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    #investigation-log-view [style*="grid-template-columns: auto 1fr auto"] select {
        width: 100% !important;
    }
    #investigation-log-view [style*="grid-template-columns: auto 1fr auto"] input {
        flex: 1 !important;
        min-width: 0 !important;
    }
}


/* --- Tactical Map HUD markers --- */
.map-marker {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    z-index: 10;
}
.marker-core {
    width: 100%;
    height: 100%;
    background: var(--accent-blue-light);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-blue-light);
}
.marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: rgba(0, 150, 255, 0.1);
    border: 1px solid var(--accent-blue-light);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: marker-pulse-anim 2s infinite;
}
.map-marker.anomaly .marker-core {
    background: var(--status-red);
    box-shadow: 0 0 12px var(--status-red);
}
.map-marker.anomaly .marker-pulse {
    background: rgba(212, 17, 17, 0.1);
    border-color: var(--status-red);
}
@keyframes marker-pulse-anim {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.location-item {
    transition: var(--transition-standard);
    border-radius: 4px;
}
.location-item:hover {
    background: rgba(0, 150, 255, 0.05) !important;
    border-color: var(--accent-blue-light) !important;
}
.location-item.active {
    background: rgba(0, 150, 255, 0.1) !important;
    border-color: var(--accent-blue-light) !important;
    box-shadow: inset 0 0 10px rgba(0, 150, 255, 0.1);
}


.main-with-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
    gap: 24px;
    align-items: start;
    width: 100%;
    min-width: 0;
}

#audio-lab-view .main-with-sidebar {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
}

.main-with-sidebar > * {
    min-width: 0;
}

.workspace-sidebar {
    min-width: 0;
    max-width: 100%;
    width: 100%;
}

.workspace-sidebar > * {
    min-width: 0;
}

@media screen and (max-width: 1100px) {
    .main-with-sidebar {
        grid-template-columns: 1fr;
    }
}

#theme-toggle {
    transition: var(--transition-standard);
}

#theme-toggle:hover {
    background: rgba(212, 17, 17, 0.1) !important;
    border-color: var(--accent-red) !important;
    color: #fff !important;
}

#sync-indicator {
    width: auto;
    height: 36px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 12px;
    border-radius: 18px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.28);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    opacity: 0.95;
    cursor: pointer;
    transition: opacity 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

#sync-indicator:hover {
    opacity: 1 !important;
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.45) !important;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.25) !important;
}

#sync-indicator .status-dot {
    width: 7px;
    height: 7px;
    min-width: 7px;
    min-height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
    background: currentColor;
}

#sync-indicator .sync-indicator-label,
#sync-indicator .mobile-hide,
#sync-indicator span:not(.status-dot) {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    line-height: 1;
    font-family: var(--font-tech, monospace);
    color: var(--success, #10b981);
}

/* On phones / narrow screens (< 600px), collapse sync indicator to clean circular icon */
@media (max-width: 599px) {
    #sync-indicator {
        width: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        justify-content: center !important;
        gap: 0 !important;
    }
    #sync-indicator .sync-indicator-label,
    #sync-indicator .mobile-hide,
    #sync-indicator span:not(.status-dot) {
        display: none !important;
    }
}

.investigation-detail-header {
    background-size: cover;
    background-position: center;
    padding: 40px;
    border-bottom: 2px solid var(--border-color);
    position: relative;
    transition: opacity 0.3s ease;
}

.header-action-buttons {
    position: absolute;
    bottom: 20px;
    right: 40px;
    display: flex;
    gap: 12px;
    z-index: 2;
}

@media screen and (max-width: 768px) {
    /* Explicitly hide redundant nav items in the mobile drawer */
    .stitch-sidebar .nav-item.mobile-hide,
    .stitch-sidebar .tools-nav-group.mobile-hide,
    .stitch-sidebar .tools-nav-group {
        display: none !important;
    }
    .investigation-detail-header {
        padding: 20px;
    }

    .header-action-buttons {
        position: static;
        margin-top: 20px;
        flex-direction: column;
        width: 100%;
    }

    .header-action-buttons button {
        width: 100%;
    }

    .investigation-detail-header h1 {
        font-size: 1.8rem !important;
    }
}

.case-details-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Case Detail — Desktop Map & Scheduled Time Side-by-Side */
.case-map-schedule-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch;
    margin-bottom: 24px;
}

.case-map-card {
    min-height: 260px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.case-schedule-card {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

@media screen and (max-width: 900px) {
    .case-map-schedule-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .case-map-card {
        min-height: 220px;
    }
}

/* Site map card header (map previously had no title and blended into the page) */
.case-map-card {
    border: 1px solid rgba(96, 165, 250, 0.3);
}
.case-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(90deg, rgba(96, 165, 250, 0.14), rgba(96, 165, 250, 0.03));
    border-bottom: 1px solid rgba(96, 165, 250, 0.3);
}
.case-map-title {
    font-size: 0.85rem;
    color: var(--accent-blue-light);
    margin: 0;
    letter-spacing: 1px;
}
.case-map-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media screen and (max-width: 768px) {
    .card.case-map-card {
        padding: 0 !important;
    }
}

/* Evidence Archive featured panel */
.evidence-archive-panel {
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-top: 3px solid var(--accent-blue-light);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 24px rgba(96, 165, 250, 0.08);
}
.evidence-archive-panel > .evidence-archive-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: -20px -20px 0;
    padding: 16px 20px;
    background: linear-gradient(90deg, rgba(96, 165, 250, 0.14), rgba(96, 165, 250, 0.02));
    border-bottom: 1px solid rgba(96, 165, 250, 0.25);
}
.evidence-archive-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.evidence-archive-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    font-size: 1.25rem;
    border-radius: 8px;
    background: rgba(96, 165, 250, 0.12);
    border: 1px solid rgba(96, 165, 250, 0.35);
}
.evidence-archive-title {
    font-size: 1.05rem;
    margin: 0;
    color: var(--accent-blue-light);
    letter-spacing: 1.5px;
}
.evidence-archive-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.evidence-archive-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
@media screen and (max-width: 768px) {
    .evidence-archive-panel {
        padding: 14px;
    }
    .evidence-archive-panel > .evidence-archive-header {
        margin: -14px -14px 0;
        padding: 14px;
    }
    .evidence-archive-actions {
        width: 100%;
    }
    .evidence-archive-actions .btn {
        flex: 1 1 auto;
    }
}

@media screen and (max-width: 1024px) {
    .case-details-layout {
        grid-template-columns: 1fr;
        padding: 16px;
    }
}

/* Leaflet Dark High-Tech Map Overrides */
.leaflet-container {
    background-color: #0a0e14 !important;
    font-family: var(--font-tech, monospace) !important;
    outline: none;
}
.leaflet-tile-pane {
    filter: none;
}
.leaflet-bar {
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.6) !important;
    border-radius: 4px !important;
    overflow: hidden;
}
.leaflet-bar a {
    background-color: rgba(14, 18, 26, 0.92) !important;
    color: var(--accent-blue-light, #60a5fa) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    transition: all 0.2s ease;
}
.leaflet-bar a:hover {
    background-color: rgba(30, 41, 59, 0.98) !important;
    color: #fff !important;
}
.leaflet-popup-pane,
.leaflet-popup {
    z-index: 1000 !important;
}
.leaflet-popup-content-wrapper {
    background: #0d1117 !important;
    color: var(--text-primary, #f3f6fb) !important;
    border: 1px solid var(--border-color, rgba(255,255,255,0.12)) !important;
    border-radius: 6px !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.95), 0 0 1px rgba(255, 255, 255, 0.2) !important;
    opacity: 1 !important;
}
.leaflet-popup-tip {
    background: #0d1117 !important;
    opacity: 1 !important;
}

/* Radar Sweeper Animation Overlay */
.radar-sweeper {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    transform-origin: 50% 50%;
    opacity: 1 !important;
    background:
        radial-gradient(circle at 50% 50%, transparent 0 18%, rgba(56, 189, 248, 0.16) 18.2% 18.5%, transparent 18.8% 36%, rgba(56, 189, 248, 0.12) 36.2% 36.5%, transparent 36.8% 54%, rgba(56, 189, 248, 0.1) 54.2% 54.5%, transparent 54.8%),
        linear-gradient(rgba(56, 189, 248, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, transparent, transparent);
    background-size: auto, 64px 64px, 64px 64px, auto;
    mix-blend-mode: screen;
    pointer-events: none;
    z-index: 390;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* Suppress radar overlay when popup card is displayed so card is 100% clear & unobstructed */
.locations-map-wrapper:has(.leaflet-popup) .radar-sweeper,
.radar-sweeper.radar-suppressed {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.radar-sweeper::before {
    content: '';
    position: absolute;
    inset: -100%;
    background: conic-gradient(from 0deg at 50% 50%,
        transparent 0deg,
        transparent 332deg,
        rgba(56, 189, 248, 0.04) 336deg,
        rgba(56, 189, 248, 0.32) 348deg,
        rgba(186, 230, 253, 0.62) 359deg,
        transparent 360deg);
    animation: radar-spin 6s linear infinite;
    transform-origin: 50% 50%;
    pointer-events: none;
}

@keyframes radar-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes update-progress {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

#update-dots {
    display: inline-block;
    width: 24px;
    text-align: left;
}

@keyframes radar-spin {
    0% { transform: scale(1.5) rotate(0deg); }
    100% { transform: scale(1.5) rotate(360deg); }
}
/* Safety Banner */
.safety-banner { 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    z-index: 10000; 
    padding: 12px 24px; 
    color: #fff; 
    text-align: center; 
    font-family: var(--font-tech); 
    font-size: 0.9rem; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); 
    pointer-events: none; 
}
/* --- Update System UI --- */
.update-prompt-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(40px + env(safe-area-inset-top, 0));
    padding-top: env(safe-area-inset-top, 0);
    background: #0f1722;
    opacity: 1;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

/* Force hide update prompt in native mobile environments */
[data-is-native="true"] .update-prompt-bar {
    display: none !important;
}
[data-is-native="true"] body.has-update-prompt {
    padding-top: 0 !important;
}
/* ============================================================
   Native (Capacitor APK) Overrides
   Force sidebar into overlay mode + always show hamburger
   ============================================================ */
[data-is-native="true"] .app-container {
    height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-x: hidden !important;
}

/* ============================================================
   Room Scanner Active: Viewfinder Overlay Mode
   Completely hides underlying app containers so native camera shines through
   ============================================================ */
html.room-scanner-active,
body.room-scanner-active {
    background: transparent !important;
    background-color: transparent !important;
}

body.room-scanner-active [data-is-native="true"] .app-container,
body.room-scanner-active .app-container,
body.room-scanner-active #main-app,
body.room-scanner-active #view-container,
body.room-scanner-active .view,
body.room-scanner-active .stitch-sidebar,
body.room-scanner-active .stitch-bottom-nav,
body.room-scanner-active .mobile-bottom-nav,
body.room-scanner-active #app-bottom-nav,
body.room-scanner-active #app-splash-loader,
body.room-scanner-active #auth-overlay {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

body.room-scanner-active #room-scanner-modal,
body.room-scanner-active #room-scanner-preview-container {
    background: transparent !important;
    background-color: transparent !important;
}

/* Force mobile navigation style on native regardless of orientation/width */
[data-is-native="true"] .stitch-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 110px !important;
    right: 0 !important;
    width: min(85vw, 300px) !important;
    min-width: 0 !important;
    max-width: none !important;
    z-index: 100120 !important;
    background: rgba(14, 18, 26, 0.99) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-top-left-radius: 20px !important;
    border-bottom-left-radius: 20px !important;
    transform: translateX(110%) !important;
    visibility: hidden !important;
    pointer-events: none !important;
    box-shadow: none !important;
    opacity: 0 !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease, opacity 0.28s ease !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    backdrop-filter: blur(40px) !important;
}

[data-is-native="true"] .stitch-sidebar.active {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
    box-shadow: -15px 0 35px rgba(0, 0, 0, 0.8) !important;
    opacity: 1 !important;
}

[data-is-native="true"] .stitch-sidebar-logo {
    margin-bottom: 0 !important;
    height: calc(var(--header-height) + env(safe-area-inset-top, 0px)) !important;
    padding: env(safe-area-inset-top, 0px) 16px 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.02) !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    position: relative !important;
    border-bottom: none !important;
}

.mobile-close-btn {
    display: none !important;
    background: rgba(212, 17, 17, 0.15) !important;
    border: 1px solid rgba(212, 17, 17, 0.35) !important;
    color: var(--accent-red) !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 18px rgba(0,0,0,0.22) !important;
    justify-content: center !important;
    align-items: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
}

[data-is-native="true"] .mobile-close-btn {
    display: flex !important;
}

.mobile-close-btn svg {
    width: 20px !important;
    height: 20px !important;
    stroke: currentColor !important;
    pointer-events: none !important;
}

.mobile-close-btn:active {
    background: rgba(212, 17, 17, 0.3) !important;
    transform: scale(0.95);
}

/* Faded Line Break */
.sidebar-divider {
    height: 1px !important;
    width: 100% !important;
    margin: 6px 0 !important;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.22) 50%, transparent 100%) !important;
    border: none !important;
    display: block !important;
}

/* Slideout Menu Item Cards - Compact & Sleek */
[data-is-native="true"] .stitch-sidebar-nav {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 12px 12px 0 12px !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

[data-is-native="true"] .stitch-sidebar-bottom {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 10px 12px 14px 12px !important;
    margin-top: auto !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item:not(.mobile-hide) {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
    box-sizing: border-box !important;
    transition: all 0.18s ease !important;
    text-decoration: none !important;
    color: var(--text-primary, #ffffff) !important;
    flex: 0 0 auto !important;
    flex-grow: 0 !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item:not(.mobile-hide):hover {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item:not(.mobile-hide).active {
    background: rgba(96, 165, 250, 0.12) !important;
    border-color: rgba(96, 165, 250, 0.4) !important;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.15) !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
    color: var(--text-muted, #94a3b8) !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item:hover svg,
[data-is-native="true"] .stitch-sidebar .stitch-nav-item.active svg {
    color: var(--accent-blue-light, #60a5fa) !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item span {
    font-family: var(--font-tech, monospace) !important;
    font-size: 0.76rem !important;
    font-weight: 600 !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
    color: #e2e8f0 !important;
    text-align: left !important;
    flex: 1 !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item:hover span,
[data-is-native="true"] .stitch-sidebar .stitch-nav-item.active span {
    color: #ffffff !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item:active {
    transform: scale(0.98) !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item.logout-item {
    border-color: rgba(212, 17, 17, 0.25) !important;
    background: rgba(212, 17, 17, 0.08) !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item.logout-item svg,
[data-is-native="true"] .stitch-sidebar .stitch-nav-item.logout-item span {
    color: #ef4444 !important;
}

[data-is-native="true"] .stitch-sidebar .stitch-nav-item.logout-item:hover,
[data-is-native="true"] .stitch-sidebar .stitch-nav-item.logout-item:active {
    background: rgba(212, 17, 17, 0.18) !important;
    border-color: rgba(212, 17, 17, 0.45) !important;
}

[data-is-native="true"] .mobile-hide,
[data-is-native="true"] .stitch-sidebar .tools-nav-group {
    display: none !important;
}

[data-is-native="true"] .desktop-hide {
    display: flex !important;
}

[data-is-native="true"] .bottom-nav-bar {
    display: grid !important;
}

[data-is-native="true"] .mobile-header-toggle,
[data-is-native="true"] .mobile-header-actions {
    display: flex !important;
}

[data-is-native="true"] .sidebar-backdrop {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
    background: rgba(0, 0, 0, 0.65) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 100110 !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease !important;
}

[data-is-native="true"] .sidebar-backdrop.active {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Main content fills the full width since sidebar is an overlay */
[data-is-native="true"] .main-content {
    grid-area: unset !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 1 !important;
    min-height: 0 !important;
    padding-left: calc(12px + env(safe-area-inset-left, 0px)) !important;
    padding-right: calc(12px + env(safe-area-inset-right, 0px)) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

[data-is-native="true"] .header {
    grid-area: unset !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-shrink: 0 !important;
    padding-top: env(safe-area-inset-top, 0) !important;
    height: calc(var(--header-height) + env(safe-area-inset-top, 0)) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding-left: calc(16px + env(safe-area-inset-left, 0px)) !important;
    padding-right: calc(16px + env(safe-area-inset-right, 0px)) !important;
    box-sizing: border-box !important;
}


.update-prompt-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.update-prompt-content span {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
}

.update-prompt-actions {
    display: flex;
    gap: 8px;
}

.update-prompt-actions .btn {
    font-size: 0.65rem;
    padding: 4px 12px;
    height: 24px;
}

.update-prompt-actions .btn-ghost {
    color: #fff;
    border-color: rgba(255,255,255,0.4);
}

.update-prompt-actions .btn-update-yes {
    background: #10b981 !important;
    color: #fff !important;
    border: 1px solid #059669 !important;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
    transition: all 0.2s ease;
}

.update-prompt-actions .btn-update-yes:hover {
    background: #059669 !important;
    transform: scale(1.08);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
    border-color: #34d399 !important;
}

.update-prompt-actions .btn-ghost:hover {
    background: rgba(255,255,255,0.1);
}

.updating-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.updating-content {
    text-align: center;
}

.updating-text {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: 4px;
}

.updating-subtext {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.dots::after {
    content: '';
    display: inline-block;
    animation: updateDots 1.5s infinite;
    width: 24px;
    text-align: left;
}

@keyframes updateDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Push app down if prompt is visible */
body.has-update-prompt {
    padding-top: calc(40px + env(safe-area-inset-top, 0));
}

body.has-update-prompt .app-container {
    height: calc(100vh - 40px - env(safe-area-inset-top, 0));
}

body.has-update-prompt .sidebar {
    top: calc(40px + env(safe-area-inset-top, 0));
}
/* --- RESPONSIVE UTILITIES --- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.grid-col-full { grid-column: 1 / -1; }

.responsive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

@media screen and (max-width: 1024px) {
    #settings-view .grid-2 {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media screen and (max-width: 768px) {
    /* Explicitly hide redundant nav items in the mobile drawer */
    .stitch-sidebar .nav-item.mobile-hide,
    .stitch-sidebar .tools-nav-group.mobile-hide,
    .stitch-sidebar .tools-nav-group {
        display: none !important;
    }
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .view {
        padding: 12px !important;
    }

    .card {
        padding: 16px !important;
    }

    /* Handle specific intake form containers */
    #investigation-intake-view .grid-2 {
        grid-template-columns: 1fr !important;
    }
}

/* Sidebar Toggle — hidden on desktop, shown via media query */
.sidebar-toggle {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex !important;
    }
}

body.has-update-prompt .sidebar-backdrop {
    top: 40px;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

#update-dots::after, #boot-dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

#sync-dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

.stat-tooltip.left-edge .stat-tooltip-text {
    left: 0;
    transform: translateX(0);
}

.stat-tooltip.right-edge .stat-tooltip-text {
    left: auto;
    right: 0;
    transform: translateX(0);
}

/* Premium Custom Themed Scrollbars - Ultra thin mobile app feel */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Scrollbar support for Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
@keyframes pulse-glow { from { box-shadow: 0 0 5px var(--accent); } to { box-shadow: 0 0 20px var(--accent); border-color: var(--accent); } }

/* --- Locations Page Enhancements --- */
.map-filter-group {
    display: flex;
    flex-wrap: wrap;
}

.map-filter-group [data-filter="near-me"] {
    margin-left: auto;
    gap: 6px;
}

.map-filter-group [data-filter="near-me"] .material-symbols-outlined {
    font-size: 18px;
}

@media (max-width: 1024px) {
    #locations-view .map-filter-group {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        box-sizing: border-box;
    }

    #locations-view .map-filter-group .filter-btn {
        min-width: 0;
        min-height: 44px !important;
        padding: 8px 4px !important;
    }

    #locations-view .map-filter-group [data-filter="near-me"] {
        grid-column: 1 / -1;
        width: 100%;
        margin-left: 0;
    }
}

.locations-main-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    height: 100%;
}

@media screen and (max-width: 992px) {
    .locations-main-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .locations-sidebar {
        order: 2;
        max-height: none !important;
    }
    .locations-map-wrapper {
        order: 1;
        min-height: 400px !important;
    }
    #site-count-badge {
        display: inline-block;
    }
}

.map-filter-group .filter-btn {
    border: 1px solid transparent;
    opacity: 0.7;
    transition: all 0.3s ease;
    color: var(--text-muted);
}

.map-filter-group .filter-btn.active {
    opacity: 1 !important;
    background: var(--accent) !important;
    color: #fff !important;
    border-color: rgba(255,255,255,0.2) !important;
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

@media screen and (max-width: 480px) {
    .locations-sidebar {
        padding: 0 !important;
    }
    .location-item {
        padding: 10px !important;
        margin-bottom: 8px !important;
    }
    .location-item .tech-text {
        font-size: 0.75rem !important;
    }
    .location-item div[style*="font-size: 0.65rem"] {
        font-size: 0.6rem !important;
    }
}

/* =========================================================
   NATIVE APP UI POLISH OVERRIDES
   ========================================================= */

/* 1. Button Micro-Animations */
.btn:active, button:active {
    transform: scale(0.97) !important;
    transition: transform 0.05s ease;
}

/* 2. Custom Checkboxes & Radio Buttons */
input[type="checkbox"],
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    outline: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
    margin: 0;
    vertical-align: middle;
}

input[type="radio"] {
    border-radius: 50%;
}

/* Checked State: Glow and Accent */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background: var(--accent-blue-light);
    border-color: var(--accent-blue-light);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.4), inset 0 1px 2px rgba(0,0,0,0.3);
}

/* Custom Checkmark for Checkbox */
input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid #0a0e14;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Custom Dot for Radio */
input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #0a0e14;
}

/* 3. Disable Default Browser Focus Ring and Add Custom App Glow */
*:focus {
    outline: none !important;
}

.form-input:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
textarea:focus,
select:focus {
    border-color: var(--accent-blue-light) !important;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.15), inset 0 1px 3px rgba(0,0,0,0.5) !important;
    background: rgba(0, 0, 0, 0.6) !important;
}

/* Special Focus for Buttons */
.btn:focus-visible {
    box-shadow: 0 0 0 2px #121212, 0 0 0 4px var(--accent-blue-light) !important;
}
/* Intake Form Tabs */
.intake-tabs {
    display: flex;
    gap: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
    /* Hide scrollbar for tabs */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.intake-tabs::-webkit-scrollbar {
    display: none;
}
.intake-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-tech);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}
.intake-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}
.intake-tab-btn.active {
    color: var(--warning);
    border-bottom: 2px solid var(--warning);
    font-weight: bold;
}
.intake-tab-content {
    display: none;
    animation: fadeInTab 0.3s ease forwards;
}
.intake-tab-content.active {
    display: block;
}
@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}


/* --- CUSTOM TWEAKS --- */
input[type='radio'], input[type='checkbox'] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.05);
    outline: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
    margin: 0;
    vertical-align: middle;
}

input[type='radio'] {
    border-radius: 50%;
}

input[type='checkbox'] {
    border-radius: 4px;
}

input[type='checkbox']:checked,
input[type='radio']:checked {
    background: var(--accent-red);
    border-color: var(--accent-red);
    box-shadow: 0 0 12px rgba(212, 17, 17, 0.4), inset 0 1px 2px rgba(0,0,0,0.3);
}

input[type='checkbox']:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type='radio']:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffffff;
}

::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

::-webkit-inner-spin-button, ::-webkit-outer-spin-button {
  filter: invert(1);
  opacity: 1;
}

select.form-input {
  min-height: 38px;
  padding: 8px 12px;
}


/* --- UI STANDARDIZATION --- */
.form-section-title, .env-subsection-header .env-subsection-title {
    color: var(--accent-blue-light) !important;
}
.tech-text-label {
    color: var(--text-muted) !important;
    font-size: 0.7rem !important;
    font-family: var(--font-tech, monospace) !important;
    text-transform: uppercase;
    display: block;
    margin-bottom: 6px;
}
.env-subsection-source, .data-source-badge {
    color: var(--text-muted) !important;
    font-size: 0.6rem !important;
    font-family: var(--font-tech, monospace) !important;
    letter-spacing: 0.04em;
    opacity: 0.8 !important;
    font-weight: normal !important;
    text-transform: none;
}
.stat-tooltip {
    color: var(--text-muted) !important;
    font-weight: bold;
    font-size: 0.75rem !important;
}

/* --- INTAKE WIZARD STYLES (legacy - scoped to .wizard-timeline only) --- */
.wizard-timeline { display: flex; align-items: center; justify-content: space-between; position: relative; margin-bottom: 24px; padding: 10px 0; }
.wizard-timeline::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 2px; background: rgba(255,255,255,0.1); z-index: 1; transform: translateY(-50%); }
.wizard-timeline .wizard-step-node { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-dark); border: 2px solid rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; position: relative; z-index: 2; transition: all 0.3s ease; color: var(--text-muted); font-size: 0.8rem; }
.wizard-timeline .wizard-step-node.active { border-color: var(--accent-blue-light); background: rgba(96, 165, 250, 0.1); color: var(--accent-blue-light); box-shadow: 0 0 10px rgba(96, 165, 250, 0.3); }
.wizard-timeline .wizard-step-node.completed { border-color: var(--success); background: rgba(16, 185, 129, 0.1); color: var(--success); }
.wizard-step-label { position: absolute; top: 38px; left: 50%; transform: translateX(-50%); font-size: 0.65rem; white-space: nowrap; color: var(--text-muted); font-family: 'Inter', sans-serif; letter-spacing: 1px; transition: color 0.3s ease; }
.wizard-timeline .wizard-step-node:first-child .wizard-step-label { left: 0; transform: none; }
.wizard-timeline .wizard-step-node:last-child .wizard-step-label { left: auto; right: 0; transform: none; }
.wizard-timeline .wizard-step-node.active .wizard-step-label { color: var(--accent-blue-light); font-weight: bold; }
.wizard-timeline .wizard-step-node.completed .wizard-step-label { color: var(--success); }
.wizard-mobile-counter { display: none; font-size: 0.85rem; color: var(--accent-blue-light); font-family: 'Inter', sans-serif; letter-spacing: 1px; margin-bottom: 16px; text-align: center; }
.wizard-action-bar { display: flex; position: sticky; bottom: -24px; background: rgba(10, 14, 20, 0.98); z-index: 100; box-shadow: 0 -10px 20px rgba(0,0,0,0.5); margin-left: -24px; margin-right: -24px; padding: 20px 24px;  justify-content: space-between; align-items: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); gap: 12px; }
.wizard-action-bar .btn-nav { flex: 1; }
@media (max-width: 768px) { .wizard-timeline { display: none; } .wizard-mobile-counter { display: block; } .wizard-action-bar, .form-footer { bottom: -16px; margin-left: -16px; margin-right: -16px; padding: 12px 16px; gap: 8px; } .wizard-action-bar .btn-nav, .form-footer button { padding: 10px 4px; font-size: 0.65rem; } }

.form-section-title {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* STITCH LAYOUT UTILITIES */
.stitch-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.stitch-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 20px;
    box-sizing: border-box !important;
}
.stitch-stat-val {
    font-size: 3rem;
    line-height: 1;
    font-weight: 700;
    margin-bottom: 12px;
}
.stitch-stat-sub {
    font-size: 9px;
    color: var(--text-secondary);
    font-weight: 500;
}
.stitch-env-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.stitch-env-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.stitch-icon-box {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stitch-section-header {
    height: 6px;
    background: var(--accent-red);
    width: 100%;
}
.stitch-case-card {
    background: #22272e;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 16px;
    display: flex;
    gap: 12px;
    position: relative;
    overflow: hidden;
    box-sizing: border-box !important;
}
.stitch-case-border {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-red);
}
.stitch-flex-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* --- VIEW TRANSITIONS --- */
.view {
    animation: viewFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-exit {
    animation: viewFadeOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes viewFadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* --- APP-LIKE OVERSCROLL & SCROLLING --- */
.main-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* --- STITCH NAVIGATION OVERHAUL --- */
:root {
    --sidebar-width: 80px;
}
@media (min-width: 768px) {
    :root {
        --sidebar-width: 96px;
    }
}

.stitch-sidebar {
    grid-area: sidebar;
    background-color: var(--bg-primary); /* Dark */
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0 20px 0;
    z-index: 20;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    box-sizing: border-box;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.stitch-sidebar-logo {
    color: var(--accent-red);
    margin-bottom: 14px;
}
.sidebar-brand-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    max-width: 100%;
}
.sidebar-brand-link .sidebar-brand-text {
    white-space: nowrap;
    text-align: center;
}
@media screen and (min-width: 1025px) {
    .sidebar-brand-link .sidebar-brand-text {
        letter-spacing: 1px !important;
    }
}
.sidebar-brand-link:hover .sidebar-brand-emblem {
    transform: scale(1.06);
    box-shadow: 0 0 22px rgba(212, 17, 17, 0.85) !important;
}
.sidebar-brand-link:hover .sidebar-brand-text {
    color: #ff6b6b !important;
    text-shadow: 0 0 14px rgba(212, 17, 17, 1);
}
@media (max-width: 1024px) {
    .sidebar-brand-link {
        flex-direction: row;
        gap: 12px;
        align-self: flex-start;
        padding-left: 8px;
    }
    .sidebar-brand-link .sidebar-brand-text {
        font-size: 0.95rem !important;
        margin-top: 0 !important;
    }
}
.stitch-sidebar-logo svg {
    height: 32px;
    width: 32px;
}

.stitch-sidebar-nav {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: center;
}

.stitch-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    transition: color 0.2s;
    text-decoration: none;
    width: 100%;
    border-left: 2px solid transparent;
}
.stitch-sidebar .stitch-nav-item {
    padding: 4px 6px;
    box-sizing: border-box;
}
.stitch-sidebar .stitch-nav-item svg {
    width: 22px;
    height: 22px;
}
.stitch-nav-item:hover { color: white; }
.stitch-nav-item.logout-item:hover { color: var(--accent-red); }
.stitch-nav-item.logout-item:hover span { color: var(--accent-red) !important; }
.stitch-nav-item.active {
    color: var(--accent-red);
    border-left-color: var(--accent-red);
}
.stitch-nav-item span {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 500;
    text-align: center;
    line-height: 1.1;
}
.stitch-nav-item.active span {
    font-weight: 700;
    letter-spacing: -0.05em;
}

/* Tools Popover (Floating beside Sidebar) */
.tools-nav-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.tools-parent-item {
    cursor: pointer;
}

.tools-popover {
    position: fixed;
    z-index: 100050;
    min-width: 255px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(13, 18, 27, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(24px);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-12px) scale(0.96);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
    pointer-events: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.tools-popover.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

/* Arrow pointing left toward the Tools sidebar icon */
.tools-popover::before {
    content: '';
    position: absolute;
    left: -6px;
    top: var(--arrow-top, 22px);
    width: 10px;
    height: 10px;
    background: rgba(13, 18, 27, 0.98);
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    transform: rotate(45deg);
    transition: top 0.15s ease;
}

.tools-popover-header {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    padding: 6px 10px 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}

.tools-popover-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.popover-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 9px 12px !important;
    border-radius: 10px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    text-decoration: none !important;
    color: var(--text-primary) !important;
    cursor: pointer !important;
    transition: all 0.18s ease !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.popover-item:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    transform: translateX(3px);
}

.popover-item.active {
    background: rgba(96, 165, 250, 0.12) !important;
    border-color: rgba(96, 165, 250, 0.35) !important;
}

.popover-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.popover-item-icon svg {
    width: 18px;
    height: 18px;
}

.popover-item-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.popover-item-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
    line-height: 1.2;
}

.popover-item.active .popover-item-title {
    color: var(--accent-blue-light, #60a5fa) !important;
}

.popover-item-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 2px;
    white-space: nowrap;
}

/* Tools Submenu Chevron & Arrow Enhancements */
.tools-chevron-icon {
    display: none;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    color: var(--text-muted);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease;
    flex-shrink: 0;
}

.tools-nav-group.open .tools-chevron-icon,
.tools-parent-item.open .tools-chevron-icon {
    transform: rotate(180deg);
    color: var(--accent-blue-light, #60a5fa);
}

.tools-submenu-arrow {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.6;
    margin-left: auto;
    transition: transform 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.popover-item:hover .tools-submenu-arrow,
.popover-item:active .tools-submenu-arrow {
    transform: translateX(3px);
    color: var(--accent-blue-light, #60a5fa);
    opacity: 1;
}

/* Quick Tool Cards (Bottom Modal Sheet) */
@keyframes slideUpMobile {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tool-quick-card {
    transition: all 0.2s ease;
}

.tool-quick-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.tool-quick-card:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    #tools-quick-menu-modal {
        background: rgba(0, 0, 0, 0.82) !important;
    }

    #tools-quick-menu-modal .card,
    #tools-quick-menu-modal .tool-quick-card {
        background-color: #0a0e14 !important;
        color: #f0f1f3 !important;
    }

    #tools-quick-menu-modal .tool-quick-card {
        background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)) !important;
    }
}

[data-is-native="true"] #tools-quick-menu-modal {
    background: rgba(0, 0, 0, 0.82) !important;
}

[data-is-native="true"] #tools-quick-menu-modal .card,
[data-is-native="true"] #tools-quick-menu-modal .tool-quick-card {
    background-color: #0a0e14 !important;
    color: #f0f1f3 !important;
}

[data-is-native="true"] #tools-quick-menu-modal .tool-quick-card {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)) !important;
}

/* Red Mode Popover Support */
body.red-mode .tools-popover {
    background: rgba(18, 10, 10, 0.98) !important;
    border-color: rgba(212, 17, 17, 0.35) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(212, 17, 17, 0.15) !important;
}

body.red-mode .tools-popover::before {
    background: rgba(18, 10, 10, 0.98) !important;
    border-left-color: rgba(212, 17, 17, 0.35) !important;
    border-bottom-color: rgba(212, 17, 17, 0.35) !important;
}

body.red-mode .popover-item.active {
    background: rgba(212, 17, 17, 0.15) !important;
    border-color: rgba(212, 17, 17, 0.45) !important;
}

body.red-mode .popover-item.active .popover-item-title {
    color: #d41111 !important;
}

body.red-mode #tools-quick-menu-modal .card {
    border-color: rgba(212, 17, 17, 0.4) !important;
    box-shadow: 0 -12px 30px rgba(212, 17, 17, 0.2) !important;
}

body.red-mode .tool-quick-card {
    border-color: rgba(212, 17, 17, 0.3) !important;
    background: rgba(212, 17, 17, 0.08) !important;
}

/* Mobile Slideout Drawer: Hide Tools item as it lives on the bottom navigation bar */
[data-is-native="true"] .stitch-sidebar .tools-nav-group,
[data-is-native="true"] .stitch-sidebar .tools-nav-group.mobile-hide {
    display: none !important;
}

@media (max-width: 768px) {
    .stitch-sidebar .tools-nav-group,
    .stitch-sidebar .tools-nav-group.mobile-hide {
        display: none !important;
    }
}

/* Modal Generic Exit Buttons (Tools Quick Menu, Floorplan, Popups) */
.tools-modal-close-btn,
.mobile-close-btn,
.glass-circle-btn,
.modal .btn-ghost[title="Close"],
.modal .btn-ghost[title="Close Map Modal"],
.modal .btn-ghost[onclick*="close"],
.modal-overlay .btn-ghost[onclick*="close"],
[id$="-modal"] .btn-ghost[onclick*="close"] {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    flex: 0 0 32px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    line-height: 1 !important;
    font-size: 1.5rem !important;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease !important;
}

.tools-modal-close-btn:hover,
.tools-modal-close-btn:active,
.mobile-close-btn:hover,
.mobile-close-btn:active,
.glass-circle-btn:hover,
.glass-circle-btn:active,
.modal .btn-ghost[onclick*="close"]:hover,
.modal .btn-ghost[onclick*="close"]:active {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
}

/* The sidebar is a fixed rail on desktop web; its drawer close button only belongs to the slide-out mode. */
@media screen and (min-width: 1025px) {
    html:not([data-is-native="true"]) .stitch-sidebar .mobile-close-btn {
        display: none !important;
    }
}


.stitch-sidebar-bottom {
    margin-top: auto !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important; /* Stacked on web desktop */
    align-items: center !important;
    gap: 8px !important;
    padding-bottom: 20px !important;
}

.stitch-sidebar-bottom .nav-item {
    width: 100% !important;
    justify-content: center !important;
}

/* Mobile Bottom Nav */
.stitch-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0)) 8px;
    z-index: 10000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.stitch-bottom-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.stitch-bottom-item.active { color: var(--accent-red); }
.stitch-bottom-item span {
    font-size: 9px;
    font-weight: 500;
    margin-top: 4px;
}
.stitch-bottom-item.active span { font-weight: 700; }
.stitch-nav-item svg, .stitch-bottom-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}
@media (min-width: 769px) {
    .stitch-bottom-nav {
        display: none !important;
    }
}
/* --- Responsive Fixes --- */
@media (max-width: 1024px) {
    .dashboard-grid-layout {
        display: flex !important;
        flex-direction: column !important;
    }
    .dashboard-grid-layout .main-column, 
    .dashboard-grid-layout .side-column {
        display: contents !important;
    }
    #stats-overview { order: 1; }
    #env-data-section { order: 2; }
    #active-inv-section { order: 3; }
    .dashboard-grid-layout .team-panel { order: 4; }
    .dashboard-grid-layout .processing-card { order: 5; }

    .stitch-env-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 16px !important;
        overflow: visible;
        padding-bottom: 4px;
    }
    .stitch-env-list .stitch-env-row {
        flex-direction: row !important;
        align-items: center;
        text-align: left;
        gap: 12px !important;
        background: rgba(255,255,255,0.03);
        padding: 12px 14px;
        border-radius: 8px;
        border: 1px solid rgba(255,255,255,0.06);
        min-width: 0;
    }
    .stitch-env-list .stitch-icon-box {
        margin-bottom: 0;
        flex-shrink: 0;
    }
}


@media (max-width: 1024px) {
    .dashboard-grid-layout, .review-grid-layout, .main-with-sidebar {
        align-items: stretch !important;
    }
    .dashboard-grid-layout > *, .review-grid-layout > *, .main-with-sidebar > * {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
}
.main-content {
    min-width: 0 !important;
}

/* --- Form Builder Mobile Override --- */
@media (max-width: 768px) {
    #wysiwyg-form-builder-card {
        grid-column: span 1 !important;
        padding: 0 !important;
    }
}

/* STITCH SWITCH UI */
.stitch-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.stitch-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.stitch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #2a2a2a;
  transition: .4s;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.1);
}
.stitch-slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
input:checked + .stitch-slider {
  background-color: var(--accent-blue-light);
  border-color: var(--accent-blue-light);
}
input:checked + .stitch-slider:before {
  transform: translateX(20px);
}

/* --- CUSTOM DATETIME PICKER (cdt-*) --- */
.cdt-panel {
    background: rgba(10, 14, 20, 0.98);
    border: 1px solid rgba(96, 165, 250, 0.35);
    border-radius: 14px;
    padding: 20px 18px 0 18px;
    width: 340px;
    max-width: 96vw;
    box-shadow: 0 0 40px rgba(96, 165, 250, 0.15), 0 24px 48px rgba(0,0,0,0.7);
    font-family: 'Inter', 'Roboto', sans-serif;
    overflow: hidden;
}
.cdt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.cdt-nav-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--accent-blue-light, #60a5fa);
    border-radius: 6px;
    width: 32px; height: 32px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.cdt-nav-btn:hover { background: rgba(96,165,250,0.15); }
.cdt-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted, #6b7280);
    letter-spacing: 1px;
    margin-bottom: 6px;
    font-family: 'Share Tech Mono', monospace;
}
.cdt-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 14px;
}
.cdt-day {
    text-align: center;
    padding: 7px 2px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-primary, #e2e8f0);
    transition: background 0.12s, color 0.12s;
    user-select: none;
}
.cdt-day:hover { background: rgba(96,165,250,0.15); color: #60a5fa; }
.cdt-day.sel { background: rgba(96,165,250,0.3); color: #60a5fa; font-weight: 700; border: 1px solid rgba(96,165,250,0.5); }
.cdt-day.tod { font-weight: 700; border: 1px solid rgba(245,158,11,0.5); color: #f59e0b; }
.cdt-day.sel.tod { background: rgba(96,165,250,0.3); border-color: #60a5fa; color: #60a5fa; }
.cdt-day.other-mo { color: rgba(255,255,255,0.2); cursor: default; }
.cdt-day.other-mo:hover { background: none; }

/* Time row */
.cdt-time-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
}
.cdt-time-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.cdt-spin-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--accent-blue-light, #60a5fa);
    border-radius: 4px;
    width: 28px; height: 22px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s;
}
.cdt-spin-btn:hover { background: rgba(96,165,250,0.2); }
.cdt-time-val, .cdt-time-input {
    font-size: 1.45rem;
    font-family: 'Share Tech Mono', monospace;
    color: #ffffff;
    width: 54px;
    height: 38px;
    text-align: center;
    letter-spacing: 2px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(96, 165, 250, 0.4);
    border-radius: 6px;
    outline: none;
    padding: 0;
    margin: 2px 0;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.cdt-time-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
    background: rgba(96, 165, 250, 0.15);
}
.cdt-time-input::-webkit-outer-spin-button,
.cdt-time-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
.cdt-time-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}
.cdt-colon {
    font-size: 1.5rem;
    font-family: 'Share Tech Mono', monospace;
    color: rgba(255,255,255,0.4);
    margin-bottom: 2px;
}
.cdt-ampm-btn {
    background: rgba(245,158,11,0.15);
    border: 1px solid rgba(245,158,11,0.4);
    color: #f59e0b;
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'Share Tech Mono', monospace;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    letter-spacing: 1px;
}
.cdt-ampm-btn:hover { background: rgba(245,158,11,0.3); }

/* Quick action row */
.cdt-quick {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 14px;
}

/* THE OK BUTTON — Styled in high-contrast vibrant cyber green */
.cdt-ok-btn {
    display: block;
    width: calc(100% + 36px);
    margin: 0 -18px;
    padding: 16px 12px;
    background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
    color: #ffffff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    border: none;
    border-top: 2px solid rgba(34, 197, 94, 0.6);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 -4px 18px rgba(34, 197, 94, 0.35);
    border-radius: 0 0 14px 14px;
    user-select: none;
}
.cdt-ok-btn:hover { background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%); box-shadow: 0 -4px 22px rgba(34, 197, 94, 0.5); }
.cdt-ok-btn:active { transform: scale(0.99); }

/* Calendar icon — amber to match warning accents */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(73%) sepia(52%) saturate(1200%) hue-rotate(5deg) brightness(105%);
    opacity: 1;
    cursor: pointer;
}

/* Hide the old flatpickr confirm */
.flatpickr-confirm, .fp-ok-confirm-btn { display: none !important; }

/* --- PERMISSIONS ONBOARDING MODAL --- */
.permissions-modal-container {
    background-color: #1a1a1a;
    border: 1px solid #ff0000;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.25);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    padding: 40px 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
}
.permissions-wave-icon {
    width: 200px;
    height: auto;
    margin: 0 auto 24px auto;
    color: #ff0000;
    animation: pulse-red 3s infinite ease-in-out;
}
@keyframes pulse-red {
    0%, 100% { opacity: 1; filter: drop-shadow(0 0 6px rgba(255,0,0,0.6)); }
    50% { opacity: 0.6; filter: drop-shadow(0 0 2px rgba(255,0,0,0.2)); }
}
.permissions-header h1 {
    font-family: 'Share Tech Mono', monospace;
    color: #ff0000;
    font-size: 1.8rem;
    letter-spacing: 4px;
    font-weight: 700;
    margin-bottom: 16px;
    text-transform: uppercase;
}
.permissions-header p {
    color: #d1d5db;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 32px;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}
.permissions-grant-btn {
    background-color: #ff0000;
    color: #ffffff;
    font-family: 'Share Tech Mono', monospace;
    width: 100%;
    max-width: 460px;
    padding: 16px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 3px;
    border: none;
    border-radius: 6px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
    box-sizing: border-box;
    margin: 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.permissions-grant-btn:hover:not(:disabled) {
    background-color: #cc0000;
    transform: scale(1.01);
}
.permissions-grant-btn:active:not(:disabled) {
    transform: scale(0.99);
}
.permissions-grant-btn:disabled {
    opacity: 0.85;
    cursor: wait;
    transform: none;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.25);
}
.permissions-decline-btn {
    background: transparent;
    color: #cbd5e1;
    font-family: 'Share Tech Mono', monospace;
    width: 100%;
    max-width: 460px;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 2px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 6px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    box-sizing: border-box;
    margin: 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.permissions-decline-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.6);
    color: #ffffff;
}
.permissions-decline-btn:active {
    transform: scale(0.99);
}
.permissions-footer {
    margin-top: 32px;
    border-top: 1px solid #333333;
    padding-top: 20px;
}
.permissions-footer p {
    color: #6b7280;
    font-size: 0.8rem;
    line-height: 1.4;
    max-width: 480px;
    margin: 0 auto;
}

/* Remove native number input spin buttons completely */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
    box-sizing: border-box !important;
    text-align: center;
}

/* --- DSP FILTER PANELS --- */
.filter-panel {
    margin-bottom: 4px;
    padding: 6px 12px 4px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    position: relative;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.3);
}

.filter-panel:first-child {
    margin-top: 0;
}

.filter-panel:last-child {
    margin-bottom: 0;
}

/* --- AUDIO LAB RESPONSIVE --- */
.audio-controls-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.audio-control-cluster {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.audio-control-cluster .btn {
    white-space: normal;
    height: auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

/* --- BOTTOM NAVIGATION BAR (APP FEEL) --- */
.bottom-nav-bar {
    display: none;
}

@media screen and (max-width: 1024px) {
    /* Explicitly hide redundant nav items in the mobile drawer */
    .stitch-sidebar .nav-item.mobile-hide,
    .stitch-sidebar .tools-nav-group.mobile-hide,
    .stitch-sidebar .tools-nav-group {
        display: none !important;
    }
    /* Show the top-left sidebar toggle on mobile & tablet */
    .mobile-header-toggle {
        display: flex !important;
    }

    .stitch-sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
        right: 0 !important;
        left: auto !important;
        width: min(75vw, 240px) !important;
        min-width: 0 !important;
        max-width: none !important;
        z-index: 100120 !important;
        background: linear-gradient(180deg, rgba(14, 18, 26, 0.98) 0%, rgba(10, 14, 20, 0.99) 100%) !important;
        border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-top-left-radius: 20px !important;
        border-bottom-left-radius: 20px !important;
        transform: translateX(110%) !important;
        visibility: hidden !important;
        pointer-events: none !important;
        box-shadow: none !important;
        opacity: 0 !important;
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease, opacity 0.28s ease !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        backdrop-filter: blur(30px) !important;
        -webkit-backdrop-filter: blur(30px) !important;
    }

    .stitch-sidebar.active {
        transform: translateX(0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
        box-shadow: -15px 0 35px rgba(0, 0, 0, 0.8) !important;
        opacity: 1 !important;
        right: 0 !important;
        left: auto !important;
    }

    /* Side Menu Header - Compact height to sit icons right at the top */
    .stitch-sidebar-logo {
        margin-bottom: 0 !important;
        height: 48px !important;
        min-height: 48px !important;
        padding: 0 14px !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        background: rgba(255, 255, 255, 0.02) !important;
        box-sizing: border-box !important;
        flex-shrink: 0 !important;
        width: 100% !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    }

    .stitch-sidebar-logo svg {
        width: 18px;
        height: 18px;
    }

    .mobile-close-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 30px !important;
        height: 30px !important;
        border-radius: 8px !important;
        background: rgba(255, 255, 255, 0.06) !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        color: var(--text-muted, #94a3b8) !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        padding: 0 !important;
    }

    .mobile-close-btn:hover,
    .mobile-close-btn:active {
        background: rgba(255, 255, 255, 0.12) !important;
        border-color: rgba(255, 255, 255, 0.25) !important;
        color: #ffffff !important;
        transform: scale(0.95) !important;
    }

    .mobile-close-btn svg {
        width: 16px !important;
        height: 16px !important;
        pointer-events: none !important;
    }

    .stitch-sidebar-nav {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        padding: 12px 12px 0 12px !important;
        flex: 0 0 auto !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .stitch-sidebar-bottom {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        padding: 10px 12px 14px 12px !important;
        margin-top: auto !important;
        flex-shrink: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    }

    .stitch-sidebar .stitch-nav-item:not(.mobile-hide) {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 10px !important;
        width: 100% !important;
        height: 40px !important;
        min-height: 40px !important;
        padding: 8px 12px !important;
        border-radius: 8px !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        background: rgba(255, 255, 255, 0.03) !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
        box-sizing: border-box !important;
        transition: all 0.18s ease !important;
        text-decoration: none !important;
        color: var(--text-primary, #ffffff) !important;
        flex: 0 0 auto !important;
        flex-grow: 0 !important;
    }

    .stitch-sidebar .stitch-nav-item:not(.mobile-hide):hover {
        background: rgba(255, 255, 255, 0.06) !important;
        border-color: rgba(255, 255, 255, 0.16) !important;
    }

    .stitch-sidebar .stitch-nav-item:not(.mobile-hide).active {
        background: rgba(96, 165, 250, 0.12) !important;
        border-color: rgba(96, 165, 250, 0.4) !important;
        box-shadow: 0 0 12px rgba(96, 165, 250, 0.15) !important;
    }

    .stitch-sidebar .stitch-nav-item svg {
        width: 18px !important;
        height: 18px !important;
        flex-shrink: 0 !important;
        color: var(--text-muted, #94a3b8) !important;
        transition: color 0.2s ease, filter 0.2s ease !important;
    }

    .stitch-sidebar .stitch-nav-item:hover svg,
    .stitch-sidebar .stitch-nav-item.active svg {
        color: var(--accent-blue-light, #60a5fa) !important;
        filter: drop-shadow(0 0 5px rgba(96, 165, 250, 0.6)) !important;
    }

    .stitch-sidebar .stitch-nav-item span {
        font-family: var(--font-tech, monospace) !important;
        font-size: 0.76rem !important;
        font-weight: 600 !important;
        letter-spacing: 1px !important;
        text-transform: uppercase !important;
        color: #e2e8f0 !important;
        text-align: left !important;
        flex: 1 !important;
        transition: color 0.2s ease !important;
    }

    .stitch-sidebar .stitch-nav-item:hover span,
    .stitch-sidebar .stitch-nav-item.active span {
        color: #ffffff !important;
    }

    .stitch-sidebar .stitch-nav-item:active {
        transform: scale(0.98) !important;
        background: rgba(255, 255, 255, 0.08) !important;
    }

    .stitch-sidebar .stitch-nav-item.logout-item {
        border-color: rgba(212, 17, 17, 0.25) !important;
        background: rgba(212, 17, 17, 0.08) !important;
    }

    .stitch-sidebar .stitch-nav-item.logout-item svg,
    .stitch-sidebar .stitch-nav-item.logout-item span {
        color: #ef4444 !important;
    }

    .stitch-sidebar .stitch-nav-item.logout-item:hover,
    .stitch-sidebar .stitch-nav-item.logout-item:active {
        background: rgba(212, 17, 17, 0.18) !important;
        border-color: rgba(212, 17, 17, 0.45) !important;
    }

    .mobile-action-btn {
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.12);
        color: var(--text-primary);
        width: 38px;
        height: 38px;
        border-radius: 14px;
        box-shadow: 0 8px 18px rgba(0,0,0,0.22);
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-action-btn svg {
        pointer-events: none;
    }

    .mobile-action-btn:active {
        background: rgba(255, 255, 255, 0.12);
        transform: scale(0.95);
    }

    .sidebar-backdrop {
        position: fixed !important;
        inset: 0 !important;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
        background: rgba(0, 0, 0, 0.65) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        z-index: 100110 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.25s ease !important;
    }

    .sidebar-backdrop.active {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Ensure modals sit on top of the mobile bottom navigation bar (z-index: 50000) */
    #floorplan-modal,
    #room-preset-modal,
    #sources-modal,
    #export-report-modal,
    #floorplan-geometry-editor,
    .modal {
        z-index: 100150 !important;
    }
    #room-preset-modal {
        z-index: 100200 !important;
    }

    .bottom-nav-bar {
        display: grid !important;
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
        justify-items: center !important;
        align-items: center !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
        min-height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
        background: linear-gradient(180deg, rgba(14, 18, 26, 0.96) 0%, rgba(9, 12, 18, 0.99) 100%) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        z-index: 50000 !important;
        padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)) !important;
        box-sizing: border-box !important;
        column-gap: 6px !important;
        overflow: visible !important;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
    }
    
    .bottom-nav-bar .nav-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        color: var(--text-muted, #94a3b8) !important;
        text-decoration: none !important;
        width: 100% !important;
        max-width: 76px !important;
        height: 100% !important;
        min-height: 0 !important;
        padding: 4px 2px !important;
        gap: 3px !important;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
        border-radius: 12px !important;
        border: 1px solid transparent !important;
        background: transparent !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        cursor: pointer !important;
        user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    .bottom-nav-bar .nav-item:hover {
        color: #e2e8f0 !important;
        background: rgba(255, 255, 255, 0.04) !important;
    }

    .bottom-nav-bar .nav-item.active {
        color: var(--accent-blue-light, #60a5fa) !important;
        background: rgba(96, 165, 250, 0.08) !important;
        border-color: rgba(96, 165, 250, 0.2) !important;
        box-shadow: 0 0 12px rgba(96, 165, 250, 0.15) !important;
    }
    
    .bottom-nav-bar .nav-item svg,
    .bottom-nav-bar .nav-item .bottom-nav-icon {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        min-height: 24px !important;
        flex-shrink: 0 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 0.85 !important;
        color: var(--text-muted, #94a3b8) !important;
        transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease, filter 0.2s ease, opacity 0.2s ease !important;
        pointer-events: none !important;
    }

    .bottom-nav-bar .nav-item:hover svg,
    .bottom-nav-bar .nav-item:hover .bottom-nav-icon {
        opacity: 1 !important;
        color: #ffffff !important;
    }

    .bottom-nav-bar .nav-item svg[fill="currentColor"],
    .bottom-nav-bar .nav-item .bottom-nav-icon[fill="currentColor"] {
        fill: currentColor !important;
    }

    .bottom-nav-bar .nav-item span {
        font-family: var(--font-tech, monospace) !important;
        font-size: 0.64rem !important;
        font-weight: 600 !important;
        line-height: 1 !important;
        letter-spacing: 0.5px !important;
        text-transform: uppercase !important;
        color: var(--text-muted, #94a3b8) !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        transition: color 0.2s ease, text-shadow 0.2s ease !important;
        margin-top: 2px !important;
    }

    .bottom-nav-bar .nav-item:hover span {
        color: #ffffff !important;
    }

    .bottom-nav-bar .nav-item.active span {
        color: #ffffff !important;
        font-weight: 700 !important;
        text-shadow: 0 0 8px rgba(96, 165, 250, 0.5) !important;
    }
    
    .bottom-nav-bar .nav-item.active svg,
    .bottom-nav-bar .nav-item.active .bottom-nav-icon {
        color: var(--accent-blue-light, #60a5fa) !important;
        opacity: 1 !important;
        filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.65)) !important;
        transform: translateY(-1px) scale(1.05) !important;
    }
    
    .fab-wrapper {
        position: relative !important;
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        margin-top: -16px !important;
        justify-self: center !important;
        overflow: visible !important;
        z-index: 10 !important;
        pointer-events: auto !important;
    }
    
    .fab-button {
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
        border-radius: 50% !important;
        background: linear-gradient(135deg, #d41111 0%, #990000 100%) !important;
        border: 2px solid rgba(255, 255, 255, 0.22) !important;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 16px rgba(212, 17, 17, 0.45) !important;
        color: #ffffff !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        cursor: pointer !important;
        position: relative !important;
        overflow: visible !important;
        padding: 0 !important;
        gap: 2px !important;
        flex-shrink: 0 !important;
        transition: transform 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.18s ease !important;
    }

    .fab-button::before {
        content: none !important;
    }

    .fab-button::after {
        content: none !important;
    }

    .fab-button .fab-action-icon {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        min-height: 24px !important;
        display: block;
        flex-shrink: 0 !important;
        color: #ffffff !important;
        filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)) !important;
        pointer-events: none !important;
        transition: transform 0.2s ease !important;
    }

    .fab-button .fab-action-icon[style*="display: none"],
    .fab-button .fab-action-icon[style*="display:none"],
    .fab-button .fab-action-icon.hidden,
    .fab-button svg#fab-icon-plus {
        display: none !important;
    }

    .fab-button .fab-label {
        font-family: var(--font-tech, monospace) !important;
        font-size: 0.58rem !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.05em !important;
        color: #ffffff !important;
        line-height: 1 !important;
        pointer-events: none !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8) !important;
    }
    
    .fab-button:active {
        transform: scale(0.92) !important;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6), 0 0 12px rgba(212, 17, 17, 0.6) !important;
    }

    .fab-button:hover {
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6), 0 0 22px rgba(212, 17, 17, 0.65) !important;
        transform: translateY(-2px) scale(1.04) !important;
        border-color: rgba(255, 255, 255, 0.4) !important;
    }

    /* Monochromatic Red Mode support for mobile navigation */
    body[data-theme="red"] .bottom-nav-bar,
    body.red-mode .bottom-nav-bar {
        background: linear-gradient(180deg, rgba(16, 2, 2, 0.96) 0%, rgba(8, 0, 0, 0.99) 100%) !important;
        border-top: 1px solid rgba(212, 17, 17, 0.3) !important;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.8), 0 0 15px rgba(212, 17, 17, 0.15) !important;
    }

    body[data-theme="red"] .bottom-nav-bar .nav-item,
    body.red-mode .bottom-nav-bar .nav-item {
        color: rgba(217, 141, 141, 0.6) !important;
    }

    body[data-theme="red"] .bottom-nav-bar .nav-item svg,
    body[data-theme="red"] .bottom-nav-bar .nav-item .bottom-nav-icon,
    body.red-mode .bottom-nav-bar .nav-item svg,
    body.red-mode .bottom-nav-bar .nav-item .bottom-nav-icon {
        color: rgba(217, 141, 141, 0.6) !important;
    }

    body[data-theme="red"] .bottom-nav-bar .nav-item span,
    body.red-mode .bottom-nav-bar .nav-item span {
        color: rgba(217, 141, 141, 0.6) !important;
    }

    body[data-theme="red"] .bottom-nav-bar .nav-item.active,
    body.red-mode .bottom-nav-bar .nav-item.active {
        color: #ff3333 !important;
        background: rgba(212, 17, 17, 0.12) !important;
        border-color: rgba(212, 17, 17, 0.35) !important;
        box-shadow: 0 0 12px rgba(212, 17, 17, 0.25) !important;
    }

    body[data-theme="red"] .bottom-nav-bar .nav-item.active svg,
    body[data-theme="red"] .bottom-nav-bar .nav-item.active .bottom-nav-icon,
    body.red-mode .bottom-nav-bar .nav-item.active svg,
    body.red-mode .bottom-nav-bar .nav-item.active .bottom-nav-icon {
        color: #ff3333 !important;
        filter: drop-shadow(0 0 8px rgba(255, 51, 51, 0.7)) !important;
    }

    body[data-theme="red"] .bottom-nav-bar .nav-item.active span,
    body.red-mode .bottom-nav-bar .nav-item.active span {
        color: #ffffff !important;
        text-shadow: 0 0 8px rgba(255, 51, 51, 0.6) !important;
    }

    body[data-theme="red"] .stitch-sidebar,
    body.red-mode .stitch-sidebar {
        background: linear-gradient(180deg, rgba(20, 2, 2, 0.98) 0%, rgba(10, 0, 0, 0.99) 100%) !important;
        border-left: 1px solid rgba(212, 17, 17, 0.25) !important;
    }

    body[data-theme="red"] .stitch-sidebar .stitch-nav-item.active,
    body.red-mode .stitch-sidebar .stitch-nav-item.active {
        background: rgba(212, 17, 17, 0.15) !important;
        border-color: rgba(212, 17, 17, 0.45) !important;
        box-shadow: 0 0 15px rgba(212, 17, 17, 0.2) !important;
    }
    
    /* Ensure content doesn't get hidden behind bottom nav without double-padding app-container */
    .main-content {
        padding-bottom: var(--bottom-clearance) !important;
        scroll-padding-bottom: var(--bottom-clearance);
    }
}

/* Base and Native Bottom Nav Bar Styles (Tablets in landscape or native mode) */
[data-is-native="true"] .bottom-nav-bar {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    justify-items: center !important;
    align-items: center !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
    min-height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
    background: linear-gradient(180deg, rgba(14, 18, 26, 0.96) 0%, rgba(9, 12, 18, 0.99) 100%) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    z-index: 50000 !important;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)) !important;
    column-gap: 6px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
}

[data-is-native="true"] .main-content {
    padding-bottom: var(--bottom-clearance) !important;
    scroll-padding-bottom: var(--bottom-clearance);
}

[data-is-native="true"] .stitch-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
    right: 0 !important;
    left: auto !important;
    width: min(85vw, 310px) !important;
    min-width: 0 !important;
    max-width: none !important;
    z-index: 100120 !important;
    background: linear-gradient(180deg, rgba(14, 18, 26, 0.98) 0%, rgba(10, 14, 20, 0.99) 100%) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-top-left-radius: 20px !important;
    border-bottom-left-radius: 20px !important;
    backdrop-filter: blur(30px) !important;
    -webkit-backdrop-filter: blur(30px) !important;
}

[data-is-native="true"] .stitch-sidebar.active {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
    box-shadow: -15px 0 40px rgba(0, 0, 0, 0.75), 0 0 1px rgba(255, 255, 255, 0.1) !important;
    opacity: 1 !important;
}

/* Ensure closed drawer never projects shadow or blocks interface */
@media screen and (max-width: 1024px) {
    .stitch-sidebar:not(.active) {
        transform: translateX(110%) !important;
        visibility: hidden !important;
        pointer-events: none !important;
        box-shadow: none !important;
        opacity: 0 !important;
    }
}
[data-is-native="true"] .stitch-sidebar:not(.active) {
    transform: translateX(110%) !important;
    visibility: hidden !important;
    pointer-events: none !important;
    box-shadow: none !important;
    opacity: 0 !important;
}

/* ========================================================
   Intake Form Pure CSS Redesign
   ======================================================== */

#investigation-intake-view.view,
#investigation-intake-view,
.intake-view-container {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Geist', sans-serif;
    animation: none !important;
    transform: none !important;
    /* Break out of .main-content 8px top padding and 32px left/right/bottom padding */
    margin: -8px -32px -32px -32px;
    width: calc(100vw - var(--sidebar-width));
    max-width: none;
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    overflow: visible;
    position: relative;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 24px 24px;
}

.app-container.desktop-sidebar-closed .intake-view-container {
    width: 100vw;
}

.intake-header {
    width: 100%;
    z-index: 50;
    padding: 16px 32px;
    background: rgba(10, 14, 20, 0.98);
    border-bottom: 1px solid #2a2a2a;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.intake-header-content {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.intake-header-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 600;
    color: #d41111;
    text-transform: uppercase;
}

.intake-header-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #00F5D4; /* custom-mint */
    text-transform: uppercase;
}

.intake-main-content {
    width: 100%;
    padding: 16px;
    padding-bottom: var(--bottom-clearance) !important;
    box-sizing: border-box;
    overflow-y: auto;
    min-height: 0;
}

/* Keep the final intake fields clear of the fixed desktop action bar. */
@media (min-width: 769px) {
    .intake-main-content {
        padding-bottom: calc(var(--bottom-clearance) + 32px) !important;
    }
}

.intake-max-width {
    width: 100%; /* Utilize full width dynamically */
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px; /* Reduced vertical gap */
}

.intake-context-text {
    color: #ffffff;
    font-size: 16px;
    margin-bottom: 16px; /* Reduced margin */
}

/* Stepper Component */
.intake-wizard-timeline {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
}

/* Connecting line via pseudo-element — sits at exact center of 32px icons */
.intake-wizard-timeline::before {
    content: '';
    position: absolute;
    top: 16px; /* half of 32px icon height */
    left: 0;
    right: 0;
    height: 2px;
    background-color: #2a2a2a;
    transform: translateY(-50%);
    z-index: 0;
}

/* Hide the legacy line div if still present in HTML */
.intake-wizard-line {
    display: none;
}

.intake-wizard-timeline .wizard-step-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    /* Explicit resets - override old .wizard-step-node rules */
    width: auto;
    height: auto;
    border: none;
    border-radius: 0;
    background: none;
    background-color: transparent;
    padding: 0 4px;
    cursor: pointer;
    z-index: 1;
    flex-shrink: 0;
    position: relative;
    box-shadow: none;
}

.intake-wizard-timeline .wizard-step-node .step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #353534;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    flex-shrink: 0;
    box-sizing: border-box;
    transition: border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.intake-wizard-timeline .wizard-step-node .step-icon span {
    font-size: 16px;
    line-height: 1;
}

.intake-wizard-timeline .wizard-step-node .step-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color 0.3s ease;
}

.intake-wizard-timeline .wizard-step-node.completed .step-icon {
    border-color: #d41111;
    color: #d41111;
}

.intake-wizard-timeline .wizard-step-node.completed .step-label {
    color: #d41111;
}

.intake-wizard-timeline .wizard-step-node.active .step-icon {
    border-color: #d41111;
    color: #d41111;
    box-shadow: 0 0 10px rgba(141, 0, 21, 0.5);
}

.intake-wizard-timeline .wizard-step-node.active .step-label {
    color: #d41111;
    font-weight: 700;
}

/* Glass Panels / Tabs */
.intake-tab-content {
    background: rgba(18, 18, 20, 0.85);
    border: 1px solid #1c1b1b;
    border-radius: 4px;
    padding: 16px; /* Reduced padding */
    position: relative;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
}

.intake-tab-content.active {
    display: block;
}

.intake-tab-accent {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: #d41111;
}

/* Intake Mode Toggle Switcher */
.intake-mode-toggle-group {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 3px;
    gap: 4px;
}

.intake-mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-family: var(--font-tech, 'JetBrains Mono', monospace);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.intake-mode-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.intake-mode-btn.active {
    background: var(--accent-blue-light, #60a5fa);
    color: #0a0e14;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.4);
}

body.red-mode .intake-mode-btn.active {
    background: #d41111;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(212, 17, 17, 0.6);
}

.quick-fast-track-banner {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.quick-fast-track-banner:hover {
    box-shadow: 0 4px 16px rgba(212, 17, 17, 0.25);
}

.intake-tab-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px; /* Reduced margin */
}

.intake-tab-dot {
    width: 8px;
    height: 8px;
    background-color: #ffffff;
    border-radius: 50%;
}

.intake-tab-title {
    font-family: 'Geist', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

/* Grids and Forms */
.intake-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px; /* Reduced gap */
}

@media (min-width: 768px) {
    .intake-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.intake-col-span-2 {
    grid-column: span 1;
}

.intake-telemetry-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

@media (min-width: 540px) {
    .intake-telemetry-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1000px) {
    .intake-telemetry-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .intake-col-span-2 {
        grid-column: span 2;
    }
}

.intake-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.intake-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
}

.intake-input, .intake-select, .intake-textarea {
    width: 100%;
    height: 46px;
    background-color: #131313;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 12px 16px;
    color: #ffffff;
    font-family: 'Geist', sans-serif;
    font-size: 16px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.intake-select {
    appearance: none;
    -webkit-appearance: none;
}

.intake-input:focus, .intake-select:focus, .intake-textarea:focus {
    outline: none;
    border-color: #b08d57 !important;
    box-shadow: 0 0 4px rgba(176, 141, 87, 0.2);
}

.intake-select-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #F3F6FB;
    pointer-events: none;
    font-size: 20px;
}

.intake-textarea {
    height: auto;
    min-height: 80px;
    resize: vertical;
}

/* Group inside form group for select dropdown arrow alignment */
.intake-input-wrapper {
    position: relative;
    width: 100%;
    height: 46px;
}

.intake-input-wrapper:focus-within {
    box-shadow: 0 0 4px rgba(176, 141, 87, 0.2);
}

.intake-flex-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.intake-btn-now {
    padding: 0 16px;
    height: 46px;
    background-color: #2a2a2a;
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
    box-sizing: border-box;
}

.intake-btn-now:hover {
    background-color: #353534;
}

.intake-radio-group {
    display: flex;
    align-items: center;
    height: 46px;
    gap: 24px;
}

.intake-radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
}

.intake-radio-label input[type="radio"],
.intake-checkbox-label input[type="checkbox"],
.intake-checkbox-item input[type="checkbox"] {
    accent-color: #d41111;
}

.intake-checkbox-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid #2a2a2a;
}

@media (min-width: 768px) {
    .intake-checkbox-grid {
        grid-template-columns: 1fr 1fr;
    }
}
@media (min-width: 1024px) {
    .intake-checkbox-grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
}

.intake-checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    transition: color 0.2s ease;
}

.intake-category-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    background-color: #131313;
    padding: 16px;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
}

@media (min-width: 768px) {
    .intake-category-grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
}

.intake-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
}

.intake-btn-refresh {
    padding: 12px 16px;
    background-color: #131313;
    border: 1px solid #d41111;
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.intake-btn-refresh:hover {
    background-color: #d41111;
}

/* Digital Questionnaire Box */
.intake-dq-box {
    margin-top: 16px;
    background-color: #353534;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 16px;
}

.intake-dq-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.intake-dq-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #00F5D4;
    letter-spacing: 0.1em;
}

.intake-dq-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.intake-dq-input {
    background-color: #131313;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 8px 12px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
}

.intake-dq-input:focus {
    border-color: #b08d57;
    box-shadow: 0 0 4px rgba(176, 141, 87, 0.2);
}

.intake-dq-btn {
    padding: 8px 16px;
    background-color: #b08d57; /* primary */
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.intake-dq-btn:hover {
    opacity: 0.9;
}

/* Pre-Sweep Phase Info Box */
.intake-info-box {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid rgba(96, 165, 250, 0.3);
    background: rgba(96, 165, 250, 0.06);
    border-radius: 4px;
}

.intake-info-title {
    font-size: 12px;
    color: #60a5fa; /* blue-400 */
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.intake-info-text {
    font-size: 14px;
    color: #F4FAFC; /* Replaced pink */
    margin-bottom: 16px;
    margin-top: 0;
}

.intake-info-btn {
    padding: 8px 16px;
    border: 1px solid #f59e0b;
    color: #f59e0b;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s ease;
}

.intake-info-btn:hover {
    background: rgba(245, 158, 11, 0.1);
}

/* Footer / Action Bar — sits permanently docked at the bottom of the intake screen */
#investigation-intake-view #wizard-action-bar,
.intake-footer {
    position: fixed !important;
    left: var(--sidebar-width, 80px) !important;
    right: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    background: linear-gradient(180deg, rgba(14, 18, 26, 0.98) 0%, rgba(9, 12, 18, 0.99) 100%) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
    padding: 12px 24px !important;
    z-index: 99999 !important;
    box-sizing: border-box !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6) !important;
    display: block !important;
}

.app-container.desktop-sidebar-closed #investigation-intake-view #wizard-action-bar,
.app-container.desktop-sidebar-closed .intake-footer {
    left: 0 !important;
}

.intake-footer-content {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    align-items: center;
}

.intake-footer-center {
    display: flex;
    flex: 1;
    gap: 16px;
    justify-content: center;
}

.intake-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 110px;
    max-width: 200px;
    height: 38px;
    padding: 0 20px;
    font-family: var(--font-tech, 'JetBrains Mono', monospace);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    white-space: nowrap;
    box-sizing: border-box;
    border: 1px solid transparent;
}

.intake-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.intake-btn-outline {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary, #ffffff);
}

.intake-btn-outline:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

/* Primary Action / Save Case button: System accent red */
.intake-btn-save,
.intake-btn-solid {
    background: var(--accent-red, #d41111);
    border: 1px solid var(--accent-red, #d41111);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(212, 17, 17, 0.35);
}

.intake-btn-save:hover:not(:disabled),
.intake-btn-solid:hover:not(:disabled) {
    background: #b30e0e;
    border-color: #b30e0e;
    box-shadow: 0 0 14px rgba(212, 17, 17, 0.55);
    color: #ffffff;
}

/* Step Forward / Next button: Cyber-command blue accent */
.intake-btn-next {
    background: rgba(96, 165, 250, 0.18);
    border: 1px solid var(--accent-blue-light, #60a5fa);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.25);
}

.intake-btn-next:hover:not(:disabled) {
    background: rgba(96, 165, 250, 0.32);
    border-color: #93c5fd;
    color: #ffffff;
    box-shadow: 0 0 14px rgba(96, 165, 250, 0.45);
}

/* Night-Vision Red Mode compliance */
body[data-theme="red"] .intake-btn-next,
body.red-mode .intake-btn-next {
    background: rgba(212, 17, 17, 0.18);
    border-color: #d41111;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(212, 17, 17, 0.4);
}

body[data-theme="red"] .intake-btn-next:hover:not(:disabled),
body.red-mode .intake-btn-next:hover:not(:disabled) {
    background: rgba(212, 17, 17, 0.35);
    border-color: #ff4d4d;
    color: #ffffff;
}

@media (max-width: 768px) {
    .intake-view-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Vertical Compaction for Header */
    .intake-header {
        padding: 8px 14px;
    }
    .intake-header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .intake-header-content > div {
        width: 100%;
        min-width: 0;
    }
    .intake-header-title {
        font-size: 14px;
        line-height: 1.35;
    }
    .intake-mode-toggle-group {
        width: 100%;
        min-width: 0;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        box-sizing: border-box;
    }
    .intake-mode-btn {
        min-width: 0;
        min-height: 44px;
        padding: 6px 8px;
        font-size: 0.62rem;
        line-height: 1.25;
        white-space: normal;
    }
    .intake-header-status {
        font-size: 9.5px;
        width: 100%;
    }

    .sensor-control-actions {
        width: 100%;
        min-width: 0;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sensor-control-actions .btn {
        min-width: 0;
        min-height: 44px;
        padding: 6px 8px !important;
        line-height: 1.25;
        white-space: normal;
    }

    /* Vertical Compaction for Main Content and Max-Width wrapper */
    .intake-main-content {
        padding: 8px 10px;
        padding-bottom: var(--bottom-clearance) !important;
    }
    .intake-max-width {
        gap: 8px;
    }
    .intake-context-text {
        font-size: 11.5px;
        line-height: 1.35;
        margin-bottom: 6px;
        color: rgba(255, 255, 255, 0.7);
    }
    .hardware-banner {
        margin-top: 4px;
        padding: 6px 10px;
        font-size: 10.5px;
    }

    /* Compact Stepper Component */
    .intake-wizard-timeline {
        margin-bottom: 10px;
    }
    .intake-wizard-timeline::before {
        top: 13px;
    }
    .intake-wizard-timeline .wizard-step-node {
        flex: 1 1 0;
        min-width: 0;
        padding: 0 1px;
        gap: 2px;
    }
    .intake-wizard-timeline .wizard-step-node .step-icon {
        width: 26px;
        height: 26px;
        border-width: 1.5px;
    }
    .intake-wizard-timeline .wizard-step-node .step-icon span {
        font-size: 13px;
    }
    .intake-wizard-timeline .wizard-step-node .step-label {
        white-space: normal;
        font-size: 8.5px;
        line-height: 1.15;
    }

    /* Compact Tab Content & Headers */
    .intake-tab-content {
        padding: 10px 12px;
    }
    .intake-tab-header {
        margin-bottom: 8px;
        gap: 6px;
    }
    .intake-tab-dot {
        width: 6px;
        height: 6px;
    }
    .intake-tab-title {
        font-size: 14px;
        letter-spacing: 0.04em;
    }

    /* Compact Form Rows, Grids, and Inputs */
    .intake-grid {
        gap: 8px;
    }
    .intake-form-group {
        gap: 3px;
    }
    .intake-label {
        font-size: 9.5px;
        letter-spacing: 0.05em;
        margin-bottom: 1px;
    }
    .intake-input, .intake-select, .intake-textarea {
        height: 36px;
        padding: 6px 10px;
        font-size: 13.5px;
    }
    .intake-input-wrapper {
        height: 36px;
    }
    .intake-select-icon {
        right: 8px;
        font-size: 18px;
    }
    .intake-textarea {
        min-height: 52px;
        padding: 6px 10px;
        font-size: 13px;
    }
    .intake-btn-now {
        height: 36px;
        padding: 0 10px;
        font-size: 10px;
    }
    .intake-radio-group {
        height: 34px;
        gap: 14px;
    }
    .intake-radio-label {
        font-size: 10px;
        gap: 6px;
    }
    .intake-checkbox-grid {
        gap: 8px;
        padding-top: 8px;
    }
    .intake-checkbox-label {
        gap: 8px;
        font-size: 10px;
    }
    .intake-category-grid {
        padding: 8px;
        gap: 6px;
    }
    .intake-checkbox-item {
        font-size: 12.5px;
        gap: 6px;
    }
    .intake-dq-box {
        margin-top: 10px;
        padding: 10px;
    }
    .intake-dq-header {
        gap: 8px;
        margin-bottom: 8px;
    }
    .intake-info-box {
        margin-top: 10px;
        padding: 10px;
    }
    .intake-info-title {
        font-size: 11px;
        margin-bottom: 4px;
    }
    .intake-info-text {
        font-size: 12px;
        margin-bottom: 10px;
    }
    .intake-info-btn {
        padding: 6px 12px;
        font-size: 11px;
    }

    /* Compact Bottom Sticky Footer */
    .intake-footer {
        left: 0;
        right: 0;
        bottom: var(--bottom-clearance);
        padding: 8px 10px;
    }

    .intake-footer-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "save save"
            "prev next";
        gap: 6px;
        align-items: stretch;
    }

    .intake-footer-center {
        grid-area: save;
        justify-content: stretch;
        flex-direction: column;
        gap: 6px;
    }

    #wizard-prev-btn {
        grid-area: prev;
    }

    #wizard-next-btn {
        grid-area: next;
    }

    .intake-footer-center .intake-btn,
    .intake-btn {
        width: 100%;
        max-width: none;
        padding: 8px 14px;
        font-size: 10.5px;
        height: auto;
        min-height: 44px;
    }
}

/* Ensure checkboxes remain perfectly square and are not stretched by flexbox */
input[type="checkbox"] {
    aspect-ratio: 1 / 1 !important;
    align-self: center !important;
    flex-shrink: 0 !important;
}

/* Mobile-specific adjustments for intake flow fields and checklists to prevent overflow on mobile & APK */
@media (max-width: 600px) {
    /* Stacks checklist categories vertically to fit mobile screen width */
    .intake-category-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    
    /* Stacks Digital Questionnaires input fields, checkbox, and button vertically */
    .intake-dq-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .intake-dq-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 12px;
    }
    
    .intake-dq-actions > div {
        flex-direction: column;
        min-width: 0 !important;
        width: 100%;
        gap: 8px;
    }
    
    .intake-dq-input {
        width: 100%;
        box-sizing: border-box;
    }
    
    .intake-dq-actions .intake-checkbox-label {
        min-width: 0 !important;
        width: 100%;
    }
    
    .intake-dq-btn {
        width: 100%;
    }
}

/* Beta Data Purge & Granular Item Badges */
.admin-item-pill {
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.admin-item-pill:hover {
    filter: brightness(1.25);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.admin-item-pill:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

.admin-item-card {
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.admin-item-card:hover {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* NOTIFICATION & PROCESSING POPOVER DROPDOWN */
.notification-popover-card {
    position: fixed !important;
    width: 390px !important;
    max-width: calc(100vw - 32px) !important;
    background: rgba(10, 14, 20, 0.98) !important;
    border: 1.5px solid #d41111 !important;
    border-radius: 16px !important;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.95),
                0 0 45px 14px rgba(0, 0, 0, 0.96),
                0 24px 65px 18px rgba(0, 0, 0, 0.98),
                0 0 24px rgba(212, 17, 17, 0.25) !important;
    z-index: 100005 !important;
    padding: 0 !important;
    overflow: visible !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    animation: popoverFadeIn 0.2s ease-out;
}

@media (min-width: 901px) {
    .notification-popover-card {
        box-shadow: 0 0 0 2px rgba(0, 0, 0, 1),
                    0 0 60px 20px rgba(0, 0, 0, 0.98),
                    0 35px 85px 25px rgba(0, 0, 0, 0.99),
                    0 0 28px rgba(212, 17, 17, 0.25) !important;
    }
}

.notification-popover-header {
    background: rgba(10, 14, 20, 0.98) !important;
    border-bottom: 1.5px solid #d41111 !important;
    padding: 8px 12px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-top-left-radius: 14.5px !important;
    border-top-right-radius: 14.5px !important;
    min-height: 38px !important;
}

.notification-popover-arrow {
    position: absolute !important;
    top: -6px !important;
    width: 10px !important;
    height: 10px !important;
    background: rgba(10, 14, 20, 0.98) !important;
    border-top: 1.5px solid #d41111 !important;
    border-left: 1.5px solid #d41111 !important;
    transform: rotate(45deg) !important;
    z-index: 100006 !important;
}

@keyframes popoverFadeIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* SYNC DETAILS POPOVER ACCENTS */
.sync-details-popover {
    border-color: rgba(16, 185, 129, 0.45) !important;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.95),
                0 0 45px 14px rgba(0, 0, 0, 0.96),
                0 24px 65px 18px rgba(0, 0, 0, 0.98),
                0 0 24px rgba(16, 185, 129, 0.22) !important;
}

@media (min-width: 901px) {
    .sync-details-popover {
        box-shadow: 0 0 0 2px rgba(0, 0, 0, 1),
                    0 0 60px 20px rgba(0, 0, 0, 0.98),
                    0 35px 85px 25px rgba(0, 0, 0, 0.99),
                    0 0 28px rgba(16, 185, 129, 0.25) !important;
    }
}

.sync-popover-header {
    border-bottom: 1.5px solid rgba(16, 185, 129, 0.45) !important;
}

.sync-popover-arrow {
    border-top: 1.5px solid rgba(16, 185, 129, 0.45) !important;
    border-left: 1.5px solid rgba(16, 185, 129, 0.45) !important;
}

.popover-dropdown-content {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 14px;
}

@media (min-width: 769px) {
    .notification-popover-card.sync-details-popover {
        width: 360px !important;
    }
    .popover-dropdown-content {
        max-height: calc(100vh - 100px) !important;
    }
}

/* Unified High-Tech Splash & Boot Loader */
.app-splash-loader {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #161b22 0%, #080b10 100%);
    z-index: 200000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 24px;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s ease;
    user-select: none;
    -webkit-user-select: none;
}

.app-splash-loader.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.app-splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    max-width: 480px;
    width: 100%;
    text-align: center;
}

.app-splash-title {
    color: var(--accent, #d41111);
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 700;
    letter-spacing: 5px;
    text-transform: uppercase;
    text-shadow: 0 0 25px rgba(212, 17, 17, 0.7);
    white-space: nowrap;
}

.app-splash-bar-wrap {
    width: min(320px, 80vw);
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.app-splash-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 30%;
    background: linear-gradient(90deg, #d41111, #b30e0e);
    box-shadow: 0 0 16px rgba(212, 17, 17, 0.8);
    transition: width 0.35s ease-out;
    animation: splash-bar-sweep 2.2s infinite ease-in-out;
}

.app-splash-subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(0.68rem, 2.5vw, 0.8rem);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
    min-height: 1.2em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.app-splash-dots {
    display: inline-block;
    width: 24px;
    text-align: left;
    margin-left: 2px;
}

@keyframes splash-bar-sweep {
    0% { left: -30%; width: 30%; }
    50% { left: 40%; width: 50%; }
    100% { left: 100%; width: 30%; }
}

/* --- EVIDENCE ARCHIVE ANIMATIONS & SKELETONS --- */
@keyframes evidenceItemFadeIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.evidence-archive-item-animated {
    animation: evidenceItemFadeIn 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    will-change: transform, opacity;
}

@keyframes skeletonShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.evidence-skeleton-card {
    border-radius: 4px;
    min-height: 130px;
    background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.07) 50%, rgba(255,255,255,0.02) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.8s infinite ease-in-out;
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
}

@keyframes inlineSpinnerRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.evidence-inline-spinner {
    display: inline-block;
    width: 9px;
    height: 9px;
    border: 2px solid var(--accent-blue-light, #60a5fa);
    border-top-color: transparent;
    border-radius: 50%;
    animation: inlineSpinnerRotate 0.75s linear infinite;
    vertical-align: middle;
    margin-right: 5px;
}

/* ==========================================================================
   EVP Baseline Calibration Workflow (Two-Stage Phonetics & Prosody)
   ========================================================================== */
.vp-calibration-card {
    border-radius: 6px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.vp-stage-card {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 16px;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.vp-stage-card.vp-stage-active {
    background: rgba(16, 185, 129, 0.08);
    border-color: var(--success, #10b981);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.18), inset 0 0 15px rgba(16, 185, 129, 0.05);
}

.vp-stage-card.vp-stage-active-stage2 {
    background: rgba(245, 158, 11, 0.08);
    border-color: var(--warning, #f59e0b);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.18), inset 0 0 15px rgba(245, 158, 11, 0.05);
}

.vp-stage-card.vp-stage-inactive {
    opacity: 0.45;
    border-color: rgba(255, 255, 255, 0.06);
    filter: grayscale(40%);
}

.vp-stage-card.vp-stage-done {
    opacity: 0.85;
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.03);
}

.vp-passage-box {
    background: rgba(5, 8, 14, 0.95);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 5px;
    padding: 14px 18px;
    margin: 12px 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #f8fafc;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
}

.vp-target-tag {
    display: inline-block;
    font-size: 0.64rem;
    font-family: var(--font-tech);
    padding: 2px 7px;
    border-radius: 3px;
    background: rgba(96, 165, 250, 0.12);
    color: var(--accent-blue-light, #60a5fa);
    border: 1px solid rgba(96, 165, 250, 0.25);
    margin: 2px;
}

.vp-target-tag.green {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.3);
}

.vp-target-tag.amber {
    background: rgba(245, 158, 11, 0.12);
    color: #fde68a;
    border-color: rgba(245, 158, 11, 0.3);
}

.vp-progress-segmented {
    position: relative;
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    overflow: hidden;
}

.vp-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #10b981 0%, #10b981 48%, #f59e0b 52%, #f59e0b 100%);
    transition: width 0.1s linear;
}

/* HAUNTED LINEAGE DIRECTORY DATABASE INTEGRATION */
.database-site-item {
    transition: all 0.2s ease !important;
}

.database-site-item:hover {
    border-color: rgba(192, 132, 252, 0.6) !important;
    background: rgba(147, 51, 234, 0.12) !important;
    transform: translateY(-1px);
}

.custom-db-map-marker {
    background: transparent;
    border: none;
    cursor: pointer;
}

.custom-db-map-marker div {
    animation: dbMarkerPulse 2.5s infinite;
}

@keyframes dbMarkerPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7); }
    70% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(168, 85, 247, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); }
}

.vp-progress-split-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 48%; /* 12s / 25s = 48% */
    width: 2px;
    background: rgba(255, 255, 255, 0.6);
    z-index: 2;
}

/* ==========================================================================
   LEAFLET MARKER CLUSTER STYLING (Haunted Lineage Spooky & Cyber Theme)
   ========================================================================== */
.marker-cluster {
    background-color: rgba(187, 0, 0, 0.4) !important;
    background-clip: padding-box !important;
    border-radius: 50% !important;
}

.marker-cluster div {
    width: 36px !important;
    height: 36px !important;
    margin-left: 4px !important;
    margin-top: 4px !important;
    text-align: center !important;
    border-radius: 50% !important;
    font-family: var(--font-tech, 'JetBrains Mono', monospace) !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    background-color: #b00 !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8), inset 0 0 4px rgba(255, 255, 255, 0.25) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.marker-cluster span {
    line-height: 36px !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(187, 0, 0, 0.4) !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: #b00 !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8), inset 0 0 4px rgba(255, 255, 255, 0.25) !important;
}

/* Red Mode overrides for Map Clusters */
body.red-mode .marker-cluster {
    background-color: rgba(239, 68, 68, 0.25) !important;
}
body.red-mode .marker-cluster div {
    background-color: #dc2626 !important;
    border: 2px solid #fca5a5 !important;
    color: #ffffff !important;
}

/* Dark Leaflet Tiles & Dark Controls */
.leaflet-container {
    background: #080808 !important;
    font-family: var(--font-tech, 'JetBrains Mono', monospace) !important;
}

.leaflet-tile-pane .dark-tiles {
    filter: invert(100%) hue-rotate(180deg) brightness(85%) contrast(120%) saturate(0.3) !important;
}

.leaflet-control-zoom a {
    background-color: rgba(10, 14, 20, 0.92) !important;
    color: var(--accent-blue-light, #60a5fa) !important;
    border: 1px solid var(--border-color, rgba(255,255,255,0.15)) !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.6) !important;
}

.leaflet-control-zoom a:hover {
    background-color: rgba(37, 99, 235, 0.25) !important;
    color: #ffffff !important;
}

.leaflet-popup-content-wrapper {
    background: #0d1117 !important;
    border: 1px solid rgba(192, 132, 252, 0.45) !important;
    color: #ffffff !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.95), 0 0 1px rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    padding: 0 !important;
    opacity: 1 !important;
}

.leaflet-popup-content {
    margin: 12px 14px !important;
    line-height: 1.4 !important;
}

.leaflet-popup-tip {
    background: #0d1117 !important;
    border: 1px solid rgba(192, 132, 252, 0.45) !important;
    opacity: 1 !important;
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-muted, #94a3b8) !important;
    padding: 4px 6px 0 0 !important;
}

.leaflet-container a.leaflet-popup-close-button:hover {
    color: #ffffff !important;
}

/* ==========================================================================
   LOCATIONS UNIFIED VIEW LAYOUT (Consistent Map Size Across All Tabs)
   ========================================================================== */
.locations-mobile-switcher {
    display: none;
}

.locations-main-layout {
    display: grid !important;
    grid-template-columns: 360px 1fr !important;
    gap: 16px !important;
    height: calc(100vh - 210px) !important;
    min-height: 560px !important;
    max-height: calc(100vh - 210px) !important;
    flex: 1 !important;
}

.locations-sidebar {
    background: rgba(0, 0, 0, 0.45) !important;
    border: 1px solid var(--border-color) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-radius: 6px !important;
    height: 100% !important;
    min-height: 100% !important;
}

.location-item-actions {
    display: flex;
    gap: 8px;
}

.location-item-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.locations-map-wrapper {
    border: 1px solid var(--border-color) !important;
    position: relative !important;
    background: #080808 !important;
    overflow: hidden !important;
    border-radius: 6px !important;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5) !important;
    height: 100% !important;
    min-height: 100% !important;
}

#tactical-map-container {
    height: 100% !important;
    width: 100% !important;
    min-height: 100% !important;
}

@media (max-width: 900px) {
    .locations-main-layout {
        grid-template-columns: 1fr !important;
        height: auto !important;
        max-height: none !important;
    }
    .locations-sidebar {
        height: 380px !important;
        min-height: 380px !important;
    }
    .locations-map-wrapper {
        height: 460px !important;
        min-height: 460px !important;
    }
}

@media (max-width: 900px) {
    .locations-mobile-switcher {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        margin-bottom: 12px;
        padding: 4px;
        background: rgba(0, 0, 0, 0.55);
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }

    .locations-mobile-switch {
        min-height: 44px;
        border: 1px solid transparent;
        border-radius: 5px;
        background: transparent;
        color: var(--text-muted);
        font-family: var(--font-tech);
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .locations-mobile-switch.active {
        color: #ffffff;
        background: rgba(96, 165, 250, 0.18);
        border-color: rgba(96, 165, 250, 0.55);
    }

    #locations-view > .stitch-card {
        min-height: 0 !important;
        overflow: visible !important;
    }

    #locations-view > .stitch-card > .stitch-section-header {
        flex: none !important;
    }

    #locations-view > .stitch-card > div[style*="flex-direction: column"] {
        flex: none !important;
    }

    .locations-main-layout {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .locations-main-layout[data-mobile-panel="directory"] .locations-map-wrapper {
        display: none !important;
    }

    .locations-sidebar {
        order: 2 !important;
        height: min(62dvh, 620px) !important;
        min-height: 0 !important;
        max-height: 620px !important;
        overflow: hidden !important;
    }

    .location-item-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .location-item-actions .btn {
        min-height: 44px;
        padding: 6px;
        line-height: 1.2;
    }

    #locations-list-sidebar {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        padding: 12px !important;
    }

    .locations-map-wrapper {
        order: 1 !important;
        height: clamp(340px, 52vh, 460px) !important;
        min-height: 340px !important;
        max-height: 480px !important;
    }

    #tactical-map-container {
        height: 100% !important;
        min-height: 100% !important;
    }

    #map-selection-hud {
        display: none !important;
    }
}

/* Map Selection HUD & Action Buttons */
#map-selection-hud {
    box-sizing: border-box !important;
    max-width: calc(100% - 24px) !important;
    overflow: hidden !important;
}

#map-selection-actions {
    display: flex !important;
    gap: 8px !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    max-width: 100% !important;
}

.map-hud-btn {
    font-size: 0.68rem !important;
    padding: 8px 12px !important;
    min-height: 36px !important;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-align: center !important;
    white-space: nowrap !important;
}

@media (max-width: 600px) {
    #map-selection-hud {
        bottom: 10px !important;
        left: 10px !important;
        right: 10px !important;
        padding: 10px 12px !important;
        width: calc(100% - 20px) !important;
    }
    #map-selection-actions {
        width: 100% !important;
        margin-top: 6px !important;
    }
    .map-hud-btn {
        font-size: 0.60rem !important;
        padding: 6px 8px !important;
        min-height: 32px !important;
    }
}

/* ============================================================
   PHASE NAVIGATION TABS / SEGMENTED CONTROLLER
   ============================================================ */
.phase-nav-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.45);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-wrap: wrap;
    justify-content: center;
}

.phase-nav-btn {
    font-family: var(--font-tech, 'Courier New', monospace);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1px;
    height: 32px;
    padding: 0 16px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    white-space: nowrap;
    text-decoration: none;
    box-sizing: border-box;
}

.phase-nav-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

.phase-nav-btn.active {
    background: var(--accent-blue, #3b82f6);
    color: #ffffff !important;
    border-color: var(--accent-blue-light, #60a5fa);
    box-shadow: 0 0 14px rgba(59, 130, 246, 0.45);
    font-weight: 700;
    cursor: default;
}

.phase-nav-btn.active.phase-green {
    background: #059669;
    border-color: var(--success, #10b981);
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.45);
}

.phase-nav-title {
    font-family: var(--font-tech, 'Courier New', monospace);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent-blue-light, #60a5fa);
    margin: 0;
    text-align: center;
    text-transform: uppercase;
}

.phase-nav-title.phase-green {
    color: var(--success, #10b981);
}

/* ==========================================================================
   Global Toast Notification System
   ========================================================================== */
.hl-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100010;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
    max-width: 420px;
    width: calc(100vw - 48px);
}

@media (max-width: 640px) {
    .hl-toast-container {
        bottom: 20px;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
    }
}

.hl-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(13, 17, 23, 0.96);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 4px solid var(--accent-blue-light, #60a5fa);
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.65);
    color: var(--text-primary, #e6edf3);
    font-family: var(--font-tech, 'Space Grotesk', monospace);
    font-size: 0.8rem;
    line-height: 1.4;
    letter-spacing: 0.3px;
    animation: hlToastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.hl-toast.hl-toast-success {
    border-left-color: var(--success, #10b981);
}

.hl-toast.hl-toast-warning {
    border-left-color: var(--warning, #f59e0b);
}

.hl-toast.hl-toast-danger {
    border-left-color: var(--danger, #d41111);
}

.hl-toast.hl-toast-info {
    border-left-color: var(--accent-blue-light, #60a5fa);
}

.hl-toast-icon {
    font-size: 1.3rem !important;
    flex-shrink: 0;
}

.hl-toast-success .hl-toast-icon { color: var(--success, #10b981); }
.hl-toast-warning .hl-toast-icon { color: var(--warning, #f59e0b); }
.hl-toast-danger .hl-toast-icon { color: var(--danger, #d41111); }
.hl-toast-info .hl-toast-icon { color: var(--accent-blue-light, #60a5fa); }

.hl-toast-message {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.hl-toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted, #8b949e);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.hl-toast-close:hover {
    opacity: 1;
    color: #ffffff;
}

.hl-toast-leaving {
    animation: hlToastSlideOut 0.25s cubic-bezier(0.7, 0, 0.84, 0) forwards !important;
}

@keyframes hlToastSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes hlToastSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
}

/* ============================================================
   3D ROOM SCANNER & LENS SELECTOR HUD
   ============================================================ */
.room-scanner-lens-select {
    background: rgba(10, 14, 20, 0.85);
    border: 1px solid rgba(96, 165, 250, 0.4);
    color: #fff;
    font-family: var(--font-tech, monospace);
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.room-scanner-lens-select:focus {
    border-color: var(--accent-blue-light, #60a5fa);
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
}

#room-scanner-corner-reel {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(96, 165, 250, 0.4) transparent;
}

#room-scanner-corner-reel::-webkit-scrollbar {
    height: 4px;
}

#room-scanner-corner-reel::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.4);
    border-radius: 2px;
}

.corner-reel-thumb {
    position: relative;
    width: 68px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(96, 165, 250, 0.5);
    background: #000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    animation: cornerThumbPop 0.25s ease-out forwards;
}

.corner-reel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.corner-reel-thumb .thumb-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(10, 14, 20, 0.88);
    font-family: var(--font-tech, monospace);
    font-size: 0.55rem;
    color: #60a5fa;
    text-align: center;
    padding: 1px 0;
    line-height: 1.2;
}

.scanner-flash-effect {
    position: absolute;
    inset: 0;
    background: #fff;
    pointer-events: none;
    z-index: 50;
    animation: scannerFlashAnim 0.3s ease-out forwards;
}

@keyframes scannerFlashAnim {
    0% { opacity: 0.85; }
    100% { opacity: 0; }
}

@keyframes cornerThumbPop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   APP-GRADE AR ROOM SCANNER HUD & GUIDANCE SYSTEM
   ========================================================================== */
.ar-app-guide-card {
    background: rgba(10, 14, 24, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(96, 165, 250, 0.55);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(96, 165, 250, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    text-align: left;
    transition: all 0.25s ease;
}

.ar-guide-live-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    display: inline-block;
    animation: arPulse 1.4s infinite ease-in-out;
}

@keyframes arPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.6; }
}

.ar-stepper-track {
    display: flex;
    align-items: center;
    gap: 3px;
}

.ar-step-node {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-tech, monospace);
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--text-muted, #94a3b8);
    transition: all 0.25s;
}

.ar-step-node.active {
    border-color: var(--accent-blue-light, #60a5fa);
    background: rgba(96, 165, 250, 0.35);
    color: #fff;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.6);
    transform: scale(1.15);
}

.ar-step-node.completed {
    border-color: #10b981;
    background: #10b981;
    color: #000;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.ar-step-line {
    width: 8px;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1px;
    transition: background 0.25s;
}

.ar-step-line.completed {
    background: #10b981;
}

.ar-guide-title {
    font-family: var(--font-tech, monospace);
    font-size: 0.96rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
    margin: 2px 0;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.4);
}

.ar-guide-detail {
    font-size: 0.74rem;
    color: #cbd5e1;
    line-height: 1.35;
    margin-top: 2px;
}

.ar-guide-detail strong {
    color: #fff;
}

.ar-shutter-btn {
    flex: 2.4;
    height: 48px;
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    border: 1.5px solid #f87171;
    border-radius: 26px;
    color: #fff;
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.ar-shutter-btn:active {
    transform: scale(0.93) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4) !important;
}

#room-scanner-corner-reel {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(96, 165, 250, 0.4) transparent;
}

#room-scanner-corner-reel::-webkit-scrollbar {
    height: 4px;
}

#room-scanner-corner-reel::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.4);
    border-radius: 2px;
}

.corner-reel-thumb {
    position: relative;
    width: 68px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(96, 165, 250, 0.5);
    background: #000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    animation: cornerThumbPop 0.25s ease-out forwards;
}

.corner-reel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.corner-reel-thumb .thumb-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(10, 14, 20, 0.88);
    font-family: var(--font-tech, monospace);
    font-size: 0.55rem;
    color: #60a5fa;
    text-align: center;
    padding: 1px 0;
    line-height: 1.2;
}

.scanner-flash-effect {
    position: absolute;
    inset: 0;
    background: #fff;
    pointer-events: none;
    z-index: 50;
    animation: scannerFlashAnim 0.3s ease-out forwards;
}

@keyframes scannerFlashAnim {
    0% { opacity: 0.85; }
    100% { opacity: 0; }
}

@keyframes cornerThumbPop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   APP-GRADE AR ROOM SCANNER HUD & GUIDANCE SYSTEM
   ========================================================================== */
.ar-app-guide-card {
    background: rgba(10, 14, 24, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(96, 165, 250, 0.55);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(96, 165, 250, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    text-align: left;
    transition: all 0.25s ease;
}

.ar-guide-live-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    display: inline-block;
    animation: arPulse 1.4s infinite ease-in-out;
}

@keyframes arPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.6; }
}

.ar-stepper-track {
    display: flex;
    align-items: center;
    gap: 3px;
}

.ar-step-node {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-tech, monospace);
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--text-muted, #94a3b8);
    transition: all 0.25s;
}

.ar-step-node.active {
    border-color: var(--accent-blue-light, #60a5fa);
    background: rgba(96, 165, 250, 0.35);
    color: #fff;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.6);
    transform: scale(1.15);
}

.ar-step-node.completed {
    border-color: #10b981;
    background: #10b981;
    color: #000;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.ar-step-line {
    width: 8px;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1px;
    transition: background 0.25s;
}

.ar-step-line.completed {
    background: #10b981;
}

.ar-guide-title {
    font-family: var(--font-tech, monospace);
    font-size: 0.96rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
    margin: 2px 0;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.4);
}

.ar-guide-detail {
    font-size: 0.74rem;
    color: #cbd5e1;
    line-height: 1.35;
    margin-top: 2px;
}

.ar-guide-detail strong {
    color: #fff;
}

.ar-shutter-btn {
    flex: 2.4;
    height: 48px;
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    border: 1.5px solid #f87171;
    border-radius: 26px;
    color: #fff;
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.ar-shutter-btn:active {
    transform: scale(0.93) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4) !important;
}

.ar-shutter-inner-ring {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ar-shutter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
}

/* Room Scanner Corner Tracker Chips */
.room-scanner-chips-track {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow-x: auto;
    padding: 2px 0;
    scrollbar-width: none;
}
.room-scanner-chips-track::-webkit-scrollbar {
    display: none;
}

.room-scanner-corner-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-family: var(--font-tech, monospace);
    font-size: 0.62rem;
    font-weight: 700;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(15, 23, 42, 0.7);
    color: #94a3b8;
}

.room-scanner-corner-chip.completed {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.35);
}

.room-scanner-corner-chip.active {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.25);
    color: #fff;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
    transform: scale(1.06);
}

/* Room Scanner Toggle Pill Buttons */
.room-scanner-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 9px;
    border-radius: 14px;
    font-family: var(--font-tech, monospace);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(10, 14, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #94a3b8;
}

.room-scanner-toggle-btn:active {
    transform: scale(0.95);
}

/* Finish Room Button Glowing Animation */
@keyframes finishPulse {
    0%, 100% {
        box-shadow: 0 0 16px rgba(16, 185, 129, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.4);
        border-color: #34d399;
    }
    50% {
        box-shadow: 0 0 28px rgba(56, 189, 248, 0.9), inset 0 1px 4px rgba(255, 255, 255, 0.6);
        border-color: #38bdf8;
    }
}

.room-scanner-finish-active {
    animation: finishPulse 2s infinite ease-in-out !important;
}

/* ============================================================ */
/* 2D ARCHITECTURAL ROOM MAPPER (DESKTOP & MOBILE RESPONSIVE)   */
/* ============================================================ */
#room-grid-builder-modal {
    position: fixed;
    inset: 0;
    z-index: 100400;
    background: #06090f;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
}

/* Header Bar */
.rgb-header {
    flex-shrink: 0;
    height: 50px;
    background: #0c111a;
    border-bottom: 1px solid rgba(56, 189, 248, 0.22);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    box-sizing: border-box;
    z-index: 20;
}

.rgb-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.rgb-brand-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    color: #e0f2fe;
    white-space: nowrap;
}

.rgb-room-input {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #f8fafc;
    font-size: 0.76rem;
    padding: 5px 9px;
    width: 140px;
    font-weight: 600;
    transition: border-color 0.2s;
}

.rgb-room-input:focus {
    border-color: #38bdf8;
    outline: none;
}

.rgb-floor-select {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 6px;
    color: #7dd3fc;
    font-size: 0.72rem;
    padding: 4px 8px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.rgb-stats-pill {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 12px;
    padding: 3px 9px;
    color: #38bdf8;
    font-size: 0.68rem;
    font-family: monospace;
    font-weight: bold;
    white-space: nowrap;
}

.rgb-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.rgb-save-btn {
    background: #10b981 !important;
    border: 1px solid #34d399 !important;
    color: #030712 !important;
    font-weight: 800 !important;
    font-size: 0.72rem !important;
    letter-spacing: 1px;
    padding: 6px 14px !important;
    border-radius: 6px !important;
    cursor: pointer;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.35);
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
}

.rgb-save-btn:hover {
    background: #34d399 !important;
    transform: translateY(-1px);
}

.rgb-save-btn:active {
    transform: translateY(1px);
}

/* Main Layout: Left Rail + Canvas + Right Sidebar */
.rgb-main-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    position: relative;
    overflow: hidden;
}

/* Left Vertical Rail */
.rgb-left-rail {
    width: 48px;
    flex-shrink: 0;
    background: #090e17;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    gap: 6px;
    box-sizing: border-box;
    z-index: 10;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.rgb-left-rail::-webkit-scrollbar {
    display: none;
}

.rgb-rail-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

.rgb-rail-btn span.rgb-rail-sub {
    font-size: 0.55rem;
    font-family: monospace;
    font-weight: bold;
    margin-top: 1px;
    line-height: 1;
}

.rgb-rail-btn:hover:not(:disabled) {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.35);
    color: #38bdf8;
}

.rgb-rail-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.rgb-rail-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.rgb-rail-btn.active {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    color: #38bdf8;
}

.rgb-rail-divider {
    width: 24px;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

/* Center Canvas Container */
.rgb-canvas-container {
    flex: 1;
    min-width: 0;
    min-height: 0;
    position: relative;
    background: #070a10;
    overflow: hidden;
    touch-action: none;
}

#room-grid-builder-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Floating Badges & Readouts inside Canvas */
.rgb-floating-coord {
    position: absolute;
    top: 10px;
    left: 12px;
    background: rgba(10, 14, 22, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 4px 8px;
    color: #94a3b8;
    font-size: 0.68rem;
    font-family: monospace;
    pointer-events: none;
    backdrop-filter: blur(4px);
    z-index: 5;
}

.rgb-floating-hint {
    position: absolute;
    top: 10px;
    right: 12px;
    background: rgba(10, 14, 22, 0.88);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 6px;
    padding: 5px 12px;
    color: #cbd5e1;
    font-size: 0.70rem;
    font-family: monospace;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    max-width: min(340px, 80vw);
    z-index: 5;
}

/* Interactive Floating Inspector Pill for Selected Item */
.rgb-floating-inspector {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 18, 28, 0.95);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 24px;
    padding: 5px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.75), 0 0 15px rgba(56, 189, 248, 0.15);
    z-index: 8;
    backdrop-filter: blur(8px);
    flex-wrap: wrap;
    justify-content: center;
}

.rgb-inspector-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    color: #f8fafc;
    font-size: 0.68rem;
    font-family: monospace;
    font-weight: bold;
    padding: 5px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    min-height: 30px;
}

.rgb-inspector-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    color: #38bdf8;
}

.rgb-inspector-btn.danger {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.35);
}

.rgb-inspector-btn.danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
}

/* Right Sidebar (Desktop Catalog) */
.rgb-right-sidebar {
    width: 215px;
    flex-shrink: 0;
    background: #0c111a;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    overflow-y: auto;
    gap: 10px;
    z-index: 10;
}

.rgb-category-dropdown {
    width: 100%;
    background: #080d14;
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 6px;
    color: #e0f2fe;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 6px 8px;
    cursor: pointer;
    outline: none;
    letter-spacing: 0.5px;
}

/* 2-Column Card Grid (matching screenshot) */
.rgb-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.rgb-card-btn {
    aspect-ratio: 1 / 1;
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 4px;
    cursor: pointer;
    color: #cbd5e1;
    transition: all 0.18s ease;
    text-align: center;
    box-sizing: border-box;
}

.rgb-card-btn svg,
.rgb-card-btn .rgb-card-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #38bdf8;
    pointer-events: none;
}

.rgb-card-btn span.rgb-card-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.1;
    pointer-events: none;
    color: #e2e8f0;
}

.rgb-card-btn:hover {
    background: rgba(56, 189, 248, 0.14);
    border-color: #38bdf8;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.rgb-card-btn:active {
    transform: translateY(0);
}

.rgb-card-btn.active {
    background: rgba(56, 189, 248, 0.25);
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* Mobile Bottom Shelf & Drawer */
.rgb-mobile-bottom-shelf {
    display: none;
}

/* ============================================================ */
/* RESPONSIVE BREAKPOINT FOR MOBILE & TABLETS (< 768px)         */
/* ============================================================ */
@media (max-width: 768px) {
    /* Hide desktop right sidebar and left vertical rail */
    .rgb-right-sidebar {
        display: none;
    }

    .rgb-left-rail {
        display: none;
    }

    /* Mobile Header adjustments */
    .rgb-header {
        height: 46px;
        padding: 0 8px;
    }

    .rgb-brand-badge {
        font-size: 0.72rem;
    }

    .rgb-room-input {
        width: 105px;
        font-size: 0.70rem;
        padding: 4px 6px;
    }

    .rgb-floor-select {
        font-size: 0.66rem;
        padding: 3px 5px;
    }

    .rgb-stats-pill {
        display: none; /* Hide on mobile to conserve header space */
    }

    .rgb-save-btn {
        padding: 5px 10px !important;
        font-size: 0.68rem !important;
    }

    /* Floating quick tools for mobile inside canvas */
    .rgb-mobile-floating-tools {
        position: absolute;
        top: 8px;
        left: 8px;
        display: flex;
        gap: 4px;
        z-index: 10;
    }

    .rgb-mobile-tool-btn {
        width: 34px;
        height: 34px;
        border-radius: 8px;
        background: rgba(12, 17, 26, 0.92);
        border: 1px solid rgba(255, 255, 255, 0.15);
        color: #e2e8f0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.9rem;
        cursor: pointer;
        backdrop-filter: blur(6px);
    }

    .rgb-mobile-tool-btn:active {
        background: #38bdf8;
        color: #030712;
    }

    /* Mobile Bottom Shelf */
    .rgb-mobile-bottom-shelf {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        background: #0c111a;
        border-top: 1px solid rgba(56, 189, 248, 0.25);
        z-index: 20;
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }

    /* Category switch tabs */
    .rgb-mobile-tabs {
        display: flex;
        overflow-x: auto;
        gap: 4px;
        padding: 6px 8px 4px 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        -webkit-overflow-scrolling: touch;
    }

    .rgb-mobile-tab-btn {
        flex: 1;
        min-width: 65px;
        padding: 4px 6px;
        font-size: 0.65rem;
        font-weight: 700;
        border-radius: 12px;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: #94a3b8;
        cursor: pointer;
        white-space: nowrap;
        text-align: center;
    }

    .rgb-mobile-tab-btn.active {
        background: rgba(56, 189, 248, 0.2);
        border-color: #38bdf8;
        color: #38bdf8;
    }

    /* Horizontal scroll row of items */
    .rgb-mobile-cards-row {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .rgb-mobile-cards-row .rgb-card-btn {
        width: 68px;
        height: 68px;
        aspect-ratio: auto;
        flex-shrink: 0;
        border-radius: 8px;
    }

    .rgb-mobile-cards-row .rgb-card-btn svg,
    .rgb-mobile-cards-row .rgb-card-btn .rgb-card-icon {
        width: 24px;
        height: 24px;
        font-size: 1.1rem;
    }

    .rgb-mobile-cards-row .rgb-card-btn span.rgb-card-label {
        font-size: 0.60rem;
    }

    .rgb-floating-inspector {
        bottom: 8px;
        max-width: 95vw;
        padding: 4px 8px;
        gap: 4px;
    }

    .rgb-inspector-btn {
        font-size: 0.62rem;
        padding: 4px 8px;
        min-height: 28px;
    }
}


/* ============================================================ */
/* POLISHED APP-LIKE 3D & CAMERA VIEW CONTROLS                  */
/* ============================================================ */

/* Segmented App Navigation Tabs (iOS / Material Style) */
.app-segmented-tabs {
    display: inline-flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.app-segmented-tab {
    padding: 6px 14px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-family: var(--font-tech, monospace);
    font-size: 0.70rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.app-segmented-tab:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.05);
}

.app-segmented-tab.active,
.app-segmented-tab[aria-selected="true"] {
    background: #38bdf8 !important;
    color: #030712 !important;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

/* Floating Viewport Controls (Overlay inside 3D Canvas) */
.viewport-floating-bar {
    position: absolute;
    display: flex;
    gap: 6px;
    align-items: center;
    z-index: 10;
    pointer-events: auto;
}

.viewport-floating-pill {
    background: rgba(10, 14, 22, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    padding: 5px 11px;
    color: #cbd5e1;
    font-family: var(--font-tech, monospace);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.viewport-floating-pill:hover {
    background: rgba(15, 23, 42, 0.95);
    border-color: #38bdf8;
    color: #fff;
    transform: translateY(-1px);
}

.viewport-floating-pill.active {
    background: rgba(56, 189, 248, 0.25) !important;
    border-color: #38bdf8 !important;
    color: #38bdf8 !important;
}

/* Circular Glass Action Buttons */
.glass-circle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.glass-circle-btn:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: #38bdf8;
    color: #fff;
    transform: scale(1.05);
}

.glass-circle-btn:active {
    transform: scale(0.92);
}

/* Native Camera Zoom Pill (0.5x | 1x) */
.camera-zoom-segmented {
    display: inline-flex;
    align-items: center;
    background: rgba(10, 14, 22, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 2px;
    gap: 2px;
    backdrop-filter: blur(8px);
}

.camera-zoom-segment {
    padding: 3px 8px;
    border-radius: 13px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-family: var(--font-tech, monospace);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
}

.camera-zoom-segment.active {
    background: #38bdf8;
    color: #030712;
    font-weight: 800;
}

/* Hide desktop pan step controls on touch/native screens */
@media (hover: none) and (pointer: coarse) {
    #room-scanner-sim-controls {
        display: none !important;
    }
}



/* ---- NATIVE TABLET / MOBILE FIXES ---- */
.h-4 { height: 1rem !important; }
.w-4 { width: 1rem !important; }
.h-6 { height: 1.5rem !important; }
.w-6 { width: 1.5rem !important; }

/* Fix the squished Hamburger menu on tablets */
.mobile-action-btn .icon-close { display: none !important; }
.mobile-action-btn .icon-menu { display: block !important; }
.mobile-action-btn.is-open .icon-menu { display: none !important; }
.mobile-action-btn.is-open .icon-close { display: block !important; }

[data-is-native="true"] .mobile-show-flex { display: flex !important; }

/* ==========================================================================
   AUDIO RESEARCH LAB - FORENSIC DAW RACK SYSTEM
   High-contrast, tactile obsidian dark mode styling matching pro studio gear
   ========================================================================== */

.audio-daw-rack-shell {
    background: #090d14 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 12px !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

.audio-daw-rack-header {
    background: linear-gradient(180deg, rgba(212, 17, 17, 0.12) 0%, rgba(13, 17, 23, 0.95) 100%) !important;
    border-bottom: 1px solid rgba(212, 17, 17, 0.3) !important;
    padding: 14px 20px !important;
}

.audio-daw-filter-card {
    background: rgba(13, 18, 27, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 8px !important;
    padding: 14px !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.audio-daw-filter-card:hover {
    border-color: rgba(212, 17, 17, 0.5) !important;
    box-shadow: 0 4px 16px rgba(212, 17, 17, 0.18) !important;
}

.audio-daw-status-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px currentColor;
}

.audio-daw-waveform-mount {
    background: radial-gradient(circle at 50% 50%, #120a0e 0%, #07070a 100%) !important;
    border: 1px solid rgba(212, 17, 17, 0.25) !important;
    border-radius: 10px !important;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8), 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 15px rgba(212, 17, 17, 0.12) !important;
}

.audio-daw-hud-badge {
    background: rgba(0, 0, 0, 0.65) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    border-radius: 6px !important;
    padding: 6px 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
}

.audio-daw-tactile-btn {
    border-radius: 6px !important;
    font-weight: 700 !important;
    letter-spacing: 0.8px !important;
    text-transform: uppercase !important;
    transition: all 0.15s ease-out !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) !important;
}

.audio-daw-tactile-btn:active {
    transform: translateY(1px) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6) !important;
}



/* ==========================================================================
   DAW AUDIO LAB � PROFESSIONAL WORKSTATION LAYOUT SYSTEM
   Three-column DAW layout: Filter Rack | Waveform Canvas | Clips/Review
   Blue accent scheme (#60a5fa) � Haunted Lineage Lab design system
   ========================================================================== */

#audio-lab-view {
    --daw-heading: #f8fafc;
    --daw-body: #d7dde7;
    --daw-muted: #929cab;
    --daw-control: #7dd3fc;
    --daw-context: #f6c761;
    --daw-live: #5eead4;
    --daw-transcript: #c4b5fd;
    --daw-caution: #fbbf24;
    --daw-danger: #fca5a5;
}

/* -- DAW Header Bar ------------------------------------------------------- */
.daw-header-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px 14px;
    background: linear-gradient(180deg, rgba(13,17,23,0.98) 0%, rgba(10,14,20,0.95) 100%);
    border-bottom: 1px solid rgba(96,165,250,0.2);
    flex-wrap: wrap;
}
.daw-header-left { display: flex; flex-direction: column; gap: 6px; }
.daw-breadcrumbs { display: flex; align-items: center; gap: 6px; }
.daw-breadcrumb-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    color: var(--daw-muted);
    font-family: var(--font-tech);
    font-size: 0.62rem;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.daw-breadcrumb-btn:hover { border-color: var(--accent-blue-light); color: var(--accent-blue-light); }
.daw-breadcrumb-sep { color: rgba(255,255,255,0.2); font-size: 0.7rem; }
.daw-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.daw-title { font-size: 1.35rem; letter-spacing: 4px; margin: 0; color: var(--daw-heading); font-weight: 800; }
.daw-title-tags { display: flex; gap: 6px; }
.daw-title-tags .status-tag:first-child {
    color: var(--daw-context);
    background: rgba(246, 199, 97, 0.08);
    border-color: rgba(246, 199, 97, 0.3);
}
.daw-title-tags .status-tag:last-child {
    color: var(--daw-transcript);
    background: rgba(196, 181, 253, 0.08);
    border-color: rgba(196, 181, 253, 0.28);
}
.daw-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* -- DAW Action Buttons ---------------------------------------------------- */
.daw-action-btn {
    border: none;
    border-radius: 6px;
    font-family: var(--font-tech);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 7px 16px;
    min-height: 34px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.daw-action-btn:active { transform: translateY(1px); }
.daw-action-secondary { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.18); color: #e2e8f0; }
.daw-action-secondary:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.3); }
.daw-action-blue { background: rgba(96,165,250,0.15); border: 1px solid var(--accent-blue-light, #60a5fa); color: var(--accent-blue-light, #60a5fa); }
.daw-action-blue:hover { background: rgba(96,165,250,0.28); }
.daw-action-green { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.5); color: #6ee7b7; }
.daw-action-green:hover { background: rgba(16,185,129,0.25); }
.daw-action-primary { background: var(--accent-blue-light, #60a5fa); border: 1px solid var(--accent-blue-light, #60a5fa); color: #000; font-weight: 800; box-shadow: 0 0 16px rgba(96,165,250,0.3); }
.daw-action-primary:hover { background: #93c5fd; box-shadow: 0 0 24px rgba(96,165,250,0.5); }

/* -- DAW Case Source Strip ------------------------------------------------- */
.daw-source-strip {
    display: grid;
    grid-template-columns: 2fr 1fr 1.2fr;
    gap: 16px;
    padding: 12px 20px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    align-items: start;
}
.daw-source-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    padding: 9px 11px;
    background: rgba(255, 255, 255, 0.018);
    border-left: 2px solid rgba(125, 211, 252, 0.45);
    border-radius: 0 6px 6px 0;
}
.daw-source-field:nth-child(2) { border-left-color: rgba(246, 199, 97, 0.5); }
.daw-source-field:nth-child(3) { border-left-color: rgba(94, 234, 212, 0.5); }
.daw-source-inner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.daw-case-select { flex: 1; min-width: 120px; height: 36px; background: #0d131d !important; color: #fff !important; font-size: 0.72rem; }
.daw-field-label {
    font-family: var(--font-tech);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    color: var(--daw-control);
    text-transform: uppercase;
    margin-bottom: 2px;
}
.daw-source-field:nth-child(2) .daw-field-label { color: var(--daw-context); }
.daw-source-field:nth-child(3) .daw-field-label { color: var(--daw-live); }
.daw-source-status { font-size: 0.6rem; color: var(--daw-muted); }
.daw-workflow-status {
    font-size: 0.65rem;
    color: var(--daw-live);
    line-height: 1.45;
    padding: 5px 8px;
    border-left: 2px solid rgba(94, 234, 212, 0.75);
    background: rgba(94, 234, 212, 0.06);
    border-radius: 0 4px 4px 0;
}
.daw-workflow-status.is-awaiting {
    color: var(--danger);
    font-weight: 700;
    border-left-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}
.daw-location-display { font-size: 0.78rem; color: var(--daw-body); line-height: 1.5; word-wrap: break-word; }
.daw-source-hud { align-items: flex-start; }
.daw-signal-info { font-size: 0.65rem; color: var(--daw-muted); margin-bottom: 4px; }
.daw-timecode-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 4px 12px;
    font-family: var(--font-tech);
}
.daw-tc-label { font-size: 0.6rem; color: var(--daw-muted); }
.daw-tc-val { font-size: 0.72rem; color: var(--daw-control); font-weight: 700; }
.daw-tc-sep { color: rgba(255,255,255,0.2); }
.daw-tc-time { font-size: 0.78rem; color: var(--daw-live); font-weight: 700; }
.daw-tc-muted { color: var(--daw-muted) !important; font-weight: 400 !important; }

/* -- DAW Transport Bar ----------------------------------------------------- */
.daw-transport-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: #0a0e14;
    border-bottom: 1px solid rgba(96,165,250,0.25);
    box-shadow: 0 2px 16px rgba(0,0,0,0.5);
    overflow-x: hidden;
    flex-wrap: wrap;
}
.daw-transport-group { display: flex; align-items: center; gap: 4px; flex: 0 1 auto; flex-wrap: wrap; min-width: 0; }
.daw-transport-divider { width: 1px; height: 28px; background: rgba(255,255,255,0.1); margin: 0 6px; flex-shrink: 0; }
.daw-tport-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 52px;
    height: 48px;
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.daw-tport-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); }
.daw-tport-btn:active { transform: translateY(1px); }
.daw-tport-icon { font-size: 0.9rem; line-height: 1; color: #e2e8f0; }
.daw-tport-label { font-family: var(--font-tech); font-size: 0.52rem; font-weight: 700; letter-spacing: 0.5px; color: var(--daw-body); text-transform: uppercase; }
.daw-tport-utility .daw-tport-label { color: var(--daw-muted); }
.daw-tport-play .daw-tport-label { color: var(--daw-control); }
.daw-tport-record .daw-tport-label { color: var(--daw-danger); }
.daw-tport-play { border-color: rgba(96,165,250,0.4); background: rgba(96,165,250,0.1); }
.daw-tport-play .daw-tport-icon { color: var(--accent-blue-light, #60a5fa); }
.daw-tport-play:hover { background: rgba(96,165,250,0.22); border-color: var(--accent-blue-light); }
.daw-tport-replay { border-color: rgba(96,165,250,0.25); background: rgba(96,165,250,0.06); }
.daw-tport-replay .daw-tport-icon { color: #93c5fd; }
.daw-tport-record { border-color: rgba(212,17,17,0.45); background: rgba(212,17,17,0.1); }
.daw-tport-record .daw-tport-icon { color: #d41111; }
.daw-tport-record:hover { background: rgba(212,17,17,0.22); border-color: #d41111; }
.daw-tport-blue { border-color: rgba(96,165,250,0.4); background: rgba(96,165,250,0.1); }
.daw-tport-blue .daw-tport-icon { color: var(--accent-blue-light, #60a5fa); }
.daw-tport-blue .daw-tport-label { color: var(--accent-blue-light, #60a5fa); }

/* Prominent Toggle Active States */
.daw-tport-btn.active,
.daw-tport-btn.is-active {
    background: rgba(96, 165, 250, 0.22) !important;
    border-color: var(--accent-blue-light, #60a5fa) !important;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.4), inset 0 0 8px rgba(96, 165, 250, 0.2) !important;
}
.daw-tport-btn.active .daw-tport-icon,
.daw-tport-btn.is-active .daw-tport-icon {
    color: #93c5fd !important;
    filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.7));
}
.daw-tport-btn.active .daw-tport-label,
.daw-tport-btn.is-active .daw-tport-label {
    color: #fff !important;
    font-weight: 900 !important;
    text-shadow: 0 0 6px rgba(96, 165, 250, 0.7);
}

.daw-tport-btn.active-amber {
    background: rgba(245, 158, 11, 0.22) !important;
    border-color: #f59e0b !important;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.45), inset 0 0 8px rgba(245, 158, 11, 0.2) !important;
}
.daw-tport-btn.active-amber .daw-tport-icon {
    color: #fbbf24 !important;
    filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.7));
}
.daw-tport-btn.active-amber .daw-tport-label {
    color: #fbbf24 !important;
    font-weight: 900 !important;
    text-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.daw-tport-btn.active-green {
    background: rgba(16, 185, 129, 0.22) !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4), inset 0 0 8px rgba(16, 185, 129, 0.2) !important;
}
.daw-tport-btn.active-green .daw-tport-icon {
    color: #34d399 !important;
    filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.7));
}
.daw-tport-btn.active-green .daw-tport-label {
    color: #34d399 !important;
    font-weight: 900 !important;
}
.daw-volume-group { gap: 6px; }
.daw-vol-btn {
    width: 24px; height: 24px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.daw-vol-btn:hover { background: rgba(255,255,255,0.15); }
.daw-vol-display { font-size: 0.8rem; color: var(--accent-blue-light, #60a5fa); min-width: 44px; text-align: right; font-family: var(--font-tech); }
.daw-vol-unit { font-size: 0.5rem; color: var(--text-muted); }
.daw-palette-select { height: 32px; font-size: 0.65rem; padding: 0 8px; border-radius: 6px; min-width: 110px; }

/* -- DAW Main 3-Column Workspace ------------------------------------------- */
.daw-workspace {
    display: grid;
    grid-template-columns: 260px 1fr 240px;
    min-height: 0;
    gap: 0;
    background: #080c12;
}

/* -- Left Column: Filter Rack ---------------------------------------------- */
.daw-rack-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.06);
    background: #090d14;
    overflow: hidden;
}
.daw-rack-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(96,165,250,0.1) 0%, rgba(13,17,23,0.95) 100%);
    border-bottom: 1px solid rgba(96,165,250,0.25);
    flex-shrink: 0;
}
.daw-rack-title { font-family: var(--font-tech); font-size: 0.72rem; font-weight: 800; letter-spacing: 1.5px; color: var(--daw-heading); flex: 1; }
.daw-rack-body {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    flex-wrap: wrap;
    display: flex;
    gap: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.daw-rack-body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* -- Rack Modules ---------------------------------------------------------- */
.daw-rack-module {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.2s;
}
.daw-rack-module:hover { border-color: rgba(255,255,255,0.18); }

/* Illuminated / Engaged Module state when toggle is ON */
.daw-rack-module.module-engaged {
    background: rgba(255,255,255,0.04) !important;
    border-color: rgba(255,255,255,0.25) !important;
    box-shadow: 0 0 14px rgba(0,0,0,0.5), inset 0 0 10px rgba(255,255,255,0.03) !important;
}
.daw-rack-module.daw-module-amber.module-engaged {
    border-color: rgba(245, 158, 11, 0.45) !important;
    border-left: 3px solid #f59e0b !important;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.2), inset 0 0 8px rgba(245, 158, 11, 0.08) !important;
}
.daw-rack-module.daw-module-blue.module-engaged {
    border-color: rgba(96, 165, 250, 0.5) !important;
    border-left: 3px solid var(--accent-blue-light, #60a5fa) !important;
    box-shadow: 0 0 14px rgba(96, 165, 250, 0.2), inset 0 0 8px rgba(96, 165, 250, 0.08) !important;
}
.daw-rack-module.daw-module-purple.module-engaged {
    border-color: rgba(139, 92, 246, 0.5) !important;
    border-left: 3px solid #8b5cf6 !important;
    box-shadow: 0 0 14px rgba(139, 92, 246, 0.2), inset 0 0 8px rgba(139, 92, 246, 0.08) !important;
}
.daw-rack-module.daw-module-teal.module-engaged {
    border-color: rgba(20, 184, 166, 0.5) !important;
    border-left: 3px solid #14b8a6 !important;
    box-shadow: 0 0 14px rgba(20, 184, 166, 0.2), inset 0 0 8px rgba(20, 184, 166, 0.08) !important;
}

/* Switch toggle glow when ON */
.switch input:checked + .slider-bg {
    box-shadow: 0 0 8px currentColor, inset 0 0 4px rgba(0,0,0,0.3);
}
.switch input:checked + .slider-bg + .slider-dot {
    background-color: #ffffff !important;
    box-shadow: 0 0 6px #fff;
}

.daw-module-label { font-family: var(--font-tech); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.5px; color: var(--text-muted); text-transform: uppercase; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.daw-module-sublabel { font-family: var(--font-tech); font-size: 0.6rem; color: var(--daw-body); }
.daw-module-caution { font-size: 0.55rem; color: var(--daw-danger); line-height: 1.3; }
.daw-module-amber { border-left: 2px solid #f59e0b; }
.daw-module-amber .daw-module-label { color: #fbbf24; }
.daw-module-blue { border-left: 2px solid var(--accent-blue-light, #60a5fa); }
.daw-module-blue .daw-module-label { color: var(--accent-blue-light, #60a5fa); }
.daw-module-purple { border-left: 2px solid #8b5cf6; }
.daw-module-purple .daw-module-label { color: #a78bfa; }
.daw-module-teal { border-left: 2px solid #14b8a6; }
.daw-module-teal .daw-module-label { color: #2dd4bf; }
.daw-module-green { border-left: 2px solid #10b981; }
.daw-module-green .daw-module-label { color: #34d399; }
.daw-module-red { border-left: 2px solid #d41111; }
.daw-module-red .daw-module-label { color: #f87171; }
.daw-module-indigo { border-left: 2px solid #3b82f6; }
.daw-module-indigo .daw-module-label { color: #93c5fd; }
.daw-module-pink { border-left: 2px solid #ec4899; }
.daw-module-pink .daw-module-label { color: #f472b6; }
.daw-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.daw-slider-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.daw-slider { flex: 1; min-width: 60px; height: 10px; padding: 0; margin: 0; }
.daw-slider-val { font-family: var(--font-tech); font-size: 0.68rem; font-weight: 700; min-width: 52px; text-align: right; }
.daw-slider-unit { font-family: var(--font-tech); font-size: 0.6rem; color: var(--text-muted); }
.daw-spinbox { display: flex; align-items: center; background: rgba(0,0,0,0.4); border: 1px solid var(--border-color); border-radius: 4px; overflow: hidden; height: 24px; flex-shrink: 0; }
.daw-spinbox-btn { width: 20px; height: 100%; padding: 0; border: none; background: rgba(255,255,255,0.06); color: #fff; font-size: 0.9rem; cursor: pointer; line-height: 1; transition: background 0.15s; }
.daw-spinbox-btn:hover { background: rgba(255,255,255,0.15); }
.daw-spinbox-input { width: 44px; height: 100%; font-size: 0.7rem; padding: 0; border: none; background: transparent; color: #fff; text-align: center; font-family: var(--font-tech); }
.daw-reset-btn { font-family: var(--font-tech); font-size: 0.55rem; font-weight: 700; padding: 2px 6px; border: 1px solid rgba(255,255,255,0.15); border-radius: 3px; background: rgba(255,255,255,0.04); color: var(--text-muted); cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.daw-reset-btn:hover { border-color: rgba(255,255,255,0.3); color: #fff; }
.daw-rack-presets { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.07); }
.daw-preset-btn { font-family: var(--font-tech); font-size: 0.62rem; font-weight: 700; padding: 8px 10px; border: 1px solid rgba(16,185,129,0.4); border-radius: 6px; background: rgba(16,185,129,0.1); color: #6ee7b7; cursor: pointer; text-align: center; transition: all 0.15s; }
.daw-preset-btn:hover { background: rgba(16,185,129,0.2); border-color: #10b981; }
.daw-reset-all-btn { font-family: var(--font-tech); font-size: 0.6rem; padding: 6px; border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; background: transparent; color: var(--text-muted); cursor: pointer; transition: all 0.15s; }
.daw-reset-all-btn:hover { border-color: rgba(255,255,255,0.25); color: #fff; }

/* -- Center Column: Main Canvas -------------------------------------------- */
.daw-main-canvas {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    overflow-y: auto;
    background: #0c1018;
    min-width: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(96,165,250,0.3) transparent;
}
.daw-waveform-mount {
    background: radial-gradient(circle at 50% 50%, #0d0e18 0%, #060608 100%) !important;
    border: 1px solid rgba(96,165,250,0.2) !important;
    border-radius: 8px !important;
    padding: 16px !important;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.8), 0 0 15px rgba(96,165,250,0.08) !important;
}
.daw-analyze-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: rgba(10,14,20,0.7);
    border: 1px solid rgba(96,165,250,0.2);
    border-radius: 6px;
}
.daw-analyze-btn {
    font-family: var(--font-tech);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    min-height: 34px;
    padding: 6px 16px;
    border: 1px solid rgba(96,165,250,0.35);
    border-radius: 6px;
    background: rgba(96,165,250,0.08);
    color: var(--accent-blue-light, #60a5fa);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.daw-analyze-btn:hover { background: rgba(96,165,250,0.18); border-color: rgba(96,165,250,0.6); }

/* -- AI Forensic Rack ------------------------------------------------------ */
.daw-ai-rack { background: #090d14; border: 1px solid rgba(96,165,250,0.25); border-radius: 10px; overflow: hidden; }
.daw-ai-rack-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(96,165,250,0.1) 0%, rgba(13,17,23,0.95) 100%);
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.daw-ai-status-badge { font-family: var(--font-tech); font-size: 0.65rem; padding: 3px 8px; border-radius: 4px; background: rgba(96,165,250,0.1); border: 1px solid rgba(96,165,250,0.3); color: #fff; }
.daw-ai-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.daw-ai-btn { font-family: var(--font-tech); font-size: 0.7rem; font-weight: 700; min-height: 34px; padding: 5px 12px; border-radius: 6px; cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; justify-content: center; text-align: center; white-space: normal; line-height: 1.25; }
.daw-ai-btn-blue { background: rgba(59,130,246,0.08); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3); }
.daw-ai-btn-blue:hover { background: rgba(59,130,246,0.18); border-color: rgba(59,130,246,0.55); }
.daw-ai-btn-blue-light { background: rgba(96,165,250,0.08); color: var(--accent-blue-light); border: 1px solid rgba(96,165,250,0.3); }
.daw-ai-btn-blue-light:hover { background: rgba(96,165,250,0.18); border-color: rgba(96,165,250,0.55); }
.daw-ai-btn-purple { background: rgba(139,92,246,0.08); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.3); }
.daw-ai-btn-purple:hover { background: rgba(139,92,246,0.18); border-color: rgba(139,92,246,0.55); }
.daw-ai-btn-teal { background: rgba(20,184,166,0.08); color: #99f6e4; border: 1px solid rgba(20,184,166,0.3); }
.daw-ai-btn-teal:hover { background: rgba(20,184,166,0.18); border-color: rgba(20,184,166,0.55); }
.daw-ai-btn-amber { background: rgba(245,158,11,0.08); color: #fcd34d; border: 1px solid rgba(245,158,11,0.3); }
.daw-ai-btn-amber:hover { background: rgba(245,158,11,0.18); border-color: rgba(245,158,11,0.55); }
.daw-ai-btn-cyan { background: rgba(6,182,212,0.08); color: #67e8f9; border: 1px solid rgba(6,182,212,0.3); }
.daw-ai-btn-cyan:hover { background: rgba(6,182,212,0.18); border-color: rgba(6,182,212,0.55); }
.daw-ai-btn-green { background: rgba(16,185,129,0.08); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }
.daw-ai-btn-green:hover { background: rgba(16,185,129,0.18); border-color: rgba(16,185,129,0.55); }
.daw-ai-btn-neutral { background: rgba(255,255,255,0.04); color: #9ca3af; border: 1px solid rgba(255,255,255,0.12); }
.daw-ai-btn-neutral:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.22); color: #f3f4f6; }
.daw-results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; padding: 12px 16px; }
.daw-result-panel { background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.08); border-radius: 6px; padding: 12px; }
.daw-result-header { font-family: var(--font-tech); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.8px; color: var(--daw-control); margin-bottom: 8px; text-transform: uppercase; }
.daw-result-panel { color: var(--daw-body); }
.daw-save-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid rgba(255,255,255,0.06); flex-wrap: wrap; }
.audio-lab-transcription-delete {
    width: 30px;
    height: 28px;
    padding: 0;
    background: rgba(212, 17, 17, 0.3);
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.75);
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 0 8px rgba(212, 17, 17, 0.16);
}
.audio-lab-transcription-delete:hover,
.audio-lab-transcription-delete:focus-visible {
    background: #d41111;
    color: #ffffff;
    border-color: #f87171;
    box-shadow: 0 0 12px rgba(212, 17, 17, 0.45);
    outline: none;
}

/* -- Right Column: Side Panel ---------------------------------------------- */
.daw-side-panel { display: flex; flex-direction: column; border-left: 1px solid rgba(255,255,255,0.06); background: #090d14; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(96,165,250,0.3) transparent; }
.daw-side-section { display: flex; flex-direction: column; border-bottom: 1px solid rgba(255,255,255,0.06); }
.daw-side-section-clips .daw-rack-header {
    background: linear-gradient(180deg, rgba(246, 199, 97, 0.09), rgba(13,17,23,0.95));
    border-bottom-color: rgba(246, 199, 97, 0.25);
}
.daw-side-section-clips .audio-daw-status-led,
.daw-side-section-clips .daw-rack-title { color: var(--daw-context) !important; }
.daw-side-section-voiceprints .daw-rack-header {
    background: linear-gradient(180deg, rgba(94, 234, 212, 0.09), rgba(13,17,23,0.95));
    border-bottom-color: rgba(94, 234, 212, 0.25);
}
.daw-side-section-voiceprints .audio-daw-status-led,
.daw-side-section-voiceprints .daw-rack-title { color: var(--daw-live) !important; }

/* -- Responsive ------------------------------------------------------------ */
@media screen and (max-width: 1200px) {
    .daw-workspace { grid-template-columns: 230px 1fr 210px; }
}
@media screen and (max-width: 960px) {
    .daw-workspace { grid-template-columns: 1fr; }
    .daw-rack-panel { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.06); }
    .daw-side-panel { border-left: none; border-top: 1px solid rgba(255,255,255,0.06); }
    .daw-source-strip { grid-template-columns: 1fr 1fr; }
    .daw-source-hud { grid-column: span 2; }
}
@media screen and (max-width: 680px) {
    .daw-header-bar { flex-direction: column; }
    .daw-source-strip { grid-template-columns: 1fr; }
    .daw-source-hud { grid-column: auto; }
    .daw-transport-bar { gap: 3px; padding: 6px 10px; }
    .daw-tport-btn { min-width: 42px; height: 40px; }
    .daw-title { font-size: 1.05rem; letter-spacing: 2px; }
}

/* -- DAW Side Panel AI section --------------------------------------------- */
.daw-side-ai-section {
    flex-shrink: 0;
}
.daw-side-ai-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.daw-side-ai-actions .daw-ai-btn {
    font-size: 0.67rem;
    min-height: 30px;
    padding: 4px 10px;
    text-align: left;
    justify-content: flex-start;
}

/* Widen the right column for AI content */
.daw-workspace {
    grid-template-columns: 260px 1fr 300px;
}
@media screen and (max-width: 1200px) {
    .daw-workspace { grid-template-columns: 220px 1fr 270px; }
}

/* -- Voiceprint Registry --------------------------------------------------- */
.daw-vp-filter-bar {
    display: flex;
    gap: 3px;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.2);
    flex-wrap: wrap;
}
.daw-vp-filter {
    font-family: var(--font-tech);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 7px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.daw-vp-filter:hover { border-color: rgba(16,185,129,0.4); color: #6ee7b7; }
.daw-vp-filter.active {
    background: rgba(16,185,129,0.18);
    border-color: #10b981;
    color: #34d399;
}

.daw-vp-add-row {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Role badge shown on each voiceprint card */
.vp-role-badge {
    font-family: var(--font-tech);
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
}
.vp-role-team      { background: rgba(96,165,250,0.15); color: var(--accent-blue-light); border: 1px solid rgba(96,165,250,0.3); }
.vp-role-owner     { background: rgba(245,158,11,0.15); color: #fbbf24;  border: 1px solid rgba(245,158,11,0.3); }
.vp-role-witness   { background: rgba(139,92,246,0.15); color: #c4b5fd;  border: 1px solid rgba(139,92,246,0.3); }
.vp-role-client    { background: rgba(20,184,166,0.15); color: #2dd4bf;  border: 1px solid rgba(20,184,166,0.3); }
.vp-role-subject   { background: rgba(212,17,17,0.15);  color: #f87171;  border: 1px solid rgba(212,17,17,0.3); }
.vp-role-other     { background: rgba(255,255,255,0.06);color: var(--text-muted); border: 1px solid rgba(255,255,255,0.12); }

/* Workspace surfaces share the auth screen's charcoal, red, and warm metal palette. */
#main-app .main-content {
    background: linear-gradient(180deg, #111318 0%, #0c0e12 100%);
}
#main-app .header {
    background: #15171c;
    border-bottom-color: rgba(224, 196, 154, 0.16);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
#main-app .stitch-sidebar {
    background: #0e1014;
    border-right-color: rgba(224, 196, 154, 0.14);
}
#main-app .stitch-nav-item {
    border-radius: 0 6px 6px 0;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
#main-app .stitch-nav-item:hover,
#main-app .stitch-nav-item.active {
    color: #fff;
    background: rgba(224, 196, 154, 0.08);
}
#main-app .stitch-nav-item.active {
    border-left-color: var(--accent-red);
}
#main-app .stitch-nav-item.active span {
    letter-spacing: 0;
}
#main-app .stitch-bottom-nav {
    background: #111318;
    border-top-color: rgba(224, 196, 154, 0.18);
}
#main-app .btn-primary {
    background: linear-gradient(135deg, #d41111, #ac1116);
    border-color: rgba(255, 155, 155, 0.32);
    box-shadow: 0 4px 14px rgba(212, 17, 17, 0.22);
}
#main-app .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #e01b1b, #b30f0f);
    box-shadow: 0 6px 18px rgba(212, 17, 17, 0.32);
}
#main-app .btn-secondary {
    background: rgba(255, 255, 255, 0.04);
}
#main-app .form-input {
    background-color: rgba(9, 10, 13, 0.72);
    border-color: var(--input-border);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.24);
}
#main-app :is(button, a, input, select, textarea, [role="button"]):focus-visible {
    outline: 2px solid var(--accent-gold) !important;
    outline-offset: 2px !important;
}
#main-app .stitch-card,
#main-app .stitch-case-card,
#main-app .card {
    border-radius: var(--border-radius-md);
}
#dashboard-view .dashboard-grid-layout {
    gap: 24px;
}
#dashboard-view .dashboard-grid-layout :is(#active-inv-section, #env-data-section, .team-panel, .processing-card) {
    background: transparent;
    border: 0;
    border-bottom: 1px solid rgba(224, 196, 154, 0.16);
    border-radius: 0;
    box-shadow: none;
}
#dashboard-view .dashboard-grid-layout .stitch-section-header {
    width: 48px;
    height: 2px;
}
#dashboard-view .dashboard-grid-layout .form-section-title {
    font-family: 'Oswald', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-gold) !important;
    letter-spacing: 0;
}
#dashboard-view .stat-card {
    background: #1b1e24;
    border: 1px solid rgba(224, 196, 154, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
#main-app :is(#investigations-view, #settings-view) > .stitch-card {
    border-color: rgba(224, 196, 154, 0.2);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
#investigations-view .page-title,
#settings-view > .stitch-card .section-title {
    font-family: 'Oswald', sans-serif;
    color: #fff !important;
    letter-spacing: 0;
}
@media (max-width: 680px) {
    #audio-lab-view {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    #audio-lab-view .daw-header-bar,
    #audio-lab-view .daw-source-strip,
    #audio-lab-view .daw-transport-bar,
    #audio-lab-view .daw-workspace {
        width: 100%;
        box-sizing: border-box;
    }
    #investigations-view .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    #investigations-view .case-list-topbar {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        width: 100%;
    }
    #investigations-view .case-header-actions {
        width: 100%;
        display: flex !important;
        gap: 8px !important;
        align-items: center;
        flex-wrap: nowrap !important;
    }
    #investigations-view .case-header-actions .btn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        text-align: center;
        justify-content: center;
        padding: 8px 6px !important;
        font-size: 0.70rem !important;
        white-space: nowrap !important;
    }
    #investigations-view .search-box,
    #investigations-view .search-box .form-input {
        width: 100% !important;
        min-width: 0;
    }
}

@media screen and (max-width: 960px) {
    #audio-lab-view .daw-workspace {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: minmax(0, 1fr) !important;
    }
    #audio-lab-view .daw-main-canvas {
        order: 1 !important;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    #audio-lab-view .daw-rack-panel {
        order: 2 !important;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    #audio-lab-view .daw-side-panel {
        order: 3 !important;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Mobile Collapsible Accordion for DSP Filter Rack */
    #audio-lab-view .daw-rack-header {
        user-select: none;
        cursor: pointer;
        padding: 10px 14px;
        background: rgba(15, 23, 42, 0.85);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        transition: background 0.2s ease;
    }
    #audio-lab-view .daw-rack-header:hover {
        background: rgba(20, 30, 50, 0.95);
    }
    #audio-lab-view .daw-rack-collapse-icon {
        display: inline-block !important;
        transition: transform 0.25s ease;
    }
    #audio-lab-view .daw-rack-panel.collapsed .daw-rack-collapse-icon {
        transform: rotate(-90deg);
    }
    #audio-lab-view .daw-rack-panel.collapsed .daw-rack-body {
        display: none !important;
    }
}

@media screen and (max-width: 680px) {
    #audio-lab-view .daw-transport-bar {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 8px 10px !important;
        background: #0d121c !important;
    }
    #audio-lab-view .daw-transport-divider {
        display: none !important;
    }
    #audio-lab-view .daw-transport-group {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
        align-items: center !important;
    }
    #audio-lab-view .daw-transport-group:first-child {
        width: 100% !important;
        justify-content: space-between !important;
        padding-bottom: 4px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    #audio-lab-view .daw-tport-play,
    #audio-lab-view .daw-tport-replay,
    #audio-lab-view .daw-tport-record {
        flex: 1 !important;
        min-height: 44px !important;
        font-size: 0.78rem !important;
        justify-content: center !important;
    }
    #audio-lab-view .daw-volume-group {
        width: 100% !important;
        justify-content: space-between !important;
        padding: 4px 0 !important;
    }
    #audio-lab-view .daw-volume-group input[type="range"] {
        flex: 1 !important;
        margin: 0 8px !important;
    }
}

@media screen and (max-width: 768px) {
    :root {
        --bottom-nav-height: 60px;
        --bottom-clearance: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    }

    .header-left,
    .header-brand-wrap {
        display: flex !important;
        flex: 0 0 auto;
    }
    .header-brand-title,
    .header-tablet-view {
        display: none !important;
    }
    .header {
        justify-content: space-between !important;
    }
    .mobile-action-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }

    .main-content,
    [data-is-native="true"] .main-content {
        padding-bottom: var(--bottom-clearance) !important;
        scroll-padding-bottom: var(--bottom-clearance);
    }
    .bottom-nav-bar,
    [data-is-native="true"] .bottom-nav-bar {
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
        min-height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
        box-sizing: border-box !important;
        padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px)) !important;
    }
    .sidebar-backdrop {
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
    }

    #tools-quick-menu-modal {
        position: fixed !important;
        inset: 0 !important;
    }
    #tools-quick-menu-modal .tools-popover-wrapper {
        position: absolute !important;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 14px) !important;
        right: 12px !important;
        width: calc(100% - 24px) !important;
        max-width: 320px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
        filter: drop-shadow(0 12px 28px rgba(0,0,0,0.7)) !important;
    }
    #tools-quick-menu-modal .card {
        width: 100% !important;
        max-height: calc(100dvh - var(--bottom-nav-height) - env(safe-area-inset-bottom, 0px) - 80px) !important;
        overflow-y: auto !important;
        margin: 0 !important;
        padding: 18px !important;
        border-radius: 20px !important;
        border: 1px solid rgba(224, 196, 154, 0.28) !important;
        background: #0a0e14 !important;
        box-shadow: 0 18px 44px rgba(0,0,0,0.7), 0 0 0 1px rgba(212,17,17,0.08) !important;
    }
    #tools-modal-caret {
        display: block !important;
        flex-shrink: 0 !important;
        width: 18px !important;
        height: 10px !important;
        margin-right: 24px !important;
        margin-top: -1px !important;
        overflow: visible !important;
    }
    #tools-modal-caret svg {
        width: 18px !important;
        height: 10px !important;
        display: block !important;
    }
    #tools-quick-menu-modal .tool-quick-card:active {
        opacity: 0.75;
        transform: scale(0.97);
    }


    #audio-lab-view .daw-transport-bar {
        flex-wrap: wrap;
        overflow-x: hidden;
        align-items: stretch;
        gap: 6px;
        padding: 8px;
    }
    #audio-lab-view .daw-transport-group {
        flex: 1 1 auto;
        flex-wrap: wrap;
        min-width: 0;
    }
    #audio-lab-view .daw-transport-divider {
        display: none;
    }
    #audio-lab-view .daw-tport-btn {
        flex: 1 1 48px;
        min-width: 48px;
        height: 42px;
        padding: 3px 5px;
    }
    #audio-lab-view .daw-volume-group,
    #audio-lab-view .daw-transport-bar > .daw-transport-group:last-child {
        flex: 1 1 100%;
        width: 100%;
        margin-left: 0 !important;
    }
    #audio-lab-view .daw-volume-group input[type="range"] {
        flex: 1;
        min-width: 80px;
    }
    #audio-lab-view .daw-palette-select {
        flex: 1;
        min-width: 0;
    }
    #audio-lab-view .daw-transport-bar > .daw-transport-group:last-child .daw-tport-btn {
        width: 100%;
    }
}

[data-is-native="true"] .mobile-action-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
}

/* Mobile readability: preserve information density without sub-12px UI text. */
@media screen and (max-width: 768px) {
    .bottom-nav-bar .nav-item span {
        font-size: 12px !important;
        line-height: 1.1 !important;
    }

    .fab-button .fab-label {
        font-size: 12px !important;
    }

    :where(.view, .modal) :is(
        [style*="font-size:0.5"],
        [style*="font-size: 0.5"],
        [style*="font-size:0.6"],
        [style*="font-size: 0.6"],
        [style*="font-size:0.7"],
        [style*="font-size: 0.7"],
        [style*="font-size:8px"],
        [style*="font-size: 8px"],
        [style*="font-size:9px"],
        [style*="font-size: 9px"],
        [style*="font-size:10px"],
        [style*="font-size: 10px"],
        [style*="font-size:11px"],
        [style*="font-size: 11px"]
    ) {
        font-size: 13px !important;
    }

    .view .btn:not(.map-hud-btn),
    .view .tech-text-label,
    .view .form-label,
    .modal .btn:not(.map-hud-btn),
    .modal .tech-text-label,
    .modal .form-label {
        font-size: 13px !important;
    }

    .view :is(.badge, .status-tag, .vp-role-badge),
    .modal :is(.badge, .status-tag, .vp-role-badge) {
        font-size: 12px !important;
        line-height: 1.2 !important;
    }

    .intake-mode-btn,
    .intake-header-status,
    .intake-label,
    .intake-wizard-timeline .wizard-step-node .step-label,
    .intake-btn-now,
    .intake-radio-label,
    .intake-checkbox-label,
    .intake-info-title,
    .intake-info-btn,
    .intake-btn {
        font-size: 12px !important;
        line-height: 1.3 !important;
    }

    .intake-context-text,
    .hardware-banner {
        font-size: 13px !important;
        line-height: 1.45 !important;
    }

    .stitch-stat-sub,
    .stitch-stat-sub span,
    .env-subsection-source,
    .data-source-badge,
    .control-group-header,
    .corr-stat-label,
    .corr-stat-sub {
        font-size: 12px !important;
        line-height: 1.4 !important;
    }

    .form-section-title {
        font-size: 14px !important;
        line-height: 1.3 !important;
    }

    .phase-nav-btn,
    .locations-mobile-switch,
    .paralibrary-cat-pill,
    .cat-pill {
        min-width: 0;
        min-height: 40px;
        font-size: 12px !important;
        line-height: 1.25 !important;
        white-space: normal;
    }

    #audio-lab-view :is(
        .daw-field-label,
        .daw-source-status,
        .daw-workflow-status,
        .daw-signal-info,
        .daw-tc-label,
        .daw-tc-val,
        .daw-tport-label,
        .daw-rack-title,
        .daw-rack-tag,
        .daw-module-label,
        .daw-module-sublabel,
        .daw-module-caution,
        .daw-slider-val,
        .daw-slider-unit,
        .daw-reset-btn,
        .daw-result-header,
        .daw-ai-status-badge,
        .daw-vp-filter,
        .vp-role-badge,
        .filter-help,
        .daw-vol-unit
    ) {
        font-size: 12px !important;
        line-height: 1.3 !important;
    }

    #audio-lab-view :is(
        .daw-preview-status,
        .daw-attach-status,
        #audio-lab-workflow-status,
        #al-rack-active-badge
    ),
    #audio-lab-view .daw-lab-header [class*="text-[9px]"],
    #audio-lab-view .daw-lab-header [class*="text-[10px]"] {
        font-size: 12px !important;
        line-height: 1.3 !important;
    }

    #audio-lab-view :is(
        .daw-breadcrumb-btn,
        .daw-action-btn,
        .daw-analyze-btn,
        .daw-ai-btn,
        .daw-preset-btn,
        .daw-reset-all-btn,
        .daw-case-select,
        .daw-palette-select,
        .daw-spinbox-input
    ) {
        font-size: 13px !important;
        line-height: 1.3 !important;
    }

    #audio-lab-view :is(.daw-action-btn, .daw-analyze-btn, .daw-ai-btn, .daw-preset-btn) {
        min-height: 40px !important;
        white-space: normal !important;
    }

    #video-lab-view :is(
        .video-lab-subtitle,
        .video-lab-zoom-controls > .tech-text,
        #video-lab-zoom-value,
        #video-lab-hud-timecode,
        #video-lab-hud-frame,
        #video-lab-hud-res,
        #video-lab-hud-fps,
        #video-timeline-pos,
        .video-timeline-heading,
        .video-timeline-label,
        .timeline-track-label,
        #telemetry-sync-status,
        #telemetry-sync-summary,
        #video-marks-count,
        .video-sidebar-tab
    ) {
        font-size: 12px !important;
        line-height: 1.3 !important;
    }

    #video-lab-view :is(
        .camera-mount-btn,
        .video-tool-btn,
        .video-zoom-btn,
        .video-zoom-reset,
        .speed-pill,
        .amp-pill,
        .cadence-btn,
        .triage-view-btn,
        .triage-filter-chip,
        .frame-mini-pill
    ) {
        min-height: 36px;
        font-size: 13px !important;
        line-height: 1.2 !important;
    }
}

/* Native landscape can exceed the phone breakpoint but needs the same DAW floor. */
[data-is-native="true"] #audio-lab-view :is(
    .daw-field-label,
    .daw-source-status,
    .daw-workflow-status,
    .daw-signal-info,
    .daw-tc-label,
    .daw-tc-val,
    .daw-tport-label,
    .daw-rack-title,
    .daw-rack-tag,
    .daw-module-label,
    .daw-module-sublabel,
    .daw-module-caution,
    .daw-slider-val,
    .daw-slider-unit,
    .daw-reset-btn,
    .daw-result-header,
    .daw-ai-status-badge,
    .daw-vp-filter,
    .vp-role-badge,
    .filter-help,
    .daw-vol-unit
) {
    font-size: 12px !important;
    line-height: 1.3 !important;
}

[data-is-native="true"] #audio-lab-view :is(
    .daw-breadcrumb-btn,
    .daw-action-btn,
    .daw-analyze-btn,
    .daw-ai-btn,
    .daw-preset-btn,
    .daw-reset-all-btn,
    .daw-case-select,
    .daw-palette-select,
    .daw-spinbox-input
) {
    font-size: 13px !important;
    line-height: 1.3 !important;
}

[data-is-native="true"] #video-lab-view :is(
    .video-lab-subtitle,
    .video-lab-zoom-controls > .tech-text,
    #video-lab-zoom-value,
    #video-lab-hud-timecode,
    #video-lab-hud-frame,
    #video-lab-hud-res,
    #video-lab-hud-fps,
    #video-timeline-pos,
    .video-timeline-heading,
    .video-timeline-label,
    .timeline-track-label,
    #telemetry-sync-status,
    #telemetry-sync-summary,
    #video-marks-count,
    .video-sidebar-tab
) {
    font-size: 12px !important;
    line-height: 1.3 !important;
}

[data-is-native="true"] #video-lab-view :is(
    .camera-mount-btn,
    .video-tool-btn,
    .video-zoom-btn,
    .video-zoom-reset,
    .speed-pill,
    .amp-pill,
    .cadence-btn,
    .triage-view-btn,
    .triage-filter-chip,
    .frame-mini-pill
) {
    min-height: 36px;
    font-size: 13px !important;
    line-height: 1.2 !important;
}

/* Console and dashboard finish */
.app-container .btn {
    box-shadow: none;
}

.app-container :is(button, a, [role="button"]):focus-visible {
    outline: 2px solid var(--accent-blue-light);
    outline-offset: 3px;
}

@media (min-width: 1025px) {
    .stitch-sidebar {
        background: #111419;
    }

    .stitch-sidebar .stitch-nav-item {
        min-height: 64px;
        justify-content: center;
        border-left-width: 3px;
    }

    .stitch-sidebar .stitch-nav-item:hover,
    .stitch-sidebar .stitch-nav-item.active {
        background: rgba(255, 255, 255, 0.055);
    }

    .stitch-nav-item.active span {
        letter-spacing: 0;
    }
}

#dashboard-view .dashboard-grid-layout {
    margin-top: 18px;
    grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr);
    gap: clamp(24px, 3vw, 44px);
}

#dashboard-view .dashboard-grid-layout .main-column {
    gap: 32px !important;
    min-width: 0;
}

#dashboard-view .dashboard-grid-layout .side-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

#dashboard-view #stats-overview {
    gap: 12px;
}

#dashboard-view #stats-overview .stitch-card {
    min-width: 0;
    padding: 22px 24px;
    text-align: left !important;
    background: #1b2026;
    border-color: #373d45;
}

#dashboard-view #stats-overview .form-section-title {
    color: var(--text-secondary) !important;
    font-size: 0.76rem;
    letter-spacing: 0.06em;
}

#dashboard-view .stitch-stat-val {
    margin: 14px 0 10px;
    font-size: clamp(2.1rem, 3vw, 2.75rem);
    font-variant-numeric: tabular-nums;
}

#dashboard-view .stitch-stat-sub {
    font-size: 0.75rem;
    line-height: 1.5;
}

#dashboard-view .dashboard-section {
    min-width: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

#dashboard-view .dashboard-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 46px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

#dashboard-view .dashboard-section-heading .form-section-title {
    margin: 0;
    color: var(--text-primary) !important;
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

#dashboard-view .dashboard-section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#dashboard-view .dashboard-section-actions .btn {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.8rem;
    line-height: 1.1;
}

#dashboard-view .dashboard-section-actions .material-symbols-outlined {
    font-size: 18px;
    margin-right: 4px;
}

#dashboard-view .dashboard-env-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#dashboard-view .dashboard-env-updated {
    color: var(--text-muted);
    font-family: var(--font-tech);
    font-size: 0.7rem;
}

#dashboard-view .dashboard-refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
}

#dashboard-view .dashboard-refresh-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

#dashboard-view .dashboard-refresh-btn .material-symbols-outlined {
    font-size: 20px;
}

#dashboard-view .dashboard-case-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#dashboard-view .dashboard-empty-state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 30px 24px;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

#dashboard-view .dashboard-empty-state .material-symbols-outlined {
    color: var(--accent-blue-light);
    font-size: 26px;
    margin-bottom: 6px;
}

#dashboard-view .dashboard-empty-state strong {
    color: var(--text-primary);
    font-size: 0.95rem;
}

#dashboard-view .stitch-case-card {
    align-items: flex-start;
    padding: 18px;
    border-color: #373d45;
    border-radius: 6px;
    background: #1b2026;
    transition: border-color 0.2s ease, background 0.2s ease;
}

#dashboard-view .stitch-case-card:hover {
    border-color: #66717e;
    background: #222830;
}

#dashboard-view .stitch-case-border {
    width: 2px;
}

#dashboard-view .stitch-case-card h3 {
    white-space: normal !important;
    overflow-wrap: anywhere;
}

#dashboard-view .stitch-case-card .btn {
    box-shadow: none;
}

#dashboard-view .stitch-case-card .btn .material-symbols-outlined {
    font-size: 18px;
}

#dashboard-view .stitch-env-list {
    gap: 0;
}

#dashboard-view .stitch-env-row {
    min-width: 0;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

#dashboard-view .stitch-env-row:first-child {
    padding-top: 0;
}

#dashboard-view .stitch-env-row > div:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

#dashboard-view .stitch-env-row > div:last-child > div:nth-child(2) {
    font-size: 1.05rem !important;
    line-height: 1.3;
}

#dashboard-view .stitch-env-row > div:last-child > div:last-child {
    font-size: 0.73rem !important;
    line-height: 1.45;
    opacity: 1 !important;
}

#dashboard-view .stitch-icon-box {
    width: 36px;
    height: 36px;
    color: var(--text-secondary);
}

#dashboard-view .stitch-icon-box svg {
    width: 28px !important;
    height: 28px !important;
}

@media (max-width: 1024px) {
    #dashboard-view .dashboard-grid-layout {
        display: flex;
        flex-direction: column;
        gap: 28px;
    }

    #dashboard-view .stitch-env-list {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px !important;
        overflow: visible;
    }

    #dashboard-view .stitch-env-list .stitch-env-row {
        flex-direction: row !important;
        align-items: flex-start;
        text-align: left;
        min-width: 0;
        padding: 0 12px 0 0;
        border-bottom: 0;
        border-right: 1px solid var(--border-color);
    }

    #dashboard-view .stitch-env-list .stitch-env-row:last-child {
        border-right: 0;
    }
}

@media (max-width: 600px) {
    #dashboard-view .dashboard-grid-layout {
        margin-top: 10px;
        gap: 26px;
    }

    #dashboard-view #stats-overview .stitch-card {
        padding: 16px;
    }

    #dashboard-view .stitch-stat-val {
        font-size: 2rem;
    }

    #dashboard-view .dashboard-section-heading {
        align-items: flex-start;
    }

    #dashboard-view .dashboard-section-actions {
        width: 100%;
        justify-content: space-between;
    }

    #dashboard-view .dashboard-section-actions .btn {
        min-height: 44px;
    }

    #dashboard-view .dashboard-refresh-btn {
        width: 44px;
        height: 44px;
    }

    #dashboard-view .stitch-env-list {
        grid-template-columns: 1fr;
        gap: 0 !important;
    }

    #dashboard-view .stitch-env-list .stitch-env-row {
        padding: 12px 0;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }

    #dashboard-view .stitch-case-card {
        padding: 14px;
    }

    #dashboard-view .stitch-case-card .btn {
        min-height: 40px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .view,
    .view-exit {
        animation: none;
    }
}

/* --- COMPREHENSIVE MOBILE POLISH (AUDIO LAB & INTAKE FORMS) --- */
@media screen and (max-width: 768px) {
    /* 1. Intake Forms Mobile Polish & Screen Boundary Lock */
    #investigation-intake-view.view,
    #investigation-intake-view,
    .intake-view-container {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    #intake-gps-status,
    #new-case-gps-status {
        word-break: break-word !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        max-width: 100% !important;
    }
    #investigation-intake-view .intake-max-width {
        padding: 0 8px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    #investigation-intake-view .grid-2,
    #investigation-intake-view .grid-3 {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    #investigation-intake-view .form-input,
    #investigation-intake-view .form-select,
    #investigation-intake-view .form-textarea,
    #investigation-intake-view .input-row {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    #investigation-intake-view #wizard-action-bar {
        position: fixed !important;
        bottom: var(--bottom-clearance) !important;
        left: 0 !important;
        right: 0 !important;
        padding: 6px 12px 6px 12px !important;
        background: linear-gradient(180deg, rgba(14, 18, 26, 0.98) 0%, rgba(9, 12, 18, 0.99) 100%) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-bottom: none !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5) !important;
        z-index: 49999 !important;
    }
    body[data-theme="red"] #investigation-intake-view #wizard-action-bar,
    body.red-mode #investigation-intake-view #wizard-action-bar {
        background: linear-gradient(180deg, rgba(16, 2, 2, 0.98) 0%, rgba(8, 0, 0, 0.99) 100%) !important;
        border-top: 1px solid rgba(212, 17, 17, 0.3) !important;
    }
    #investigation-intake-view #wizard-action-bar .intake-footer-content {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        grid-template-areas:
            "actions actions actions"
            "prev save next" !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 520px !important;
        margin: 0 auto !important;
    }
    #investigation-intake-view #wizard-action-bar:has(#wizard-prev-btn[style*="hidden"]) .intake-footer-content {
        grid-template-columns: 1fr 1fr !important;
        grid-template-areas:
            "actions actions"
            "save next" !important;
    }
    #investigation-intake-view #wizard-action-bar .intake-footer-center {
        grid-area: actions !important;
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        width: 100% !important;
    }
    #investigation-intake-view #wizard-action-bar .intake-footer-center .intake-btn,
    #investigation-intake-view #wizard-action-bar .intake-footer-center button {
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        min-height: 44px !important;
        padding: 6px 4px !important;
        font-size: 0.65rem !important;
        letter-spacing: 0.3px !important;
        line-height: 1.2 !important;
        white-space: normal !important;
        border-radius: 6px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #investigation-intake-view #wizard-action-bar #wizard-prev-btn {
        grid-area: prev !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 6px 8px !important;
        font-size: 0.72rem !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-radius: 8px !important;
    }
    #investigation-intake-view #wizard-action-bar #wizard-prev-btn[style*="hidden"] {
        display: none !important;
    }
    #investigation-intake-view #wizard-action-bar #intake-save-btn {
        grid-area: save !important;
        width: 100% !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 6px 8px !important;
        font-size: 0.72rem !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-radius: 8px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #investigation-intake-view #wizard-action-bar #wizard-next-btn {
        grid-area: next !important;
        width: 100% !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 6px 8px !important;
        font-size: 0.72rem !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-radius: 8px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #investigation-intake-view .intake-main-content {
        padding-bottom: calc(var(--bottom-clearance) + 140px) !important;
    }

    #locations-view .location-geo-fields {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 110px), 1fr)) !important;
        gap: 4px !important;
    }

    #locations-view .location-geo-fields .form-input,
    #locations-view #site-search-input,
    #locations-view #site-filter-radius {
        box-sizing: border-box !important;
        height: 28px !important;
        min-height: 28px !important;
        max-height: 28px !important;
        font-size: 0.65rem !important;
        padding: 2px 6px !important;
        line-height: 1.2 !important;
    }

        /* Field Event Logger & Audit Entry Mobile Layout */
    .event-log-header,
    #investigation-log-view .event-log-header {
        display: none !important;
    }

    .event-log-row,
    #investigation-log-view .event-log-row,
    .audit-entry.event-log-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        padding: 10px 12px !important;
        background: rgba(255, 255, 255, 0.02) !important;
        border: 1px solid rgba(255, 255, 255, 0.06) !important;
        border-radius: 6px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        grid-template-columns: none !important;
    }

    .event-log-meta-wrap {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
        flex-wrap: wrap !important;
    }

    .event-log-meta-wrap .audit-time,
    .event-log-row .audit-time {
        font-family: var(--font-tech) !important;
        font-size: 0.72rem !important;
        color: var(--warning) !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    .event-log-category-pill {
        font-family: var(--font-tech) !important;
        font-size: 0.65rem !important;
        font-weight: 700 !important;
        padding: 2px 7px !important;
        border-radius: 4px !important;
        letter-spacing: 0.5px !important;
        white-space: nowrap !important;
        text-transform: uppercase !important;
    }

    .event-log-row .entry-note {
        width: 100% !important;
        font-size: 0.82rem !important;
        color: var(--text-primary) !important;
        line-height: 1.45 !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
        min-width: 0 !important;
        margin-top: 2px !important;
    }

    .event-log-actions {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        gap: 12px !important;
        width: 100% !important;
        border-top: 1px solid rgba(255, 255, 255, 0.04) !important;
        padding-top: 4px !important;
        margin-top: 2px !important;
    }

    .event-log-actions .log-action-btn {
        padding: 6px 12px !important;
        font-size: 1rem !important;
        min-height: 36px !important;
    }

    .logger-input {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .logger-input #event-log-input {
        flex: 1 1 100% !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .logger-input #event-log-category {
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
    }

    .logger-input button {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    #video-lab-view :is(.video-tool-btn, .speed-pill) {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* 2. Audio Lab Mobile Polish */
    #audio-lab-view {
        padding: 4px !important;
    }
    #audio-lab-view .daw-workspace {
        gap: 8px !important;
    }
    #audio-lab-view .daw-header-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        height: auto !important;
        padding: 12px !important;
    }
    #audio-lab-view .daw-header-left,
    #audio-lab-view .daw-header-right {
        width: 100% !important;
        justify-content: center !important;
    }
    #audio-lab-view .daw-transport-bar {
        padding: 10px 4px !important;
    }
    #audio-lab-view .daw-tport-btn {
        flex: 1 1 30% !important;
        min-height: 48px !important; 
        font-size: 0.85rem !important;
    }
    #audio-lab-view .daw-volume-group {
        width: 100% !important;
        margin-top: 8px !important;
    }
    #audio-lab-view .daw-main-canvas canvas {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Audio Lab Compact Button & Layout Overrides */
    #audio-lab-view button.al-nudge-btn {
        min-height: 26px !important;
        height: 26px !important;
        padding: 0 8px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
    }

    #audio-lab-view button.al-batch-btn {
        min-height: 26px !important;
        height: 26px !important;
        padding: 0 10px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
    }

    #audio-lab-view button.al-source-edit-btn {
        min-height: 24px !important;
        height: 24px !important;
        padding: 2px 8px !important;
        font-size: 10px !important;
        line-height: 1 !important;
    }

    #audio-lab-transcription-output {
        min-height: 200px !important;
        max-height: 50vh !important;
        overflow-y: auto !important;
    }

    #audio-lab-source-info {
        max-width: 100% !important;
        overflow: visible !important;
    }
}

/* ─── Document Signing Modal Responsive & Mobile Touch Support ─── */
#document-signing-modal {
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y !important;
}

#document-signing-modal .signing-workspace-card {
    max-width: 1180px;
    margin: 1vh auto;
    padding: 18px;
    background: var(--bg-card, #121820);
    border: 1px solid var(--border-color, #334155);
    border-top: 3px solid var(--warning, #f59e0b);
    border-radius: 6px;
    box-sizing: border-box;
}

#document-signing-modal .signing-grid {
    display: grid;
    grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
    gap: 16px;
}

#document-signing-modal #signing-preview-wrap {
    position: relative;
    overflow: auto;
    max-height: 72vh;
    background: #343b46;
    text-align: center;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y pinch-zoom;
}

#document-signing-modal #signing-preview {
    display: block;
    margin: 0 auto;
    background: #fff;
    max-width: 100%;
    height: auto;
    cursor: crosshair;
    touch-action: manipulation;
}

#document-signing-modal #signature-canvas {
    touch-action: none !important;
}

@media screen and (max-width: 768px) {
    #document-signing-modal {
        padding: 4px !important;
    }
    #document-signing-modal .signing-workspace-card {
        margin: 0 !important;
        padding: 12px 10px !important;
        min-height: 100%;
        border-radius: 0 !important;
    }
    #document-signing-modal .signing-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    #document-signing-modal #signing-preview-wrap {
        max-height: 50vh !important;
    }
    #document-signing-modal .signing-footer {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    #document-signing-modal .signing-footer .signing-action-buttons {
        width: 100% !important;
        justify-content: stretch !important;
    }
    #document-signing-modal .signing-footer .signing-action-buttons button {
        flex: 1 !important;
    }
    #document-signing-modal .signer-step-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
}

/* ==========================================================================
   MOBILE VIRTUAL KEYBOARD ADAPTATION & ACCESSIBLE MODAL SCROLLING
   Prevents on-screen keyboards from obscuring inputs, textareas, and buttons
   ========================================================================== */

/* Keep all modals scrollable and never allow content to get clipped offscreen */
.modal,
.modal-overlay,
[id$="-modal"],
.audio-lab-modal,
.video-lab-modal {
    box-sizing: border-box !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
}

@media screen and (max-width: 768px) {
    /* Only force flex on modals not explicitly hidden inline, so closed modals stay hidden */
    .modal:not([style*="display: none"]):not([style*="display:none"]),
    .modal-overlay:not([style*="display: none"]):not([style*="display:none"]),
    [id$="-modal"]:not([style*="display: none"]):not([style*="display:none"]) {
        display: flex !important;
    }

    .modal,
    .modal-overlay,
    [id$="-modal"] {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: max(28px, env(safe-area-inset-top, 28px)) 12px calc(24px + var(--keyboard-height, 0px) + env(safe-area-inset-bottom, 0px)) !important;
        box-sizing: border-box !important;
    }

    /* Modals center perfectly on mobile with safe area top clearance */
    .modal > .card,
    .modal-overlay > .card,
    [id$="-modal"] > .card,
    .modal > div[class*="card"],
    .modal-overlay > div[class*="card"],
    [id$="-modal"] > div[class*="card"],
    .modal > div[class*="stitch-card"],
    .modal-overlay > div[class*="stitch-card"],
    [id$="-modal"] > div[class*="stitch-card"] {
        margin: auto !important;
        max-height: min(88vh, calc(var(--visual-viewport-height, 100dvh) - 48px)) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        box-sizing: border-box !important;
        flex-shrink: 0 !important;
    }

    /* Ensure specific critical modals always use the adaptive height */
    #mobile-quick-log-modal .card,
    #new-case-modal .card,
    #case-import-modal .card,
    #team-membership-modal .card,
    #scheduled-date-modal .card,
    #add-device-modal .card,
    #use-template-modal .card,
    #tools-quick-menu-modal .card,
    #help-guide-modal .card,
    #paralibrary-doc-modal .card,
    #glossary-entry-modal .card {
        max-height: min(94dvh, calc(var(--visual-viewport-height, 100dvh) - 24px)) !important;
        overflow-y: auto !important;
    }

    #mobile-quick-log-modal .quick-log-modal-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        width: 100% !important;
        min-width: 0 !important;
        gap: 8px !important;
    }

    #mobile-quick-log-modal .quick-log-modal-actions > button {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        min-height: 44px !important;
        padding: 0 8px !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
    }

    /* Quick category tag buttons responsive grid */
    .quick-cat-tag {
        flex: 1 1 calc(33.333% - 6px) !important;
        min-width: 85px !important;
        height: 28px !important;
        padding: 0 6px !important;
        font-size: 0.65rem !important;
        border-radius: 14px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: nowrap !important;
        margin: auto 0 !important;
    }

    /* --- 3. Phase 3A Pre-Sweep (Investigation On-Site) Mobile Polish --- */
    #investigation-onsite-view {
        padding: 10px 10px 90px 10px !important;
        box-sizing: border-box !important;
    }

    #investigation-onsite-view .phase-nav-container {
        display: flex !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 3px !important;
        gap: 4px !important;
        box-sizing: border-box !important;
    }

    #investigation-onsite-view .phase-nav-btn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 38px !important;
        padding: 6px 3px !important;
        font-size: 0.65rem !important;
        white-space: normal !important;
        text-align: center !important;
        line-height: 1.15 !important;
    }

    #investigation-onsite-view .phase-nav-title {
        font-size: 0.78rem !important;
        word-break: break-word !important;
        text-align: center !important;
        margin-top: 2px !important;
        padding: 0 4px !important;
    }

    #investigation-onsite-view .onsite-case-banner {
        padding: 8px 10px !important;
    }

    #investigation-onsite-view .onsite-case-banner button {
        padding: 6px 8px !important;
        font-size: 0.62rem !important;
    }

    #investigation-onsite-view .grid-2,
    #investigation-onsite-view .onsite-main-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 14px !important;
    }

    #investigation-onsite-view .onsite-telemetry-grid,
    #investigation-onsite-view .onsite-outdoor-grid,
    #investigation-onsite-view div[style*="grid-template-columns: repeat(2"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 14px !important;
    }

    #investigation-onsite-view .stitch-card > div[style*="padding: 20px"],
    #investigation-onsite-view .card {
        padding: 14px 12px !important;
    }

    #investigation-onsite-view #onsite-sample-mic-btn {
        width: 100% !important;
        white-space: normal !important;
        word-break: break-word !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        padding: 10px 8px !important;
        font-size: 0.72rem !important;
        min-height: 42px !important;
    }

    #investigation-onsite-view #onsite-sample-mic-btn-label {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }

    #investigation-onsite-view .onsite-emf-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
    }

    #investigation-onsite-view #onsite-baseline-emf-type {
        width: 105px !important;
        flex: 0 0 105px !important;
        height: 34px !important;
    }

    #investigation-onsite-view #onsite-baseline-emf-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 6px !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    #investigation-onsite-view #onsite-baseline-emf-container[style*="display: none"] {
        display: none !important;
    }

    #investigation-onsite-view #onsite-baseline-emf {
        flex: 1 1 auto !important;
        min-width: 40px !important;
        width: auto !important;
        height: 34px !important;
    }

    #investigation-onsite-view #baseline-emf-btn {
        min-width: 38px !important;
        height: 34px !important;
        font-size: 0.65rem !important;
        padding: 0 8px !important;
        white-space: nowrap !important;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
    }

    #investigation-onsite-view select.form-input,
    #investigation-onsite-view input.form-input {
        height: 34px !important;
        font-size: 0.78rem !important;
    }

    #investigation-onsite-view .form-input {
        box-sizing: border-box !important;
    }

    #investigation-onsite-view .onsite-top-actions {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 6px !important;
    }

    #investigation-onsite-view .onsite-top-actions button {
        height: 32px !important;
        padding: 0 10px !important;
        font-size: 0.68rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    #investigation-onsite-view #onsite-save-status {
        font-size: 0.58rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: inline-block !important;
        max-width: 100% !important;
        text-align: center !important;
    }
}

/* When virtual keyboard is open */
body.keyboard-visible #app-bottom-nav,
body.keyboard-visible .stitch-bottom-nav,
body.keyboard-visible .mobile-bottom-nav,
body.keyboard-visible .bottom-nav-bar {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Provide bottom breathing room for focused inputs/forms */
body.keyboard-visible main.main-content,
body.keyboard-visible .view-container,
body.keyboard-visible #view-container,
body.keyboard-visible .view {
    padding-bottom: calc(var(--keyboard-height, 260px) + 24px) !important;
}

/* Team Beacon Heatmap Standby / Greyscale State */
#team-beacon-map.map-beacon-inactive .leaflet-tile-pane {
    filter: grayscale(100%) brightness(0.48) contrast(1.15) !important;
    transition: filter 0.4s ease;
}

#team-beacon-map.pin-placement-mode,
#team-beacon-map.pin-placement-mode .leaflet-container,
#team-beacon-map.pin-placement-mode .leaflet-grab,
#team-beacon-map.pin-placement-mode .leaflet-interactive {
    cursor: crosshair !important;
}

.team-desktop-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.address-suggestion-item {
    transition: background-color 0.15s ease;
}

.address-suggestion-item:hover,
.address-suggestion-item:focus {
    background: rgba(96, 165, 250, 0.16) !important;
}

@media screen and (max-width: 768px) {
    #team-map-active-manual-bar {
        align-items: flex-start !important;
        padding: 8px !important;
    }

    #team-map-active-manual-bar > .team-map-manual-actions {
        flex: 1 1 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    #team-map-active-manual-bar > .team-map-manual-actions > button {
        flex: 1 1 160px;
        min-height: 40px;
        height: auto !important;
        white-space: normal;
    }

    .team-manual-address-search {
        align-items: stretch;
    }

    .team-manual-address-field {
        min-width: 0;
    }
}

/* Camera Mount Profile Button States (Video Lab) */
.camera-mount-btn {
    opacity: 0.6;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.camera-mount-btn::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    margin-left: 2px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.camera-mount-btn:hover:not(.active) {
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #f1f5f9;
}

.camera-mount-btn.active {
    opacity: 1 !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    cursor: default;
}

.camera-mount-btn#mount-btn-stationary.active,
.camera-mount-btn.mount-stationary.active {
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.35) 0%, rgba(5, 150, 105, 0.20) 100%) !important;
    border: 1px solid #10b981 !important;
    color: #ffffff !important;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.6), inset 0 0 8px rgba(16, 185, 129, 0.25) !important;
    text-shadow: 0 0 8px rgba(110, 231, 183, 0.85);
}

.camera-mount-btn#mount-btn-stationary.active::after,
.camera-mount-btn.mount-stationary.active::after {
    background: #10b981 !important;
    box-shadow: 0 0 8px #10b981, 0 0 12px #34d399 !important;
}

.camera-mount-btn#mount-btn-moving.active,
.camera-mount-btn.mount-moving.active {
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.35) 0%, rgba(37, 99, 235, 0.20) 100%) !important;
    border: 1px solid #60a5fa !important;
    color: #ffffff !important;
    box-shadow: 0 0 14px rgba(96, 165, 250, 0.6), inset 0 0 8px rgba(96, 165, 250, 0.25) !important;
    text-shadow: 0 0 8px rgba(147, 197, 253, 0.85);
}

.camera-mount-btn#mount-btn-moving.active::after,
.camera-mount-btn.mount-moving.active::after {
    background: #60a5fa !important;
    box-shadow: 0 0 8px #60a5fa, 0 0 12px #93c5fd !important;
}

/* Sidebar Mount Cards */
.camera-mount-card {
    opacity: 0.65;
    transition: all 0.2s ease;
}

.camera-mount-card:hover:not(.active) {
    opacity: 0.95;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

.camera-mount-card.active {
    opacity: 1 !important;
    font-weight: 700;
}

.camera-mount-card#triage-mount-stat-btn.active,
.camera-mount-card.mount-stationary.active {
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.28) 0%, rgba(5, 150, 105, 0.15) 100%) !important;
    border: 1px solid #10b981 !important;
    color: #ffffff !important;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.5), inset 0 0 8px rgba(16, 185, 129, 0.2) !important;
}

.camera-mount-card#triage-mount-stat-btn.active .tech-text,
.camera-mount-card.mount-stationary.active .tech-text {
    color: #ffffff !important;
    text-shadow: 0 0 8px rgba(110, 231, 183, 0.8);
}

.camera-mount-card#triage-mount-move-btn.active,
.camera-mount-card.mount-moving.active {
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.28) 0%, rgba(37, 99, 235, 0.15) 100%) !important;
    border: 1px solid #60a5fa !important;
    color: #ffffff !important;
    box-shadow: 0 0 14px rgba(96, 165, 250, 0.5), inset 0 0 8px rgba(96, 165, 250, 0.2) !important;
}

.camera-mount-card#triage-mount-move-btn.active .tech-text,
.camera-mount-card.mount-moving.active .tech-text {
    color: #ffffff !important;
    text-shadow: 0 0 8px rgba(147, 197, 253, 0.8);
}

/* Red Mode Night Vision Protection */
body.red-mode .camera-mount-btn#mount-btn-stationary.active,
body.red-mode .camera-mount-btn#mount-btn-moving.active,
body.red-mode .camera-mount-card#triage-mount-stat-btn.active,
body.red-mode .camera-mount-card#triage-mount-move-btn.active,
[data-theme="red"] .camera-mount-btn#mount-btn-stationary.active,
[data-theme="red"] .camera-mount-btn#mount-btn-moving.active,
[data-theme="red"] .camera-mount-card#triage-mount-stat-btn.active,
[data-theme="red"] .camera-mount-card#triage-mount-move-btn.active {
    background: linear-gradient(180deg, rgba(212, 17, 17, 0.4) 0%, rgba(153, 27, 27, 0.22) 100%) !important;
    border: 1px solid #d41111 !important;
    color: #ffffff !important;
    box-shadow: 0 0 14px rgba(212, 17, 17, 0.7), inset 0 0 8px rgba(212, 17, 17, 0.3) !important;
    text-shadow: 0 0 8px rgba(248, 113, 113, 0.8) !important;
}

body.red-mode .camera-mount-btn.active::after,
[data-theme="red"] .camera-mount-btn.active::after {
    background: #d41111 !important;
    box-shadow: 0 0 8px #d41111, 0 0 12px #f87171 !important;
}

@media screen and (max-width: 1024px) {
    .stitch-sidebar,
    .sidebar-backdrop {
        top: calc(env(safe-area-inset-top, 0px) + (var(--header-height, 64px) - 41px) / 2) !important;
    }

    .mobile-close-btn {
        position: absolute !important;
        top: 0 !important;
        right: 15px !important;
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        flex: 0 0 40px !important;
    }
}

[data-is-native="true"] .stitch-sidebar,
[data-is-native="true"] .sidebar-backdrop {
    top: calc(env(safe-area-inset-top, 0px) + (var(--header-height, 64px) - 41px) / 2) !important;
}

[data-is-native="true"] .mobile-close-btn {
    position: absolute !important;
    top: 0 !important;
    right: 15px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    flex: 0 0 40px !important;
}

/* Typed input must never be force-uppercased by .tech-text (login IDs / passwords are case-sensitive) */
input.tech-text, textarea.tech-text, select.tech-text, input.form-input, textarea.form-input {
    text-transform: none;
}

/* Text-style CANCEL in reauth modal must not inherit the 32px icon close-button sizing */
#reauth-modal .btn-ghost.reauth-cancel-btn {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 30px !important;
    flex: 0 0 auto !important;
    padding: 4px 12px !important;
    font-size: 0.68rem !important;
    letter-spacing: 0.05em !important;
}

/* Admin-controlled PostHog Feedback widget (Labmin > Settings > PostHog Feedback Widget) */
html[data-feedback-widget="off"] [class*="PostHogSurvey"],
html[data-feedback-widget="off"] .ph-survey-widget-tab,
html[data-feedback-widget="off"] .ph-survey-widget-container {
    display: none !important;
}
