/* ========== RESET Y BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #2c3e50;
    overflow: hidden;
    height: 100vh;
}

/* ========== SPLASH SCREEN ========== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.8s ease-in-out, visibility 0.8s ease-in-out;
    opacity: 1;
    visibility: visible;
}

.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

 .splash-content { text-align: center; max-width: 90%; animation: gentleScale 1.2s ease-out; }
.splash-content img { max-width: 280px; width: 100%; height: auto; display: block; margin: 0 auto; border-radius: 24px; box-shadow: 0 20px 35px -10px rgba(0,0,0,0.1); }
@keyframes gentleScale { 0% { transform: scale(.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.splash-sub { margin-top: 24px; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, sans-serif; font-size: 1rem; color: #2c3e4e; font-weight: 500; letter-spacing: .3px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.splash-sub span { animation: pulseOpacity 1.4s infinite; }
.splash-sub span:nth-child(2) { animation-delay: .2s; }
.splash-sub span:nth-child(3) { animation-delay: .4s; }
@keyframes pulseOpacity { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

.district-control { position:absolute; z-index:950; top:14px; left:50%; transform:translateX(-50%); display:flex; align-items:center; gap:8px; flex-wrap:wrap; width:max-content; max-width:calc(100% - 24px); padding:9px 12px; background:#fff; border-radius:12px; box-shadow:0 3px 15px #0003; font-size:13px; }
.district-control label { font-weight:700; color:#18385f }
.district-control select,.district-control button { padding:7px 9px; border:1px solid #b9c9d8; border-radius:7px; background:white; color:#193552; font:inherit }
.district-control button[aria-pressed="true"] { background:#164d8a; color:white }
.district-control small { flex-basis:100%; color:#52697a; font-size:11px }
@media(max-width:768px) { .district-control { top:10px; width:calc(100% - 20px); justify-content:center } .district-control select { max-width:65% } body.sheet-open .district-control { display:none } }

/* ========== MAIN APP ========== */
#mainApp {
    opacity: 0;
    transition: opacity 0.5s ease;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Desktop layout */
.container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sección izquierda (lista) */
.section.left {
    width: 30%;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
}

/* Sección derecha (mapa) */
.section.right {
    width: 70%;
    background: #2c3e50;
    position: relative;
}

/* Divider solo visible en desktop */
.divider {
    width: 4px;
    background: #cbd5e0;
    cursor: col-resize;
    transition: background 0.2s;
}

.divider:hover {
    background: #3498db;
}

/* ========== HEADER LISTA ========== */
.lista-header {
    background: white;
    padding: 16px 20px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

.banner-img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin-bottom: 12px;
}

.lista-header h2 {
    color: #2c3e50;
    font-size: 1.4rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#total-records {
    background: #3498db;
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    padding: 0 16px;
    gap: 4px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
}

.tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    font-weight: 500;
    color: #7f8c8d;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.filter-icon {
    flex: 0;
    padding: 12px 16px;
    font-size: 1.2rem;
    cursor: pointer;
    color: #7f8c8d;
}

.filter-icon:hover {
    color: #3498db;
}

/* ========== LISTA DE REPORTES ========== */
.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f8f9fa;
}

.tab-content.hidden {
    display: none;
}

/* Items de la lista */
.report-item {
    background: white;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}

.details-expanded {
    flex-basis: 100%;
}

.report-body {
    flex: 1;
    min-width: 0;
}

.report-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.report-ref {
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: nowrap;
}

.category-badge-main {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    letter-spacing: 0.2px;
}

.votes-badge {
    background: #eef2ff;
    color: #4f46e5;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}

@keyframes highlightPulse {
    0% { box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.55); background: #eff6ff; }
    100% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0); }
}

.highlight-report {
    animation: highlightPulse 1s ease 2;
}

/* Toolbar de reportes (orden por votos + modos de visualización) */
.report-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.report-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.report-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
}

.category-badge {
    background: #ecf0f1;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}

.report-description {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-bottom: 8px;
    line-height: 1.4;
}

.report-footer-list {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: #95a5a6;
    margin-top: 6px;
}

.report-meta-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.report-date {
    white-space: nowrap;
}

.report-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Botones de acción como chips cuadrados solo-icono */
.report-actions .icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.15s, background 0.2s;
}

.report-actions .icon-action:hover {
    transform: translateY(-1px);
}

.report-actions .view-on-map-btn {
    background: #eef2ff;
    color: #2563eb;
}

.report-actions .view-on-map-btn:hover {
    background: #dbeafe;
}

.report-actions .btn-done {
    background: #ecfdf5;
    color: #059669;
    width: 30px;
    margin-top: 0;
}

.report-actions .btn-done:hover {
    background: #d1fae5;
}

.report-actions .btn-delete-item {
    background: #fef2f2;
    color: #ef4444;
    border: none;
    width: 30px;
    margin-top: 0;
}

.report-actions .btn-delete-item:hover {
    background: #ef4444;
    color: #fff;
}

/* Botón de regreso a lista dentro del popup del mapa */
.popup-back-list {
    flex: 1;
    margin-top: 10px;
    padding: 8px 12px;
    border: none;
    border-radius: 20px;
    background: #2563eb;
    color: white;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.popup-back-list:hover {
    background: #1d4ed8;
}

/* Botón "Ir a Reporte" dentro del popup del mapa */
.popup-go-report {
    flex: 1;
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid #2563eb;
    border-radius: 20px;
    background: transparent;
    color: #2563eb;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, color 0.2s;
}

.popup-go-report:hover {
    background: #2563eb;
    color: white;
}

/* Botón de eliminar reporte dentro del popup del mapa (staff con permiso) */
.popup-delete {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    border: 1px solid #ef4444;
    border-radius: 20px;
    background: transparent;
    color: #ef4444;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, color 0.2s;
}

.popup-delete:hover {
    background: #ef4444;
    color: white;
}

/* ========== VISTA DETALLE EXPANDIDO ========== */
.details-expanded {
    margin-top: 12px;
    padding: 12px;
    background: #f0f2f5;
    border-radius: 10px;
}

.details-expanded img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: zoom-in;
}

.btn-done {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 10px;
}

.btn-delete-item {
    background: transparent;
    color: #ef4444;
    border: 1px solid #ef4444;
    padding: 8px;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 8px;
    transition: background 0.2s, color 0.2s;
}

.btn-delete-item:hover {
    background: #ef4444;
    color: white;
}

.btn-close {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 1.2rem;
    cursor: pointer;
}

/* ========== MAPA ========== */
#map {
    width: 100%;
    height: 100%;
    background: #cbd5e0;
}

/* ========== TOGGLE MÓVIL ========== */
.mobile-toggle {
    display: none;
    background: white;
    padding: 8px 16px;
    gap: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: #ecf0f1;
    color: #7f8c8d;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: #3498db;
    color: white;
}

/* Botón flotante móvil */
.fab-map {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #3498db;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    border: none;
    font-size: 1.3rem;
}

.fab-list {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #2c3e50;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    border: none;
    font-size: 1.3rem;
}

/* ========== FILTER POPUP ========== */
.popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.popup-content {
    background: white;
    width: min(400px, 92vw);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    animation: popIn 0.22s ease;
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.popup-content h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.popup-head h3 {
    margin-bottom: 0;
    font-size: 0.95rem;
}

.popup-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: #eef2f7;
    color: #475569;
    cursor: pointer;
    font-size: 0.9rem;
}

.popup-close:hover {
    background: #e2e8f0;
}

.popup-actions {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
    flex-shrink: 0;
}

.popup-actions .btn-sm {
    flex: 1;
    padding: 0.4rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.75rem;
    cursor: pointer;
}

.popup-actions .btn-sm:hover {
    background: #e2e8f0;
}

#category-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    max-height: 320px;
}

#category-list li {
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: #1e293b;
}

#category-list li .cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

#category-list li .cat-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#category-list li .cat-count {
    margin-left: auto;
    font-size: 0.7rem;
    color: #94a3b8;
    flex-shrink: 0;
}

#category-list li:hover {
    background: #ecf0f1;
}

#category-list li.highlight {
    background: #3498db;
    color: white;
}

#category-list li.highlight .cat-count {
    color: rgba(255,255,255,0.85);
}

#apply-filters {
    width: 100%;
    padding: 10px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 10px;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .popup-content {
        width: 400px;
    }
    #category-list {
        max-height: 380px;
    }
}

/* ========== MODAL IMAGEN ========== */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10002;
    align-items: center;
    justify-content: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .container {
        display: flex;
    }

    .section.left,
    .section.right {
        width: 100% !important;
        height: 100%;
    }

    .section.left.hide-on-mobile {
        display: none !important;
    }

    .section.right.hide-on-mobile {
        display: none !important;
    }

    .divider {
        display: none;
    }

    .mobile-toggle {
        display: flex;
    }

    .fab-map,
    .fab-list {
        display: flex;
    }
}

@media (min-width: 769px) {

    .fab-map,
    .fab-list {
        display: none;
    }

    .mobile-toggle {
        display: none;
    }
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.status-dot.resolved {
    background: #27ae60;
}

.status-dot.pending {
    background: #e74c3c;
}


/* ========== HEADER CON SCROLL BEHAVIOR - CIERRE COMPLETO ========== */
.lista-header {
    background: white;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
    overflow: hidden;
}

.lista-header.hide-header {
    padding: 0 !important;
    max-height: 0 !important;
    min-height: 0 !important;
    height: 0 !important;
    border-bottom: none;
    opacity: 0;
    margin: 0;
}

.lista-header .banner-img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.lista-header.hide-header .banner-img {
    display: none;
    margin: 0;
    padding: 0;
    height: 0;
}

.lista-header h2 {
    color: #2c3e50;
    font-size: 1.4rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    padding: 0;
}

.lista-header.hide-header h2 {
    font-size: 0;
    margin: 0;
    padding: 0;
    min-height: 0;
    height: 0;
    opacity: 0;
    visibility: hidden;
}

.lista-header.hide-header h2 span,
.lista-header.hide-header h2 #total-records {
    display: none;
    height: 0;
}

/* ========== NEW PUBLIC MAP LAYOUT ========== */

#map {
    width: 100%;
    height: 100%;
}

.map-full {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Contenedor de controles del mapa (zoom + pins) — esquina inferior derecha, L inversa */
.map-controls {
    position: fixed;
    bottom: 12px;
    right: 10px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

/* Zoom controls (movidos desde Leaflet a este contenedor) */
.map-zoom-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.map-zoom-controls .leaflet-control-zoom {
    margin: 0;
}

/* Toggle de pins: debajo del zoom */
.pin-mode-toggle {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 9px;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}
.pin-mode-btn {
    border: none;
    background: transparent;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 7px;
    color: #475569;
    cursor: pointer;
}
.pin-mode-btn.active {
    background: #2563eb;
    color: #fff;
}
.pin-mode-btn.reload-tiles-btn:hover {
    background: #0ea5e9;
    color: #fff;
}

/* Al abrir un sheet móvil (chat/reportes) se ocultan los controles del mapa */
body.sheet-open #mapControls {
    display: none;
}

/* Toast efímero del mapa público (recarga de tiles, etc.) */
.pub-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.pub-toast.show {
    opacity: 1;
}

/* Desktop Panels */
.panel {
    position: fixed;
    top: 1rem;
    bottom: 1rem;
    width: 340px;
    max-height: calc(100vh - 2rem);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s;
    opacity: 1;
}

.panel[aria-hidden="true"] {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-100%);
}

.panel-right[aria-hidden="true"] {
    transform: translateX(100%);
}

.panel-left {
    left: 1rem;
}

.panel-right {
    right: 1rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 16px 16px 0 0;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 1rem;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.panel-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: white;
}

.panel-tab {
    flex: 1;
    padding: 0.75rem 0.5rem;
    border: none;
    background: transparent;
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.panel-tab:hover {
    color: #334155;
    background: #f8fafc;
}

.panel-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* Filtros de tiempo (semana/mes/semestre/todas) */
.time-filter-bar {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.time-filter-btn {
    flex: 1;
    padding: 4px 6px;
    border: 1px solid #e2e8f0;
    background: white;
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.time-filter-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.time-filter-btn.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.panel-banner {
    padding: 0.5rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    transition: opacity 1.2s ease;
}

.panel-banner.banner-fadeout {
    opacity: 0;
}

.panel-banner img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-content {
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.chat-message.own {
    align-self: flex-end;
}

.chat-message.other {
    align-self: flex-start;
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    color: #64748b;
}

.chat-message-header .nickname {
    font-weight: 500;
    color: #475569;
    font-size: 0.75rem;
}

/* Registrados: azul + negritas. Anónimos: sin negritas por defecto. */
.chat-message.registered .nickname {
    font-weight: 700;
    color: #2563eb;
}

.chat-message.own .nickname {
    font-weight: 700;
    color: #2563eb;
}

/* Escudo de nivel del chat (icono, color según nivel/level_max) */
.chat-level-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.35rem;
    font-size: 0.85rem;
    vertical-align: middle;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
    opacity: 0.95;
    transition: transform 0.15s;
}

.chat-level-badge:hover {
    transform: scale(1.15);
    opacity: 1;
}

.chat-message-header .time {
    font-size: 0.65rem;
    color: #94a3b8;
}

.chat-message-text {
    background: #f1f5f9;
    padding: 0.6rem 0.85rem;
    border-radius: 18px 18px 18px 4px;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #1e293b;
    word-wrap: break-word;
}

.chat-message.own .chat-message-text {
    background: #2563eb;
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.chat-status {
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    color: #64748b;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-status .nickname {
    font-weight: 600;
    color: #1e293b;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0 0 16px 16px;
}

.chat-input-area input {
    flex: 1;
    padding: 0.6rem 0.9rem;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    font-size: 0.85rem;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-area input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.chat-input-area .btn-sm {
    width: 36px;
    height: 36px;
    border: none;
    background: #2563eb;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-input-area .btn-sm:hover {
    background: #1d4ed8;
}

/* FAB Buttons (Desktop) */
.fab-group {
    position: fixed;
    bottom: 1.5rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.fab-left {
    left: 1.5rem;
}

.fab-right {
    right: 1.5rem;
}

.fab {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    font-size: 1.3rem;
    box-shadow: 0 4px 16px rgba(37,99,235,0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(37,99,235,0.5);
    background: #1d4ed8;
}

.fab:active {
    transform: scale(0.98);
}

.fab-group .fab + .fab {
    background: #10b981;
}

.fab-group .fab + .fab:hover {
    background: #059669;
}

/* Mobile FAB Menu (single logo button + sub-menu circles) */
.fab-menu {
    display: none;
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 250;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    pointer-events: none;
}

.fab-menu.open {
    display: flex;
}

.fab-menu-items {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    opacity: 0;
    transform: translateY(16px) scale(0.6);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.fab-menu.open .fab-menu-item {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.fab-menu.open .fab-menu-item:nth-child(1) { transition-delay: 0.12s; }
.fab-menu.open .fab-menu-item:nth-child(2) { transition-delay: 0.08s; }
.fab-menu.open .fab-menu-item:nth-child(3) { transition-delay: 0.04s; }
.fab-menu.open .fab-menu-item:nth-child(4) { transition-delay: 0s; }

.fab-menu-item:active .fab-menu-icon {
    transform: scale(0.92);
}

.fab-menu-label {
    background: rgba(15, 23, 42, 0.85);
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    white-space: nowrap;
}

.fab-menu-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 16px rgba(37,99,235,0.4);
    transition: transform 0.15s ease;
}

.fab-menu-item[data-view="map"] .fab-menu-icon {
    background: #10b981;
    box-shadow: 0 4px 16px rgba(16,185,129,0.4);
}

.fab-menu-item[data-view="chat"] .fab-menu-icon {
    background: #2563eb;
    box-shadow: 0 4px 16px rgba(37,99,235,0.4);
}

.fab-menu-item[data-view="reports"] .fab-menu-icon {
    background: #f59e0b;
    box-shadow: 0 4px 16px rgba(245,158,11,0.4);
}

.fab-menu-item.fab-menu-admin .fab-menu-icon {
    background: #7c3aed;
    box-shadow: 0 4px 16px rgba(124,58,237,0.4);
}

.fab-menu-trigger {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: 3px solid white;
    background: white;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    pointer-events: auto;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fab-menu-trigger:hover {
    transform: scale(1.05);
}

.fab-menu-trigger:active {
    transform: scale(0.96);
}

.fab-menu-trigger img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Mobile Sheets */
.mobile-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    max-height: 92vh;
    background: white;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -12px 40px rgba(0,0,0,0.18);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
    z-index: 300;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-sheet.open {
    transform: translateY(0);
}

.sheet-handle {
    width: 48px;
    height: 5px;
    background: linear-gradient(90deg, #cbd5e1, #94a3b8, #cbd5e1);
    border-radius: 3px;
    margin: 1rem auto 0.75rem;
    cursor: grab;
    touch-action: none;
    transition: background 0.2s, transform 0.1s;
}
.sheet-handle:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 24px 24px 0 0;
    flex-shrink: 0;
}

.sheet-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sheet-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    line-height: 1;
    border-radius: 8px;
}
.sheet-close:hover {
    color: #1e293b;
    background: #e2e8f0;
}

.sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem 2rem;
    -webkit-overflow-scrolling: touch;
}

/* Chat sheet: ocupa todo el alto, mensajes flexibles */
.sheet-content.chat-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    min-height: 0;
}

.sheet-content.chat-content .chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 0.75rem;
}

.sheet-content.chat-content .chat-status,
.sheet-content.chat-content .chat-input-area {
    flex-shrink: 0;
}

/* Chat sheet full screen en móvil */
#mobileSheetChat.mobile-sheet {
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
}

#mobileSheetChat.mobile-sheet .sheet-header {
    border-radius: 0;
}

.sheet-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 250;
    opacity: 0;
    transition: opacity 0.3s;
}

.sheet-overlay.open {
    display: block;
    opacity: 1;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .panel {
        display: none !important;
    }
    .fab-group {
        display: none !important;
    }
    .fab-menu {
        display: flex;
    }
    .mobile-sheet {
        display: flex !important;
    }
}

@media (min-width: 769px) {
    .fab-menu {
        display: none !important;
    }
    .mobile-sheet {
        display: none !important;
    }
    .sheet-overlay {
        display: none !important;
    }
}

/* Report items in panels/sheets - reuse existing .report-item styles but adapt */
.panel-content .report-item,
.sheet-content .report-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.85rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.panel-content .report-item:hover,
.sheet-content .report-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.panel-content .report-header,
.sheet-content .report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.panel-content .report-title,
.sheet-content .report-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
    line-height: 1.3;
}

.panel-content .category-badge,
.sheet-content .category-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.panel-content .report-description,
.sheet-content .report-description {
    font-size: 0.75rem;
    color: #475569;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.panel-content .report-footer,
.sheet-content .report-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: #94a3b8;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== FLOATING CHAT (DESKTOP) ========== */
.floating-chat {
    position: fixed;
    right: 1.5rem;
    left: auto;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    z-index: 150;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    pointer-events: none;
}

.floating-chat > * {
    pointer-events: auto;
}

/* Dock derecho: centrado vertical, anclado a la derecha */
.floating-chat.docked-right {
    top: 50%;
    right: 1.5rem;
    left: auto;
    bottom: auto;
    transform: translateY(-50%);
    align-items: flex-end;
}

/* Dock izquierdo: centrado vertical, anclado a la izquierda */
.floating-chat.docked-left {
    top: 50%;
    right: auto;
    left: 1.5rem;
    bottom: auto;
    transform: translateY(-50%);
    align-items: flex-start;
}

/* Dock abajo: anclado abajo-derecha */
.floating-chat.docked-bottom {
    top: auto;
    right: 1.5rem;
    left: auto;
    bottom: 1.5rem;
    transform: none;
    align-items: flex-end;
}

/* Dock arriba: anclado arriba-derecha */
.floating-chat.docked-top {
    top: 1.5rem;
    right: 1.5rem;
    left: auto;
    bottom: auto;
    transform: none;
    align-items: flex-end;
}

/* Al abrir: tamaño razonable, positioned freely */
.floating-chat.open {
    transform: none;
}

.floating-chat.open .chat-window {
    width: 360px;
    height: 480px;
    min-width: 280px;
    min-height: 200px;
    max-width: calc(100vw - 3rem);
    max-height: calc(100vh - 3rem);
}

.floating-chat.dragged {
    transform: none;
}

.floating-chat.dragging {
    cursor: grabbing;
}

.floating-chat.dragging .chat-handle {
    cursor: grabbing;
}

/* ========== RESIZE HANDLES ========== */
.chat-resize-handle {
    position: absolute;
    z-index: 10;
}
.chat-resize-handle.edge-top    { top: -4px; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.chat-resize-handle.edge-bottom { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.chat-resize-handle.edge-left   { top: 8px; bottom: 8px; left: -4px; width: 8px; cursor: w-resize; }
.chat-resize-handle.edge-right  { top: 8px; bottom: 8px; right: -4px; width: 8px; cursor: e-resize; }
.chat-resize-handle.corner-tl   { top: -6px; left: -6px; width: 14px; height: 14px; cursor: nw-resize; }
.chat-resize-handle.corner-tr   { top: -6px; right: -6px; width: 14px; height: 14px; cursor: ne-resize; }
.chat-resize-handle.corner-bl   { bottom: -6px; left: -6px; width: 14px; height: 14px; cursor: sw-resize; }
.chat-resize-handle.corner-br   { bottom: -6px; right: -6px; width: 14px; height: 14px; cursor: se-resize; }

.chat-window {
    width: 340px;
    max-height: calc(100vh - 8rem);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.floating-chat:not(.open) .chat-window {
    display: none;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    background: #2563eb;
    color: white;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
}

.chat-header:active {
    cursor: grabbing;
}

.chat-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-controls {
    display: flex;
    gap: 0.3rem;
}

.chat-toggle,
.chat-close {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-toggle:hover,
.chat-close:hover {
    background: rgba(255,255,255,0.3);
}

.chat-handle {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    font-size: 1.3rem;
    box-shadow: 0 4px 16px rgba(37,99,235,0.4);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    touch-action: none;
    user-select: none;
}

.chat-handle:hover {
    transform: scale(1.05);
    background: #1d4ed8;
}

.chat-handle:active {
    cursor: grabbing;
}

.floating-chat.open .chat-handle {
    display: none;
}

@media (max-width: 768px) {
    .floating-chat {
        display: none !important;
    }
}
.home-back{position:fixed;top:12px;left:55px;z-index:1000;display:grid;place-items:center;width:40px;height:40px;border-radius:8px;background:#fff;color:#153e65;box-shadow:0 1px 5px #0005;text-decoration:none;font-size:24px;line-height:1}.home-back:focus-visible{outline:3px solid #2563eb;outline-offset:2px}
