/* ============================================
   SPANSENSE - INDEX/HOMEPAGE
   Matching REFINED main page palette exactly
   ============================================ */

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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #eef2f8;
    color: #2c3e44;
    transition: background 0.3s ease, color 0.3s ease;
    padding-top: 84px !important;
}

/* ============================================
   FLOATING NAVBAR - FIXED VERSION
   ============================================ */

/* Make navbar floating - preserves internal layout */
.navbar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 67%;
    max-width: 1190px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 60px;
    border: 1px solid rgba(138, 180, 176, 0.35);
    box-shadow: 0 8px 28px rgba(44, 90, 87, 0.12);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 64px;
}

/* Ensure all navbar children keep their layout */
.navbar .left,
.navbar .search-bar,
.navbar .right {
    display: flex !important;
    align-items: center !important;
}

.navbar .left {
    gap: 24px !important;
}

.navbar .right {
    gap: 10px !important;
}

/* Fix search bar width */
.navbar .search-bar {
    width: 280px !important;
    position: relative !important;
}

.navbar .search-bar input {
    width: 100% !important;
    padding: 8px 16px !important;
    border: 1px solid rgba(224, 232, 240, 0.5) !important;
    border-radius: 24px !important;
    font-size: 0.85rem !important;
    background: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(5px) !important;
    outline: none !important;
}

/* Fix menu and logo */
.navbar .menu a {
    text-decoration: none !important;
    color: #4a5b6e !important;
    font-weight: 500 !important;
    font-size: 0.85rem !important;
}

.navbar .logo {
    font-size: 1.2rem !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, #5b8c8a 0%, #7ba8a5 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* Account / contact icon buttons */
.navbar .account-links {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}
.navbar .account-links a {
    text-decoration: none !important;
    color: #5f6b73 !important;
    font-size: 1.2rem !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.2s, transform 0.15s, background 0.2s !important;
}
.navbar .account-links a:hover {
    background: #e2e8f0 !important;
    color: #5b8c8a !important;
    transform: scale(1.1) !important;
}

/* Fix night mode toggle */
.night-mode-toggle {
    cursor: pointer !important;
    font-size: 1.2rem !important;
    color: #5b8c8a !important;
    background: rgba(240, 242, 245, 0.8) !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.night-mode-toggle:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}



/* Add these additional styles for main content adjustment */
.main-content {
    margin-left: 80px;
    margin-top: 80px;
    padding: 24px;
    transition: margin-left 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

/* When sidebar expands, content shifts */
.sidebar:hover ~ .main-content,
.sidebar.expanded ~ .main-content {
    margin-left: 280px;
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }
}

/* ============================================
   REFINED SIDEBAR STYLES - Matching Main Theme
   All classes and IDs preserved
   ============================================ */

/* Sidebar Container */
.sidebar {
    position: fixed;
    top: 100px !important;
    left: 20px;
    height: auto;
    max-height: calc(100vh - 120px);
    width: 68px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 28px;
    box-shadow: 0 8px 28px rgba(44, 90, 87, 0.12);
    z-index: 999;
    transition: width 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid rgba(138, 180, 176, 0.35);
}

.sidebar:hover {
    width: 280px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

/* For touch devices - also expand on click */
.sidebar.expanded {
    width: 280px;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
    margin: 20px 0;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px 16px 16px 20px;
    border-bottom: 1px solid #eef2f6;
    margin-bottom: 8px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease 0.1s;
}

.sidebar:hover .sidebar-header,
.sidebar.expanded .sidebar-header {
    opacity: 1;
}

.sidebar-header h3 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #5f6b73;
    margin: 0;
}

/* Main Menu List */
.sidebar > ul {
    list-style-type: none;
    padding: 0 0 16px;
    margin: 0;
}

.sidebar > ul > li {
    margin-bottom: 2px;
}

/* Menu Item Links - preserve existing IDs */
.sidebar > ul > li > a {
    color: #2c3e44;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    white-space: nowrap;
    margin: 0 8px;
}

.sidebar > ul > li > a:hover {
    background: #eef4f2;
    color: #5b8c8a;
}

.sidebar > ul > li > a.active {
    background: #eef4f2;
    color: #5b8c8a;
    font-weight: 600;
}

.sidebar > ul > li > a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #5b8c8a;
    border-radius: 0 3px 3px 0;
}

/* Menu Icons */
.sidebar > ul > li > a i:first-child {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
    color: #5f6b73;
    transition: color 0.2s;
}

.sidebar > ul > li > a:hover i:first-child,
.sidebar > ul > li > a.active i:first-child {
    color: #5b8c8a;
}

/* Menu Text - hidden when collapsed */
.sidebar > ul > li > a span {
    opacity: 0;
    transition: opacity 0.2s ease 0.1s;
}

.sidebar:hover > ul > li > a span,
.sidebar.expanded > ul > li > a span {
    opacity: 1;
}

/* Expand/Collapse Chevron */
.sidebar .menu-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    color: #b0c0cc;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
}

.sidebar:hover .menu-chevron,
.sidebar.expanded .menu-chevron {
    opacity: 1;
}

.sidebar .menu-chevron.rotated {
    transform: rotate(180deg);
}

/* CRITICAL: Hide submenus when sidebar is collapsed */
.sidebar:not(:hover):not(.expanded) .submenu {
    grid-template-rows: 0fr !important;
    visibility: hidden;
}

.sidebar:not(:hover):not(.expanded) .submenu.active {
    grid-template-rows: 0fr !important;
}

/* Also reset chevron rotation when collapsed */
.sidebar:not(:hover):not(.expanded) .menu-chevron.rotated {
    transform: rotate(0deg) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Submenu Container - preserve existing classes */
.submenu {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    list-style-type: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.submenu.active {
    grid-template-rows: 1fr;
}

.submenu > div {
    overflow: hidden;
}

.submenu li {
    padding: 0;
}

/* Submenu Items */
.submenu li a {
    padding: 10px 16px 10px 54px;
    font-size: 0.85rem;
    color: #2c3e44;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    border-radius: 10px;
    margin: 2px 8px;
    white-space: nowrap;
}

.submenu li a:hover {
    background: #eef4f2;
    color: #5b8c8a;
}

.submenu li a i {
    width: 20px;
    font-size: 0.9rem;
}

/* Checkbox items in submenu - preserve existing structure */
.submenu label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 16px 10px 54px;
    font-size: 0.85rem;
    color: #2c3e44;
    transition: all 0.2s ease;
    border-radius: 10px;
    margin: 2px 8px;
    white-space: nowrap;
}

.submenu label:hover {
    background: #eef4f2;
    color: #5b8c8a;
}

.submenu input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    accent-color: #5b8c8a;
    cursor: pointer;
    flex-shrink: 0;
}

/* Nested submenu (3rd level) */
.submenu .submenu {
    padding-left: 0;
    background: transparent;
}

.submenu .submenu li a,
.submenu .submenu label {
    padding-left: 70px;
    font-size: 0.82rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #eef2f6;
    margin-top: 20px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease 0.1s;
}

.sidebar:hover .sidebar-footer,
.sidebar.expanded .sidebar-footer {
    opacity: 1;
}

.sidebar-footer .version {
    font-size: 0.7rem;
    color: #b0c0cc;
    text-align: center;
}

/* ============================================
   SIDEBAR NIGHT MODE - MATCHING MAIN THEME
   ============================================ */

.night-mode .sidebar {
    background: rgba(47, 62, 72, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.night-mode .sidebar > ul > li > a {
    color: #a8c4cc;
}

.night-mode .sidebar > ul > li > a:hover {
    background: #3a6b62;
    color: white;
}

.night-mode .sidebar > ul > li > a.active {
    background: #3a6b62;
    color: white;
}

.night-mode .sidebar > ul > li > a.active::before {
    background: #8ab4b0;
}

.night-mode .sidebar > ul > li > a i:first-child {
    color: #9eb8c2;
}

.night-mode .sidebar > ul > li > a:hover i:first-child,
.night-mode .sidebar > ul > li > a.active i:first-child {
    color: white;
}

.night-mode .submenu li a,
.night-mode .submenu label {
    color: #9ab0b8;
}

.night-mode .submenu li a:hover,
.night-mode .submenu label:hover {
    background: #3a6b62;
    color: white;
}

.night-mode .sidebar-header,
.night-mode .sidebar-footer {
    border-color: #3e525e;
}

.night-mode .sidebar-header h3 {
    color: #a8b8bf;
}

.night-mode .sidebar-footer .version {
    color: #a8b8bf;
}

.night-mode .sidebar .menu-chevron {
    color: #a8b8bf;
}

/* ============================================
   RESPONSIVE SIDEBAR
   ============================================ */

@media (max-width: 1000px) {
    .sidebar {
        top: 70px;
        left: 12px;
        max-height: calc(100vh - 90px);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 0;
        visibility: hidden;
        left: 0;
        top: 64px;
        bottom: 0;
        border-radius: 0;
    }
    
    .sidebar:hover,
    .sidebar.expanded {
        width: 280px;
        visibility: visible;
        left: 0;
        top: 64px;
        bottom: 0;
        border-radius: 0;
    }
}

/* ============================================
   MAP CONTAINER
   ============================================ */

/* Make the map full screen and position it as the background */
#map {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 0 !important;
}

.leaflet-popup-content {
    font-size: 14px;
    color: #2c3e44;
    font-family: 'Segoe UI', sans-serif;
}

/* Structure ID/name label under each marker - only shown once zoomed in (see LABEL_ZOOM_THRESHOLD in map.js) */
.leaflet-tooltip.structure-label {
    background: white;
    border: 1px solid #e2e8ee;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #2c3e44;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}
.leaflet-tooltip.structure-label::before { display: none; }
#map.labels-visible .leaflet-tooltip.structure-label { opacity: 1; visibility: visible; }
.structure-label-id { color: #2d7a6e; font-weight: 700; margin-right: 4px; }

/* ============================================
   SEARCH RESULTS DROPDOWN
   ============================================ */

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e9edf2;
    border-radius: 12px;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
    z-index: 1001;
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.search-results div {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #2c3e44;
    border-bottom: 1px solid #e9edf2;
    transition: all 0.15s;
}

.search-results div:last-child {
    border-bottom: none;
}

.search-results div:hover {
    background: #eef4f2;
    color: #5b8c8a;
}

/* ============================================
   DASHBOARD
   ============================================ */

#dashboard {
    display: none;
    padding: 28px;
    max-width: 1200px;
    margin: 0 auto;
}

#dashboard h2 {
    margin-top: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e44;
    margin-bottom: 24px;
}

.back-button {
    background: white;
    border: 1px solid #e9edf2;
    padding: 10px 24px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    color: #4d5960;
    transition: all 0.2s;
    margin-bottom: 24px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-button:hover {
    background: #f8fafc;
    border-color: #8ab4b0;
    color: #5b8c8a;
}

#dashboard .charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

#dashboard .chart-container {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-radius: 20px;
    border: 1px solid rgba(138, 180, 176, 0.28);
    padding: 24px;
    box-shadow: 0 10px 28px rgba(44, 90, 87, 0.12);
    transition: all 0.2s;
}

#dashboard .chart-container:hover {
    box-shadow: 0 16px 38px rgba(44, 90, 87, 0.16);
}

.night-mode #dashboard .chart-container {
    background: rgba(51, 68, 79, 0.88);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

.night-mode #dashboard .chart-container:hover {
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.36);
}

#dashboard .chart-container canvas {
    max-width: 100%;
    height: auto !important;
    max-height: 350px;
}

/* ============================================
   MODAL STYLES - Bridge Modal
   ============================================ */

/* Prevent body from shifting when modal opens */
body.modal-open {
    overflow: hidden;
    padding-right: 0 !important;
}

/* Ensure modal doesn't cause horizontal scroll */
/* REPLACE your .modal rule with: */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    display: none;
    /* Navbar is top:20px + height:64px = ends at 84px - padding-top of
       exactly 84px left zero breathing room, so the modal's own shadow/blur
       touched the navbar's with no gap (same issue the share modal had -
       see map/share.js). Match the navbar's own 20px offset for a real gap. */
    padding-top: 104px;
    box-sizing: border-box;
}

/* ADD this — when modal is active, flex kicks in */
.modal.active,
.modal[style*="display: block"],
.modal[style*="display:block"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* REPLACE .modal-content with: */
.modal-content {
    position: relative;
    background: white;
    margin: auto;
    padding: 0;
    border: 1px solid #e9edf2;
    width: 90%;
    max-width: 480px;
    max-height: 90%;
    overflow-y: auto;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    animation: modalFade 0.25s ease;
}

.close {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #5f6b73;
    transition: color 0.2s, background 0.2s;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    line-height: 1;  /* ← add this */
}

.close:hover {
    background: #fdf2f2;
    color: #c47070;
}

/* ============================================
   BRIDGE MODAL - Glassmorphism card redesign.
   Everything scoped under #bridgeModal so it can't
   affect the Documents modal or any other shared
   classes/components elsewhere in this stylesheet.
   ============================================ */
#bridgeModal .bridge-card {
    background: rgba(244, 248, 247, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 24px;
    box-shadow:
        0 24px 80px rgba(44, 90, 87, 0.16),
        0 8px 24px rgba(44, 90, 87, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(138, 180, 176, 0.32);
    display: flex;
    flex-direction: column;
}

#bridgeModal .card-header {
    padding: 18px 28px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    background: rgba(248,250,252,0.8);
    border-bottom: 1px solid rgba(233, 237, 242, 0.6);
}

#bridgeModal .header-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

#bridgeModal .header-text h2 {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #5f6b73;
    margin-bottom: 4px;
}

#bridgeModal .header-text .bridge-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1e2a33;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

#bridgeModal .card-header .close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    color: #5f6b73;
    /* Matches .ss-close-btn (Previous Inspections modal) exactly - the
       shared .close class's 1.5rem is sized for a thin &times; glyph,
       which reads much bigger once rendered as a solid fa-times icon. */
    font-size: 1.1rem;
    transition: color 0.2s, background 0.2s;
    /* .card-header aligns to flex-start (so the avatar sits at the top of a
       two-line title instead of drifting to its vertical middle) - that
       pins this button to the top of the row too unless it opts back into
       centering itself. */
    align-self: center;
}
#bridgeModal .card-header .close:hover {
    background: #fdf2f2;
    color: #c47070;
}

/* Photo, with location badge embedded in the image area */
#bridgeModal .photo-section {
    position: relative;
    margin: 16px 28px 0;
    border-radius: 20px;
    overflow: hidden;
    background: #f0f4f8;
    border: 1px solid rgba(233, 237, 242, 0.8);
    /* .bridge-card is a flex column with max-height:90% + overflow:hidden
       (see .modal-content / .bridge-modal .modal-content) - on shorter
       viewports (laptops) that combo let flexbox shrink its children to
       fit, crushing this section well below its aspect-ratio height.
       Pinning it keeps the photo at its intended size; the 2:1 ratio and
       the tightened paddings through the rest of the card keep the whole
       card short enough to fit within max-height without scrolling. */
    flex-shrink: 0;
}
#bridgeModal .photo-section .bridge-img {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    /* Centered rather than anchored toward the bottom - keeps the crop
       predictable across the mix of seed/placeholder photo framing instead
       of biasing toward one edge. */
    object-position: center center;
    display: block;
    transition: transform 0.4s ease;
}
#bridgeModal .photo-section:hover .bridge-img {
    transform: scale(1.03);
}
#bridgeModal .photo-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #5b8c8a;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid rgba(255,255,255,0.5);
}

/* Stats */
#bridgeModal .stats-row {
    display: flex;
    gap: 12px;
    padding: 14px 28px;
}
#bridgeModal .stat-pill {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 13px;
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid rgba(233, 237, 242, 0.8);
    border-radius: 14px;
    transition: all 0.2s;
}
#bridgeModal .stat-pill:hover {
    border-color: #c5dbd8;
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}
#bridgeModal .stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: white;
    border: 1px solid #e9edf2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5b8c8a;
    font-size: 0.85rem;
    flex-shrink: 0;
}
#bridgeModal .stat-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
#bridgeModal .stat-label {
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #5f6b73;
    white-space: nowrap;
}
#bridgeModal .stat-label sub { text-transform: none; }
#bridgeModal .stat-value {
    font-size: 0.98rem;
    font-weight: 700;
    color: #1e2a33;
    white-space: nowrap;
}

/* Quick Info Grid */
#bridgeModal .info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 0 28px;
    margin-bottom: 10px;
}
#bridgeModal .info-item {
    /* Label (icon + "Type"/"Length"/...) stacks above the value instead of
       sharing a row with it - "Retaining Wall"/"Sign Gantry" previously had
       to squeeze into whatever width was left after the icon and label on
       the same line, which forced a wrap and made that row (and the whole
       modal) taller only for those structure types. On its own line the
       value gets the cell's full width instead. */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 8px 10px;
    background: rgba(248, 250, 252, 0.5);
    border-radius: 12px;
    color: #4d5960;
    /* Grid tracks otherwise grow to fit each item's min-content (a long
       "184m" widens its own column at the other columns' expense, even
       though they share nothing) - min-width:0 lets a track shrink to its
       1fr share and wrap long text inside its own cell instead. */
    min-width: 0;
}
#bridgeModal .info-item .info-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    color: #4d5960;
    white-space: nowrap;
}
#bridgeModal .info-item i {
    color: #8ab4b0;
    font-size: 0.78rem;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
#bridgeModal .info-item strong {
    color: #2c3e44;
    font-weight: 700;
    font-size: 0.82rem;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Actions */
#bridgeModal .actions-section {
    /* Bottom padding needs to clear the card's 24px border-radius or the
       last button reads as flush against the curve with no gap at all. */
    padding: 0 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#bridgeModal .btn-primary {
    width: 100%;
    padding: 12px 24px;
    border-radius: 40px;
    border: none;
    background: #5b8c8a;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(91, 140, 138, 0.3);
    font-family: inherit;
}
#bridgeModal .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(91, 140, 138, 0.4);
}
#bridgeModal .btn-secondary-row {
    display: flex;
    gap: 10px;
}
#bridgeModal .btn-secondary {
    flex: 1;
    padding: 10px 10px;
    border-radius: 40px;
    border: 1px solid #a8bcc6;
    background: rgba(248, 250, 252, 0.6);
    color: #4d5960;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
}
#bridgeModal .btn-secondary:hover {
    background: #f8fafc;
    border-color: #8ab4b0;
    color: #5b8c8a;
    transform: translateY(-1px);
}

/* Night mode */
.night-mode #bridgeModal .bridge-card {
    background: rgba(51, 68, 79, 0.92);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.35),
        0 8px 24px rgba(0, 0, 0, 0.18);
}
.night-mode #bridgeModal .card-header {
    background: rgba(30,42,47,0.8);
    border-color: rgba(47, 62, 69, 0.6);
}
.night-mode #bridgeModal .header-text .bridge-name { color: #d4dfe3; }
.night-mode #bridgeModal .card-header .close {
    background: none;
    color: #9ab0b8;
}
.night-mode #bridgeModal .card-header .close:hover {
    background: rgba(196, 112, 112, 0.15);
    color: #e8a0a0;
}
.night-mode #bridgeModal .photo-section {
    background: #1e2a2f;
    border-color: rgba(47, 62, 69, 0.6);
}
.night-mode #bridgeModal .photo-badge {
    background: rgba(47, 62, 72, 0.9);
    color: #8ab4b0;
    border-color: rgba(255,255,255,0.05);
}
.night-mode #bridgeModal .stat-pill {
    background: rgba(30, 42, 47, 0.6);
    border-color: rgba(47, 62, 69, 0.6);
}
.night-mode #bridgeModal .stat-icon {
    background: #2f3e48;
    border-color: #3e525e;
    color: #8ab4b0;
}
.night-mode #bridgeModal .stat-value { color: #d4dfe3; }
.night-mode #bridgeModal .info-item {
    background: rgba(30, 42, 47, 0.4);
    color: #a8b8bf;
}
/* .info-label sets its own color rather than inheriting .info-item's, so it
   needs the same night-mode override explicitly or it stays stuck at the
   light-mode grey. */
.night-mode #bridgeModal .info-item .info-label { color: #a8b8bf; }
.night-mode #bridgeModal .info-item strong { color: #c5d3d9; }
.night-mode #bridgeModal .btn-secondary {
    background: rgba(30, 42, 47, 0.6);
    border-color: #5a7885;
    color: #a8b8bf;
}
.night-mode #bridgeModal .btn-secondary:hover {
    background: #2f3e48;
    border-color: #4a6070;
    color: #c5d3d9;
}

/* ============================================
   MODAL STYLES - SPANSENSE GLASSY DESIGN
   ============================================ */

/* Modal Container */
.bridge-modal .modal-content {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    padding: 0;
    overflow: hidden;
    max-width: 448px;
    width: 90%;
    /* .modal-content's own max-height:90% is 90% of .modal's 100vh - it
       doesn't know .modal also reserves 104px at the top (padding-top, for
       the vertically-centered flex child), so the card could size right up
       to that 90% figure while less space than that actually remains below
       it. The overflow was landing on the bottom padding, reading as "no
       padding" rather than a visible scrollbar. Account for the 104px here
       directly so the card never sizes past what's actually available. */
    max-height: calc(100vh - 104px - 24px);
    animation: modalSlideIn 0.4s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

/* Close Button */
.bridge-modal .documents-modal-header .close {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #5f6b73;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
}

.bridge-modal .documents-modal-header .close:hover {
    background: #fdf2f2;
    color: #c47070;
}

/* Bridge Header Section */
.bridge-header-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 24px 0 24px;
}

.bridge-icon {
    width: 56px;
    height: 56px;
    background: #eef4f2;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5b8c8a;
    font-size: 1.6rem;
}

.bridge-header-section h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e44;
    margin-bottom: 8px;
}

.bridge-badge {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.bridge-badge span {
    font-size: 0.7rem;
    padding: 4px 10px;
    background: #f8fafc;
    border-radius: 20px;
    color: #4d5960;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e9edf2;
}

.bridge-badge span i {
    font-size: 0.65rem;
    color: #8ab4b0;
}

/* Bridge Stats Cards */
.bridge-stats {
    display: flex;
    gap: 16px;
    padding: 0 24px;
    margin-bottom: 24px;
}

.stat-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 16px;
    border: 1px solid #e9edf2;
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: #c5dbd8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.stat-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5b8c8a;
    font-size: 1.1rem;
    border: 1px solid #e9edf2;
}

.stat-info {
    flex: 1;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: #5f6b73;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e44;
}

.stat-value.critical {
    color: #e8a87c;
}

/* Action Buttons */
.bridge-actions {
    padding: 0 24px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    width: 100%;
    padding: 12px 20px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: inherit;
    border: none;
}

.primary-action {
    background: #5b8c8a;
    color: white;
    box-shadow: 0 2px 8px rgba(91, 140, 138, 0.25);
}

.primary-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(91, 140, 138, 0.35);
}

.secondary-action {
    background: transparent;
    color: #4d5960;
    border: 1px solid #e9edf2;
}

.secondary-action:hover {
    background: #f8fafc;
    border-color: #8ab4b0;
    color: #5b8c8a;
    transform: translateY(-1px);
}

/* Night Mode */
.night-mode .bridge-modal .modal-content {
    background: rgba(47, 62, 72, 0.98);
}

.night-mode .bridge-icon {
    background: #1e2a2f;
    color: #8ab4b0;
}

.night-mode .bridge-header-section h2 {
    color: #d4dfe3;
}

.night-mode .bridge-badge span {
    background: #1e2a2f;
    border-color: #3e525e;
    color: #a8b8bf;
}

.night-mode .stat-card {
    background: #1e2a2f;
    border-color: #3e525e;
}

.night-mode .stat-icon {
    background: #2f3e48;
    border-color: #3e525e;
    color: #8ab4b0;
}

.night-mode .stat-value {
    color: #d4dfe3;
}

.night-mode .secondary-action {
    color: #a8b8bf;
    border-color: #3e525e;
}

.night-mode .secondary-action:hover {
    background: #2f4a48;
    color: #8ab4b0;
}

/* Responsive */
@media (max-width: 480px) {
    .bridge-header-section {
        flex-direction: column;
        text-align: center;
    }
    
    .bridge-stats {
        flex-direction: column;
    }
    
    .stat-card {
        padding: 12px;
    }
}

.bridge-icon {
    width: 56px;
    height: 56px;
    background: #eef4f2 !important;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5b8c8a;
    font-size: 1.6rem;
}

/* Modal Header */
.documents-modal-header {
    padding: 24px 28px;
    background: #f8fafc;
    border-bottom: 1px solid #e9edf2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.documents-modal-header .header-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.bridge-avatar {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: #8ab4b0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.documents-modal-header .bridge-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.documents-modal-header .bridge-id-line {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #5f6b73;
    font-weight: 600;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

.documents-modal-header .bridge-id-line span {
    color: #5b8c8a;
    font-weight: 700;
}

.documents-modal-header .bridge-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e44;
    letter-spacing: -0.02em;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

/* Close button in header */
.documents-modal-header .close {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #5f6b73;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
}

.documents-modal-header .close:hover {
    background: #fdf2f2;
    color: #c47070;
}

/* Quick Stats Bar */
.quick-stats {
    display: flex;
    gap: 94px;
    padding: 16px 28px;
    background: white;
    border-bottom: 1px solid #e9edf2;
    flex-wrap: wrap;
    justify-content: center;
}

.quick-stat {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quick-stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e9edf2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8ab4b0;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.quick-stat-content {
    display: flex;
    flex-direction: column;
}

.quick-stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #5f6b73;
    font-weight: 600;
}

.quick-stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #2c3e44;
}

#documentsTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#documentsTable thead {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 10;
}

#documentsTable th {
    text-align: left;
    padding: 14px 28px;
    color: #5f6b73;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    border-bottom: 2px solid #e9edf2;
    background: #f8fafc;
}

#documentsTable td {
    padding: 18px 28px;
    border-bottom: 1px solid #f0f4f8;
    font-size: 0.9rem;
    color: #2c3e44;
    vertical-align: middle;
}

#documentsTable tbody tr {
    transition: background 0.15s;
}

#documentsTable tbody tr:hover {
    background: #fafbfc;
}

#documentsTable tbody tr.critical {
    background: #fdf8f5;
}

#documentsTable tbody tr.critical:hover {
    background: #fdf2f2;
}

/* Date Cell */
.date-cell {
    font-weight: 600;
    color: #2c3e44;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.date-relative {
    font-size: 0.75rem;
    color: #5f6b73;
    font-weight: 500;
}

/* Type Badge - Circular style */
.type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.type-gi {
    background: #eef4f2;
    color: #5b8c8a;
    border: 2px solid #c5dbd8;
}

.type-pi {
    background: #f0f4ff;
    color: #5b7c8a;
    border: 2px solid #c5d0db;
}

/* Score Cell */
.score-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.score-main {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 1.1rem;
}

.score-good { color: #5b8c8a; }
.score-warning { color: #d4a373; }
.score-danger { color: #c47070; }

.score-bar {
    width: 60px;
    height: 4px;
    background: #e9edf2;
    border-radius: 2px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

.fill-good { background: #8ab4b0; }
.fill-warning { background: #e8a87c; }
.fill-danger { background: #c47070; }

/* Actions */
#documentsTable .actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-action {
    padding: 8px 18px;
    border-radius: 20px;
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-action.btn-edit {
    background: #8ab4b0;
    color: white;
    box-shadow: 0 2px 6px rgba(138, 180, 176, 0.25);
}

.btn-action.btn-edit:hover {
    background: #5b8c8a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(91, 140, 138, 0.3);
}

.btn-action.btn-report {
    background: #f1f3f5;
    color: #4d5960;
    border: 1px solid #e9edf2;
}

.btn-action.btn-report:hover {
    background: #e9ecef;
    color: #4a5b6e;
    border-color: #c5dbd8;
}

.btn-action.btn-bci {
    background: transparent;
    color: #5f6b73;
    padding: 8px 12px;
}

.btn-action.btn-bci:hover {
    color: #5b8c8a;
    background: #f8fafc;
}

/* Modal Footer */
.documents-modal-footer {
    padding: 16px 28px;
    background: #f8fafc;
    border-top: 1px solid #e9edf2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-note {
    font-size: 0.8rem;
    color: #5f6b73;
}

.btn-close-modal {
    padding: 10px 28px;
    border-radius: 24px;
    border: none;
    background: #8ab4b0;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-close-modal:hover {
    background: #5b8c8a;
}


/* ============================================
   FILE EXPLORER MODAL
   ============================================ */

.file-explorer-modal .modal-content {
    width: 80%;
    max-width: 720px;
    padding: 0;
    border-radius: 24px;
    overflow: hidden;
    background: rgba(244, 248, 247, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow:
        0 24px 80px rgba(44, 90, 87, 0.16),
        0 8px 24px rgba(44, 90, 87, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(138, 180, 176, 0.32);
}

.file-explorer-modal .modal-header {
    padding: 24px 28px 20px;
    background: rgba(248,250,252,0.8);
    border-bottom: 1px solid rgba(233, 237, 242, 0.6);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-explorer-modal .modal-title {
    margin: 0;
    font-size: 1.15rem;
    color: #1e2a33;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.file-explorer-modal .modal-title::before {
    content: '\f07c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #8ab4b0;
    font-size: 1rem;
}

/* REPLACE WITH: */
.close-modal {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #5f6b73;
    transition: color 0.2s, background 0.2s;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
}

.close-modal:hover {
    background: #fdf2f2;
    color: #c47070;
}

.toolbar {
    display: flex;
    gap: 10px;
    padding: 16px 28px;
    margin-bottom: 0;
    border-bottom: 1px solid rgba(233, 237, 242, 0.6);
    background: rgba(248, 250, 252, 0.5);
}

.toolbar button {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #e9edf2;
    padding: 9px 16px;
    border-radius: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: #4d5960;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
}

.toolbar button:hover {
    background: #eef4f2;
    border-color: #8ab4b0;
    color: #5b8c8a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.toolbar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.breadcrumbs {
    padding: 12px 28px;
    background: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(233, 237, 242, 0.6);
    font-size: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.breadcrumb {
    padding: 5px 12px;
    border-radius: 20px;
    color: #4d5960;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 600;
}

.breadcrumb:hover {
    background: #eef4f2;
    color: #5b8c8a;
}

.breadcrumb:not(:last-child)::after {
    content: '›';
    margin-left: 8px;
    color: #c5d3d9;
}

.breadcrumb-current {
    color: #2c4a48;
    cursor: default;
}
.breadcrumb-current:hover {
    background: none;
    color: #2c4a48;
}

.file-list {
    list-style: none;
    padding: 10px 12px;
    margin: 0;
    width: 100%;
    min-height: 180px;
}

.file-list li {
    display: flex;
    align-items: center;
    padding: 11px 16px;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.9rem;
    color: #4d5960;
    border-radius: 14px;
    /* Always reserve the 1px .selected adds below, so selecting a row only
       changes its border's color, not its width - a border appearing out of
       nowhere shrank the content box and made the icon/text visibly jump. */
    border: 1px solid transparent;
}

.file-list li:hover {
    background: #eef4f2;
    color: #5b8c8a;
}

/* Deliberately stronger/more saturated than :hover (which shares this same
   tint) - otherwise a selected row looks identical to whatever the mouse
   happens to be resting on, and reads as "barely visible" once it isn't. */
.file-list li.selected {
    background: rgba(91, 140, 138, 0.18);
    border: 1px solid #5b8c8a;
    color: #2c5a57;
}

#folderForm {
    margin: 0;
    padding: 18px 28px;
    border-top: 1px solid rgba(233, 237, 242, 0.6);
    background: rgba(248, 250, 252, 0.6);
    display: flex;
    gap: 10px;
    align-items: center;
}

#folderForm input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #e9edf2;
    border-radius: 40px;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    color: #2c3e44;
    outline: none;
}

#folderForm input:focus {
    border-color: #8ab4b0;
}

#folderForm button {
    padding: 10px 22px;
    border: none;
    border-radius: 40px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#createFolderBtn {
    background: #5b8c8a;
    color: white;
    box-shadow: 0 4px 16px rgba(91, 140, 138, 0.3);
}

#createFolderBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(91, 140, 138, 0.4);
}

#cancelFolderBtn {
    background: white;
    color: #4d5960;
    border: 1px solid #e9edf2;
}

#cancelFolderBtn:hover {
    background: #f8fafc;
}

/* List View */
.file-list.list-view {
    display: block;
}

.file-list.list-view li {
    display: flex;
    align-items: center;
    padding: 11px 16px;
    width: 100%;
}

/* Folder View */
.file-list.folder-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    align-items: start;
    align-content: start;
    gap: 16px;
    padding: 20px 28px;
}

.file-list.folder-view li {
    flex-direction: column;
    text-align: center;
    padding: 18px 14px;
    width: auto;
    background: rgba(248, 250, 252, 0.8);
    border-radius: 18px;
    border: 1px solid rgba(233, 237, 242, 0.8);
    transition: all 0.2s;
}

.file-list.folder-view li:hover {
    background: #eef4f2;
    border-color: #8ab4b0;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

/* Needed in addition to the plain .file-list li.selected rule above - same
   specificity as .file-list.folder-view li but that one comes later in the
   cascade, so without this override a selected card's highlight silently
   disappeared the moment the mouse stopped hovering it. */
.file-list.folder-view li.selected {
    background: rgba(91, 140, 138, 0.18);
    border-color: #5b8c8a;
    color: #2c5a57;
}

.file-list.folder-view .file-icon {
    font-size: 2.2em;
    margin-bottom: 8px;
}

.file-list.folder-view .file-name {
    word-break: break-word;
    font-size: 0.8rem;
}

/* ============================================
   CHAT CONTAINER - FIXED POSITION & GLASSY
   ============================================ */

/* Move chat up to avoid map attribution */
.chat-container {
    position: fixed !important;
    bottom: 65px !important;  /* Changed from 30px to 80px */
    right: 20px !important;
    z-index: 1000 !important;
}

/* Make chat toggle match navbar style */
.chat-toggle {
    background: rgba(255, 255, 255, 0.72) !important;
    backdrop-filter: blur(16px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(160%) !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 10px 30px rgba(44, 90, 87, 0.14) !important;
    transition: all 0.3s ease !important;
    border: 1px solid rgba(138, 180, 176, 0.3) !important;
}

.chat-toggle i {
    color: #5b8c8a !important;
    font-size: 1.3rem !important;
}

.chat-toggle:hover {
    transform: scale(1.05) !important;
    background: rgba(255, 255, 255, 0.85) !important;
}

/* Chat box glassy */
.chat-box {
    position: absolute !important;
    bottom: 0 !important;
    right: 0 !important;
    width: 360px !important;
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(20px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(160%) !important;
    border-radius: 24px !important;
    box-shadow: 0 10px 30px rgba(44, 90, 87, 0.16) !important;
    opacity: 0 !important;
    transform: translateY(20px) !important;
    transition: all 0.3s ease !important;
    display: none !important;
    border: 1px solid rgba(138, 180, 176, 0.3) !important;
    overflow: hidden !important;
}

.chat-box.active {
    opacity: 1 !important;
    transform: translateY(0) !important;
    display: block !important;
}

/* Chat header gradient */
.chat-header {
    background: #5b8c8a !important;
    color: white !important;
    padding: 16px 20px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.chat-header h3 {
    font-size: 1rem !important;
    font-weight: 600 !important;
    margin: 0 !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.chat-beta-badge {
    background: rgba(255, 255, 255, 0.22) !important;
    color: white !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    padding: 2px 8px !important;
    border-radius: 20px !important;
}

.chat-close {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: white !important;
    cursor: pointer !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.chat-messages {
    height: 280px !important;
    padding: 16px !important;
    overflow-y: auto !important;
    background: rgba(245, 247, 251, 0.5) !important;
}

/* Thin teal scrollbar, same as the app's other custom scrollbars (e.g.
   author/map.html's .route-list, inspection.css's .modal-body). The
   standard scrollbar-* properties are Firefox-only here: Chrome 121+
   lets them override the ::-webkit-scrollbar rules and draws its own
   thin bar with arrow buttons instead. */
@supports not selector(::-webkit-scrollbar) {
    .chat-messages { scrollbar-width: thin; scrollbar-color: #c5dbd8 transparent; }
    .night-mode .chat-messages { scrollbar-color: #2f4a48 transparent; }
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.chat-messages::-webkit-scrollbar-thumb { background: #c5dbd8; border-radius: 10px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: #8ab4b0; }
.night-mode .chat-messages::-webkit-scrollbar-thumb { background: #2f4a48; }
.night-mode .chat-messages::-webkit-scrollbar-thumb:hover { background: #3a5c5a; }

/* Message bubbles */
.message.bot {
    background: white !important;
    color: #2c3e44 !important;
    border: 1px solid rgba(233, 237, 242, 0.5) !important;
    border-radius: 16px !important;
    border-bottom-left-radius: 4px !important;
    padding: 10px 14px !important;
    margin: 8px 0 !important;
    max-width: 80% !important;
    font-size: 0.85rem !important;
}

.message.user {
    background: #8ab4b0 !important;
    color: white !important;
    border-radius: 16px !important;
    border-bottom-right-radius: 4px !important;
    padding: 10px 14px !important;
    margin: 8px 0 !important;
    margin-left: auto !important;
    max-width: 80% !important;
    font-size: 0.85rem !important;
}

/* Chat input glassy */
.chat-input {
    display: flex !important;
    padding: 14px 16px !important;
    background: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(5px) !important;
    border-top: 1px solid rgba(233, 237, 242, 0.5) !important;
    gap: 10px !important;
}

.chat-input input {
    flex: 1 !important;
    padding: 10px 14px !important;
    border: 1px solid rgba(224, 232, 240, 0.5) !important;
    border-radius: 24px !important;
    font-size: 0.85rem !important;
    background: rgba(255, 255, 255, 0.5) !important;
    outline: none !important;
}

.chat-send {
    background: #8ab4b0 !important;
    border: none !important;
    color: white !important;
    padding: 10px 18px !important;
    border-radius: 24px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
}

.chat-send:hover {
    background: #5b8c8a !important;
}

/* ============================================
   NIGHT MODE CHAT
   ============================================ */

.night-mode .chat-toggle {
    background: rgba(47, 62, 72, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.night-mode .chat-toggle i {
    color: #8ab4b0 !important;
}

.night-mode .chat-box {
    background: rgba(51, 68, 79, 0.82) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
}

.night-mode .chat-header {
    background: #3a6b62 !important;
}

.night-mode .chat-messages {
    background: rgba(30, 42, 47, 0.5) !important;
}

.night-mode .message.bot {
    background: #2f3e48 !important;
    color: #d0dce2 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.night-mode .message.user {
    background: #3a6b62 !important;
}

.night-mode .chat-input {
    background: rgba(47, 62, 72, 0.5) !important;
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}

.night-mode .chat-input input {
    background: rgba(30, 42, 47, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    color: #d0dce2 !important;
}

.night-mode .chat-send {
    background: #3a6b62 !important;
}

.night-mode .chat-send:hover {
    background: #4a7a70 !important;
}

/* ============================================
   RESPONSIVE CHAT
   ============================================ */

@media (max-width: 768px) {
    .chat-container {
        bottom: 70px !important;
        right: 15px !important;
    }
    
    .chat-toggle {
        width: 48px !important;
        height: 48px !important;
    }
    
    .chat-box {
        width: calc(100vw - 40px) !important;
        max-width: 360px !important;
        right: 0 !important;
    }
}

/* ============================================
   TOAST
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 10px 30px rgba(44, 90, 87, 0.14);
    border: 1px solid rgba(138, 180, 176, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show { transform: translateX(0); }
.toast-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.toast-icon.success { background: #e8f5f0; color: #2d7a6e; }
.toast-icon.error { background: #fdf2f2; color: #c47070; }
.toast-content { flex: 1; }
.toast-content .toast-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c4a48;
    margin-bottom: 2px;
}
.toast-content .toast-msg {
    font-size: 0.8rem;
    color: #5f6b73;
}
.toast-close {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: #f8fafc;
    color: #5f6b73;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.toast-close:hover { background: #e9ecef; color: #4a5b6e; }

/* ============================================
   BUTTON HELPERS
   ============================================ */

.edit-button, .bci-button {
    padding: 8px 16px;
    margin: 4px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    font-family: inherit;
}

.edit-button {
    background: #e8f5e9;
    color: #2e7d32;
}

.edit-button:hover {
    background: #2e7d32;
    color: white;
}

.bci-button {
    background: #e3f2fd;
    color: #1565c0;
}

.bci-button:hover {
    background: #1565c0;
    color: white;
}

/* ============================================
   PHOTO CONTAINER
   ============================================ */

.photo-container {
    margin-bottom: 20px;
}

.photo-item {
    border: 1px solid #e9edf2;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: white;
    page-break-inside: avoid;
}

.photo-item img {
    max-width: 100%;
    max-height: 200px;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
}

.photo-caption {
    font-size: 0.85em;
    margin: 8px 0 4px;
    font-style: italic;
    color: #4d5960;
}

.photo-meta {
    font-size: 0.8em;
    color: #5f6b73;
}



/* ============================================
   NIGHT MODE - EXACTLY MATCHING REFINED MAIN PAGE
   ============================================ */

.night-mode {
    background-color: #243038;
    color: #e0e8ed;
}

.night-mode .modal-content,
.night-mode .chart-container,
.night-mode .search-results,
.night-mode .chat-box,
.night-mode .photo-item,
.night-mode .file-list.folder-view li,
.night-mode .back-button {
    background: #2f3e48;
    border-color: #3e525e;
}

/* Night mode */
.night-mode .navbar {
    background: rgba(47, 62, 72, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.night-mode .navbar .logo {
    background: linear-gradient(135deg, #8ab4b0 0%, #a0c8c4 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.night-mode .navbar .menu a,
.night-mode .navbar .account-links a {
    color: #9ab0b8 !important;
}

.night-mode .navbar .search-bar input {
    background: rgba(30, 42, 47, 0.6) !important;
    color: #d0dce2 !important;
}

.night-mode .night-mode-toggle {
    background: rgba(62, 82, 94, 0.8) !important;
    color: #c5e0e6 !important;
}

.night-mode .night-mode-toggle:hover {
    background: #4a6570;
}

.night-mode .navbar .account-links a {
    color: #c5e0e6 !important;
}

.night-mode .navbar .account-links a:hover {
    background: #4a6570 !important;
    color: #8ab4b0 !important;
}


/* Search results */
.night-mode .search-results div {
    color: #a8b8bf;
    border-bottom-color: #3e525e;
}

.night-mode .search-results div:hover {
    background: #3a6b62;
    color: white;
}

/* Dashboard night mode */
.night-mode #dashboard h2 {
    color: #e0e8ed;
}

.night-mode .back-button {
    background: #3e525e;
    color: #a8b8bf;
    border-color: #4a6070;
}

.night-mode .back-button:hover {
    background: #4a6570;
    color: #d0dce2;
}

/* Modals night mode */
.night-mode .modal-content {
    border-color: #3e525e;
}

.night-mode .bridge-info div {
    background: #243038;
    border-color: #4a6070;
}

.night-mode .bridge-info span {
    color: #9eb8c2;
}

.night-mode .bridge-info strong {
    color: #d0dce2;
}

.night-mode .primary-btn {
    background: #3a6b62;
    box-shadow: 0 2px 6px rgba(58, 107, 98, 0.25);
}

.night-mode .primary-btn:hover {
    background: #4a7a70;
}

.night-mode .secondary-btn {
    border-color: #4a6070;
    color: #a8b8bf;
}

.night-mode .secondary-btn:hover {
    background: #3a6b62;
    border-color: #7aaea4;
    color: white;
}

/* Documents modal */
.night-mode #bridgeInfo {
    background: #243038;
    border-color: #4a6070;
}

.night-mode #bridgeInfo p {
    color: #a8b8bf;
}

.night-mode #bridgeInfo strong {
    color: #d0dce2;
}

.night-mode #documentsTable th {
    background: #243038;
    color: #9eb8c2;
    border-bottom-color: #3e525e;
}

.night-mode #documentsTable td {
    color: #a8b8bf;
    border-bottom-color: #3e525e;
}

.night-mode #documentsTable tr:hover {
    background: #243038;
}

.night-mode #documentsTable button {
    background: #3a6b62;
}

.night-mode #documentsTable button:hover {
    background: #4a7a70;
}

/* File explorer night mode - same glass treatment as #bridgeModal/.ss-modal */
.night-mode .file-explorer-modal .modal-content {
    background: rgba(51, 68, 79, 0.92);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.18);
}

.night-mode .file-explorer-modal .modal-header {
    background: rgba(30,42,47,0.8);
    border-color: rgba(47, 62, 69, 0.6);
}

.night-mode .toolbar,
.night-mode .breadcrumbs,
.night-mode #folderForm {
    background: rgba(30, 42, 47, 0.6);
    border-color: #3e525e;
}

.night-mode .file-explorer-modal .modal-title {
    color: #e0e8ed;
}

.night-mode .file-list.folder-view li {
    background: rgba(30, 42, 47, 0.6);
}

/* REPLACE WITH: */
.night-mode .close-modal,
.night-mode .close {
    color: #9ab0b8;
    background: none;
}

.night-mode .close-modal:hover,
.night-mode .close:hover {
    background: rgba(196, 112, 112, 0.15);
    color: #e8a0a0;
}

.night-mode .toolbar button {
    background: #3e525e;
    border-color: #4a6070;
    color: #a8b8bf;
}

.night-mode .toolbar button:hover {
    background: #3a6b62;
    border-color: #7aaea4;
    color: white;
}

.night-mode .breadcrumb {
    color: #a8b8bf;
}

.night-mode .breadcrumb:hover {
    background: #3a6b62;
    color: white;
}

.night-mode .breadcrumb-current {
    color: #d4dfe3;
}
.night-mode .breadcrumb-current:hover {
    background: none;
    color: #d4dfe3;
}

.night-mode .file-list li {
    color: #a8b8bf;
}

.night-mode .file-list li:hover {
    background: #3a6b62;
    color: white;
}

.night-mode .file-list li.selected {
    background: #3a6b62;
    color: white;
}

.night-mode .file-list.folder-view li {
    background: #243038;
    border-color: #4a6070;
}

.night-mode .file-list.folder-view li:hover {
    background: #3a6b62;
    border-color: #7aaea4;
}

/* Same cascade-order fix as the light-mode rule above - without this, a
   selected card's teal highlight only ever showed while also hovered. */
.night-mode .file-list.folder-view li.selected {
    background: #3a6b62;
    border-color: #7aaea4;
    color: white;
}

.night-mode #folderForm input {
    background: #2f3e48;
    border-color: #4a6070;
    color: #d0dce2;
}

.night-mode #folderForm input:focus {
    border-color: #7aaea4;
}

.night-mode #createFolderBtn {
    background: #3a6b62;
}

.night-mode #createFolderBtn:hover {
    background: #4a7a70;
}

.night-mode #cancelFolderBtn {
    background: #3e525e;
    color: #a8b8bf;
    border-color: #4a6070;
}

.night-mode #cancelFolderBtn:hover {
    background: #4a6570;
}

/* Chat night mode */
.night-mode .chat-toggle {
    background: #3a6b62;
}

.night-mode .chat-toggle:hover {
    background: #4a7a70;
}

.night-mode .chat-header {
    background: #3a6b62;
}

.night-mode .chat-messages {
    background: #1e2a2f;
}

.night-mode .message.bot {
    background: #2f3e48;
    color: #d0dce2;
    border-color: #4a6070;
}

.night-mode .message.user {
    background: #3a6b62;
}

.night-mode .chat-input {
    background: #2f3e48;
    border-color: #3e525e;
}

.night-mode .chat-input input {
    background: #243038;
    border-color: #4a6070;
    color: #d0dce2;
}

.night-mode .chat-input input:focus {
    border-color: #7aaea4;
}

.night-mode .chat-send {
    background: #3a6b62;
}

.night-mode .chat-send:hover {
    background: #4a7a70;
}

/* Toast night mode */
.night-mode .toast {
    background: rgba(51, 68, 79, 0.88);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.night-mode .toast-content .toast-title { color: #d4dfe3; }
.night-mode .toast-content .toast-msg { color: #a8b8bf; }
.night-mode .toast-close { background: #1e2a2f; color: #a8b8bf; }
.night-mode .toast-close:hover { background: #2a3a40; color: #d4dfe3; }

/* Button helpers night mode */
.night-mode .edit-button {
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
}

.night-mode .edit-button:hover {
    background: #3fb950;
    color: white;
}

.night-mode .bci-button {
    background: rgba(56, 139, 253, 0.15);
    color: #58a6ff;
}

.night-mode .bci-button:hover {
    background: #58a6ff;
    color: white;
}

/* Leaflet popup night mode */
.night-mode .leaflet-popup-content-wrapper {
    background: #2f3e48;
    color: #d4dfe3;
    box-shadow: 0 3px 14px rgba(0,0,0,0.4);
}
.night-mode .leaflet-popup-content {
    color: #d4dfe3;
}
.night-mode .leaflet-popup-tip {
    background: #2f3e48;
}

.night-mode .leaflet-tooltip.structure-label {
    background: #2f3e48;
    border-color: #3e525e;
    color: #d4dfe3;
}
.night-mode .structure-label-id {
    color: #8ab4b0;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        top: 10px !important;
        left: 10px !important;
        right: 10px !important;
        border-radius: 40px !important;
        padding: 0 16px !important;
    }
    
    body {
        padding-top: 74px !important;
    }
    
    #map {
        height: calc(100vh - 74px) !important;
    }
    
    .sidebar {
        top: 84px !important;
    }
    
    .navbar .search-bar {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .navbar {
        top: 8px !important;
        left: 8px !important;
        right: 8px !important;
        border-radius: 32px !important;
    }
    
    body {
        padding-top: 68px !important;
    }
    
    #map {
        height: calc(100vh - 68px) !important;
    }
}

.night-mode .documents-modal-header {
    background: #1e2a2f;
    border-bottom-color: #2f3e45;
}

.night-mode .documents-modal-header .bridge-id-line {
    color: #a8b8bf;
}

.night-mode .documents-modal-header .bridge-id-line span {
    color: #8ab4b0;
}

.night-mode .documents-modal-header .bridge-name {
    color: #d4dfe3;
}

.night-mode .documents-modal-header .close {
    color: #9ab0b8;
}

.night-mode .documents-modal-header .close:hover {
    background: #3a2a2a;
    color: #e8a0a0;
    border-color: #5a3a3a;
}

.night-mode .quick-stats {
    background: #232e34;
    border-bottom-color: #2f3e45;
}

.night-mode .quick-stat-icon {
    background: #1e2a2f;
    border-color: #3a4b53;
    color: #8ab4b0;
}

.night-mode .quick-stat-label {
    color: #a8b8bf;
}

.night-mode .quick-stat-value {
    color: #d4dfe3;
}

.night-mode #documentsTable {
    background: #2f3e48;
}

.night-mode #documentsTable thead {
    background: #1e2a2f;
}

.night-mode #documentsTable th {
    background: #1e2a2f;
    color: #a8b8bf;
    border-bottom-color: #2f3e45;
}

.night-mode #documentsTable td {
    color: #c5d3d9;
    border-bottom-color: #1e2a2f;
}

.night-mode #documentsTable tbody tr:hover {
    background: #1e2a2f;
}

.night-mode #documentsTable tbody tr.critical {
    background: #2f2a25;
}

.night-mode #documentsTable tbody tr.critical:hover {
    background: #3a2a25;
}

.night-mode .date-cell {
    color: #d4dfe3;
}

.night-mode .date-relative {
    color: #a8b8bf;
}

.night-mode .type-gi {
    background: #2f4a48;
    color: #8ab4b0;
    border-color: #3a6b62;
}

.night-mode .type-pi {
    background: #2a3a4a;
    color: #7aa0b0;
    border-color: #3a5a6a;
}

.night-mode .score-good { color: #8ab4b0; }
.night-mode .score-warning { color: #d4a373; }
.night-mode .score-danger { color: #c47070; }

.night-mode .score-bar {
    background: #2f3e45;
}

.night-mode .btn-action.btn-edit {
    background: #2f4a48;
    box-shadow: 0 2px 6px rgba(47, 74, 72, 0.25);
}

.night-mode .btn-action.btn-edit:hover {
    background: #3a5c5a;
}

.night-mode .btn-action.btn-report {
    background: #2f3e45;
    color: #9ab0b8;
    border-color: #3a4b53;
}

.night-mode .btn-action.btn-report:hover {
    background: #3a4b53;
    color: #c5d3d9;
}

.night-mode .btn-action.btn-bci {
    color: #a8b8bf;
}

.night-mode .btn-action.btn-bci:hover {
    color: #8ab4b0;
    background: #2f3e45;
}

.night-mode .documents-modal-footer {
    background: #1e2a2f;
    border-top-color: #2f3e45;
}

.night-mode .footer-note {
    color: #a8b8bf;
}

.night-mode .btn-close-modal {
    background: #2f4a48;
}

.night-mode .btn-close-modal:hover {
    background: #3a5c5a;
}



/* ============================================
   JS-GENERATED BUTTON STYLES (for index.js)
   ============================================ */

#documentsTable .bci-button,
#documentsTable .normal-btn,
#documentsTable, .simple-report-button {
    padding: 8px 18px;
    border-radius: 20px;
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    margin: 0 2px;
}

#documentsTable .bci-button,
#documentsTable .normal-btn,
#documentsTable .simple-report-button {
    background: #8ab4b0;
    color: white;
    box-shadow: 0 2px 6px rgba(138, 180, 176, 0.25);
}

#documentsTable .normal-btn:hover,
#documentsTable .simple-report-button {
    background: #5b8c8a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(91, 140, 138, 0.3);
}

#documentsTable .report-button {
    background: #f1f3f5;
    color: #4d5960;
    border: 1px solid #e9edf2;
}

#documentsTable .report-button:hover {
    background: #e9ecef;
    color: #4a5b6e;
    border-color: #c5dbd8;
}

#documentsTable .bci-button {
    background: transparent;
    color: #5f6b73;
    padding: 8px 12px;
}

#documentsTable .bci-button:hover {
    color: #5b8c8a;
    background: #f8fafc;
}

/* Night mode for JS buttons */
.night-mode #documentsTable .normal-btn,
.night-mode #documentsTable .simple-report-button {
    background: #2f4a48;
    box-shadow: 0 2px 6px rgba(47, 74, 72, 0.25);
}

.night-mode #documentsTable .normal-btn:hover,
.night-mode #documentsTable .simple-report-button {
    background: #3a5c5a;
}

.night-mode #documentsTable .report-button {
    background: #2f3e45;
    color: #9ab0b8;
    border-color: #3a4b53;
}

.night-mode #documentsTable .report-button:hover {
    background: #3a4b53;
    color: #c5d3d9;
}

.night-mode #documentsTable .bci-button {
    color: #a8b8bf;
}

.night-mode #documentsTable .bci-button:hover {
    color: #8ab4b0;
    background: #2f3e45;
}



/* ============================================
   FALLBACK STYLES FOR JS-GENERATED ROWS
   ============================================ */

/* Style plain text dates in JS-generated rows */
#documentsTable tbody td:first-child {
    font-weight: 600;
    color: #2c3e44;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Style plain text type cells (GI/PI) */
#documentsTable tbody td:nth-child(2) {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
}

/* Style plain score cells */
#documentsTable tbody td:nth-child(3),
#documentsTable tbody td:nth-child(4) {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 1.1rem;
}

/* Color scores based on value (attribute selectors won't work for dynamic content,
   so we rely on the JS adding classes or inline styles) */

/* Night mode fallbacks */
.night-mode #documentsTable tbody td:first-child {
    color: #d4dfe3;
}

.night-mode #documentsTable tbody td:nth-child(2) {
    color: #c5d3d9;
}

.night-mode #documentsTable tbody td:nth-child(3),
.night-mode #documentsTable tbody td:nth-child(4) {
    color: #c5d3d9;
}


/* ============================================
   RESPONSIVE - DOCUMENTS MODAL
   ============================================ */

@media (max-width: 768px) {

    .documents-modal-header {
        padding: 16px 20px;
    }

    .bridge-avatar {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .documents-modal-header .bridge-name {
        font-size: 1.1rem;
    }

    .quick-stats {
        padding: 12px 20px;
        gap: 12px;
    }

    .quick-stat {
        flex: 1;
        min-width: 120px;
    }

    #documentsTable th,
    #documentsTable td {
        padding: 12px 16px;
    }

    .documents-modal-footer {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .btn-action {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .quick-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    #documentsTable th:nth-child(3),
    #documentsTable td:nth-child(3) {
        display: none;
    }

    .actions {
        flex-direction: column;
        gap: 4px;
    }

    .btn-action {
        width: 100%;
        text-align: center;
    }
}


/* ============================================
   MODERN ROUNDED MAP CONTROLS - Reduced Gap
   ============================================ */

/* Custom Zoom Control */
.leaflet-control-zoom {
    border: none !important;
    border-radius: 48px !important;
    box-shadow: 0 10px 30px rgba(44, 90, 87, 0.14) !important;
    overflow: hidden !important;
    margin: 100px 20px 8px 20px !important;  /* Reduced bottom margin */
}

.leaflet-control-zoom a {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(16px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(160%) !important;
    color: #5b8c8a !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 18px !important;
    font-weight: 500 !important;
    transition: all 0.25s ease !important;
    border: none !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(238, 244, 242, 0.9) !important;
    color: #2c5a57 !important;
    transform: scale(0.98);
}

.leaflet-control-zoom-in {
    border-bottom: 1px solid rgba(138, 180, 176, 0.25) !important;
    border-radius: 48px 48px 0 0 !important;
}

.leaflet-control-zoom-out {
    border-radius: 0 0 48px 48px !important;
}

/* Custom Layer Control - Pill shaped, closer to zoom */
.leaflet-control-layers {
    border: 1px solid rgba(138, 180, 176, 0.3) !important;
    border-radius: 48px !important;
    box-shadow: 0 10px 30px rgba(44, 90, 87, 0.14) !important;
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(16px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(160%) !important;
    margin: 8px 20px 20px 20px !important;  /* Reduced top margin */
}

.leaflet-control-layers-toggle {
    background-color: rgba(255, 255, 255, 0.55) !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 48px !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%235b8c8a" width="20px" height="20px"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 3h18v2H3V3zm0 16h18v2H3v-2zm0-8h18v2H3v-2z"/></svg>') !important;
    background-size: 20px !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    transition: all 0.25s ease !important;
}

.leaflet-control-layers-toggle:hover {
    background-color: rgba(238, 244, 242, 0.85) !important;
    transform: scale(0.95);
}

.leaflet-control-layers-expanded {
    padding: 12px !important;
    background: rgba(244, 248, 247, 0.92) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid rgba(138, 180, 176, 0.32) !important;
    border-radius: 20px !important;
    min-width: 160px !important;
    box-shadow: 0 20px 40px rgba(44, 90, 87, 0.16) !important;
    margin-bottom: 12px !important;
}

.leaflet-control-layers-expanded label {
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    color: #4a5b6e !important;
    padding: 8px 12px !important;
    margin: 0 !important;
    border-radius: 12px !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.leaflet-control-layers-expanded label:hover {
    background: #eef4f2 !important;
    color: #5b8c8a !important;
}

.leaflet-control-layers-expanded label input {
    margin: 0 !important;
    width: 16px !important;
    height: 16px !important;
    accent-color: #5b8c8a !important;
}

.leaflet-control-layers-separator {
    border-top: 1px solid #e9edf2 !important;
    margin: 8px 0 !important;
}

/* Attribution - also rounded */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.75) !important;
    backdrop-filter: blur(8px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(8px) saturate(160%) !important;
    border: 1px solid rgba(138, 180, 176, 0.25) !important;
    border-radius: 24px !important;
    padding: 6px 14px !important;
    font-size: 10px !important;
    color: #5f6b73 !important;
    margin: 12px !important;
    box-shadow: 0 4px 14px rgba(44, 90, 87, 0.1) !important;
}

.leaflet-control-attribution a {
    color: #5b8c8a !important;
    text-decoration: none !important;
}

.leaflet-control-attribution a:hover {
    text-decoration: underline !important;
}

/* Scale bar (author/map.js's route planner only, Core doesn't add one) -
   same translucent-chip treatment as attribution above rather than
   Leaflet's default plain white/gray box with a hard black border.
   orgSwitcher.js's fixed chip moved to top-right (see that file), so this
   corner's just the normal margin - no clearance to reserve here anymore. */
.leaflet-control-scale {
    margin: 20px !important;
}

.leaflet-control-scale-line {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(16px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(160%) !important;
    border: 1px solid rgba(138, 180, 176, 0.3) !important;
    border-radius: 24px !important;
    box-shadow: 0 10px 30px rgba(44, 90, 87, 0.14) !important;
    padding: 5px 14px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #2c645c !important;
}

/* ============================================
   NIGHT MODE - ROUNDED CONTROLS
   ============================================ */

.night-mode .leaflet-control-zoom {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
}

.night-mode .leaflet-control-zoom a {
    background: rgba(51, 68, 79, 0.82) !important;
    color: #8ab4b0 !important;
}

.night-mode .leaflet-control-zoom a:hover {
    background: #3a6b62 !important;
    color: white !important;
}

.night-mode .leaflet-control-zoom-in {
    border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

.night-mode .leaflet-control-layers {
    background: rgba(51, 68, 79, 0.82) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
}

.night-mode .leaflet-control-layers-toggle {
    background-color: rgba(51, 68, 79, 0.65) !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%238ab4b0" width="20px" height="20px"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 3h18v2H3V3zm0 16h18v2H3v-2zm0-8h18v2H3v-2z"/></svg>') !important;
}

.night-mode .leaflet-control-layers-toggle:hover {
    background-color: #3a6b62 !important;
}

.night-mode .leaflet-control-layers-expanded {
    background: rgba(51, 68, 79, 0.92) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35) !important;
}

.night-mode .leaflet-control-layers-expanded label {
    color: #a8b8bf !important;
}

.night-mode .leaflet-control-layers-expanded label:hover {
    background: #3a6b62 !important;
    color: white !important;
}

.night-mode .leaflet-control-layers-separator {
    border-top-color: #3e525e !important;
}

.night-mode .leaflet-control-attribution {
    background: rgba(51, 68, 79, 0.72) !important;
    backdrop-filter: blur(8px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(8px) saturate(160%) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #a8b8bf !important;
}

.night-mode .leaflet-control-attribution a {
    color: #8ab4b0 !important;
}

.night-mode .leaflet-control-scale-line {
    background: rgba(51, 68, 79, 0.82) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
    color: #8ab4b0 !important;
}

/* ============================================
   ANIMATION
   ============================================ */

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.leaflet-control-zoom,
.leaflet-control-layers,
.leaflet-control-attribution,
.leaflet-control-scale-line {
    animation: floatIn 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1) forwards !important;
}

/* Bridge metadata styling */
.bridge-metadata {
    margin-bottom: 16px;
}

.bridge-metadata .bridge-subtitle {
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: #5f6b73;
}

.bridge-metadata .bridge-subtitle:last-child {
    margin-bottom: 0;
}












/* ============================================
   SS PREVIOUS INSPECTIONS MODAL
   All classes prefixed ss- to avoid conflicts
   ============================================ */

.ss-modal-overlay {
  position: fixed;
  inset: 0;
  /* Matches .modal's overlay (bridgeModal / Documents) exactly, so the
     backdrop dims and blurs the same amount no matter which modal opens. */
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
}

.ss-modal {
  background: rgba(244, 248, 247, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(138, 180, 176, 0.32);
  border-radius: 24px;
  width: 100%;
  max-width: 720px;
  /* Sized to fit exactly two inspection card rows (header + stats bar +
     filters + 2 cards + footer measured at ~481px) - min() so it still
     backs off gracefully on very short viewports instead of overflowing. */
  max-height: min(490px, 85vh);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(44,90,87,0.16), 0 8px 24px rgba(44,90,87,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
  overflow: hidden;
  animation: ssModalUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ssModalUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ss-modal-hdr {
  padding: 24px 28px 20px;
  background: rgba(248,250,252,0.8);
  border-bottom: 1px solid rgba(233, 237, 242, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.ss-hdr-main { display: flex; align-items: center; gap: 16px; }

.ss-avatar {
  width: 52px; height: 52px; border-radius: 16px;
  background: #8ab4b0;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(91, 140, 138, 0.3);
}

.ss-hdr-text { display: flex; flex-direction: column; gap: 4px; }

.ss-hdr-label {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.14em; color: #5f6b73;
}

.ss-hdr-title {
  font-size: 1.35rem; font-weight: 700; color: #1e2a33;
  letter-spacing: -0.02em; line-height: 1.2;
}

.ss-hdr-sub { font-size: 0.8rem; color: #5f6b73; font-weight: 500; }
.ss-hdr-sub span { color: #5b8c8a; font-weight: 600; }

.ss-close-btn {
  -webkit-appearance: none; appearance: none;
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: none; color: #5f6b73; font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s; flex-shrink: 0;
}
.ss-close-btn:hover { background: #fdf2f2; color: #c47070; }

/* Stats bar */
.ss-stats-bar {
  display: flex; gap: 12px; padding: 16px 28px;
  background: rgba(248, 250, 252, 0.5); border-bottom: 1px solid #f0f4f8; flex-wrap: wrap;
}

.ss-stat-pill {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: #f8fafc; border: 1px solid #e9edf2; border-radius: 14px;
  flex: 1; min-width: 130px; transition: all 0.2s;
}
.ss-stat-pill:hover {
  border-color: #c5dbd8; transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.ss-stat-icon {
  width: 36px; height: 36px; border-radius: 10px; background: white;
  border: 1px solid #e9edf2; display: flex; align-items: center;
  justify-content: center; color: #5b8c8a; font-size: 0.9rem; flex-shrink: 0;
}

.ss-stat-content { display: flex; flex-direction: column; gap: 2px; }

.ss-stat-lbl {
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: #5f6b73;
}
.ss-stat-lbl sub { text-transform: none; }

.ss-stat-val { font-size: 0.95rem; font-weight: 700; color: #1e2a33; }
.ss-stat-val .ss-trend { font-size: 0.7rem; font-weight: 600; margin-left: 4px; }
.ss-trend-up { color: #5b8c8a; }
.ss-trend-dn  { color: #c47070; }

/* Filters */
.ss-filters {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 28px; background: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid #f0f4f8; flex-wrap: wrap;
}

.ss-chip {
  padding: 6px 14px; border-radius: 20px; border: 1px solid #e9edf2;
  background: white; color: #4d5960; font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.ss-chip:hover { border-color: #c5dbd8; background: #f8fafc; }
.ss-chip.active {
  background: #5b8c8a;
  color: white; border-color: #5b8c8a;
  box-shadow: 0 2px 8px rgba(91, 140, 138, 0.25);
}
.ss-chip i { font-size: 0.7rem; }

.ss-filter-spacer { flex: 1; }

.ss-search-wrap { position: relative; }
.ss-search-wrap input {
  padding: 6px 12px 6px 32px; border-radius: 20px;
  border: 1px solid #e9edf2; background: #f8fafc;
  font-size: 0.8rem; font-family: inherit; color: #2c3e44;
  width: 180px; outline: none; transition: all 0.2s;
}
.ss-search-wrap input:focus {
  border-color: #8ab4b0; background: white;
  box-shadow: 0 0 0 3px rgba(138, 180, 176, 0.15);
}
.ss-search-wrap i {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); color: #5f6b73; font-size: 0.75rem;
}

/* Card list */
.ss-card-list {
  flex: 1; overflow-y: auto; padding: 6px 28px 14px;; background: rgba(255, 255, 255, 0.5);
}
.ss-card-list::-webkit-scrollbar { width: 5px; }
.ss-card-list::-webkit-scrollbar-track { background: transparent; }
.ss-card-list::-webkit-scrollbar-thumb { background: #d0d8e0; border-radius: 10px; }
.ss-card-list::-webkit-scrollbar-thumb:hover { background: #8ab4b0; }

/* Inspection card */
.ss-card {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  margin-bottom: 6px; background: #fafbfc; border: 1px solid #f0f4f8;
  border-radius: 14px; transition: all 0.2s; cursor: pointer;
}
.ss-card:hover {
  background: #f5f8fa; border-color: #c5dbd8;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.ss-card.ss-very-poor {
  background: #fdf8f5;
  border-color: #f0ddd0;
}
.ss-card.ss-very-poor:hover {
  border-color: #e8c4b0;
  background: #fdf5f0;
}

.ss-date-block {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; width: 52px; height: 52px;
  background: white; border: 1px solid #e9edf2; border-radius: 12px; flex-shrink: 0;
}
.ss-date-block .ss-year { font-size: 1.05rem; font-weight: 700; color: #1e2a33; line-height: 1; }
.ss-date-block .ss-mday {
  font-size: 0.6rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: #5f6b73;
}

.ss-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ss-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.ss-type-badge {
  padding: 3px 10px; border-radius: 20px; font-size: 0.65rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
}
.ss-badge-gi { background: #eef4f2; color: #5b8c8a; border: 1px solid #c5dbd8; }
.ss-badge-pi { background: #f0f4ff; color: #5b7c8a; border: 1px solid #c5d0db; }
.ss-badge-si { background: #fff8e6; color: #b8953a; border: 1px solid #e8d8a8; }

.ss-inspector { font-size: 0.78rem; font-weight: 500; color: #5f6b73; }

/* Score pills */
.ss-score-pills { display: flex; gap: 6px; flex-shrink: 0; }
.ss-score-pill {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 12px; background: white; border: 1px solid #e9edf2;
  border-radius: 10px; min-width: 56px;
}
.ss-score-lbl {
  font-size: 0.5rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: #5f6b73;
}
.ss-score-val { font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ss-sg { color: #5b8c8a; }
.ss-sw { color: #d4a373; }
.ss-sp { color: #c47070; }
.ss-sd { color: #c0392b; }

.ss-sbar { width: 36px; height: 3px; background: #e9edf2; border-radius: 2px; overflow: hidden; margin-top: 1px; }
.ss-sbar-fill { height: 100%; border-radius: 2px; }
.ss-fg { background: #8ab4b0; }
.ss-fw { background: #e8a87c; }
.ss-fp { background: #c47070; }
.ss-fd { background: #c0392b; }

/* Card action buttons */
.ss-card-acts { display: flex; gap: 4px; flex-shrink: 0; }
.ss-act-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid #e9edf2;
  background: white; color: #5f6b73; font-size: 0.8rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.ss-act-btn:hover {
  background: #f8fafc; border-color: #8ab4b0; color: #5b8c8a; transform: scale(1.05);
}
.ss-act-btn.ss-act-primary {
  background: #5b8c8a;
  color: white; border: none; box-shadow: 0 2px 8px rgba(91, 140, 138, 0.3);
}
.ss-act-btn.ss-act-primary:hover {
  transform: scale(1.05); box-shadow: 0 4px 14px rgba(91, 140, 138, 0.4);
}
.ss-act-btn.ss-act-danger:hover {
  background: #fdf2f2; border-color: #e0a0a0; color: #c0392b; transform: scale(1.05);
}
.night-mode .ss-act-btn.ss-act-danger:hover {
  background: #3a2323; border-color: #6b3a3a; color: #e57373;
}

/* Footer */
.ss-modal-ftr {
  padding: 14px 28px; background: rgba(248, 250, 252, 0.5); border-top: 1px solid #e9edf2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.ss-ftr-info { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: #5f6b73; }
.ss-ftr-info i { color: #8ab4b0; font-size: 0.85rem; }
.ss-ftr-acts { display: flex; gap: 8px; }

.ss-btn {
  padding: 8px 18px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s; font-family: inherit; border: none;
}
.ss-btn-sec { background: white; color: #4d5960; border: 1px solid #e9edf2; }
.ss-btn-sec:hover { background: #f8fafc; border-color: #8ab4b0; color: #5b8c8a; }
.ss-btn-pri {
  background: #5b8c8a;
  color: white; box-shadow: 0 2px 8px rgba(91, 140, 138, 0.25);
}
.ss-btn-pri:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(91, 140, 138, 0.35); }

.ss-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px 20px; color: #5f6b73; font-size: 0.9rem; gap: 8px;
}
.ss-empty i { font-size: 2rem; opacity: 0.4; }

/* Night mode - same glass treatment as #bridgeModal/.file-explorer-modal in dark mode */
.night-mode .ss-modal {
  background: rgba(51, 68, 79, 0.92);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.18);
}
.night-mode .ss-modal-hdr { background: rgba(30,42,47,0.8); border-bottom-color: rgba(47, 62, 69, 0.6); }
.night-mode .ss-close-btn { color: #9ab0b8; }
.night-mode .ss-close-btn:hover { background: rgba(196, 112, 112, 0.15); color: #e8a0a0; }
.night-mode .ss-hdr-label { color: #a8b8bf; }
.night-mode .ss-hdr-title { color: #d4dfe3; }
.night-mode .ss-hdr-sub { color: #a8b8bf; }
.night-mode .ss-hdr-sub span { color: #8ab4b0; }
.night-mode .ss-stats-bar { background: rgba(30, 42, 47, 0.6); border-bottom-color: #2f3e45; }
.night-mode .ss-stat-pill { background: #1e2a2f; border-color: #2f3e45; }
.night-mode .ss-stat-icon { background: #2f3e48; border-color: #3e525e; color: #8ab4b0; }
.night-mode .ss-stat-lbl { color: #a8b8bf; }
.night-mode .ss-stat-val { color: #d4dfe3; }
.night-mode .ss-filters { background: rgba(30, 42, 47, 0.6); border-bottom-color: #2f3e45; }
.night-mode .ss-chip { background: #1e2a2f; border-color: #2f3e45; color: #a8b8bf; }
.night-mode .ss-chip:hover { background: #2f3e48; border-color: #3e525e; }
.night-mode .ss-chip.active { background: #3a6b62; border-color: #3a6b62; }
.night-mode .ss-search-wrap input { background: #1e2a2f; border-color: #2f3e45; color: #d4dfe3; }
.night-mode .ss-search-wrap input:focus { border-color: #3a6b62; box-shadow: 0 0 0 3px rgba(58,107,98,0.2); }
.night-mode .ss-card-list { background: rgba(30, 42, 47, 0.5); }
.night-mode .ss-card { background: #1e2a2f; border-color: #2f3e45; }
.night-mode .ss-card:hover { background: #2a3a40; border-color: #3a5c5a; }
.night-mode .ss-card.ss-very-poor { background: #2f2a25; border-color: #4a3a30; }
.night-mode .ss-date-block { background: #2f3e48; border-color: #3e525e; }
.night-mode .ss-date-block .ss-year { color: #d4dfe3; }
.night-mode .ss-date-block .ss-mday { color: #a8b8bf; }
.night-mode .ss-inspector { color: #a8b8bf; }
.night-mode .ss-score-pill { background: #2f3e48; border-color: #3e525e; }
.night-mode .ss-score-lbl { color: #a8b8bf; }
.night-mode .ss-act-btn { background: #2f3e48; border-color: #3e525e; color: #a8b8bf; }
.night-mode .ss-act-btn:hover { background: #3a4b53; border-color: #4a6070; color: #c5d3d9; }
.night-mode .ss-modal-ftr { background: rgba(30, 42, 47, 0.6); border-top-color: #2f3e45; }
.night-mode .ss-ftr-info { color: #a8b8bf; }
.night-mode .ss-btn-sec { background: #2f3e48; border-color: #3e525e; color: #a8b8bf; }
.night-mode .ss-badge-gi { background: #2f4a48; color: #8ab4b0; border-color: #3a6b62; }
.night-mode .ss-badge-pi { background: #2a3a4a; color: #7aa0b0; border-color: #3a5a6a; }
.night-mode .ss-badge-si { background: #2f2a1a; color: #c8a84a; border-color: #4a3a20; }

/* Responsive */
@media (max-width: 640px) {
  .ss-modal { max-height: 95vh; border-radius: 20px; }
  .ss-modal-hdr, .ss-stats-bar, .ss-filters, .ss-card-list, .ss-modal-ftr { padding-left: 16px; padding-right: 16px; }
  .ss-hdr-title { font-size: 1.1rem; }
  .ss-card { flex-wrap: wrap; padding: 12px 14px; }
  .ss-score-pills { width: 100%; justify-content: flex-start; margin-top: 6px; }
  .ss-card-acts { width: 100%; justify-content: flex-end; margin-top: 6px; }
}

/* ============================================
   MAP LEGEND - Bottom-left, type only
   ============================================ */

.map-legend {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid rgba(138, 180, 176, 0.3);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(44, 90, 87, 0.14);
    padding: 10px 20px;
    z-index: 998;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    pointer-events: none;
    white-space: nowrap;
}

.leg-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.leg-pip {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.leg-label {
    font-size: 11.5px;
    font-weight: 500;
    color: #4a5b6e;
    white-space: nowrap;
}

.night-mode .map-legend {
    background: rgba(51, 68, 79, 0.82);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

.night-mode .leg-label {
    color: #a8b8bf;
}

/* ============================================
   CONFIRM MODAL (styled stand-in for confirm())
   Same look/API as inspection.html's #confirmModalOverlay - ported here
   for the Previous Inspections modal's delete action.
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 46, 52, 0.25);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Below .navbar's z-index (1200) so the confirm dialog's backdrop
       doesn't dim/cover the floating navbar - see a189649. */
    z-index: 1190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-card {
    background: rgba(244, 248, 247, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 32px;
    padding: 44px 40px 36px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    border: 1px solid rgba(138, 180, 176, 0.32);
    box-shadow:
        0 8px 24px rgba(44, 90, 87, 0.08),
        0 24px 48px rgba(44, 90, 87, 0.12);
    transform: scale(0.96) translateY(16px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}
.modal-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 1.6rem;
    background: #e8f5f2;
    color: #5b8c8a;
    box-shadow: 0 4px 16px rgba(91, 140, 138, 0.12);
}
.modal-icon.warning {
    background: #fef9e8;
    color: #c9a227;
    box-shadow: 0 4px 16px rgba(201, 162, 39, 0.12);
}
.modal-icon.success {
    background: #d4ede8;
    color: #3a6b62;
    box-shadow: 0 4px 16px rgba(91, 140, 138, 0.15);
}
.modal-icon.error {
    background: #fdf2f2;
    color: #c07070;
    box-shadow: 0 4px 16px rgba(192, 112, 112, 0.1);
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c4a48;
    margin-bottom: 14px;
    letter-spacing: -0.3px;
}
.modal-message {
    font-size: 0.9rem;
    color: #5f6b73;
    line-height: 1.7;
    margin-bottom: 32px;
    white-space: pre-line;
}
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.modal-btn {
    padding: 13px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.2px;
    min-width: 120px;
    border: none;
}
.modal-btn.primary {
    background: #5b8c8a;
    color: white;
    box-shadow: 0 4px 16px rgba(91, 140, 138, 0.25);
}
.modal-btn.primary:hover {
    background: #4a7876;
    box-shadow: 0 6px 20px rgba(91, 140, 138, 0.35);
    transform: translateY(-2px);
}
.modal-btn.secondary {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #4d5960;
}
.modal-btn.secondary:hover {
    background: #f1f5f4;
    border-color: #c5dbd8;
    color: #5b8c8a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(91, 140, 138, 0.08);
}
.modal-btn.danger {
    background: #c07070;
    color: white;
    box-shadow: 0 4px 16px rgba(192, 112, 112, 0.2);
}
.modal-btn.danger:hover {
    background: #a85a5a;
    box-shadow: 0 6px 20px rgba(192, 112, 112, 0.3);
    transform: translateY(-2px);
}
.night-mode .modal-overlay { background: rgba(15, 24, 28, 0.5); }
.night-mode .modal-card {
    background: rgba(51, 68, 79, 0.92);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 24px 48px rgba(0, 0, 0, 0.3);
}
.night-mode .modal-title { color: #d4dfe3; }
.night-mode .modal-message { color: #a8b8bf; }
.night-mode .modal-btn.secondary { color: #a8b8bf; }

/* Muted-text selectors that had no night-mode value at all (so they
   inherited the light-mode grey unchanged, illegible on a dark card). */
.night-mode #bridgeModal .header-text h2,
.night-mode #bridgeModal .stat-label,
.night-mode .bridge-modal .documents-modal-header .close,
.night-mode .stat-label,
.night-mode .photo-caption,
.night-mode .photo-meta,
.night-mode .bridge-metadata .bridge-subtitle,
.night-mode .ss-search-wrap i,
.night-mode .ss-empty {
    color: #a8b8bf;
}

.night-mode .modal-icon {
    background: #1e3a36;
    color: #8ab4b0;
    box-shadow: 0 4px 16px rgba(138, 180, 176, 0.1);
}
.night-mode .modal-icon.warning {
    background: #3a2f1a;
    color: #d4b86a;
}
.night-mode .modal-icon.success {
    background: #1e3a36;
    color: #8ab4b0;
}
.night-mode .modal-icon.error {
    background: #3a2020;
    color: #c07070;
}

/* ============================================
   "MORE ACTIONS" OVERFLOW (holds the Share entry
   point) - sits in #bridgeModal's secondary button
   row, deliberately a fixed width rather than flex:1
   like its siblings, so it doesn't take space away
   from the Previous Inspections/Documents labels.
   ============================================ */
#bridgeModal .btn-secondary.btn-overflow {
    flex: 0 0 44px;
    padding: 10px 0;
}
#bridgeModal .actions-section { position: relative; }
.more-actions-menu {
    position: absolute;
    right: 28px;
    bottom: 62px;
    background: white;
    border: 1px solid #e9edf2;
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(30,42,51,0.18);
    padding: 6px;
    width: 180px;
    z-index: 5;
}
.more-actions-item {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    background: none;
    color: #33444f;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 9px;
    text-align: left;
}
.more-actions-item:hover { background: #eef4f2; color: #3c6a68; }
.more-actions-item i { color: #5b8c8a; width: 14px; text-align: center; }

.night-mode .more-actions-menu {
    background: #33444f;
    border-color: rgba(255,255,255,0.1);
}
.night-mode .more-actions-item { color: #d4dfe3; }
.night-mode .more-actions-item:hover { background: #2f4a48; color: #8ab4b0; }
.night-mode .more-actions-item i { color: #8ab4b0; }
