
    :root {
      --primary: #1b2e20;
      --primary-light: #2d4a36;
      --accent: #ff6b00;
      --danger: #ff3333;
      --success: #00cc66;
      --text: #e0e0e0;
      --text-muted: #888;
      --bg-panel: rgba(30, 41, 35, 0.95);
      --border: rgba(255, 255, 255, 0.1);
    }

    * { box-sizing: border-box; font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
    body, html { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; background: #000; color: var(--text); }
    
    /* MAPA ABSOLUTO */
    #map { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1; }

    /* PANEL PRINCIPAL (BOTTOM SHEET / SIDEBAR) */
    .ui-panel {
      position: absolute;
      z-index: 2000;
      background: var(--bg-panel);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      box-shadow: 0 4px 20px rgba(0,0,0,0.5);
      display: flex;
      flex-direction: column;
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Móvil: Bottom Sheet */
    @media (max-width: 767px) {
      .ui-panel {
        bottom: 0; left: 0; right: 0;
        border-radius: 20px 20px 0 0;
        border-top: 1px solid var(--border);
        max-height: 85vh;
      }
      .ui-panel.collapsed { transform: translateY(calc(100% - 100px)); }
      .drag-handle { width: 40px; height: 5px; background: rgba(255,255,255,0.3); border-radius: 3px; cursor: grab; align-self: center; margin-bottom: 10px;}
      .drag-handle:active { cursor: grabbing; }
    }

    /* Escritorio: Floating Sidebar */
    @media (min-width: 768px) {
      .ui-panel {
        top: 20px; left: 20px; bottom: 20px; width: 400px;
        border-radius: 12px;
        border: 1px solid var(--border);
      }
      .drag-handle { display: none; }
      .ui-panel.collapsed { transform: none; } /* En escritorio no colapsa verticalmente */
      .fab-container { bottom: 30px !important; }
    }

    .panel-header { padding: 10px 20px 15px; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); }
    .panel-header-top { display: flex; justify-content: space-between; align-items: center; width: 100%; cursor: pointer; }
    .panel-header h2 { margin: 0; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); display:flex; align-items:center; gap:8px;}
    .status-badge { font-size: 0.8rem; background: var(--border); padding: 4px 8px; border-radius: 12px; }
    
    .panel-nav { display: flex; gap: 5px; background: rgba(0,0,0,0.3); padding: 5px; border-radius: 8px; margin-top: 15px; width: 100%;}
    .panel-nav-btn { flex: 1; background: transparent; border: none; color: var(--text-muted); padding: 8px 0; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; gap: 5px; transition: 0.2s; }
    .panel-nav-btn.active { background: var(--primary); color: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
    .panel-nav-btn:active { transform: scale(0.95); }

    .panel-content { padding: 15px 20px; overflow-y: auto; flex: 1; }
    .panel-view { display: none; }
    .panel-view.active { display: block; animation: fadeIn 0.3s; }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

    /* MARCADORES TÁCTICOS Y CALIBRACIÓN */
    .tactical-marker { border-radius: 50%; background: #ffcc00; border: 2px solid #000; box-shadow: 0 4px 6px rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; }
    .tactical-marker svg { stroke: #000; fill: none; }
    
    .target-marker { border-radius: 50%; background: rgba(220, 53, 69, 0.2); border: 2px solid var(--danger); box-shadow: 0 0 10px rgba(220,53,69,0.5); display: flex; align-items: center; justify-content: center; }
    
    .calibrating-halo { animation: pulseDashed 1.5s infinite; cursor: grab !important; outline: 3px dashed var(--danger); outline-offset: 3px; border-radius: 50%; }
    .calibrating-halo:active { cursor: grabbing !important; }
    @keyframes pulseDashed { 0% { outline-color: var(--danger); } 50% { outline-color: transparent; } 100% { outline-color: var(--danger); } }

    #toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
    .toast { background: rgba(0,0,0,0.85); color: #fff; padding: 10px 20px; border-radius: 6px; font-size: 0.9rem; font-weight: bold; box-shadow: 0 4px 10px rgba(0,0,0,0.5); animation: slideDown 0.3s forwards, fadeOut 0.3s 2.7s forwards; border-left: 4px solid var(--success); }
    @keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
    @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

    /* FORMULARIOS Y CONTROLES */
    .section { margin-bottom: 20px; }
    .section h3 { margin: 0 0 10px 0; font-size: 0.95rem; color: #fff; display:flex; align-items:center; gap:6px;}
    
    label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 5px; }
    input, select {
      width: 100%; padding: 12px;
      background: rgba(0,0,0,0.3); border: 1px solid var(--border);
      border-radius: 8px; color: #fff; font-size: 1rem; outline: none;
    }
    input:focus, select:focus { border-color: var(--accent); }
    
    .flex-row { display: flex; gap: 10px; }
    .flex-row > * { flex: 1; }

    /* Stepper Moderno */
    .stepper-modern { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: rgba(0,0,0,0.2); }
    .stepper-modern button { flex: 1; background: transparent; border: none; border-right: 1px solid var(--border); color: var(--accent); font-weight: bold; font-size: 1.1rem; cursor: pointer; padding: 10px 0; }
    .stepper-modern button:last-child { border-right: none; }
    .stepper-modern button:active { background: rgba(255,255,255,0.1); }
    .stepper-modern input { border: none; border-right: 1px solid var(--border); border-radius: 0; text-align: center; font-weight: bold; padding: 10px; }

    /* Botones */
    .btn {
      width: 100%; padding: 14px; border: none; border-radius: 8px;
      font-size: 1rem; font-weight: bold; cursor: pointer; text-transform: uppercase;
      display: flex; justify-content: center; align-items: center; gap: 8px;
      transition: all 0.2s;
    }
    .btn:active { transform: scale(0.98); }
    .btn-main { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(255,107,0,0.3); }
    .btn-secondary { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid var(--border); }
    .btn-danger { background: rgba(255,51,51,0.2); color: var(--danger); border: 1px solid var(--danger); }

    /* FABS (Botones flotantes) */
    .fab-container { position: absolute; right: 20px; bottom: 130px; z-index: 1000; display: flex; flex-direction: column; gap: 15px; }
    .fab { width: 50px; height: 50px; border-radius: 50%; background: var(--primary-light); border: 1px solid var(--border); color: #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; cursor: pointer; transition: transform 0.2s; }
    .fab:active { transform: scale(0.9); }
    .fab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; }

    /* Popups Tácticos */
    .leaflet-popup-content { font-size: 0.9rem; color: #333; }
    .leaflet-popup-content .popup-btn {
      background: #222; color: #fff; border: 1px solid #000; border-radius: 6px; padding: 6px 10px; width: 100%; text-align: center; font-size: 0.8rem; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 5px; font-weight: bold; margin-top: 2px;
    }
    .leaflet-popup-content .popup-btn:active { background: #444; }

    /* Modal (Herramientas / Historial) */
    .modal-overlay { position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); z-index: 2000; display: none; justify-content: center; align-items: center; }
    .modal-content { background: var(--primary); border: 1px solid var(--border); border-radius: 12px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); }
    .modal-close { float: right; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.5rem; }

    .resultado-card { background: rgba(0, 204, 102, 0.1); border: 1px solid var(--success); border-radius: 8px; padding: 15px; margin-top: 15px; }
    .resultado-card h4 { margin: 0 0 10px 0; color: var(--success); }
    
    .svg-icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    /* Brújula Web HUD */
    #brujula-hud { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 20, 15, 0.95); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); z-index: 3000; display: none; flex-direction: column; align-items: center; justify-content: center; color: #fff; overflow: hidden; transition: background 0.3s; }
    #brujula-hud.active { display: flex; }
    #brujula-video { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; object-fit: cover; z-index: -1; opacity: 0; transition: opacity 0.5s; pointer-events: none; }
    .brujula-close { position: absolute; top: 20px; right: 20px; width: 48px; height: 48px; border: none; background: rgba(255,255,255,0.1); border-radius: 50%; color: #fff; font-size: 2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
    .brujula-close:active { background: rgba(255,51,51,0.5); }
    .brujula-display { font-size: 5rem; font-weight: 900; font-family: monospace; color: var(--accent); margin-bottom: 20px; text-shadow: 0 0 20px rgba(255,107,0,0.5); }
    .brujula-ring-container { position: relative; width: 280px; height: 280px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2); box-shadow: inset 0 0 30px rgba(0,0,0,0.8); }
    .brujula-ring { position: absolute; width: 100%; height: 100%; transition: transform 0.05s linear; will-change: transform; }
    .brujula-mark { position: absolute; left: 50%; bottom: 50%; transform-origin: center bottom; width: 2px; height: 15px; background: rgba(255,255,255,0.5); margin-left: -1px; }
    .brujula-mark.major { height: 25px; background: #fff; width: 4px; margin-left: -2px; }
    .brujula-label { position: absolute; left: 50%; bottom: 50%; transform-origin: center bottom; width: 40px; text-align: center; margin-left: -20px; padding-bottom: 35px; font-weight: bold; color: rgba(255,255,255,0.8); font-size: 1.1rem; }
    .brujula-label.norte { color: var(--danger); font-size: 1.4rem; }
    .brujula-crosshair { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 4px; height: 40px; background: var(--danger); z-index: 10; border-radius: 2px; box-shadow: 0 0 10px red; }
    .brujula-actions { position: absolute; bottom: 30px; width: 90%; max-width: 400px; display: flex; flex-direction: column; gap: 10px; }
    .brujula-permission-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.95); z-index: 3010; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; text-align: center; }
  
.badge { padding: 3px 8px; border-radius: 12px; color: white; font-size: 0.85em; font-weight: bold; display: inline-block; margin: 2px; }
.badge-zona { background-color: #b91c1c; }
.badge-comarca { background-color: #ea580c; }
.badge-biif { background-color: #16a34a; }
.badge-112 { background-color: #0891b2; }
.badge-comarca112 { background-color: #2563eb; }

/* === GPS FAB === */
.gps-fab {
    position: absolute;
    bottom: 120px;
    right: 20px;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: white;
    border: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gps-fab:active {
    background-color: #f0f0f0;
}

/* === Pulsating Blue Dot === */
.pulsating-dot-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}
.pulsating-dot {
    width: 14px;
    height: 14px;
    background-color: #2a93ee;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
    position: relative;
}
.pulsating-dot::after {
    content: "";
    display: block;
    position: absolute;
    top: -14px;
    left: -14px;
    width: 38px;
    height: 38px;
    background-color: #2a93ee;
    border-radius: 50%;
    opacity: 0.5;
    animation: ripple 1.5s infinite ease-in-out;
    z-index: -1;
}
@keyframes ripple {
    0% { transform: scale(0.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 0; }
}

/* === GATEKEEPER MODAL === */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    padding: 1rem;
}

.modal-card {
    background: #1e1e1e;
    border: 1px solid #ffb300;
    box-shadow: 0 0 40px rgba(255, 179, 0, 0.15);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    color: #e0e0e0;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

.modal-icon {
    font-size: 3rem; margin-bottom: 0.5rem; display: block; text-align: center;
}

.modal-title {
    text-align: center; color: #ffb300; font-size: 1.5rem; 
    margin: 0 0 1rem 0; text-transform: uppercase; letter-spacing: 1px;
    border-bottom: 1px solid #333; padding-bottom: 1rem;
}

.modal-body { font-size: 0.95rem; line-height: 1.6; color: #ccc; }
.modal-body ul { list-style: none; padding: 0; margin: 0 0 1.5rem 0; }
.modal-body li { 
    margin-bottom: 0.8rem; padding-left: 1.5rem; position: relative; 
}
.modal-body li::before {
    content: "➤"; color: #ffb300; position: absolute; left: 0; top: 0; font-size: 0.8rem;
}
.modal-warning {
    background: rgba(255, 87, 34, 0.1); border-left: 4px solid #ff5722;
    padding: 0.8rem; margin-bottom: 1rem; font-size: 0.85rem; color: #ffab91;
    border-radius: 0 4px 4px 0;
}

.btn-gatekeeper {
    border: none; padding: 1rem 1.2rem; border-radius: 8px; cursor: pointer;
    font-weight: 600; font-size: 1rem; transition: all 0.2s; display: inline-flex; 
    align-items: center; justify-content: center; gap: 0.5rem; text-decoration: none;
    background: #ff9800; color: black; box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}
.btn-gatekeeper:hover { background: #f57c00; transform: translateY(-1px); }
