/* Custom Scrollbars */
::-webkit-scrollbar { 
    width: 6px; 
    height: 6px; 
}
::-webkit-scrollbar-track { 
    background: #f1f1f1; 
}
::-webkit-scrollbar-thumb { 
    background: #cbd5e1; 
    border-radius: 4px; 
}

/* Map */
#map { 
    z-index: 10; 
    height: 100%; 
    width: 100%; 
}

.leaflet-popup-content { 
    margin: 12px; 
    min-width: 240px; 
    max-width: 300px; 
}

/* Leaflet Layer Control */
.leaflet-control-layers {
    border-radius: 12px !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    padding: 4px !important;
}

.leaflet-control-layers-expanded {
    padding: 10px !important;
    background: white !important;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif !important;
    font-size: 12px !important;
    font-weight: 600 !important;
}

/* Tabs (legacy + sidebar) */
.tab-active,
.sidebar-tab.tab-active {
    color: #2563eb;
    font-weight: 700;
    background: #eff6ff;
    border-color: #bfdbfe;
}

/* Marker Colour Filters */
.marker-red { filter: hue-rotate(140deg) saturate(3) brightness(0.8) !important; }
.marker-amber { filter: hue-rotate(190deg) saturate(3) !important; }
.marker-green { filter: hue-rotate(260deg) saturate(3) !important; }
.marker-blue { filter: none !important; }

/* Day plan — clear route control (Leaflet topleft) */
.dayplan-clear-control {
    margin-top: 0.5rem !important;
    pointer-events: auto;
}

.dayplan-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: #4f46e5;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 9999px;
    padding: 0.5rem 0.875rem;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
    white-space: nowrap;
    line-height: 1;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}

.dayplan-clear-btn:hover {
    background: #4338ca;
}

.dayplan-clear-btn i {
    font-size: 0.875rem;
}

.dayplan-clear-control {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.dayplan-pill-export {
    background: #16a34a;
}

.dayplan-pill-export:hover {
    background: #15803d;
}

.dayplan-pill-print {
    background: #0891b2;
}

.dayplan-pill-print:hover {
    background: #0e7490;
}

.leaflet-marker-icon.marker-warning {
    box-shadow: none !important;
    border: 2.5px solid #f59e0b !important;
    border-radius: 4px 4px 4px 0;
    box-sizing: border-box;
}

.pin-warning-banner {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.pin-warning-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #d97706;
    font-size: 0.75rem;
}

/* Priority-based cluster icons (highest due-date urgency wins) */
.gm-cluster-wrap {
    background: transparent !important;
    border: none !important;
}

.gm-cluster {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    line-height: 1;
    border: 3px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.gm-cluster-red { background: #ef4444; }
.gm-cluster-amber { background: #f59e0b; }
.gm-cluster-green { background: #22c55e; }
.gm-cluster-blue { background: #3b82f6; }

/* Filter Chips */
.filter-chip { 
    cursor: pointer; 
    transition: all 0.2s; 
    opacity: 0.5; 
    border-color: transparent; 
}

.filter-chip.active { 
    opacity: 1; 
    transform: translateY(-1px); 
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); 
}

.filter-chip.active.chip-red { 
    border-color: #ef4444; 
    background-color: #fef2f2; 
}

.filter-chip.active.chip-amber { 
    border-color: #f59e0b; 
    background-color: #fffbeb; 
}

.filter-chip.active.chip-green { 
    border-color: #22c55e; 
    background-color: #f0fdf4; 
}

.filter-chip.active.chip-blue { 
    border-color: #3b82f6; 
    background-color: #eff6ff; 
}

.filter-chip.active.chip-warning {
    border-color: #f59e0b;
    background-color: #fffbeb;
}

/* Map Action Buttons */
.btn-map-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-decoration: none !important;
    transition: all 0.2s;
    letter-spacing: 0.025em;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: none;
    cursor: pointer;
}

.btn-directions { 
    background-color: #4285F4; 
    color: #ffffff !important; 
}

.btn-streetview {
    background-color: #34a853;
    color: #ffffff !important;
}

.btn-share {
    background-color: #7c3aed;
    color: #ffffff !important;
}

/* List Action Icons */
.list-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    color: #9ca3af;
    transition: all 0.2s;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    text-decoration: none;
    box-sizing: border-box;
    vertical-align: middle;
}

.list-action-icon:hover {
    background-color: #f3f4f6;
}

.list-action-icon:hover.directions-icon { 
    color: #2563eb; 
    background-color: #eff6ff; 
}

.list-action-icon:hover.streetview-icon { 
    color: #16a34a; 
    background-color: #f0fdf4; 
}

.list-action-icon:hover.trash-icon { 
    color: #ef4444; 
    background-color: #fef2f2; 
}

.list-action-icon:hover.relocate-icon {
    color: #d97706;
    background-color: #fffbeb;
}

.list-action-icon:hover.share-icon {
    color: #7c3aed;
    background-color: #f5f3ff;
}

#map.relocate-pick-cursor {
    cursor: grab !important;
}

/* Fixed centre pin while relocating — the map moves beneath it */
#relocate-center-pin {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 800;
    pointer-events: none;
}

#relocate-center-pin i {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, -12%);
    font-size: 2.75rem;
    line-height: 1;
    color: #d97706;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}

#relocate-center-pin .relocate-center-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 7px;
    height: 7px;
    transform: translate(-50%, -50%);
    background: #d97706;
    border: 1.5px solid #fff;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#relocate-modal.relocate-pick-mode {
    background: transparent !important;
    backdrop-filter: none !important;
    pointer-events: none;
}

#relocate-modal.relocate-pick-mode #relocate-modal-dialog {
    display: none;
}

#relocate-modal.relocate-pick-mode .relocate-pick-hint {
    display: flex !important;
    pointer-events: auto;
}

/* This stylesheet loads after Tailwind; component display rules (flex/grid)
   would otherwise defeat the hidden utility — as they did for the mobile FABs
   and the inline rename row. hidden must always win. Consequence: never combine
   hidden with responsive display classes (md:flex) — use a media query here. */
.hidden {
    display: none !important;
}

#desktop-toggle {
    display: none;
}

@media (min-width: 768px) {
    #desktop-toggle {
        display: flex;
    }
}

/* Sidebar */
.sidebar-panel,
#sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.sidebar-mobile-bar {
    flex-shrink: 0;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.sidebar-drag-handle {
    display: flex;
    justify-content: center;
    padding: 0.625rem 0 0.25rem;
}

.sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: calc(100% - 1.5rem);
    margin: 0 0.75rem 0.625rem;
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 9999px;
    background: #2563eb;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.sidebar-close-btn:active {
    transform: scale(0.98);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.sidebar-drag-handle::after {
    content: '';
    width: 2.5rem;
    height: 0.3rem;
    border-radius: 9999px;
    background: #e5e7eb;
}

.sidebar-tools {
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

/* Full-width soft pill: reads as an expandable section (chevron at the right) */
.sidebar-tools-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: calc(100% - 2rem);
    margin: 0.625rem 1rem 0.25rem;
    padding: 0.55rem 1rem;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.sidebar-tools-toggle:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

.sidebar-tools-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.sidebar-tools-toggle-label i {
    font-size: 1rem;
    color: #2563eb;
}

.sidebar-tools-chevron {
    transition: transform 0.2s ease;
    font-size: 0.875rem;
}

.sidebar-tools.collapsed .sidebar-tools-chevron {
    transform: rotate(180deg);
}

/* One tall flat panel — everything visible with headers, no tabs or dropdowns.
   Scrolls as a single region only when taller than the space the sidebar allows. */
.sidebar-tools-body {
    max-height: min(64vh, 46rem);
    overflow-y: auto;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.sidebar-section-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-size: 0.625rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
}

.sidebar-section-label i {
    font-size: 0.8rem;
}

.coord-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.coord-row-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-left: 0.25rem;
}

.coord-row-fields {
    display: flex;
    gap: 0.375rem;
}

.coord-input {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.5rem 0.625rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    outline: none;
}

.coord-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.coord-add-btn {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background-color 0.15s ease;
    min-height: 2.25rem;
}

.coord-add-btn:hover {
    background: #2563eb;
}

.coord-icon-btn {
    flex-shrink: 0;
    width: 2.25rem;
    min-height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.coord-icon-btn:hover {
    background: #fee2e2;
}

.coord-row-hint {
    margin: 0 0 0 0.25rem;
    font-size: 0.6rem;
    color: #94a3b8;
}

.coord-row-hint:empty {
    display: none;
}

/* Import & save icon tiles */
.tool-tile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.tool-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.75rem 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
    min-height: 4.25rem;
}

.tool-tile i {
    font-size: 1.4rem;
}

.tool-tile span {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #475569;
    line-height: 1.25;
}

.tool-tile:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.tool-tile:active {
    transform: scale(0.97);
}

.tool-tile-amber:hover {
    border-color: #fcd34d;
    background: #fffbeb;
}

.tool-tile-indigo:hover {
    border-color: #a5b4fc;
    background: #eef2ff;
}

/* Shared-mark pin (received via a share link) */
.shared-mark-dot {
    width: 18px;
    height: 18px;
    border-radius: 9999px;
    background: #7c3aed;
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px #7c3aed55, 0 2px 8px rgba(0, 0, 0, 0.35);
    animation: shared-mark-pulse 1.6s ease-out infinite;
}

@keyframes shared-mark-pulse {
    0% { box-shadow: 0 0 0 2px #7c3aed55, 0 2px 8px rgba(0, 0, 0, 0.35); }
    60% { box-shadow: 0 0 0 10px #7c3aed00, 0 2px 8px rgba(0, 0, 0, 0.35); }
    100% { box-shadow: 0 0 0 2px #7c3aed00, 0 2px 8px rgba(0, 0, 0, 0.35); }
}

.sidebar-tools.collapsed .sidebar-tools-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

.sidebar-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.375rem;
    padding: 0 0.75rem 0.5rem;
}

.sidebar-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.5rem 0.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #fff;
    color: #64748b;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 3.25rem;
}

.sidebar-tab i {
    font-size: 1.125rem;
}

.sidebar-tab:hover {
    border-color: #cbd5e1;
    color: #334155;
}

.sidebar-action-panel {
    padding: 0 1rem 1rem;
}

.sidebar-hint {
    margin: 0.5rem 0 0;
    font-size: 0.65rem;
    line-height: 1.4;
    color: #94a3b8;
}

.sidebar-search-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: start;
}

.sidebar-search-form .sidebar-hint {
    grid-column: 1 / -1;
}

.sidebar-gps-btn {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #86efac;
    border-radius: 0.75rem;
    background: #ecfdf5;
    color: #047857;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.sidebar-gps-btn:hover {
    background: #d1fae5;
    border-color: #4ade80;
}

.sidebar-gps-btn.is-loading,
.gps-mark-fab.is-loading {
    opacity: 0.65;
    pointer-events: none;
}

.map-fab {
    position: fixed;
    z-index: 60;
    width: 3.5rem;
    height: 3.5rem;
    border: none;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.2s ease;
}

/* Right thumb stack, bottom to top: list, add-at-centre, GPS */
.gps-mark-fab {
    right: max(1rem, env(safe-area-inset-right, 0px));
    bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + 8.5rem);
    background: #059669;
    color: #fff;
    box-shadow: 0 10px 25px rgba(5, 150, 105, 0.35);
}

.map-fab-list {
    right: max(1rem, env(safe-area-inset-right, 0px));
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    background: #2563eb;
    color: #fff;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
}

/* Add-at-centre pin: stacked above the list button in the right thumb zone */
.add-pin-fab {
    right: max(1rem, env(safe-area-inset-right, 0px));
    bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + 4.25rem);
    background: #d97706;
    color: #fff;
    box-shadow: 0 10px 25px rgba(217, 119, 6, 0.35);
}

body.addpin-mode .map-fab {
    opacity: 0;
    pointer-events: none;
}

/* FABs are mobile-only; this stylesheet loads after Tailwind, so its
   .map-fab display rule would otherwise defeat the md:hidden class */
@media (min-width: 768px) {
    .map-fab {
        display: none !important;
    }
}

/* Tile credit collapses to a © chip on mobile (providers require the credit
   to remain accessible — it expands on tap) */
@media (max-width: 768px) {
    .gm-attrib-chip:not(.gm-attrib-open) {
        font-size: 0;
        line-height: 1;
        padding: 0.15rem 0.4rem;
        cursor: pointer;
    }

    .gm-attrib-chip:not(.gm-attrib-open)::before {
        content: '©';
        font-size: 11px;
        color: #6b7280;
    }

    .gm-attrib-chip.gm-attrib-open {
        font-size: 10px;
        cursor: pointer;
    }
}

.map-fab:active,
.gps-mark-fab:active {
    transform: scale(0.95);
}

body.sidebar-mobile-open .map-fab {
    opacity: 0;
    pointer-events: none;
}

.sidebar-search-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    outline: none;
}

.sidebar-search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.sidebar-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    min-height: 2.5rem;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
}

.sidebar-search-btn:hover {
    background: #2563eb;
}

.sidebar-marks {
    background: #fff;
    min-height: 0;
}

.sidebar-marks-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.sidebar-marks-heading {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.sidebar-marks-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.15rem;
}

.sidebar-mark-count {
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
}

.sidebar-geocode-status {
    font-size: 0.65rem;
    font-weight: 700;
    color: #3b82f6;
}

.marks-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.marks-toolbar-footer {
    flex-shrink: 0;
    flex-direction: column;
    align-items: stretch;
    margin-top: auto;
    padding: 0.625rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.06);
    position: sticky;
    bottom: 0;
    z-index: 4;
}

.marks-toolbar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.marks-toolbar-row .marks-toolbar-group {
    flex: 1;
    min-width: 0;
}

.marks-toolbar-row .marks-toolbar-btn {
    flex: 1;
    justify-content: center;
}

.marks-toolbar-row .marks-toolbar-danger {
    margin-left: 0;
    flex-shrink: 0;
}

.marks-toolbar-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.875rem;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.35);
}

.marks-toolbar-primary:hover {
    background: #4338ca;
}

.marks-toolbar-group {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #fff;
}

.marks-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.55rem;
    border: none;
    border-right: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.marks-toolbar-btn:last-child {
    border-right: none;
}

.marks-toolbar-btn:hover {
    background: #f8fafc;
    color: #1e293b;
}

.marks-toolbar-btn i {
    font-size: 0.9rem;
}

.marks-toolbar-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: auto;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    background: #fff;
    color: #ef4444;
    cursor: pointer;
}

.marks-toolbar-danger:hover {
    background: #fef2f2;
}

.sidebar-empty {
    color: #94a3b8;
}

.sidebar-empty-icon {
    font-size: 2.5rem;
    opacity: 0.25;
    margin-bottom: 0.75rem;
}

.sidebar-empty-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #64748b;
}

.sidebar-empty-hint {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    line-height: 1.45;
    max-width: 14rem;
}

.sidebar-empty-cta {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    border: 1px solid #bfdbfe;
    border-radius: 9999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.sidebar-empty-cta:hover {
    background: #dbeafe;
}

.sidebar-marks-list {
    list-style: none;
    margin: 0;
    padding: 0;
    scroll-padding-top: 0.5rem;
    scroll-padding-bottom: 0.5rem;
}

.sidebar-filter-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: #64748b;
}

.sidebar-filter-empty-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #475569;
}

.sidebar-filter-empty-hint {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    line-height: 1.45;
}

.sidebar-filter-empty-btn {
    margin-top: 0.875rem;
    padding: 0.5rem 1rem;
    border: 1px solid #bfdbfe;
    border-radius: 9999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.sidebar-filter-empty-btn:hover {
    background: #dbeafe;
}

.sidebar-mark-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.625rem;
    align-items: start;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s ease;
}

.sidebar-mark-item:hover {
    background: #f8fafc;
}

.sidebar-mark-item-active {
    background: #eff6ff !important;
    box-shadow: inset 3px 0 0 #3b82f6;
}

.mark-dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 9999px;
    margin-top: 0.35rem;
    flex-shrink: 0;
}

.mark-dot-red { background: #ef4444; }
.mark-dot-amber { background: #f59e0b; }
.mark-dot-green { background: #22c55e; }
.mark-dot-blue { background: #3b82f6; }

.sidebar-mark-body {
    min-width: 0;
}

.sidebar-mark-header {
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
}

.sidebar-mark-label {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.35;
}

.sidebar-mark-name {
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
}

.sidebar-mark-edit {
    display: inline-flex;
    padding: 0.125rem;
    border: none;
    background: transparent;
    color: #93c5fd;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.sidebar-mark-item:hover .sidebar-mark-edit,
.sidebar-mark-edit:focus {
    opacity: 1;
}

.sidebar-mark-rename {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.sidebar-mark-rename input {
    flex: 1;
    min-width: 0;
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.sidebar-mark-rename-save,
.sidebar-mark-rename-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
}

.sidebar-mark-rename-save {
    background: #3b82f6;
    color: #fff;
}

.sidebar-mark-rename-cancel {
    background: #e5e7eb;
    color: #64748b;
}

.sidebar-mark-address {
    margin: 0.25rem 0 0;
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 1.4;
    word-break: break-word;
}

.sidebar-mark-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    margin-top: 0.25rem;
    min-width: 0;
}

.sidebar-mark-date {
    font-size: 0.625rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.mark-date-urgent { color: #dc2626; }
.mark-date-soon { color: #d97706; }
.mark-date-normal { color: #6366f1; }

.sidebar-mark-notes {
    flex: 1 1 100%;
    font-size: 0.65rem;
    color: #94a3b8;
    font-style: italic;
    line-height: 1.35;
    word-break: break-word;
}

.sidebar-mark-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.sidebar-mark-actions .list-action-icon {
    width: 1.65rem;
    height: 1.65rem;
}

.sidebar-mark-actions .list-action-icon i {
    font-size: 0.95rem;
}

.sidebar-load-more {
    padding: 0.875rem 1rem;
    text-align: center;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    position: sticky;
    bottom: 0;
}

.sidebar-load-more button {
    width: 100%;
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: #2563eb;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.sidebar-load-more p {
    margin: 0.25rem 0 0;
    font-size: 0.625rem;
    color: #94a3b8;
}

@media (hover: none) {
    .sidebar-mark-edit {
        opacity: 1;
    }
}

#sidebar.collapsed-desktop {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
    border-right: none;
}

@media (min-width: 768px) {
    #desktop-toggle {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: calc(26rem - 1rem);
        z-index: 70;
        transition: left 0.3s ease, background-color 0.2s, color 0.2s;
    }

    #main-content.sidebar-collapsed #desktop-toggle {
        left: 0;
        border-radius: 0 0.5rem 0.5rem 0;
    }
}

/* App modals above mobile sidebar (sidebar z-index 500) */
#mapper-modal,
#ai-modal,
#scan-modal,
#bulk-edit-modal,
#streetview-modal,
#relocate-modal,
#import-progress {
    z-index: 700 !important;
}

#import-progress-fill.import-progress-indeterminate {
    width: 35% !important;
    animation: import-progress-pulse 1.2s ease-in-out infinite;
}

@keyframes import-progress-pulse {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

#toast {
    z-index: 750 !important;
}

.toast-action {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    min-height: 2rem;
    transition: background-color 0.15s ease;
}

.toast-action:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Completed-work archive list inside marker popups */
.archive-nearby {
    margin-top: 0.5rem;
    border: 1px solid #e0e7ff;
    background: #eef2ff;
    border-radius: 0.5rem;
    font-size: 10px;
}

.archive-nearby summary {
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    font-weight: 700;
    color: #4338ca;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    list-style: none;
}

.archive-nearby summary::-webkit-details-marker {
    display: none;
}

.archive-nearby[open] summary {
    border-bottom: 1px solid #e0e7ff;
}

.archive-nearby ul {
    max-height: 10rem;
    overflow-y: auto;
    padding: 0.35rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0;
    list-style: none;
}

.archive-nearby-item {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: baseline;
}

.archive-nearby-dist {
    font-weight: 700;
    color: #4338ca;
    min-width: 2.2rem;
}

.archive-nearby-main {
    color: #374151;
    font-weight: 600;
}

.archive-nearby-meta {
    color: #9ca3af;
    width: 100%;
    padding-left: 2.5rem;
}

.archive-nearby-recovered .archive-nearby-main {
    color: #b91c1c;
}

.archive-nearby-outstanding .archive-nearby-main {
    color: #b45309;
}

.archive-nearby-field {
    display: block;
    width: 100%;
    padding-left: 2.5rem;
    color: #6b7280;
}

.archive-nearby-field strong {
    color: #4b5563;
    font-weight: 600;
}

.archive-nearby-more {
    padding: 0.25rem 0.6rem 0.4rem;
    color: #9ca3af;
    margin: 0;
}

/* Drag & drop import overlay */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.75rem 1.25rem;
    border: 2px dashed rgba(255, 255, 255, 0.45);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.08);
    text-align: center;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.drop-zone * {
    pointer-events: none; /* keep drop target = the zone itself */
}

.drop-zone-active {
    background: rgba(255, 255, 255, 0.22);
    border-color: #fff;
    transform: scale(1.03);
}

.drop-zone-title {
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}

.drop-zone-hint {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.65rem;
    line-height: 1.35;
}

.filter-chip-label {
    font-size: 0.625rem;
    line-height: 1;
    white-space: nowrap;
}

/* Chips scroll sideways on narrow phones instead of wrapping the banner */
.filter-chip-row {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-chip-row::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    flex-shrink: 0;
}

/* iOS Safari: 100vh extends under the collapsing URL bar, pushing bottom
   controls off screen — dvh tracks the visible viewport instead */
@supports (height: 100dvh) {
    body {
        height: 100dvh;
    }
}

#load-error {
    z-index: 9999 !important;
}

/* Mobile Sidebar */
@media (max-width: 768px) {
    /* pinch to zoom on touch — the +/- buttons just take space */
    .leaflet-control-zoom {
        display: none;
    }

    #sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: min(86%, calc(100% - env(safe-area-inset-top, 0px) - 2rem));
        width: 100% !important;
        z-index: 500;
        transform: translateY(100%);
        border-radius: 1rem 1rem 0 0;
        box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
    }
    #sidebar.active {
        transform: translateY(0);
    }
    #desktop-toggle {
        display: none;
    }
    .sidebar-tools-body {
        max-height: min(58vh, 40rem);
    }
    .sidebar-mark-header {
        align-items: center;
    }
    .sidebar-mark-actions {
        align-items: center;
        gap: 0.125rem;
    }
    .marks-toolbar-footer {
        padding: 0.625rem 1rem max(0.5rem, env(safe-area-inset-bottom, 0px));
        gap: 0.5rem;
    }
    .marks-toolbar-primary {
        width: 100%;
        justify-content: center;
        min-height: 2.5rem;
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    .marks-toolbar-btn {
        min-height: 2.5rem;
        padding: 0.45rem 0.35rem;
        font-size: 0.6rem;
    }
    .marks-toolbar-danger {
        width: 2.5rem;
        height: 2.5rem;
    }
    .sidebar-mark-actions .list-action-icon {
        width: 2.25rem;
        height: 2.25rem;
    }
    .sidebar-mark-actions .list-action-icon i {
        font-size: 1rem;
    }
    #ai-modal {
        padding: 0;
        align-items: flex-end;
    }
    #ai-modal > .bg-white {
        width: 100%;
        max-width: 100%;
        max-height: min(92vh, calc(100% - env(safe-area-inset-top, 0px)));
        border-radius: 1rem 1rem 0 0;
    }
    #ai-modal-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    }
    #ai-modal-footer > div {
        display: flex;
        flex-wrap: wrap;
        justify-content: stretch;
        gap: 0.5rem;
        width: 100%;
        margin-left: 0 !important;
    }
    #ai-modal-footer button {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        font-size: 0.75rem;
    }
    #ai-plan-generate-btn {
        flex: 1 1 100%;
    }
    .leaflet-popup {
        margin-bottom: max(0.25rem, env(safe-area-inset-bottom, 0px));
    }
}

/* Plan Day */
.day-plan-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.day-plan-stat {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.75rem;
    text-align: center;
}

.day-plan-stat-value {
    font-size: 1.125rem;
    font-weight: 800;
    color: #4338ca;
    line-height: 1.2;
}

.day-plan-stat-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.day-plan-table-wrap {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
}

.day-plan-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.day-plan-table th {
    background: #f1f5f9;
    text-align: left;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    white-space: nowrap;
}

.day-plan-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.day-plan-table tr:last-child td {
    border-bottom: none;
}

.day-plan-table tr:hover td {
    background: #f8fafc;
}

.day-plan-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: #4f46e5;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
}

.day-plan-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.day-plan-tab {
    padding: 0.5rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.15s;
}

.day-plan-tab:hover {
    background: #f1f5f9;
    color: #4338ca;
}

.day-plan-tab.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}

.day-plan-jump {
    color: #4f46e5;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.day-plan-jump:hover {
    text-decoration: underline;
}

.day-plan-note {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 1rem;
    line-height: 1.5;
}

@media print {
    body * { visibility: hidden; }
    #ai-modal, #ai-modal * { visibility: visible; }
    #ai-modal {
        position: absolute;
        inset: 0;
        background: white !important;
        display: flex !important;
        padding: 0 !important;
    }
    #ai-modal-footer, #ai-plan-back-btn, #ai-plan-map-btn { display: none !important; }
}

/* AI Modal Markdown Table Styling */
.markdown-content table {
    width: 100%; 
    border-collapse: collapse; 
    margin-bottom: 1.5rem; 
    font-size: 0.85rem; 
}

.markdown-content th { 
    background: #f8fafc; 
    text-align: left; 
    padding: 10px; 
    border: 1px solid #e2e8f0; 
    font-weight: bold; 
}

.markdown-content td { 
    padding: 10px; 
    border: 1px solid #e2e8f0; 
    vertical-align: middle; 
}

/* Street View modal — 95% viewport */
#streetview-panel {
    width: 95vw;
    height: 95vh;
    max-width: 95vw;
    max-height: 95vh;
}

#sv-mini-map {
    background: #f8fafc;
}

#sv-embed-wrap iframe {
    border: 0;
}

#sv-pin-overlay .sv-pin-overlay-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    line-height: 1.35;
}
.sv-pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 9999px;
    background: #ef4444;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #ef4444;
}
.sv-cam-dot {
    width: 12px;
    height: 12px;
    border-radius: 9999px;
    background: #2563eb;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #2563eb;
}
.sv-map-label {
    background: rgba(255, 255, 255, 0.92);
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    font-size: 10px;
    font-weight: 700;
    color: #374151;
    padding: 2px 6px;
}
.mapper-details-picks .mapper-detail-pick:has(input:checked) {
    background: #eff6ff;
}

.mapper-details-picks .mapper-detail-pick:has(input:checked) span {
    color: #1d4ed8;
    font-weight: 600;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: rgba(59, 130, 246, 0.25);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: rgba(37, 99, 235, 0.85);
    color: #fff;
    font-weight: 700;
}

.mapper-col-chip {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px 8px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sv-direction-badge {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 6px;
}