@font-face { font-family: "DM Sans"; src: url("/fonts/dm-sans-latin-wght-normal.woff2") format("woff2"); font-weight: 100 1000; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "DM Sans"; src: url("/fonts/dm-sans-latin-ext-wght-normal.woff2") format("woff2"); font-weight: 100 1000; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --ink: #0B1622; --ink2: #13233A; --ink3: #1D3350;
  --paper: #F4F7F9; --card: #FFFFFF; --line: #DCE4EA;
  --text: #0E1B2A; --muted: #5B6B7A;
  --blue: #1E73BE; --sky: #6EC1F5; --amber: #F2A93B; --red: #D8433B; --green: #1E9E6A;
  --r: 16px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --shadow: 0 10px 30px rgba(11, 22, 34, .18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--ink); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 8px; }

/* ---------- mapa ---------- */
#map { position: fixed; inset: 0; background: #E8EEF1; }
.maplibregl-ctrl-bottom-right { bottom: calc(46vh + 4px); transition: bottom .3s; }
body[data-sheet="peek"] .maplibregl-ctrl-bottom-right { bottom: calc(118px + var(--sab)); }
body[data-sheet="full"] .maplibregl-ctrl-bottom-right { bottom: 8px; opacity: 0; }
.maplibregl-ctrl-attrib { font-size: 11px; }
.map-note { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); width: min(320px, 80vw); text-align: center; color: #5B6B7A; font-size: 14.5px; line-height: 1.45; }
.lf-cam { display: block; width: 20px; height: 20px; border-radius: 50%; background: #0B1622; border: 3px solid #6EC1F5; box-sizing: border-box; box-shadow: 0 1px 4px rgba(11, 22, 34, .4); }
.lf-cl { display: grid; place-items: center; border-radius: 50%; background: #1E73BE; color: #fff; font: 700 13px "DM Sans", sans-serif; border: 3px solid rgba(255, 255, 255, .92); box-sizing: border-box; box-shadow: 0 2px 8px rgba(11, 22, 34, .3); }
.leaflet-container { font-family: "DM Sans", sans-serif; background: #E8EEF1; }
.leaflet-bottom.leaflet-right { bottom: calc(46vh + 2px); }
body[data-sheet="peek"] .leaflet-bottom.leaflet-right { bottom: calc(112px + var(--sab)); }
.pulse { width: 22px; height: 22px; border-radius: 50%; background: var(--amber); border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(242, 169, 59, .6); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 18px rgba(242, 169, 59, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 169, 59, 0); } }

/* ---------- cabecera ---------- */
.top { position: fixed; z-index: 30; left: 0; right: 0; top: 0; padding: calc(10px + var(--sat)) 12px 14px; background: linear-gradient(180deg, rgba(11, 22, 34, .94) 0%, rgba(11, 22, 34, .82) 62%, rgba(11, 22, 34, 0) 100%); }
.brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.logo { display: inline-flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; }
.logo-mark { width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, var(--sky), var(--blue)); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(30, 115, 190, .45); }
.logo-mark i { width: 9px; height: 9px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .28); animation: live 2s infinite; }
@keyframes live { 50% { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0); } }
.logo-text { font-size: 19px; font-weight: 700; letter-spacing: -.4px; }
.logo-text b { font-weight: 400; opacity: .7; margin: 0 1px; }
.ghost { color: #D5E2EE; font-size: 14px; font-weight: 500; padding: 8px 10px; border-radius: 10px; }
.ghost.dark { color: var(--blue); font-weight: 600; background: #EAF2FA; padding: 8px 12px; white-space: nowrap; }

.search { position: relative; display: flex; align-items: center; background: #fff; border-radius: 16px; height: 54px; padding: 0 8px 0 16px; box-shadow: var(--shadow); }
.search-ico { color: var(--muted); width: 22px; height: 22px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 17px; padding: 0 10px; color: var(--text); }
.search input::placeholder { color: #7C8B99; }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); border-radius: 12px; }
.sug { position: absolute; left: 0; right: 0; top: 60px; margin: 0; padding: 6px; list-style: none; background: #fff; border-radius: 16px; box-shadow: var(--shadow); max-height: 56vh; overflow: auto; z-index: 5; }
.sug li { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; cursor: pointer; min-height: 52px; }
.sug li[aria-selected="true"], .sug li:hover { background: #EEF4F9; }
.sug .s-ico { width: 34px; height: 34px; border-radius: 10px; background: #EAF2FA; color: var(--blue); display: grid; place-items: center; flex: none; }
.sug .s-ico.road { background: #FFF3DD; color: #9A6406; }
.sug .s-main { font-weight: 600; font-size: 16px; line-height: 1.2; }
.sug .s-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.sug .s-none { color: var(--muted); cursor: default; }

.chips { display: flex; gap: 8px; margin: 10px -12px 0; padding: 0 12px 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 999px; background: rgba(255, 255, 255, .96); color: var(--text); font-size: 14.5px; font-weight: 600; box-shadow: 0 3px 10px rgba(11, 22, 34, .16); white-space: nowrap; }
.chip svg { width: 17px; height: 17px; }
.chip-strong { background: var(--blue); color: #fff; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip-sep { flex: none; width: 1px; margin: 8px 2px; background: rgba(255, 255, 255, .45); }

/* ---------- panel de cámaras ---------- */
.sheet { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: 46vh; background: var(--paper); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(11, 22, 34, .22); display: flex; flex-direction: column; transition: height .32s cubic-bezier(.2, .8, .2, 1); will-change: height; }
.sheet[data-state="peek"] { height: calc(110px + var(--sab)); }
.sheet[data-state="full"] { height: calc(100vh - var(--top-h, 180px) + 10px); height: calc(100dvh - var(--top-h, 180px) + 10px); }
.grab { width: 100%; height: 24px; display: grid; place-items: center; flex: none; touch-action: none; }
.grab i { width: 44px; height: 5px; border-radius: 3px; background: #C3CFD9; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0 16px 10px; flex: none; touch-action: none; }
.sheet-titles { min-width: 0; }
.sheet h1 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.3px; font-weight: 700; }
.sheet-head p { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 2px 12px calc(16px + var(--sab)); }

.wx { margin: 0 12px 10px; padding: 12px 14px; border-radius: var(--r); background: linear-gradient(135deg, var(--ink2), var(--ink3)); color: #fff; flex: none; }
.wx-now { display: flex; align-items: center; gap: 12px; }
.wx-now svg { width: 34px; height: 34px; stroke-width: 1.7; color: var(--sky); }
.wx-t { font-size: 30px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.wx-d { font-size: 15px; font-weight: 600; }
.wx-m { font-size: 13px; color: #B9CADB; margin-top: 2px; }
.wx-hours { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.wx-hours::-webkit-scrollbar { display: none; }
.wx-h { flex: 1 0 58px; text-align: center; padding: 7px 4px; border-radius: 12px; background: rgba(255, 255, 255, .08); font-size: 12.5px; color: #C9D8E6; }
.wx-h b { display: block; font-size: 15px; color: #fff; margin: 3px 0 1px; }
.wx-h svg { width: 18px; height: 18px; color: var(--sky); }
.wx-src { font-size: 11px; color: #8FA5BA; margin-top: 8px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cam { position: relative; display: block; width: 100%; text-align: left; border-radius: 14px; overflow: hidden; background: var(--ink2); aspect-ratio: 4 / 3; box-shadow: 0 2px 8px rgba(11, 22, 34, .12); }
.cam img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.cam img.ok { opacity: 1; }
.cam::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, #13233A 30%, #1D3350 50%, #13233A 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.cam.done::before { animation: none; background: #13233A; }
@keyframes shimmer { to { background-position: -200% 0; } }
.cam-shade { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 9px 8px; background: linear-gradient(180deg, rgba(11, 22, 34, 0), rgba(11, 22, 34, .88)); color: #fff; }
.cam-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cam-meta { font-size: 12px; color: #C6D4E1; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-dist { position: absolute; top: 7px; right: 7px; padding: 3px 8px; border-radius: 999px; background: rgba(11, 22, 34, .72); color: #fff; font-size: 12px; font-weight: 600; }
.cam-off { position: absolute; inset: 0; display: grid; place-items: center; color: #9FB3C6; font-size: 13px; padding: 0 10px 34px; text-align: center; }
.rb { display: inline-block; padding: 1px 6px; border-radius: 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; color: #fff; background: #44566A; margin-right: 5px; vertical-align: 1px; }
.rb.a { background: #1257A6; } .rb.n { background: #C4302B; } .rb.c { background: #D97A0B; }
.empty { text-align: center; color: var(--muted); padding: 28px 18px; font-size: 15px; line-height: 1.45; }
.foot { padding: 18px 6px 4px; color: #7A8997; font-size: 12px; line-height: 1.45; }
.foot p { margin: 0 0 6px; }
.link { color: var(--blue); font-weight: 600; text-decoration: underline; font-size: 13px; }

/* ---------- visor ---------- */
.viewer { position: fixed; inset: 0; z-index: 60; background: var(--ink); color: #fff; display: flex; flex-direction: column; overflow-y: auto; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.v-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: calc(8px + var(--sat)) 10px 8px; background: linear-gradient(180deg, rgba(11, 22, 34, .95), rgba(11, 22, 34, .6)); }
.v-btn { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); color: #fff; }
.v-btn svg { width: 24px; height: 24px; }
.v-btn.light { background: #EEF3F7; color: var(--text); }
.v-btn[aria-pressed="true"] { background: var(--red); }
.v-btn[aria-pressed="true"] svg { fill: #fff; }
.v-live { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; letter-spacing: 1.4px; color: #E6EEF6; }
.v-live i { width: 9px; height: 9px; border-radius: 50%; background: #FF4D43; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.v-stage { position: relative; background: #000; min-height: 220px; display: grid; place-items: center; flex: none; }
.v-stage img { display: block; width: 100%; max-height: 62vh; object-fit: contain; background: #000; transition: opacity .25s; }
.v-stage.loading img { opacity: .35; }
.v-yt { width: 100%; aspect-ratio: 16 / 9; max-height: 70vh; border: 0; display: block; background: #000; }
.v-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: #B9CADB; font-size: 15px; line-height: 1.45; }
.v-info { padding: 14px 16px calc(24px + var(--sab)); max-width: 980px; width: 100%; margin: 0 auto; }
.v-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag { padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); font-size: 12.5px; font-weight: 600; color: #D6E3EF; }
.v-info h2 { margin: 0; font-size: 24px; line-height: 1.15; letter-spacing: -.4px; }
.v-sub { margin: 6px 0 0; color: #B9CADB; font-size: 15.5px; }
.v-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 68px; border-radius: 14px; background: rgba(255, 255, 255, .09); color: #fff; font-size: 13.5px; font-weight: 600; text-decoration: none; }
.act.primary { background: var(--blue); }
.act svg { width: 22px; height: 22px; }
.v-note { color: #8FA5BA; font-size: 12.5px; line-height: 1.45; margin: 14px 0 0; }
.v-h3 { font-size: 15px; margin: 22px 0 10px; color: #E6EEF6; }
.v-near { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ---------- modal y avisos ---------- */
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(11, 22, 34, .6); display: grid; place-items: end center; }
.modal-card { background: #fff; width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 18px 18px calc(22px + var(--sab)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 21px; }
#aBody { font-size: 15px; line-height: 1.5; color: #263646; }
#aBody table { width: 100%; border-collapse: collapse; margin: 10px 0; }
#aBody td { padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
#aBody td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
#aBody small { color: var(--muted); display: block; }
#aBody .warn { color: #A5560A; }
.toast { position: fixed; z-index: 90; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14.5px; font-weight: 500; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center; }

/* ---------- tablet y escritorio ---------- */
@media (min-width: 620px) {
  .grid, .v-near { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  body { display: block; }
  #map { left: 440px; }
  .top { right: auto; width: 440px; background: var(--ink); padding: 16px 16px 14px; }
  .chips { margin: 12px -16px 0; padding: 0 16px 2px; flex-wrap: wrap; overflow: visible; }
  .chip { box-shadow: none; background: rgba(255, 255, 255, .1); color: #E6EEF6; }
  .chip-strong { background: var(--blue); color: #fff; }
  .chip[aria-pressed="true"] { background: #fff; color: var(--ink); }
  .chip-sep { display: none; }
  .chips .chip:nth-of-type(n+10) { display: none; }
  .sheet, .sheet[data-state] { right: auto; width: 440px; top: var(--top-h, 210px); height: auto; border-radius: 0; box-shadow: none; transition: none; }
  .grab { display: none; }
  .sheet-head { padding-top: 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .maplibregl-ctrl-bottom-right, body[data-sheet] .maplibregl-ctrl-bottom-right { bottom: 0; opacity: 1; }
  .leaflet-bottom.leaflet-right, body[data-sheet] .leaflet-bottom.leaflet-right { bottom: 0; }
  .viewer { left: 440px; }
  .v-stage img { max-height: 70vh; }
  .v-near { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal { place-items: center; }
  .modal-card { border-radius: 22px; }
  .toast { left: calc(440px + (100vw - 440px) / 2); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
