/* geoDashboard-v6 Custom Styles */

/* Prevent horizontal overflow */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Sidebar */
.sidebar {
    transition: width 0.3s ease;
}

.sidebar .nav-link {
    color: var(--bs-body-color);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 2px;
    font-size: 0.9rem;
}

.sidebar .nav-link:hover {
    background-color: var(--bs-primary-bg-subtle);
}

.sidebar .nav-link.active {
    background-color: var(--bs-primary);
    color: white;
}

.sidebar .nav-link i {
    width: 1.25rem;
    text-align: center;
}

/* Breadcrumbs in navbar */
.navbar .breadcrumb-item a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
}

.navbar .breadcrumb-item a:hover {
    color: white;
}

.navbar .breadcrumb-item.active {
    color: rgba(255, 255, 255, 0.9);
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Score badges */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1rem;
    color: white;
}

.score-good { background-color: #1a9641; }
.score-satisfactory { background-color: #66bd63; }
.score-fair { background-color: #fee08b; color: #333; }
.score-poor { background-color: #fdae61; }
.score-very-poor { background-color: #f46d43; }
.score-serious { background-color: #d73027; }
.score-failed { background-color: #a50026; }

/* Map container */
.map-container {
    height: calc(100vh - 56px);
    width: 100%;
}

.map-fullscreen {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 500;
}

/* Layer panel */
.layer-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    width: 280px;
}

/* GIS toolbar */
.gis-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gis-toolbar .btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Kanban board */
.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
}

.kanban-column {
    min-width: 280px;
    max-width: 320px;
    flex-shrink: 0;
    background: var(--bs-body-tertiary-bg, #f8f9fa);
    border-radius: 8px;
    padding: 12px;
}

.kanban-card {
    background: white;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: grab;
}

.kanban-card:active {
    cursor: grabbing;
}

/* Dashboard widgets */
.dashboard-widget {
    cursor: move;
    transition: transform 0.2s;
}

.dashboard-widget:hover {
    transform: translateY(-2px);
}

/* Section dashboard quick-link cards */
.hover-shadow { transition: box-shadow 0.2s, transform 0.2s; }
.hover-shadow:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-2px); }
.cursor-pointer { cursor: pointer; }

/* Export builder */
.field-list {
    min-height: 200px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 12px;
}

.field-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 4px;
    cursor: grab;
}

.field-item:active {
    cursor: grabbing;
}

/* Help panel field tooltips */
.field-help-icon {
    cursor: pointer;
    color: var(--bs-info);
    font-size: 0.85rem;
}

.field-help-icon:hover {
    color: var(--bs-primary);
}

/* Radar chart container */
.radar-chart-container {
    width: 300px;
    height: 300px;
    margin: 0 auto;
}

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

/* Segment detail panel (map popup) */
.segment-detail-panel {
    position: absolute;
    z-index: 1100;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    min-width: 340px;
    min-height: 200px;
    overflow: hidden;
    resize: both;
    display: flex;
    flex-direction: column;
}

.segment-detail-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bs-primary);
    color: white;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.segment-detail-panel .panel-header:active {
    cursor: grabbing;
}

.segment-detail-panel .panel-header h6 {
    margin: 0;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 60px);
}

.segment-detail-panel .panel-header .btn-close-panel {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    line-height: 1;
}

.segment-detail-panel .panel-header .btn-close-panel:hover {
    opacity: 1;
}

.segment-detail-panel .panel-body {
    padding: 14px 16px;
    overflow-y: auto;
    flex: 1;
    font-size: 1.02rem;        /* +20% per Action Items */
    line-height: 1.55;
}

.segment-detail-panel .panel-body .score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 1rem;
}

.segment-detail-panel .panel-body .score-row:last-child {
    border-bottom: none;
}

.segment-detail-panel .panel-body .score-value {
    font-weight: 700;
    font-size: 1.14rem;        /* +20% */
}

.segment-detail-panel .panel-body .score-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.segment-detail-panel .panel-footer {
    padding: 8px 14px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Dark mode support */
[data-bs-theme="dark"] .segment-detail-panel {
    background: var(--bs-body-bg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .segment-detail-panel .panel-body .score-row {
    border-bottom-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .segment-detail-panel .panel-footer {
    border-top-color: var(--bs-border-color);
}

/* Project flag markers on dashboard map */
.project-flag-marker {
    background: transparent;
    border: none;
}

.project-flag-marker div:hover {
    background: #0b5ed7 !important;
    transform: scale(1.05);
    transition: all 0.15s;
}

/* Segment detail panel tab styling — pill design */
.segment-detail-panel .nav-tabs {
    font-size: 0.78rem;
    border-bottom: none;
    flex-shrink: 0;
    gap: 4px;
    padding: 4px 0;
}

.segment-detail-panel .nav-tabs .nav-link {
    padding: 5px 10px;
    color: #555;
    background: #f0f2f5;
    border: none;
    border-radius: 20px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.segment-detail-panel .nav-tabs .nav-link:hover:not(.active):not(.disabled) {
    background: #e2e5e9;
    color: #333;
}

.segment-detail-panel .nav-tabs .nav-link.active {
    font-weight: 600;
    background: linear-gradient(135deg, #00bcd4, #0097a7);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,188,212,0.3);
    border: none;
}

.segment-detail-panel .nav-tabs .nav-link.active .badge {
    background: rgba(255,255,255,0.92) !important;
    color: #0097a7;
}

.segment-detail-panel .tab-content {
    flex: 1;
    overflow-y: auto;
    padding-top: 8px;
}

/* Sticky tabs — stay visible while scrolling panel content */
.segment-panel-body {
    position: relative;
}
.segment-panel-body > .nav-tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    margin-left: -16px;
    margin-right: -16px;
    padding: 0 16px;
}
[data-bs-theme="dark"] .segment-panel-body > .nav-tabs {
    background: var(--bs-body-bg);
}

/* Severity bar (inline stacked bar for distress table) */
.severity-bar {
    display: flex;
    height: 14px;
    border-radius: 3px;
    overflow: hidden;
    min-width: 60px;
    background: #f0f0f0;
}
.severity-bar > span {
    display: block;
    height: 100%;
    transition: width 0.3s;
}

/* Distress stacked bar chart container */
.distress-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}
.distress-bar-row:last-child { border-bottom: none; }
.distress-bar-label {
    width: 130px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}
.distress-bar-track {
    flex: 1;
    display: flex;
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    background: #f0f0f0;
    position: relative;
}
.distress-bar-track > div {
    height: 100%;
    transition: width 0.4s ease;
}
.distress-bar-count {
    width: 28px;
    text-align: right;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}
.distress-bar-area {
    width: 55px;
    text-align: right;
    font-size: 0.65rem;
    color: #6c757d;
    flex-shrink: 0;
}
[data-bs-theme="dark"] .distress-bar-row { border-bottom-color: var(--bs-border-color); }
[data-bs-theme="dark"] .distress-bar-track, [data-bs-theme="dark"] .severity-bar { background: #2b3035; }

/* ── ObjectClassCard module (.occ-*) — v4 redesign ─────────── */
.occ-card {
    border: 1px dashed rgba(0,0,0,0.15);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.occ-card:hover {
    box-shadow: 0 4px 18px rgba(0,0,0,0.10);
}
.occ-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 8px;
}
.occ-dot {
    width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.occ-card-title {
    font-weight: 700; font-size: 0.9rem; color: #1565c0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.occ-chart-box {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    background: #fafbfc;
    margin: 0 14px;
    padding: 14px 10px 10px;
    text-align: center;
}
.occ-chart-box canvas {
    display: block;
    margin: 0 auto 10px;
}
.occ-css-doughnut {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    margin: 0 auto 10px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.occ-css-doughnut-center {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #fafbfc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #333;
    position: relative;
    z-index: 1;
}
.occ-legend {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.65rem;
    color: #555;
}
.occ-legend-item {
    display: flex; align-items: center; gap: 4px;
}
.occ-legend-swatch {
    width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
}
.occ-sev-badges {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    padding: 10px 14px 6px;
}
.occ-sev-badge {
    display: block;
    text-align: center;
    padding: 5px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.occ-note {
    background: #fffbea;
    border-top: 1px solid #f5e6b8;
    text-align: center;
    padding: 6px 14px;
    font-size: 0.68rem;
    color: #7a6c2a;
    margin: 6px 14px 0;
    border-radius: 6px;
}
/* Confidence badge */
.seg-conf-badge {
    font-size: 0.65rem; font-weight: 600; padding: 2px 8px;
    border-radius: 10px; background: #198754; color: #fff;
    white-space: nowrap;
}
/* Image carousel (kept from v3) */
.occ-carousel { border-top: 1px solid #e9ecef; margin-top: 10px; }
.occ-viewport { background: #1a1a2e; text-align: center; min-height: 60px; }
.occ-canvas { max-width: 100%; display: block; margin: 0 auto; }
.occ-nav {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; background: #f8fafb; border-top: 1px solid #e9ecef;
}
.occ-img-loading { padding: 10px; display: flex; align-items: center; }
.occ-img-error { padding: 6px 10px; }

/* Section wrapper for each object tab */
.occ-section-wrapper {
    border: 1px dashed rgba(0,0,0,0.12);
    border-radius: 14px;
    background: #f8fafc;
    padding: 16px;
}
.occ-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--bs-body-color);
}

/* Responsive grid for object class cards */
.occ-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.segment-detail-panel.fullpage .occ-grid {
    grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 600px) {
    .occ-grid { grid-template-columns: 1fr; }
}

/* Distress summary table */
.occ-summary-header {
    display: grid;
    grid-template-columns: 14px 1fr 70px 70px 60px;
    gap: 8px;
    padding: 0 8px 8px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6c757d;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 6px;
}
.occ-summary-table-grid {
    display: flex;
    flex-wrap: wrap;
}
.occ-summary-row {
    display: grid;
    grid-template-columns: 14px 1fr 70px 70px 60px;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    font-size: 0.78rem;
    width: 50%;
    border-bottom: 1px solid #f0f0f0;
}
.occ-summary-row:hover { background: rgba(0,0,0,0.02); }
.occ-summary-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.occ-summary-name {
    font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.occ-summary-val {
    text-align: center;
    font-weight: 500;
    color: #495057;
}
/* When < 700px, summary rows go full width */
@media (max-width: 700px) {
    .occ-summary-row { width: 100%; }
}

/* Tab summary stat bar */
.occ-tab-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 12px;
    background: #f0f4f8;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.78rem;
}
.occ-tab-stat-val {
    font-weight: 700;
    font-size: 1rem;
    color: #0d6efd;
}

/* Dark mode */
[data-bs-theme="dark"] .occ-card { background: rgba(33,37,41,0.95); border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .occ-card-title { color: #64b5f6; }
[data-bs-theme="dark"] .occ-chart-box { background: rgba(255,255,255,0.04); border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .occ-css-doughnut-center { background: #1e1e1e; color: #ccc; }
[data-bs-theme="dark"] .occ-note { background: rgba(255,251,234,0.08); border-color: var(--bs-border-color); color: #d4c87a; }
[data-bs-theme="dark"] .occ-section-wrapper { background: rgba(255,255,255,0.03); border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .occ-nav { background: rgba(255,255,255,0.04); border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .occ-carousel { border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .occ-summary-row { border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .occ-summary-header { border-color: var(--bs-border-color); color: #adb5bd; }
[data-bs-theme="dark"] .occ-tab-stats { background: rgba(255,255,255,0.05); }

/* Segment panel resize handle */
.segment-detail-panel::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--bs-border-color) 50%);
    border-radius: 0 0 8px 0;
    z-index: 2;
}

/* Full-page mode for segment detail panel */
.segment-detail-panel.fullpage {
    width: 100vw !important; height: 100vh !important;
    left: 0 !important; top: 0 !important;
    transform: none !important; border-radius: 0 !important;
    min-width: unset !important;
}
.segment-detail-panel.fullpage.open {
    transform: none !important;
}
.segment-detail-panel.fullpage .segment-panel-header { border-radius: 0; cursor: default; }
.segment-detail-panel.fullpage .drag-handle { display: none; }
.segment-detail-panel.fullpage::after { display: none; }

/* Dark mode support for tabs */
[data-bs-theme="dark"] .segment-detail-panel .nav-tabs {
    border-bottom: none;
}

[data-bs-theme="dark"] .segment-detail-panel .nav-tabs .nav-link {
    background: rgba(255,255,255,0.08);
    color: #adb5bd;
}

[data-bs-theme="dark"] .segment-detail-panel .nav-tabs .nav-link:hover:not(.active):not(.disabled) {
    background: rgba(255,255,255,0.14);
    color: #e9ecef;
}

[data-bs-theme="dark"] .segment-detail-panel .nav-tabs .nav-link.active {
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
    color: #fff;
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .layer-panel {
    background: var(--bs-body-bg);
}

/* Skip link for accessibility */
.skip-link:focus {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 9999;
    background: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Focus indicator for accessibility */
:focus-visible {
    outline: 3px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Mobile responsive */
@media (max-width: 991.98px) {
    .sidebar {
        display: none !important;
    }
    main {
        margin-left: 0 !important;
        max-width: 100vw !important;
    }
}

@media (max-width: 767.98px) {
    .map-container {
        height: calc(100vh - 56px);
    }
    .gis-toolbar {
        top: auto;
        bottom: 60px;
        right: 8px;
    }
    .layer-panel {
        width: calc(100vw - 16px);
        max-height: 50vh;
        bottom: 0;
        top: auto;
        left: 8px;
        border-radius: 8px 8px 0 0;
    }
    .segment-detail-panel {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        min-width: 100% !important;
        max-height: 60vh;
        border-radius: 12px 12px 0 0;
    }
}

/* Date selector bar (Phase 5) */
.date-selector-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .date-selector-bar {
    background: rgba(33, 37, 41, 0.92);
}

/* Compact layers panel (projects redesign) */
.layer-panel-trigger {
    position: absolute;
    bottom: 80px;
    right: 10px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.layer-panel-compact {
    position: absolute;
    top: 46px;
    left: 10px;
    z-index: 1010;
    width: 260px;
    min-width: 220px;
    max-height: 70vh;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Drag header */
.lp-header {
    padding: 6px 12px 4px;
    cursor: move;
    user-select: none;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}
.lp-drag-indicator {
    width: 32px; height: 3px;
    background: #ccc; border-radius: 2px;
    margin: 0 auto 4px;
}
.lp-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

/* Section headers */
.lp-section { border-bottom: 1px solid #f0f0f0; }
.lp-section:last-of-type { border-bottom: none; }
.lp-section-header {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 12px; cursor: pointer;
    font-size: 0.72rem; font-weight: 700;
    color: #333; text-transform: uppercase; letter-spacing: 0.3px;
    transition: background 0.12s;
}
.lp-section-header:hover { background: #f0f4f8; }

/* Layer rows */
.lp-layer-row {
    padding: 2px 12px 2px 20px;
}
.lp-layer-label {
    font-size: 0.72rem !important;
    display: inline-flex; align-items: center; gap: 4px;
    cursor: pointer;
}
.lp-layer-label i { font-size: 0.75rem; width: 16px; text-align: center; flex-shrink: 0; }

/* Disabled / unavailable layers */
.lp-layer-disabled {
    opacity: 0.65;
    cursor: not-allowed;
}
.lp-layer-disabled .form-check-input { cursor: not-allowed; }
.lp-layer-disabled .lp-layer-label { cursor: not-allowed; color: #6c757d !important; }
.lp-lock-icon { font-size: 0.55rem; color: #868e96; margin-left: 2px; }

/* Road category count badge */
.lp-cat-count {
    font-size: 0.55rem; font-weight: 600;
    background: #e9ecef; color: #495057;
    padding: 0 5px; border-radius: 8px;
    margin-left: auto;
}

/* Layer color swatches */
.lp-swatch {
    display: inline-block; width: 14px; height: 8px; border-radius: 2px;
    flex-shrink: 0; vertical-align: middle;
}
.lp-swatch-circle {
    width: 10px; height: 10px; border-radius: 50%;
    border: 1.5px solid #fff; box-shadow: 0 0 0 0.5px rgba(0,0,0,0.2);
}
.lp-swatch-diamond {
    width: 10px; height: 10px; border-radius: 2px;
    transform: rotate(45deg); border: 1.5px solid #fff;
    box-shadow: 0 0 0 0.5px rgba(0,0,0,0.2);
}

/* Zoom-level hint badge */
.lp-zoom-hint {
    font-size: 0.5rem; font-weight: 600;
    color: #fd7e14; background: #fff3e0;
    padding: 0 4px; border-radius: 6px;
    margin-left: auto; white-space: nowrap;
    animation: lp-pulse 2s ease-in-out infinite;
}
@keyframes lp-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Section count badge */
.lp-section-badge {
    font-size: 0.5rem; font-weight: 700;
    background: #0d6efd; color: #fff;
    padding: 0 5px; border-radius: 8px;
    margin-left: auto;
}

/* Resize handle */
.lp-resize-handle {
    position: absolute; bottom: 0; right: 0;
    width: 14px; height: 14px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.15) 50%);
    border-radius: 0 0 10px 0;
}

[data-bs-theme="dark"] .layer-panel-compact {
    background: rgba(33,37,41,0.96);
    border-color: var(--bs-border-color);
}
[data-bs-theme="dark"] .lp-header { border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .lp-section { border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .lp-section-header { color: #ccc; }
[data-bs-theme="dark"] .lp-section-header:hover { background: rgba(255,255,255,0.05); }

/* Annotation layer inline filters */
.lp-layer-filter { padding: 0 12px 4px 20px; }
.lp-layer-filter .input-group { max-width: 200px; }
.lp-filter-count { display: block; font-size: 0.55rem; color: #6c757d; margin-top: 2px; padding-left: 2px; }
[data-bs-theme="dark"] .lp-layer-filter .form-control,
[data-bs-theme="dark"] .lp-layer-filter .form-select { background: rgba(255,255,255,0.05); border-color: var(--bs-border-color); color: #ccc; }
[data-bs-theme="dark"] .lp-filter-count { color: #999; }

/* Compare bar (projects redesign) */
.compare-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .compare-bar {
    background: rgba(33, 37, 41, 0.92);
}

/* Project map layouts */
.project-map-container {
    position: relative;
    height: calc(100vh - 56px);
    display: flex;
}

.project-sidebar {
    width: 340px;
    min-width: 340px;
    height: 100%;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border-right: 1px solid var(--bs-border-color);
    transition: margin-left 0.3s ease;
    z-index: 500;
}

.project-sidebar.collapsed {
    margin-left: -340px;
}

.project-sidebar-toggle {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 501;
    width: 24px;
    height: 48px;
    border: 1px solid var(--bs-border-color);
    border-left: none;
    border-radius: 0 6px 6px 0;
    background: var(--bs-body-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: left 0.3s ease;
}

.project-sidebar.collapsed + .project-map-area .project-sidebar-toggle {
    left: 0;
}

.project-map-area {
    flex: 1;
    position: relative;
    min-width: 0;
}

.project-map-area #project-map {
    width: 100%;
    height: 100%;
}

/* Comparison slider (before/after) */
.comparison-slider-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 800;
    pointer-events: none;
}

.comparison-slider-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #fff;
    box-shadow: 0 0 8px rgba(0,0,0,0.4);
    cursor: ew-resize;
    z-index: 801;
    pointer-events: all;
}

.comparison-slider-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -12px;
    width: 28px;
    height: 28px;
    background: #fff;
    border: 2px solid #3388ff;
    border-radius: 50%;
    transform: translateY(-50%);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.comparison-slider-label {
    position: absolute;
    top: 60px;
    padding: 4px 12px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    z-index: 802;
    pointer-events: none;
}

.comparison-slider-label.left { left: 10px; }
.comparison-slider-label.right { right: 10px; }

/* Segment highlight animation */
@keyframes segmentPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.segment-highlight {
    animation: segmentPulse 0.6s ease-in-out 3;
}

/* Study area / discussion create modals within project sidebar */
.project-sidebar .modal-body .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

/* Statistics hub (Phase 6) */
.stats-card { break-inside: avoid; }
.chart-container { break-inside: avoid; max-height: 400px; }
.stats-table { font-size: 10pt; }
.stats-table th { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; }

/* Touch targets — WCAG 2.5.5 minimum 44x44px */
@media (max-width: 767.98px) {
    .btn-sm, .btn-group-sm > .btn {
        min-width: 44px;
        min-height: 44px;
    }
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    /* Tables become cards on mobile */
    .table-responsive-cards thead { display: none; }
    .table-responsive-cards tbody tr {
        display: block;
        border: 1px solid var(--bs-border-color);
        border-radius: 8px;
        margin-bottom: 8px;
        padding: 12px;
    }
    .table-responsive-cards tbody td {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        border: none;
    }
    .table-responsive-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 8px;
    }
}

/* Study area indicator in navbar */
.study-area-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    background: rgba(25, 135, 84, 0.15);
    color: #198754;
    border: 1px solid rgba(25, 135, 84, 0.3);
}

[data-bs-theme="dark"] .study-area-indicator {
    background: rgba(25, 135, 84, 0.25);
    color: #75b798;
}

/* HTMX loading regions */
[aria-live] .htmx-indicator {
    display: none;
}
[aria-live] .htmx-request .htmx-indicator {
    display: inline-block;
}

/* Intelligence report compact spacing */
.intelligence-report > div { margin-top: 0.5rem !important; }
.intelligence-report > div:first-child { margin-top: 0 !important; }

/* Print styles */
/* Tooltips for tracking map markers */
.seg-map-tooltip { font-size: 0.82rem; padding: 3px 6px; }
.seg-map-tooltip strong { font-weight: 600; }

/* Rich notes toolbar */
.seg-notes-toolbar .btn { padding: 2px 5px; font-size: 0.72rem; }

/* ── Virtual Drive Viewer ── */
.seg-drive-container {
    border-radius: 10px; overflow: hidden;
    border: 1px solid rgba(0, 188, 212, 0.18);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    background: #0c0c18; position: relative;
    display: flex; flex-direction: column;
    /* Set explicit height so flex children fill the space */
    height: clamp(360px, 55vh, 560px);
}
.segment-detail-panel.fullpage .seg-drive-container {
    height: clamp(460px, calc(100vh - 300px), 680px);
}

/* Main area — 40% map left, 60% image right */
.seg-drive-main {
    display: flex; flex-direction: row;
    flex: 1 1 auto; min-height: 0; outline: none;
}

/* Left panel — tracking map (40%) */
.seg-drive-sidebar {
    width: 40%; flex: 0 0 40%; background: #0a0a14;
    display: flex; flex-direction: column; position: relative;
    padding: 8px; padding-right: 4px; overflow: hidden;
    min-height: 0;
}
.seg-drive-sidebar-map {
    flex: 1; position: relative; min-height: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.seg-drive-sidebar-map .seg-drive-trackmap {
    width: 100%; height: 100%;
}
.seg-drive-sidebar-map .seg-drive-trackmap .leaflet-control-container { display: none; }
.seg-drive-sidebar-info {
    margin-top: 6px; padding: 8px 12px;
    font-size: 0.88rem; color: #ddd;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    display: flex; flex-direction: column; gap: 4px; flex-shrink: 0;
}
.seg-drive-sidebar-info-row {
    display: flex; justify-content: space-between; align-items: center;
}
.seg-drive-sidebar-info-label { color: #d0d0d8; text-transform: uppercase; letter-spacing: 0.4px; font-size: 0.85rem; font-weight: 600; }
.seg-drive-sidebar-info-value { color: #fff; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.95rem; font-weight: 600; }

/* Right panel — image viewport (60%) */
.seg-drive-viewport {
    flex: 1 1 0%; position: relative; background: #080810;
    cursor: default; outline: none; overflow: hidden;
    padding: 8px; padding-left: 4px;
    min-height: 0;
}

/* Framed image area */
.seg-drive-image-wrap {
    position: absolute; top: 8px; right: 8px; bottom: 8px; left: 4px;
    overflow: hidden; background: #000;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    display: flex; align-items: center; justify-content: center;
}
.seg-drive-image {
    width: 100%; height: 100%; object-fit: contain; display: block;
    transition: opacity 0.15s ease;
}

/* Bbox canvas overlay (inside image wrap) */
.seg-drive-bbox-canvas {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 3;
}

/* Click zones (prev/next) */
.seg-drive-click-zone {
    position: absolute; top: 0; width: 18%; height: 100%; z-index: 10;
    display: flex; align-items: center; cursor: pointer;
    opacity: 0; transition: opacity 0.2s;
}
.seg-drive-click-zone:hover { opacity: 1; }
.seg-drive-click-prev { left: 0; justify-content: flex-start; padding-left: 10px;
    background: linear-gradient(90deg, rgba(0,0,0,0.4), transparent); }
.seg-drive-click-next { right: 0; justify-content: flex-end; padding-right: 10px;
    background: linear-gradient(-90deg, rgba(0,0,0,0.4), transparent); }
.seg-drive-click-zone i { font-size: 2.2rem; color: #fff; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5)); }

/* HUD overlay */
.seg-drive-hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; padding: 6px 8px; }
.seg-drive-hud-tr { position: absolute; top: 6px; right: 8px; }
.seg-drive-hud-br { position: absolute; bottom: 6px; right: 8px; display: flex; gap: 4px; }
.seg-drive-hud-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(0,0,0,0.78); backdrop-filter: blur(4px);
    color: #fff; font-size: 1.15rem; font-weight: 700;
    padding: 6px 14px; border-radius: 6px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.seg-drive-hud-speed { color: #00e676; font-weight: 800; }

/* Recording indicator */
.seg-drive-rec { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 6; }
.seg-drive-rec-dot {
    display: inline-block; width: 12px; height: 12px; border-radius: 50%;
    background: #ff1744; box-shadow: 0 0 8px #ff1744;
    animation: segDriveRecPulse 1s ease-in-out infinite;
}
@keyframes segDriveRecPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Progress bar */
.seg-drive-progress {
    position: relative; height: 5px; background: #1a1a2e; cursor: pointer; flex-shrink: 0;
}
.seg-drive-progress-fill {
    height: 100%; background: linear-gradient(90deg, #00bcd4, #00e5ff);
    transition: width 0.1s linear; border-radius: 0 2px 2px 0;
}
.seg-drive-scrubber {
    position: absolute; inset: -8px 0; width: 100%; height: 20px;
    opacity: 0; cursor: pointer; z-index: 2; margin: 0;
    -webkit-appearance: none; appearance: none; background: transparent;
}
.seg-drive-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px;
    border-radius: 50%; background: #00e5ff; cursor: grab;
    box-shadow: 0 0 6px rgba(0,229,255,0.5);
}
.seg-drive-progress:hover .seg-drive-scrubber { opacity: 1; }
.seg-drive-progress:hover { height: 7px; }

/* Map marker (shared) */
.seg-drive-map-marker { background: none !important; border: none !important; }

/* Control bar — sized ~75% larger per Action Items.md */
.seg-drive-controls {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px; background: #0d0d1a; flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    gap: 10px;
}
.seg-drive-btn {
    background: none; border: none; color: #e8e8ec; padding: 9px 16px;
    font-size: 1.7rem; cursor: pointer; border-radius: 7px;
    transition: color 0.15s, background 0.15s;
}
.seg-drive-btn:hover:not(:disabled) { color: #fff; background: rgba(255,255,255,0.12); }
.seg-drive-btn:disabled { opacity: 0.45; cursor: default; }
.seg-drive-btn-play {
    width: 64px; height: 64px; font-size: 2rem;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: rgba(0,188,212,0.18); color: #00e5ff;
}
.seg-drive-btn-play:hover { background: rgba(0,188,212,0.32); }
.seg-drive-btn-active { color: #00e5ff !important; background: rgba(0,188,212,0.2) !important; }

/* Speed selector */
.seg-drive-speed-group {
    display: flex; border-radius: 6px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.18);
}
.seg-drive-speed-btn {
    background: none; border: none; color: #d8d8dc; padding: 9px 18px;
    font-size: 1.4rem; font-weight: 700; cursor: pointer;
    transition: all 0.15s;
}
.seg-drive-speed-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.seg-drive-speed-btn.active { color: #00e5ff; background: rgba(0,188,212,0.2); }

/* Direction toggle */
.seg-drive-dir-toggle {
    display: flex; border-radius: 4px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
}
.seg-drive-dir-btn {
    background: none; border: none; color: #ccc; padding: 5px 12px;
    font-size: 1.2rem; cursor: pointer; transition: all 0.15s;
}
.seg-drive-dir-btn:hover { color: #fff; }
.seg-drive-dir-btn.active { color: #00e5ff; background: rgba(0,188,212,0.15); }

/* Drive selector */
.seg-drive-select {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15);
    color: #fff; font-size: 0.95rem; padding: 4px 8px; border-radius: 4px;
    max-width: 240px;
}
.seg-drive-select:focus { border-color: #00bcd4; outline: none; }
.seg-drive-select option { background: #1a1a2e; color: #fff; }

/* Marker customization modal */
.seg-drive-marker-modal {
    position: absolute; bottom: 62px; right: 8px; z-index: 20;
    background: #1a1a2e; border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px; width: 300px; box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.seg-drive-marker-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.08);
    color: #fff; font-size: 0.95rem;
}
.seg-drive-marker-modal-body { padding: 12px 14px; }
.seg-drive-marker-grid {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
}
.seg-drive-marker-opt {
    background: rgba(255,255,255,0.05); border: 2px solid transparent;
    border-radius: 6px; padding: 4px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; min-height: 32px;
}
.seg-drive-marker-opt:hover { background: rgba(255,255,255,0.1); }
.seg-drive-marker-opt.active { border-color: #00e5ff; background: rgba(0,188,212,0.1); }
.seg-drive-color-swatch {
    width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
    cursor: pointer; transition: all 0.15s;
}
.seg-drive-color-swatch:hover { transform: scale(1.15); }
.seg-drive-color-swatch.active { border-color: #fff; box-shadow: 0 0 6px rgba(255,255,255,0.3); }
.seg-drive-size-btn {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12);
    color: #ddd; padding: 4px 14px; border-radius: 5px; font-size: 0.88rem;
    font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.seg-drive-size-btn:hover { color: #fff; }
.seg-drive-size-btn.active { color: #00e5ff; background: rgba(0,188,212,0.15); border-color: #00bcd4; }

/* Empty state */
.seg-drive-empty-icon {
    width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
    background: linear-gradient(135deg, #e0f7fa, #b2ebf2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: #00838f;
}

/* Keyboard hints */
.seg-drive-kbd-hint {
    text-align: center; padding: 5px 10px; font-size: 0.88rem; color: #ccc;
    background: #0a0a14; border-top: 1px solid rgba(255,255,255,0.06); flex-shrink: 0;
}
.seg-drive-kbd-hint kbd {
    display: inline-block; padding: 1px 5px; font-size: 0.78rem;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px; color: #fff; margin: 0 2px;
}

/* Basemap toggle on tracking map */
.seg-drive-basemap-toggle {
    position: absolute; top: 6px; right: 6px; z-index: 1000;
    background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px; padding: 3px 6px; cursor: pointer;
    color: #fff; font-size: 0.82rem; transition: background 0.15s;
    backdrop-filter: blur(4px); line-height: 1;
}
.seg-drive-basemap-toggle:hover { background: rgba(0,0,0,0.85); }

/* Download button styles */
.seg-drive-btn-download { position: relative; }

/* Category layer toggles in drive sidebar */
.seg-drive-layer-toggles {
    display: flex; gap: 4px; padding: 6px 4px;
    justify-content: center; flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 4px;
}
.seg-drive-layer-btn {
    background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 5px; padding: 4px 8px; cursor: pointer;
    font-size: 0.82rem; color: #888; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.seg-drive-layer-btn:hover { background: rgba(255, 255, 255, 0.08); color: #ccc; }
.seg-drive-layer-btn.active { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.2); }

/* Category color picker in marker modal */
.seg-drive-cat-color {
    width: 24px; height: 24px; border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px; cursor: pointer; background: none; padding: 0;
}
.seg-drive-cat-color::-webkit-color-swatch-wrapper { padding: 1px; }
.seg-drive-cat-color::-webkit-color-swatch { border: none; border-radius: 3px; }

/* Category visibility toggle in marker modal */
.seg-drive-cat-vis-btn {
    background: none; border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px; padding: 2px 6px; cursor: pointer;
    color: #888; font-size: 0.78rem; transition: all 0.15s;
}
.seg-drive-cat-vis-btn:hover { color: #ccc; }
.seg-drive-cat-vis-btn.active { color: #00e5ff; border-color: rgba(0, 188, 212, 0.3); }

/* Responsive — stack vertically on narrow viewports */
@media (max-width: 768px) {
    .seg-drive-main { flex-direction: column !important; }
    .seg-drive-sidebar { width: 100% !important; flex: 0 0 160px !important; padding: 6px; padding-bottom: 3px; }
    .seg-drive-viewport { flex: 1 !important; min-height: 200px; padding: 6px; padding-top: 3px; }
}

/* Dark mode adjustments */
[data-bs-theme="dark"] .seg-drive-container { border-color: rgba(0, 188, 212, 0.18); }
[data-bs-theme="dark"] .seg-drive-empty-icon { background: linear-gradient(135deg, #1a2e3e, #0d2137); color: #4dd0e1; }
[data-bs-theme="dark"] .seg-drive-marker-modal { background: #111122; }

/* Tag library dropdown */
.seg-tag-library { max-height: 150px; overflow-y: auto; }
.seg-tag-library .dropdown-item { padding: 2px 8px; font-size: 0.82rem; }

/* Nearby context cards */
.seg-nearby-card { border-radius: 6px; transition: box-shadow 0.2s; }
.seg-nearby-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

[data-bs-theme="dark"] .seg-nearby-card { border-color: var(--bs-border-color); }

@media print {
    .sidebar, .navbar, .gis-toolbar, #help-panel, #mobileSidebar, .skip-link,
    #bugReportModal, .btn-scroll-top, .btn-bug-report {
        display: none !important;
    }
    main {
        margin-left: 0 !important;
        max-width: 100% !important;
    }
    .stats-card { break-inside: avoid; }
    .chart-container { break-inside: avoid; max-height: 400px; }
    .stats-table th { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a[href]::after { content: none !important; }
}
