:root {
    --fondo: #0b1220;
    --superficie: #152033;
    --superficie-2: #1c2b42;
    --borde: #2d3f5c;
    --texto: #f3f6fb;
    --muted: #9db0c9;
    --acento: #f59e0b;
    --acento-hover: #fbbf24;
    --ok: #34d399;
    --error: #f87171;
    --azul: #38bdf8;
    --tabbar: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --radio: 16px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    padding-top: var(--safe-top);
    padding-bottom: calc(var(--tabbar) + var(--safe-bottom) + 8px);
}

button,
.boton,
a,
input {
    touch-action: manipulation;
}

a {
    color: var(--acento);
    text-decoration: none;
}

.app {
    width: min(560px, 100%);
    margin: 0 auto;
    padding: 12px 16px 24px;
}

.topbar {
    margin-bottom: 14px;
}

.marca {
    margin: 0 0 2px;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

h1 {
    margin: 0;
    font-size: 1.55rem;
    line-height: 1.2;
}

.subtitulo {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.tarjeta {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 20px;
    padding: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.92rem;
}

input[type="text"],
input[type="search"] {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--borde);
    background: var(--superficie-2);
    color: var(--texto);
    font-size: 16px;
    appearance: none;
    -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="search"]:focus {
    outline: 2px solid rgba(245, 158, 11, 0.45);
    border-color: var(--acento);
}

.campo {
    margin-bottom: 16px;
}

.camara {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    background: #071018;
    border: 1px dashed var(--borde);
    min-height: 220px;
}

.camara img {
    display: block;
    width: 100%;
    height: 240px;
    object-fit: cover;
}

.camara .placeholder {
    min-height: 220px;
    display: grid;
    place-items: center;
    color: var(--muted);
    text-align: center;
    padding: 24px 18px;
    font-size: 0.95rem;
    line-height: 1.45;
}

.acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.acciones-foto {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

button,
.boton {
    appearance: none;
    border: 0;
    border-radius: 14px;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    color: inherit;
}

.primario {
    background: var(--acento);
    color: #111827;
}

.secundario {
    background: var(--superficie-2);
    color: var(--texto);
    border: 1px solid var(--borde);
}

a.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.boton.bloque,
button.bloque {
    width: 100%;
}

.maps {
    background: #1a73e8;
    color: #fff;
}

.oculto {
    display: none !important;
}

.coords {
    margin-top: 14px;
    padding: 14px;
    border-radius: 16px;
    background: #071018;
    border: 1px solid var(--borde);
    font-size: 0.9rem;
    line-height: 1.45;
}

.coords span {
    color: var(--ok);
}

.coords.alerta-gps span {
    color: var(--error);
}

.coords dl {
    margin: 0;
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 6px 10px;
}

.coords dt {
    color: var(--muted);
    font-weight: 700;
}

.coords dd {
    margin: 0;
    color: var(--ok);
    word-break: break-all;
}

.gps-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(52, 211, 153, 0.12);
    color: var(--ok);
    font-size: 0.82rem;
    font-weight: 700;
}

.alerta {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.4;
}

.ok {
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: var(--ok);
}

.error {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: var(--error);
}

.barra-guardar {
    position: sticky;
    bottom: calc(var(--tabbar) + var(--safe-bottom) + 10px);
    z-index: 20;
    margin-top: 16px;
    padding-top: 8px;
}

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    height: calc(var(--tabbar) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(11, 18, 32, 0.96);
    border-top: 1px solid var(--borde);
    backdrop-filter: blur(16px);
}

.tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.tabbar svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tabbar a.activo {
    color: var(--acento);
}

.buscador-fijo {
    position: sticky;
    top: var(--safe-top);
    z-index: 10;
    margin: -12px -16px 14px;
    padding: 12px 16px;
    background: rgba(11, 18, 32, 0.94);
    backdrop-filter: blur(12px);
}

.lista-cards {
    display: grid;
    gap: 12px;
}

.card-auto {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 12px;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 18px;
    overflow: hidden;
    color: inherit;
    align-items: stretch;
}

.card-auto > a {
    display: block;
    height: 100%;
}

.card-auto img {
    width: 92px;
    height: 100%;
    min-height: 92px;
    object-fit: cover;
    background: #071018;
}

.card-cuerpo {
    padding: 12px 12px 12px 0;
    min-width: 0;
}

.card-cuerpo h2 {
    margin: 0 0 6px;
    font-size: 1.05rem;
}

.card-cuerpo p {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.card-cuerpo .boton {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.88rem;
}

.vacio {
    text-align: center;
    color: var(--muted);
    padding: 48px 16px;
}

html.pagina-mapa,
html.pagina-mapa body {
    height: 100%;
    overflow: hidden;
}

body.pagina-mapa {
    padding: 0;
}

body.pagina-mapa .tabbar {
    position: relative;
}

.mapa-app {
    height: 100dvh;
    display: grid;
    grid-template-rows: 1fr auto auto;
}

.mapa-lienzo {
    position: relative;
    min-height: 0;
}

#mapa {
    height: 100%;
    width: 100%;
    background: #1a2a1a;
}

#mapa .leaflet-tile {
    image-rendering: auto;
}

.mapa-top {
    position: absolute;
    top: calc(10px + var(--safe-top));
    left: 12px;
    right: 12px;
    z-index: 500;
}

.mapa-busqueda {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.mapa-busqueda input {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.mapa-resultados {
    margin-top: 8px;
    max-height: 38dvh;
    overflow: auto;
    background: rgba(15, 20, 25, 0.96);
    border: 1px solid var(--borde);
    border-radius: 16px;
}

.mapa-estado {
    margin: 8px 2px 0;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(11, 18, 32, 0.82);
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.mapa-estado.error-texto {
    color: var(--error);
}

.mapa-vacio {
    color: var(--muted);
    padding: 16px;
}

.item-auto {
    width: 100%;
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 10px;
    align-items: center;
    text-align: left;
    background: transparent;
    color: var(--texto);
    border: 0;
    border-bottom: 1px solid var(--borde);
    border-radius: 0;
    min-height: 64px;
    padding: 8px 12px;
}

.item-auto:last-child {
    border-bottom: 0;
}

.item-auto img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 10px;
}

.item-auto span {
    display: grid;
    gap: 2px;
}

.item-auto small {
    color: var(--muted);
}

.item-auto.activo {
    background: rgba(245, 158, 11, 0.12);
}

.mapa-fabs {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: grid;
    gap: 8px;
    z-index: 500;
}

.fab {
    width: 52px;
    min-height: 52px;
    padding: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.fab svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ficha-auto {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 12px;
    padding: 12px 16px 10px;
    background: rgba(11, 18, 32, 0.97);
    border-top: 1px solid var(--borde);
}

.ficha-auto img {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 12px;
    background: #071018;
}

.ficha-auto h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
}

.ficha-auto p {
    margin: 0 0 4px;
    font-size: 0.9rem;
}

.ficha-auto .meta {
    color: var(--muted);
    font-size: 0.75rem;
}

.ficha-auto .acciones {
    margin-top: 8px;
}

.ficha-auto .acciones .boton,
.ficha-auto .acciones button {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.marcador-auto {
    border: 3px solid #f59e0b;
    border-radius: 50%;
    overflow: hidden;
    background: #0b1220;
    box-shadow: 0 0 0 3px rgba(15, 20, 25, 0.65);
}

.marcador-auto img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.marcador-auto.activo {
    border-color: #fff;
    box-shadow: 0 0 0 4px #f59e0b;
}

.yo-marker {
    background: none;
    border: 0;
}

.yo-punto {
    width: 16px;
    height: 16px;
    margin: 3px;
    border-radius: 50%;
    background: var(--azul);
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.45);
}

.yo-pulso {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.28);
    animation: pulso 1.8s ease-out infinite;
}

@keyframes pulso {
    from { transform: scale(0.7); opacity: 0.8; }
    to { transform: scale(1.8); opacity: 0; }
}

.leaflet-control-zoom {
    margin-bottom: 12px !important;
    margin-left: 12px !important;
}

.leaflet-control-zoom a {
    background: #1a2332 !important;
    color: #e8eef6 !important;
    border-color: #334155 !important;
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
}

.leaflet-control-attribution {
    font-size: 9px !important;
    background: rgba(11, 18, 32, 0.7) !important;
    color: #9db0c9 !important;
}

@media (min-width: 720px) {
    .app {
        padding-top: 24px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .camara img,
    .camara .placeholder {
        min-height: 300px;
        height: 300px;
    }
}
