/*
 * ManageLinks page styles — scoped under .page-mobile-sites.
 * Shared utilities (scrollbars, leaflet popups) live unscoped as they're safe globally.
 */

/* =========================================
   STRUCTURAL LAYOUT
   ========================================= */

.page-mobile-sites.ms-container {
    position: fixed;
    top: var(--ls-nav-height); /* below navbar */
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    overflow: hidden;
    background: var(--ls-bg-panel);
}

.page-mobile-sites .ms-sidebar {
    width: 310px;
    flex-shrink: 0;
    flex-direction: row;
    display: flex;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 2;
    background: var(--ls-bg-panel);
}

.page-mobile-sites .ms-map-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.page-mobile-sites .ms-right-panel {
    width: 400px;
    display: flex;
    flex-direction: column;
    position: absolute;
    right: -400px;
    z-index: 100;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
    background-color: var(--ls-bg-popup);
    transition: right 0.3s ease, width 0.3s ease;
}

.page-mobile-sites .ms-right-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.page-mobile-sites .ms-right-panel .panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.page-mobile-sites .ms-right-panel .panel-controls {
    display: flex;
    gap: 0.4rem;
}

/* =========================================
   FILTER GROUP / FORM CONTROL BASE STYLES
   ========================================= */

.page-mobile-sites .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.page-mobile-sites .filter-group {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--ls-border-subtle);
    border-radius: 6px;
}

.page-mobile-sites .filter-label {
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
}

.page-mobile-sites .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.5);
}

.page-mobile-sites .empty-state i {
    font-size: 2.4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* =========================================
   MULTI-SELECT BUTTON GROUP FILTERS
   Used by Link Status and Region — checkbox-style toggle pills
   ========================================= */

.ms-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.ms-filter-chip {
    background: transparent;
    border: 1px solid var(--ls-border-medium);
    color: rgba(255, 255, 255, 0.65);
    border-radius: 14px;
    padding: 4px 11px;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}

.ms-filter-chip i {
    font-size: 0.65rem;
    opacity: 0.55;
}

.ms-filter-chip:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

.ms-filter-chip.checked {
    background: rgba(0, 188, 140, 0.18);
    color: var(--ls-accent);
    border-color: rgba(0, 188, 140, 0.5);
}

.ms-filter-chip.checked i {
    opacity: 1;
}

.ms-filter-chip.checked:hover {
    background: rgba(0, 188, 140, 0.25);
    border-color: var(--ls-accent);
}

/* Status-specific accent colors when checked (subtle dot per status) */
.ms-filter-chip[data-status="pending"].checked {
    background: rgba(231, 76, 60, 0.18);
    color: #f5b8b1;
    border-color: rgba(231, 76, 60, 0.5);
}

.ms-filter-chip[data-status="inprogress"].checked {
    background: rgba(52, 152, 219, 0.18);
    color: #b8d8f0;
    border-color: rgba(52, 152, 219, 0.5);
}

.ms-filter-chip[data-status="complete"].checked {
    background: rgba(0, 188, 140, 0.18);
    color: #a8e6d2;
    border-color: rgba(0, 188, 140, 0.5);
}

.ms-filter-chips-empty {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.72rem;
    font-style: italic;
    padding: 4px 0;
}

.ms-campaign-card {
    background: var(--ms-bg-card, #1e1e1e);
    border: 1px solid var(--ms-border, rgba(255,255,255,0.08));
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ms-campaign-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ms-text, #e0e0e0);
}

.ms-campaign-meta {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
}

/* =========================================
   MAP CONTENT AREA (ManageLinks specific)
   ========================================= */

.page-mobile-sites .ms-map-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

    .page-mobile-sites .ms-map-area .map-area-wrapper {
        flex: 1;
        position: relative;
        overflow: hidden;
    }

    .page-mobile-sites .ms-map-area #map {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
    }

/* Leaflet attribution - keep compact and prevent overlap */
/* Map overlay message */
.page-mobile-sites #map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    text-align: center;
    padding: 20px;
}

/* =========================================
   LEFT PANEL - ICON SIDEBAR NAV
   ========================================= */

.page-mobile-sites .ms-sidebar {
    flex-direction: row;
}

.icon-sidebar {
    width: 48px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 4px;
    background: var(--ls-bg-base);
    border-right: 1px solid var(--ls-border-subtle);
}

.icon-sidebar-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #888;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    position: relative;
}

    .icon-sidebar-btn:hover {
        background: var(--ls-border-subtle);
        color: #ccc;
    }

    .icon-sidebar-btn.active {
        background: var(--ls-accent-bg);
        color: var(--ls-accent);
    }

    .icon-sidebar-btn.active::before {
        content: '';
        position: absolute;
        left: -4px;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 18px;
        background: var(--ls-accent);
        border-radius: 0 2px 2px 0;
    }

.sidebar-panels {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-panel {
    flex: 1;
    min-height: 0;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

    .sidebar-panel.active {
        display: flex;
    }

.sidebar-panel-header {
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #adb5bd;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

/* =========================================
   DOCUMENT MANAGER MODAL
   ========================================= */

#docManagerModal .modal-header {
    background: rgba(0, 0, 0, 0.3);
}

#docManagerModal .table thead th {
    background: #1a1d21;
    border-bottom: 2px solid #343a40;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #adb5bd;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

#docManagerModal .table tbody td {
    font-size: 0.82rem;
    vertical-align: middle;
    border-color: #2a2d31;
}

#docManagerModal .table tbody tr:hover {
    background-color: rgba(0, 188, 140, 0.06) !important;
}

#docManagerModal .table tbody tr.selected {
    background-color: rgba(52, 152, 219, 0.12) !important;
}

.doc-file-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .doc-file-info i {
        font-size: 1.1rem;
        flex-shrink: 0;
    }

.doc-file-name {
    font-weight: 500;
    color: #f8f9fa;
    word-break: break-word;
}

.doc-file-notes {
    font-size: 0.7rem;
    color: #888;
    margin-top: 2px;
}

.doc-manager-toolbar {
    padding: 8px 0;
    border-bottom: 1px solid #343a40;
}

.doc-date-group,
.doc-search-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.doc-filter-icon {
    color: #6c757d;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.doc-filter-input {
    background-color: var(--ls-bg-input);
    border: 1px solid #495057;
    color: #e0e0e0;
    max-width: 150px;
    transition: border-color 0.2s ease;
    color-scheme: dark;
}

.doc-filter-input:focus {
    background-color: var(--ls-bg-input);
    border-color: var(--ls-accent);
    color: #e0e0e0;
    box-shadow: 0 0 0 0.15rem var(--ls-accent-glow);
}

.doc-filter-search {
    max-width: 200px;
}

.doc-filter-btn {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    line-height: 1.5;
}

/* =========================================
   STATISTICS BAR
   ========================================= */

.statistics-bar {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background-color: var(--ls-bg-panel);
    border-bottom: 1px solid var(--ls-border-subtle);
    padding: 0.4rem 0.85rem;
    gap: 0.75rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
    z-index: 100;
    min-height: 50px;
}

.stat-group {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0.2rem 0.75rem 0.2rem 0.6rem;
    background-color: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    gap: 0.6rem;
}

.stat-group-caption {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ls-accent);
    line-height: 1;
    padding: 0.1rem 0;
    border-right: none;
}

.stat-group-items {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-left: 0.55rem;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.25rem 0.5rem;
    min-width: 60px;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

    .stat-value small {
        font-size: 0.65rem;
        font-weight: 400;
        opacity: 0.7;
    }

.stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-top: 0.15rem;
    white-space: nowrap;
}

.stat-item.stat-pending .stat-value {
    color: var(--ls-danger);
}

.stat-item.stat-inprogress .stat-value {
    color: #3498db;
}

.stat-item.stat-complete .stat-value {
    color: var(--ls-accent);
}

/* Progress Ring */
.stat-item.stat-progress {
    padding: 0.25rem 0.5rem;
}

.progress-ring {
    width: 44px;
    height: 44px;
}

    .progress-ring svg {
        width: 100%;
        height: 100%;
        transform: rotate(-90deg);
    }

.progress-ring-bg {
    fill: none;
    stroke: #434343;
    stroke-width: 3;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--ls-accent);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.progress-ring-text {
    fill: #fff;
    font-size: 8px;
    font-weight: 700;
    text-anchor: middle;
    transform: rotate(90deg);
    transform-origin: center;
}

/* Statistics responsive */
@media (max-width: 1200px) {
    .statistics-bar {
        padding: 0.4rem 0.5rem;
        gap: 0.5rem;
    }

    .stat-group-items {
        gap: 0.1rem;
    }

    .stat-item {
        min-width: 50px;
        padding: 0.15rem 0.25rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .progress-ring {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 992px) {
    .statistics-bar {
        overflow-x: auto;
        justify-content: flex-start;
    }
}

/* =========================================
   RIGHT PANEL OVERRIDES (ManageLinks only)
   ========================================= */

.page-mobile-sites .ms-right-panel {
    background-color: var(--ls-bg-popup);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
    z-index: 1050;
    top: 0;
    bottom: 0;
}

    .page-mobile-sites .ms-right-panel.active {
        right: 0;
    }

    .page-mobile-sites .ms-right-panel .panel-header {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #495057;
        flex-shrink: 0;
    }

    .page-mobile-sites .ms-right-panel .panel-content {
        overflow-x: hidden;
        padding: 0;
    }

/* Docked, the panel sits at the map area's right edge. Expanded, it detaches and floats centred
   over the map. Percentages resolve against .ms-map-area, so the backdrop covers the map only. */
.page-mobile-sites .ms-panel-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.page-mobile-sites .ms-panel-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.page-mobile-sites .ms-right-panel.expanded {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(1080px, 92%);
    height: min(880px, 90%);
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    transition: transform 0.25s ease, width 0.25s ease, height 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
    .page-mobile-sites .ms-panel-backdrop,
    .page-mobile-sites .ms-right-panel.expanded {
        transition: none;
    }
}

/* =========================================
   PANEL DATA FIELDS
   ========================================= */

.form-label-sm {
    font-size: 0.7rem;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

.panel-data-field {
    font-size: 0.95rem;
    color: #f8f9fa;
    padding-bottom: 0.5rem;
}

.panel-data-notes {
    font-size: 0.85rem;
    color: #ced4da;
    white-space: pre-wrap;
}

/* =========================================
   STATUS BADGES
   ========================================= */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

    .status-badge.status-pending {
        background-color: rgba(231, 76, 60, 0.15);
        color: var(--ls-danger);
        border: 1px solid rgba(231, 76, 60, 0.3);
    }

    .status-badge.status-inprogress {
        background-color: rgba(52, 152, 219, 0.15);
        color: #3498db;
        border: 1px solid rgba(52, 152, 219, 0.3);
    }

    .status-badge.status-complete {
        background-color: var(--ls-accent-bg);
        color: var(--ls-accent);
        border: 1px solid rgba(0, 188, 140, 0.3);
    }

.status-toggle-btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.65rem;
    margin-left: 0.5rem;
}

/* =========================================
   REPORTS LIST
   ========================================= */

.reports-list {
    max-height: 350px;
    overflow-y: auto;
}

.report-item {
    transition: all 0.2s ease;
}

    .report-item:hover {
        background-color: #2a2a2a !important;
        border-color: #4a9eff !important;
    }

    .report-item .btn-group {
        opacity: 0.8;
        transition: opacity 0.2s ease;
    }

    .report-item:hover .btn-group {
        opacity: 1;
    }

    .report-item .report-filename {
        word-break: break-word;
        line-height: 1.3;
        flex: 1;
    }

    .report-item i.fa-file-pdf {
        color: #dc3545;
    }

    .report-item i.fa-file-excel {
        color: #28a745;
    }

    .report-item i.fa-file-image {
        color: #ffc107;
    }

    .report-item i.fa-file-archive {
        color: #6c757d;
    }

    .report-item i.fa-file {
        color: #17a2b8;
    }

/* =========================================
   DELETE BUTTONS
   ========================================= */

.btn-delete-link,
.btn-delete-report {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

    .btn-delete-link:hover,
    .btn-delete-report:hover {
        opacity: 1;
    }

/* =========================================
   ACTIVITY TIMELINE
   ========================================= */

.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: calc(100vh - 320px);
    overflow-y: auto;
    overflow-x: hidden;
}

.activity-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-left: 2px solid #434343;
    margin-left: 0.75rem;
    padding-left: 1rem;
    position: relative;
    transition: background-color 0.2s ease;
}

    .activity-item:hover {
        background-color: rgba(255, 255, 255, 0.03);
    }

    .activity-item::before {
        content: '';
        position: absolute;
        left: -5px;
        top: 1rem;
        width: 8px;
        height: 8px;
        background: #434343;
        border-radius: 50%;
    }

    .activity-item:first-child {
        padding-top: 0;
    }

    .activity-item:last-child {
        border-left-color: transparent;
    }

.activity-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #3a3a3a;
    border-radius: 6px;
    flex-shrink: 0;
}

    .activity-icon i {
        font-size: 0.75rem;
    }

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-description {
    font-size: 0.8rem;
    color: #ebebeb;
    margin: 0;
    line-height: 1.4;
    word-wrap: break-word;
}

.activity-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.3rem;
}

.activity-user,
.activity-time {
    font-size: 0.65rem;
    color: #888;
    display: flex;
    align-items: center;
}

    .activity-user i,
    .activity-time i {
        font-size: 0.55rem;
        opacity: 0.7;
    }

#activity-panel .date-range-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#activity-panel input[type="date"] {
    background-color: #303030;
    border-color: #434343;
    color: #ebebeb;
    font-size: 0.8rem;
    width: 100%;
}

    #activity-panel input[type="date"]:focus {
        border-color: var(--ls-accent);
        box-shadow: 0 0 0 2px rgba(0, 188, 140, 0.25);
    }

#admin-panel .panel-content {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* =========================================
   IMPORT MODAL
   ========================================= */

#importLinksModal .form-label-sm {
    font-size: 0.7rem;
    color: #999;
    margin-bottom: 0.2rem;
    display: block;
}

#importLinksModal .form-select-sm {
    background-color: #303030;
    border-color: #434343;
    color: #ebebeb;
    font-size: 0.8rem;
}

    #importLinksModal .form-select-sm:focus {
        border-color: var(--ls-accent);
        box-shadow: 0 0 0 2px rgba(0, 188, 140, 0.25);
    }

#sampleDataTable {
    font-size: 0.7rem;
}

    #sampleDataTable th {
        background-color: #303030;
        position: sticky;
        top: 0;
        font-weight: 600;
        white-space: nowrap;
    }

    #sampleDataTable td {
        white-space: nowrap;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

/* =========================================
   MAP MARKERS & TOOLTIPS
   ========================================= */

.page-mobile-sites .custom-marker {
    background: none !important;
    border: none !important;
    filter: none !important;
}

.site-name-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    border: 1px solid #495057 !important;
    color: white !important;
    font-size: 11px !important;
    padding: 6px !important;
    border-radius: 4px !important;
}

.link-tooltip {
    background-color: #2d2d2d !important;
    border: 1px solid #434343 !important;
    color: #fff !important;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

/* =========================================
   REUSABLE SCROLLBAR UTILITIES
   ========================================= */

/* (scrollbars use the shared .ls-scroll / .ls-scroll--thin utility in site.css) */

.filter-group small.text-muted {
    font-size: 0.7rem;
    line-height: 1.3;
}

/* =========================================
   FLOATING MAP SEARCH BAR
   ========================================= */

.map-search-container {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 550;
    width: 90%;
    max-width: 550px;
    pointer-events: none;
}

/* Search container is now inside .map-area-wrapper, positioned relative to the map */

.map-search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(22, 22, 22, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--ls-border-medium);
    border-radius: 10px;
    padding: 0.5rem 0.6rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.map-search-type-toggle {
    display: flex;
    gap: 0.2rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    padding: 0.2rem;
    flex-shrink: 0;
}

.search-type-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    background: transparent;
    border: none;
    color: #9ca3af;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

    .search-type-btn:hover {
        background: #3a3f46;
        color: #e5e7eb;
    }

    .search-type-btn.active {
        background: var(--ls-accent);
        color: #fff;
        font-weight: 500;
    }

.map-search-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
    color: #f8f9fa;
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    min-width: 0;
    transition: all 0.2s ease;
}

    .map-search-input:focus {
        outline: none;
        border-color: var(--ls-accent);
        box-shadow: 0 0 0 2px var(--ls-accent-glow);
    }

    .map-search-input::placeholder {
        color: rgba(255, 255, 255, 0.35);
    }

.map-search-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

    .map-search-clear-btn:hover {
        background: var(--ls-danger);
        color: #fff;
    }

/* Search Results Dropdown */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background: rgba(22, 22, 22, 0.97);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: none;
    pointer-events: auto;
}

    .search-results-dropdown.show {
        display: block;
    }

    /* (search-results-dropdown scrollbar uses the shared .ls-scroll utility) */

.search-results-section {
    border-bottom: 1px solid #343a40;
}

    .search-results-section:last-of-type {
        border-bottom: none;
    }

.search-results-header {
    padding: 0.6rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    background: rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 1;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid rgba(52, 58, 64, 0.5);
}

    .search-result-item:last-child {
        border-bottom: none;
    }

    .search-result-item:hover {
        background: rgba(0, 188, 140, 0.1);
    }

.search-result-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    flex-shrink: 0;
}

    .search-result-icon i {
        font-size: 0.85rem;
    }

    .search-result-icon.site-icon i {
        color: #ea4335;
    }

    .search-result-icon.link-icon i {
        color: var(--ls-accent);
    }

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #f8f9fa;
    font-weight: 500;
}

    .search-result-title .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
        font-weight: 500;
    }

.search-result-subtitle {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-empty-state {
    padding: 2rem 1rem;
    text-align: center;
    color: #6c757d;
}

    .search-empty-state i {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
        opacity: 0.4;
    }

    .search-empty-state p {
        font-size: 0.95rem;
        margin-bottom: 0.25rem;
    }

.search-more-results {
    padding: 0.75rem 1rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid #343a40;
}

@media (max-width: 768px) {
    .map-search-container {
        width: 95%;
        top: 10px;
    }

    /* Search container positioned relative to map-area-wrapper, no offset needed */

    .map-search-bar {
        flex-wrap: wrap;
        padding: 0.4rem;
    }

    .map-search-type-toggle {
        order: 2;
        width: 100%;
        margin-top: 0.4rem;
        justify-content: center;
    }

    .map-search-input {
        order: 1;
        flex: 1;
    }

    .map-search-clear-btn {
        order: 1;
    }

    .search-result-item {
        padding: 0.6rem 0.75rem;
    }
}

/* =========================================
   RIGHT PANEL SCROLLBAR
   ========================================= */

/* (panel-content scrollbars use the shared .ls-scroll utility) */

/* =========================================
   MAP CAPTURE CONTROL (Leaflet PNG/clipboard buttons)
   ========================================= */

.page-mobile-sites .ms-capture-control {
    margin-top: 10px !important;
    border-radius: 8px !important;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.page-mobile-sites .ms-capture-control a {
    background: rgba(20, 20, 20, 0.92) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    border: none !important;
    border-bottom: 1px solid var(--ls-border-subtle) !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 14px;
    text-align: center;
    transition: background 0.15s ease, color 0.15s ease;
    backdrop-filter: blur(6px);
}

.page-mobile-sites .ms-capture-control a:last-child {
    border-bottom: none !important;
}

.page-mobile-sites .ms-capture-control a:hover {
    background: var(--ls-accent) !important;
    color: #000 !important;
}

/* Match the Leaflet layer control to the dark theme */
.page-mobile-sites .ms-map-area .leaflet-control-layers-expanded {
    background: var(--ls-bg-card);
    color: #f0f0f0;
    border: 1px solid #333;
    border-radius: 6px;
}

.page-mobile-sites .ms-map-area .leaflet-control-layers label {
    color: #f0f0f0;
}

.page-mobile-sites .ms-map-area .leaflet-control-layers input[type="radio"] {
    accent-color: var(--ls-accent);
}

/* =========================================
   SEARCH BAR — RESET BUTTON & DIVIDER
   ========================================= */

.map-search-divider {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
    margin: 0 2px;
}

.map-search-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.map-search-action-btn:hover {
    background: var(--ls-accent);
    color: #000;
}

/* =========================================
   UNIFIED POPUP — used by both site marker & link picker
   ========================================= */

.ms-popup-custom .leaflet-popup-content-wrapper {
    background: var(--ls-bg-popup) !important;
    color: #f0f0f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 10px !important;
    padding: 0 !important;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.6),
        0 8px 28px rgba(0, 0, 0, 0.7) !important;
}

.ms-popup-custom .leaflet-popup-content {
    margin: 0 !important;
    line-height: 1.4 !important;
    color: #f0f0f0 !important;
}

.ms-popup-custom .leaflet-popup-tip {
    background: var(--ls-bg-popup) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
}

.ms-popup-custom .leaflet-popup-close-button {
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 18px !important;
    top: 6px !important;
    right: 8px !important;
}

.ms-popup-custom .leaflet-popup-close-button:hover {
    color: #fff !important;
}

.ms-popup {
    color: #f0f0f0;
    font-size: 0.78rem;
    line-height: 1.4;
}

.ms-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--ls-border-subtle);
}

.ms-popup-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ls-accent-bg);
    color: var(--ls-accent);
    border: 1px solid rgba(0, 188, 140, 0.3);
    flex-shrink: 0;
    font-size: 0.85rem;
}

.ms-popup-title {
    flex: 1;
    min-width: 0;
}

.ms-popup-name {
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ms-popup-meta {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.68rem;
    margin-top: 1px;
}

.ms-popup-coords {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 14px;
    padding: 8px 12px;
    background: rgba(0, 188, 140, 0.08);
    border: 1px solid rgba(0, 188, 140, 0.3);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.74rem;
    font-family: 'Consolas', 'Monaco', monospace;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.ms-popup-coords:hover {
    background: var(--ls-accent-bg);
    border-color: rgba(0, 188, 140, 0.5);
}

.ms-popup-coords.copied {
    background: rgba(0, 188, 140, 0.25);
    border-color: var(--ls-accent);
}

.ms-popup-coords > i:first-child {
    color: var(--ls-accent);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.ms-popup-coords span {
    flex: 1;
}

.ms-popup-coords-copy {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.72rem;
    flex-shrink: 0;
}

.ms-popup-coords:hover .ms-popup-coords-copy {
    color: var(--ls-accent);
}

.ms-popup-rows {
    padding: 4px 14px 12px;
}

.ms-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ms-popup-row:last-child {
    border-bottom: none;
}

.ms-popup-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.ms-popup-value {
    color: #f0f0f0;
    font-weight: 500;
    font-size: 0.78rem;
}

/* Link picker list — used when multiple links share a polyline */
.ms-popup-link-list {
    padding: 4px 0 8px;
    max-height: 280px;
    overflow-y: auto;
}

.ms-popup-link-item {
    display: block;
    padding: 9px 14px;
    color: #f0f0f0 !important;
    text-decoration: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s ease;
}

.ms-popup-link-item:first-child {
    border-top: none;
}

.ms-popup-link-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ms-popup-link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.ms-popup-link-item strong {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
}

.ms-popup-link-item small {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.68rem;
}

/* Status pill — also reused in the right panel */
.ms-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border: 1px solid transparent;
}

.ms-status-pill.pending {
    background: rgba(231, 76, 60, 0.18);
    color: #f5b8b1;
    border-color: rgba(231, 76, 60, 0.4);
}

.ms-status-pill.inprogress {
    background: rgba(52, 152, 219, 0.18);
    color: #b8d8f0;
    border-color: rgba(52, 152, 219, 0.4);
}

.ms-status-pill.complete {
    background: rgba(0, 188, 140, 0.18);
    color: #a8e6d2;
    border-color: var(--ls-accent-border);
}

/* =========================================
   SIDEBAR PANEL CONTROL OVERRIDES
   Themes Bootstrap form controls / buttons inside the panels
   to match the dark + green-accent design language.
   ========================================= */

.page-mobile-sites .sidebar-panel .form-select,
.page-mobile-sites .sidebar-panel .form-control {
    background-color: var(--ls-bg-input);
    border: 1px solid #444;
    color: #f0f0f0;
    font-size: 0.82rem;
    color-scheme: dark;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.page-mobile-sites .sidebar-panel .form-select:focus,
.page-mobile-sites .sidebar-panel .form-control:focus {
    background-color: var(--ls-bg-input);
    border-color: var(--ls-accent);
    color: #f0f0f0;
    box-shadow: 0 0 0 0.15rem var(--ls-accent-glow);
}

.page-mobile-sites .sidebar-panel .form-control::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.page-mobile-sites .sidebar-panel .filter-label {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
}

.page-mobile-sites .sidebar-panel .text-muted,
.page-mobile-sites .sidebar-panel .text-light,
.page-mobile-sites .sidebar-panel small.text-muted {
    color: rgba(255, 255, 255, 0.5) !important;
}

.page-mobile-sites .sidebar-panel .filter-group {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ls-border-subtle);
    border-radius: 8px;
}

/* Buttons — turn the Bootstrap variants into themed greens / outlines */
.page-mobile-sites .sidebar-panel .btn-success,
.page-mobile-sites .sidebar-panel .btn-primary {
    background: var(--ls-accent);
    border: 1px solid var(--ls-accent);
    color: #000;
    font-weight: 600;
    font-size: 0.78rem;
}

.page-mobile-sites .sidebar-panel .btn-success:hover,
.page-mobile-sites .sidebar-panel .btn-primary:hover {
    filter: brightness(1.15);
    color: #000;
}

.page-mobile-sites .sidebar-panel .btn-info {
    background: rgba(52, 152, 219, 0.18);
    border: 1px solid rgba(52, 152, 219, 0.5);
    color: #5dade2;
    font-weight: 600;
    font-size: 0.78rem;
}

.page-mobile-sites .sidebar-panel .btn-info:hover {
    background: rgba(52, 152, 219, 0.28);
    color: #fff;
}

.page-mobile-sites .sidebar-panel .btn-info.disabled,
.page-mobile-sites .sidebar-panel .btn-info[disabled] {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
    opacity: 1;
}

.page-mobile-sites .sidebar-panel .btn-outline-danger {
    background: transparent;
    border: 1px solid rgba(231, 76, 60, 0.5);
    color: #f5b8b1;
    font-weight: 500;
    font-size: 0.78rem;
}

.page-mobile-sites .sidebar-panel .btn-outline-danger:hover {
    background: rgba(231, 76, 60, 0.18);
    color: #fff;
    border-color: var(--ls-danger);
}

.page-mobile-sites .sidebar-panel .btn-outline-danger:disabled {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
}

.page-mobile-sites .sidebar-panel hr,
.page-mobile-sites .sidebar-panel .border-bottom {
    border-color: var(--ls-border-subtle) !important;
}

.page-mobile-sites .sidebar-panel .badge.bg-info {
    background: rgba(0, 188, 140, 0.18) !important;
    color: var(--ls-accent) !important;
    border: 1px solid var(--ls-accent-border);
    border-radius: 10px;
    padding: 3px 9px;
    font-size: 0.65rem;
    font-weight: 600;
}

/* =========================================
   RIGHT PANEL CONTENT — themed Bootstrap overrides
   The link details panel HTML is built dynamically by JS
   using bootstrap classes; these overrides give it the dark
   + green-accent look.
   ========================================= */

.page-mobile-sites .ms-right-panel {
    background-color: var(--ls-bg-popup);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.page-mobile-sites .ms-right-panel .panel-header {
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.page-mobile-sites .ms-right-panel .panel-title {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-mobile-sites .ms-right-panel .panel-controls .btn {
    background: transparent;
    border: 1px solid var(--ls-border-medium);
    color: rgba(255, 255, 255, 0.7);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
}

.page-mobile-sites .ms-right-panel .panel-controls .btn:hover {
    background: var(--ls-border-subtle);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

.page-mobile-sites .ms-right-panel .panel-controls .btn-danger:hover {
    background: rgba(231, 76, 60, 0.25);
    border-color: var(--ls-danger);
    color: #fff;
}

.page-mobile-sites .ms-right-panel .form-label-sm {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.page-mobile-sites .ms-right-panel .panel-data-field {
    color: #f0f0f0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ls-border-subtle);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 500;
}

.page-mobile-sites .ms-right-panel .panel-data-notes {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ls-border-subtle);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.78rem;
    margin: 0;
}

.page-mobile-sites .ms-right-panel .text-warning {
    color: var(--ls-accent) !important;
    font-weight: 600;
}

.page-mobile-sites .ms-right-panel .text-muted {
    color: rgba(255, 255, 255, 0.45) !important;
}

.page-mobile-sites .ms-right-panel .text-light {
    color: #f0f0f0 !important;
}

.page-mobile-sites .ms-right-panel hr,
.page-mobile-sites .ms-right-panel .border-secondary {
    border-color: var(--ls-border-subtle) !important;
}

.page-mobile-sites .ms-right-panel .badge.bg-secondary {
    background: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.8) !important;
    border-radius: 10px;
    padding: 3px 9px;
    font-size: 0.65rem;
    font-weight: 600;
}

.page-mobile-sites .ms-right-panel .alert.alert-dark {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ls-border-subtle);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.78rem;
}

.page-mobile-sites .ms-right-panel .alert.alert-danger {
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #f5c4be;
}

/* Status badge inside the panel — match the popup status pill */
.page-mobile-sites .ms-right-panel .status-badge {
    border-radius: 10px;
    padding: 4px 10px;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.page-mobile-sites .ms-right-panel .status-badge.status-pending {
    background: rgba(231, 76, 60, 0.18);
    color: #f5b8b1;
    border-color: rgba(231, 76, 60, 0.5);
}

.page-mobile-sites .ms-right-panel .status-badge.status-inprogress {
    background: rgba(52, 152, 219, 0.18);
    color: #b8d8f0;
    border-color: rgba(52, 152, 219, 0.5);
}

.page-mobile-sites .ms-right-panel .status-badge.status-complete {
    background: rgba(0, 188, 140, 0.18);
    color: #a8e6d2;
    border-color: rgba(0, 188, 140, 0.5);
}

/* Right panel buttons — themed bootstrap overrides */
.page-mobile-sites .ms-right-panel .btn-primary {
    background: var(--ls-accent);
    border: 1px solid var(--ls-accent);
    color: #000;
    font-weight: 600;
    font-size: 0.78rem;
}

.page-mobile-sites .ms-right-panel .btn-primary:hover {
    filter: brightness(1.15);
    color: #000;
}

.page-mobile-sites .ms-right-panel .btn-success {
    background: rgba(0, 188, 140, 0.18);
    border: 1px solid rgba(0, 188, 140, 0.5);
    color: var(--ls-accent);
    font-weight: 600;
    font-size: 0.78rem;
}

.page-mobile-sites .ms-right-panel .btn-success:hover {
    background: rgba(0, 188, 140, 0.28);
    color: #fff;
}

.page-mobile-sites .ms-right-panel .btn-outline-warning {
    background: transparent;
    border: 1px solid rgba(241, 196, 15, 0.5);
    color: #f1c40f;
    font-weight: 500;
}

.page-mobile-sites .ms-right-panel .btn-outline-warning:hover {
    background: rgba(241, 196, 15, 0.15);
    color: #fff;
    border-color: #f1c40f;
}

.page-mobile-sites .ms-right-panel .btn-outline-success {
    background: transparent;
    border: 1px solid rgba(0, 188, 140, 0.5);
    color: #a8e6d2;
    font-weight: 500;
}

.page-mobile-sites .ms-right-panel .btn-outline-success:hover {
    background: rgba(0, 188, 140, 0.18);
    color: #fff;
    border-color: var(--ls-accent);
}

.page-mobile-sites .ms-right-panel .btn-outline-danger {
    background: transparent;
    border: 1px solid rgba(231, 76, 60, 0.5);
    color: #f5b8b1;
    font-weight: 500;
}

.page-mobile-sites .ms-right-panel .btn-outline-danger:hover {
    background: rgba(231, 76, 60, 0.18);
    color: #fff;
    border-color: var(--ls-danger);
}

/* Neutral action, sized to match .btn-primary above. */
.page-mobile-sites .ms-right-panel .btn-outline-secondary {
    background: transparent;
    border: 1px solid var(--ls-border-medium);
    color: #c5ccd3;
    font-weight: 500;
    font-size: 0.78rem;
}

.page-mobile-sites .ms-right-panel .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: var(--ls-border-light);
}

.page-mobile-sites .ms-right-panel .form-select,
.page-mobile-sites .ms-right-panel .form-control {
    background-color: var(--ls-bg-input);
    border: 1px solid #444;
    color: #f0f0f0;
    font-size: 0.82rem;
    color-scheme: dark;
}

.page-mobile-sites .ms-right-panel .form-select:focus,
.page-mobile-sites .ms-right-panel .form-control:focus {
    background-color: var(--ls-bg-input);
    border-color: var(--ls-accent);
    color: #f0f0f0;
    box-shadow: 0 0 0 0.15rem var(--ls-accent-glow);
}

/* Report card — restyled list item */
.page-mobile-sites .ms-right-panel .report-item.card {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid var(--ls-border-subtle) !important;
    border-radius: 8px !important;
}

.page-mobile-sites .ms-right-panel .report-item .card-header,
.page-mobile-sites .ms-right-panel .report-item .card-footer {
    background: transparent !important;
    border-color: rgba(255, 255, 255, 0.06) !important;
}

.page-mobile-sites .ms-right-panel .report-item:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--ls-accent-border) !important;
}

.page-mobile-sites .ms-right-panel .report-filename {
    color: #f0f0f0 !important;
}

/* =========================================
   RIGHT PANEL TABS
   ========================================= */

/* Pinned to the top of the scrolling panel content. */
.ms-panel-tabs {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    padding: 0 1rem;
    background: var(--ls-bg-popup);
    border-bottom: 1px solid var(--ls-border-subtle);
}

.ms-panel-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--ls-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.ms-panel-tab:hover {
    color: #f0f0f0;
}

.ms-panel-tab.active {
    color: var(--ls-accent);
    border-bottom-color: var(--ls-accent);
}

.ms-panel-tab-count {
    background: var(--ls-neutral-bg);
    color: var(--ls-text-muted);
    border-radius: 20px;
    padding: 0.05rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
}

.ms-panel-tab.active .ms-panel-tab-count {
    background: var(--ls-accent-bg);
    color: var(--ls-accent);
}

.ms-panel-pane {
    display: none;
}

.ms-panel-pane.active {
    display: block;
}

/* =========================================
   SITES TAB
   ========================================= */

.ms-site-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ls-border-subtle);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.ms-site-role {
    font-size: 0.65rem;
    color: var(--ls-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.ms-site-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f8f9fa;
    line-height: 1.35;
    word-break: break-word;
}

/* Sits directly under the name: the two read as one identity block. */
.ms-site-coords {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: var(--ls-text-muted);
    font-variant-numeric: tabular-nums;
}

.ms-site-card .btn {
    margin-top: 0.7rem;
}

.ms-panel-note {
    display: flex;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--ls-text-muted);
    background: var(--ls-neutral-bg);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
}

/* Shown only while the coordinates in the site form differ from the stored ones. */
.ms-hop-warning {
    display: none;
    background: var(--ls-warning-bg);
    border: 1px solid rgba(246, 194, 62, 0.3);
    border-radius: 6px;
    padding: 0.6rem 0.7rem;
    margin-bottom: 0.85rem;
}

.ms-hop-warning.show {
    display: block;
}

.ms-hop-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: #f8f9fa;
    cursor: pointer;
    margin-bottom: 0;
}

.ms-hop-check .form-check-input {
    margin: 0;
    flex: 0 0 auto;
}

.ms-hop-check .form-check-input:checked {
    background-color: var(--ls-accent);
    border-color: var(--ls-accent);
}

.ms-hop-detail {
    margin-top: 0.35rem;
    font-size: 0.7rem;
    color: var(--ls-text-muted);
}

/* =========================================
   LINK EDIT FORM
   ========================================= */

/* A container query, not a media query: the panel resizes on expand while the viewport does not. */
.ms-edit-form {
    container-type: inline-size;
    padding: 1rem;
}

.ms-edit-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 0.75rem;
}

@container (min-width: 520px) {
    .ms-edit-grid {
        grid-template-columns: 1fr 1fr;
    }

    .ms-edit-grid .ms-edit-field-wide {
        grid-column: 1 / -1;
    }
}

.ms-edit-field {
    margin-bottom: 0.85rem;
}

/* Read-only header showing the link's endpoint sites. */
.ms-edit-context {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ls-border-subtle);
    border-left: 2px solid var(--ls-accent-border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    margin-bottom: 1rem;
}

.ms-edit-context-route {
    font-size: 0.8rem;
    color: #f0f0f0;
}

.ms-edit-context-hint {
    font-size: 0.7rem;
    color: var(--ls-text-muted);
    margin-top: 0.15rem;
}

.ms-edit-error {
    display: none;
    font-size: 0.7rem;
    color: #f5b8b1;
    margin-top: 0.25rem;
}

.ms-edit-field.has-error .ms-edit-error {
    display: block;
}

.page-mobile-sites .ms-right-panel .ms-edit-field.has-error .form-control {
    border-color: var(--ls-danger);
}

.page-mobile-sites .ms-right-panel .ms-edit-field.has-error .form-control:focus {
    border-color: var(--ls-danger);
    box-shadow: 0 0 0 0.15rem rgba(231, 76, 60, 0.25);
}

/* Pinned to the bottom of the panel; the form scrolls beneath it. */
.ms-edit-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0 -1rem -1rem;
    background: var(--ls-bg-popup);
    border-top: 1px solid var(--ls-border-subtle);
}

.ms-edit-actions .btn {
    flex: 1;
}

.ms-edit-form-error {
    display: none;
    font-size: 0.75rem;
    color: #f5b8b1;
    background: var(--ls-danger-bg);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.75rem;
}

.ms-edit-form-error.show {
    display: block;
}

/* Applied to a read-mode field for one cycle after a save changes it. */
@keyframes ms-field-flash {
    from {
        background-color: var(--ls-accent-bg);
        border-color: var(--ls-accent-border);
    }
    to {
        background-color: transparent;
        border-color: transparent;
    }
}

.ms-field-flash {
    border-radius: 4px;
    border: 1px solid transparent;
    margin: 0 -0.35rem;
    padding: 0 0.35rem;
    animation: ms-field-flash 1.6s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .ms-field-flash {
        animation: none;
    }
}
