:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #102e4c;
  --neu-bg: #eaf2f7;
  --neu-bg-light: #f1f6f9;
  --neu-primary: #0868a9;
  --neu-primary-dark: #0a315c;
  --neu-primary-mid: #1b5e95;
  --neu-text: #102e4c;
  --neu-text-secondary: #5f7488;
  --neu-shadow-dark: rgba(70, 105, 130, .22);
  --neu-shadow-light: rgba(255, 255, 255, .9);
  --neu-focus: rgba(8, 104, 169, .24);
  --neu-raised: 12px 12px 26px var(--neu-shadow-dark), -10px -10px 24px var(--neu-shadow-light);
  --neu-inset: inset 3px 3px 7px rgba(70, 105, 130, .18), inset -3px -3px 7px rgba(255, 255, 255, .88);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; background: var(--neu-bg); color: var(--neu-text); }
body.modal-open { overflow: hidden; }
main { position: relative; width: 100%; height: 100%; }
#map { position: fixed; inset: 0; width: 100vw; height: 100vh; background: #cfe5ef; }
/* Leaflet necesita conservar el tamaño y posicionamiento absoluto de cada tile. */
#map.leaflet-container { overflow: hidden; }
#map .leaflet-pane,
#map .leaflet-map-pane,
#map .leaflet-tile-pane,
#map .leaflet-tile { position: absolute; left: 0; top: 0; }
#map img.leaflet-tile { max-width: none !important; max-height: none !important; margin: 0; padding: 0; border: 0; }

.icon { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.center-marker { position: absolute; z-index: 450; left: 50%; top: 50%; width: 42px; height: 42px; transform: translate(-50%, -50%); pointer-events: none; filter: drop-shadow(0 2px 4px rgba(10, 49, 92, .3)); }
.center-marker::before,
.center-marker::after { content: ""; position: absolute; left: 50%; top: 50%; background: rgba(255, 255, 255, .96); box-shadow: 0 0 0 1px rgba(8, 104, 169, .42); transform: translate(-50%, -50%); }
.center-marker::before { width: 2px; height: 42px; }
.center-marker::after { width: 42px; height: 2px; }
.center-marker-ring { position: absolute; z-index: 1; inset: 9px; border: 2px solid var(--neu-primary); border-radius: 50%; background: rgba(241, 246, 249, .78); }
.center-marker-dot { position: absolute; z-index: 2; left: 50%; top: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--neu-primary-dark); transform: translate(-50%, -50%); }
.center-marker.is-moving .center-marker-ring { background: rgba(224, 242, 251, .88); transform: scale(.88); }

.neu-panel { background: rgba(234, 242, 247, .97); box-shadow: var(--neu-raised); }
.panel { position: fixed; z-index: 500; top: 30px; left: 30px; width: min(400px, calc(100vw - 60px)); max-height: calc(100vh - 60px); overflow: auto; padding: 28px; border: 1px solid rgba(255, 255, 255, .72); border-radius: 26px; backdrop-filter: blur(12px); }
.panel-header { margin: 0 0 13px; text-align: center; }
.brand-name { margin: 0 0 5px; color: var(--neu-primary); font-size: .7rem; font-weight: 900; letter-spacing: .22em; }
.panel-title { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--neu-primary-dark); }
.panel-title h1 { margin: 0; font-size: clamp(1.5rem, 2vw, 1.72rem); line-height: 1.12; letter-spacing: -.025em; }
.icon-anchor { width: 25px; height: 25px; stroke-width: 1.7; }
.maritime-divider { display: flex; align-items: center; justify-content: center; gap: 8px; width: 74%; margin: 10px auto 0; color: var(--neu-primary-mid); opacity: .66; }
.maritime-divider span { width: 100%; height: 1px; background: currentColor; opacity: .48; }
.maritime-divider .icon-waves { width: 28px; height: 17px; }
.hint { margin: 0 0 16px; color: var(--neu-text-secondary); font-size: .9rem; font-weight: 650; line-height: 1.35; text-align: center; }

.zone-search { position: relative; margin: 0 0 14px; }
.input-shell { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 13px; background: var(--neu-bg-light); }
.neu-inset { box-shadow: var(--neu-inset); }
.input-shell:focus-within { box-shadow: var(--neu-inset), 0 0 0 3px var(--neu-focus); }
.field-icon { position: absolute; z-index: 1; width: 19px; height: 19px; color: var(--neu-primary-mid); pointer-events: none; }
.field-icon-left { left: 15px; }
.field-icon-right { right: 13px; }
.input-shell input { width: 100%; min-width: 0; min-height: 47px; border: 0; outline: 0; border-radius: inherit; background: transparent; color: var(--neu-text); font: inherit; font-size: .94rem; font-weight: 650; }
.search-shell input { padding: 12px 42px 12px 46px; }
.coordinate-shell input { padding: 11px 38px 11px 13px; }
.input-shell input::placeholder { color: #6d8193; font-weight: 500; opacity: 1; }
.input-shell input[type="search"]::-webkit-search-cancel-button { opacity: .62; }

.zone-results { position: absolute; z-index: 700; top: calc(100% + 7px); left: 3px; right: 3px; overflow: hidden; border: 1px solid rgba(95, 116, 136, .2); border-radius: 13px; background: var(--neu-bg-light); box-shadow: 7px 9px 20px rgba(43, 73, 94, .2), -4px -4px 12px rgba(255, 255, 255, .76); }
.zone-result { width: 100%; display: block; padding: 10px 13px; border: 0; border-bottom: 1px solid rgba(95, 116, 136, .14); border-radius: 0; background: transparent; color: var(--neu-text); text-align: left; font-weight: 750; cursor: pointer; }
.zone-result:last-child { border-bottom: 0; }
.zone-result:hover,
.zone-result:focus-visible { outline: 0; background: rgba(8, 104, 169, .09); color: var(--neu-primary-dark); box-shadow: inset 3px 3px 7px rgba(70, 105, 130, .1); }
.zone-result small { display: block; margin-top: 2px; color: var(--neu-text-secondary); font-size: .72rem; font-weight: 600; }
.zone-message { margin: 7px 4px 0; color: var(--neu-text-secondary); font-size: .78rem; line-height: 1.35; }

.coordinates { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 17px; }
.panel label { display: grid; gap: 7px; margin: 0; color: var(--neu-primary-dark); font-size: .78rem; font-weight: 800; }
button, .download { width: 100%; border: 0; border-radius: 13px; padding: 12px 16px; background: var(--neu-primary); color: white; font-weight: 800; cursor: pointer; text-align: center; text-decoration: none; display: block; }
.neu-button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; background: linear-gradient(145deg, #0a70b3, #174f8b); box-shadow: 7px 8px 16px rgba(37, 78, 108, .3), -5px -5px 13px rgba(255, 255, 255, .75); font-size: .96rem; letter-spacing: .01em; transition: transform .16s ease, box-shadow .16s ease, filter .16s ease; }
.neu-button:hover { filter: brightness(1.035); transform: translateY(-1px); }
.neu-button:active { transform: translateY(1px); box-shadow: inset 4px 4px 9px rgba(5, 39, 70, .38), inset -3px -3px 8px rgba(81, 153, 204, .3); }
.neu-button:focus-visible { outline: 3px solid rgba(255, 255, 255, .95); outline-offset: -6px; box-shadow: 7px 8px 16px rgba(37, 78, 108, .3), 0 0 0 4px var(--neu-focus); }
.button-icon { width: 23px; height: 23px; stroke-width: 2; }
button:disabled { opacity: .6; cursor: wait; transform: none; }
button.download-limit,
button.download-limit:hover,
button.download-limit:disabled { background: #8c9ba6; color: #f7f9fa; opacity: 1; cursor: not-allowed; }
.status { min-height: 2.4em; margin: 14px 2px 0; color: var(--neu-text-secondary); font-size: .8rem; line-height: 1.4; }
.status.error { color: #8d2d36; }

.leaflet-control-zoom { margin-top: 28px !important; margin-right: 28px !important; border: 0 !important; border-radius: 13px !important; box-shadow: 7px 7px 16px rgba(48, 79, 99, .25), -4px -4px 12px rgba(255, 255, 255, .72) !important; }
.leaflet-control-zoom a { width: 38px !important; height: 38px !important; line-height: 37px !important; border: 0 !important; background: rgba(234, 242, 247, .96) !important; color: var(--neu-primary-dark) !important; font-weight: 700; }
.leaflet-control-zoom a:first-child { border-radius: 12px 12px 0 0 !important; border-bottom: 1px solid rgba(95, 116, 136, .16) !important; }
.leaflet-control-zoom a:last-child { border-radius: 0 0 12px 12px !important; }
.leaflet-control-zoom a:hover { background: #f4f8fa !important; color: var(--neu-primary) !important; }

.modal[hidden] { display: none; }
.modal { position: fixed; z-index: 1500; inset: 0; display: grid; place-items: center; padding: 20px; overflow: hidden; overscroll-behavior: contain; background: rgba(8, 30, 49, .62); backdrop-filter: blur(5px); }
.modal-card { position: relative; display: flex; flex-direction: column; width: min(580px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow: hidden; border: 1px solid rgba(255, 255, 255, .7); border-radius: 22px; background: var(--neu-bg); box-shadow: 15px 18px 45px rgba(4, 18, 28, .36), -8px -8px 24px rgba(255, 255, 255, .3); }
.modal-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 30px; scrollbar-gutter: stable; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.modal-close { position: absolute; z-index: 5; top: 12px; right: 12px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--neu-primary); color: #fff; box-shadow: 4px 5px 10px rgba(10, 49, 92, .24), -2px -2px 7px rgba(255, 255, 255, .72); font-size: 1.45rem; line-height: 1; cursor: pointer; }
.modal-close:hover { background: var(--neu-primary-mid); }
.modal-close:focus-visible { outline: 3px solid #fff; outline-offset: -5px; box-shadow: 0 0 0 3px var(--neu-focus), 4px 5px 10px rgba(10, 49, 92, .24); }
.modal-close:active { background: var(--neu-primary-dark); transform: translateY(1px) scale(.98); }
.modal-kicker { color: var(--neu-primary); font-size: .72rem; letter-spacing: .15em; font-weight: 800; text-transform: uppercase; }
.modal h2 { margin: 7px 42px 8px 0; color: var(--neu-primary-dark); font-size: 1.55rem; }
.modal h3 { margin: 18px 0 7px; color: var(--neu-primary-dark); font-size: .92rem; }
.modal p { color: var(--neu-text-secondary); line-height: 1.5; }
.coord-card, .price-card, .test-warning, .ready-meta { padding: 14px 16px; border-radius: 13px; background: var(--neu-bg-light); box-shadow: var(--neu-inset); }
.coord-card { display: flex; justify-content: space-between; gap: 16px; font-weight: 800; color: var(--neu-text); }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 18px; padding: 0; list-style: none; color: #40576a; font-size: .9rem; }
.features li::before { content: "✓"; margin-right: 7px; color: var(--neu-primary); font-weight: 900; }
.price-card { display: flex; align-items: center; justify-content: space-between; margin: 18px 0; }
.price-card strong { color: var(--neu-primary); font-size: 1.55rem; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; }
.button-secondary { background: #dfeaf0; color: var(--neu-primary-dark); }
.button-secondary:hover { background: #d5e3ea; }
.button-danger { background: #7f4650; }
.button-danger:hover { background: #6c3942; }
.test-warning { margin: 16px 0; border: 1px solid rgba(10, 49, 92, .2); color: #5b4a25 !important; font-size: .8rem; font-weight: 800; text-align: center; }
.spinner { width: 42px; height: 42px; margin: 22px auto; border: 4px solid #d2e2ea; border-top-color: var(--neu-primary); border-radius: 50%; animation: spin .8s linear infinite; }
.success-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; border-radius: 50%; background: #d9eee5; color: #236345; font-size: 1.5rem; font-weight: 900; }
.preview { width: min(250px, 100%); max-height: 320px; object-fit: contain; display: block; margin: 18px auto; border: 1px solid rgba(95, 116, 136, .22); box-shadow: 8px 10px 24px rgba(20, 48, 64, .16); }
.message-error { color: #852d36 !important; font-weight: 700; }
.asset-section { margin-top: 10px; }
.asset-section h3 { margin: 0 0 9px; letter-spacing: .07em; }
.tsm-assets { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.forecast-delivery, .tsm-delivery { border: 1px solid rgba(255,255,255,.78); border-radius: 17px; }
.forecast-delivery { padding: 11px; background: linear-gradient(145deg, rgba(225,241,249,.9), rgba(241,248,251,.96)); box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 5px 7px 16px rgba(26,75,108,.12); }
.tsm-delivery { margin-top: 13px; padding: 12px; background: linear-gradient(155deg, rgba(213,235,246,.9), rgba(235,246,251,.94)); box-shadow: inset 0 1px 0 rgba(255,255,255,.85), 6px 8px 18px rgba(26,75,108,.13); }
.asset-card { position: relative; min-width: 0; overflow: hidden; padding: 13px; border: 1px solid rgba(8,104,169,.13); border-radius: 14px; background: linear-gradient(145deg, #f5fafc, #dcecf4); box-shadow: 5px 6px 13px rgba(47,91,119,.17), -3px -3px 8px rgba(255,255,255,.82); }
.asset-card::before { position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--neu-primary), #42a9d5); content: ""; }
.asset-card-forecast { background: linear-gradient(145deg, #edf7fb, #d5eaf4); }
.asset-card-tsm { background: linear-gradient(155deg, #f3f9fc, #d8eaf3); }
.asset-card-copy { display: grid; gap: 3px; margin-bottom: 10px; }
.asset-card-copy strong { color: var(--neu-primary-dark); font-size: .9rem; text-transform: uppercase; }
.asset-card-copy small { color: var(--neu-text-secondary); }
.asset-card-copy span { min-height: 2.1em; color: var(--neu-primary-mid); font-size: .75rem; font-weight: 800; line-height: 1.25; }
.asset-download { min-height: 44px; padding: 10px; background: linear-gradient(135deg, var(--neu-primary), #137dbb); box-shadow: 0 5px 11px rgba(8,104,169,.2), inset 0 1px 0 rgba(255,255,255,.18); font-size: .8rem; }
.asset-download:hover { background: linear-gradient(135deg, var(--neu-primary-mid), var(--neu-primary)); }
.asset-message { min-height: 1.25em; margin: 8px 1px 0 !important; font-size: .72rem; line-height: 1.25 !important; }
.delivery-brand { margin: 22px 0 0 !important; color: var(--neu-primary-mid) !important; font-size: .76rem; font-weight: 800; text-align: center; letter-spacing: .05em; }
.delivery-view { text-align: center; }
.delivery-view h2 { margin: 4px 42px 5px; font-size: 1.36rem; line-height: 1.15; text-align: center; }
.delivery-view .modal-kicker { font-size: .66rem; }
.delivery-view .success-mark { width: 38px; height: 38px; margin: 0 auto 5px; font-size: 1.22rem; }
.delivery-summary { max-width: 480px; margin: 4px auto 9px; font-size: .86rem; line-height: 1.35 !important; }
.delivery-view .coord-card { justify-content: center; padding: 9px 13px; }
.delivery-view .ready-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 8px; padding: 8px; }
.delivery-view .ready-meta span { display: grid; align-content: center; min-height: 38px; padding: 5px; border-radius: 9px; background: rgba(255,255,255,.48); color: var(--neu-text-secondary); font-size: .7rem; line-height: 1.15; }
.delivery-view .ready-meta strong { color: var(--neu-primary-dark); font-size: .78rem; }
.delivery-view .preview { width: min(160px, 46%); max-height: 190px; margin: 9px auto; border-radius: 8px; }
.delivery-view .asset-card-copy { justify-items: center; text-align: center; }
.delivery-view .asset-section h3, .delivery-view .asset-message { text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  html, body { height: 100%; height: 100dvh; }
  main { display: grid; grid-template-rows: minmax(0, 1fr) auto; width: 100%; height: 100%; height: 100dvh; min-height: 0; background: var(--neu-bg); }
  #map { position: relative; inset: auto; grid-row: 1; width: 100%; height: 100%; min-height: 0; }
  .panel { position: relative; z-index: 500; grid-row: 2; top: auto; left: auto; width: 100%; max-height: none; overflow: visible; padding: 13px 18px 12px; border: 0; border-radius: 28px 28px 0 0; backdrop-filter: none; }
  .neu-panel { box-shadow: 0 -9px 22px rgba(52, 84, 105, .2), inset 0 1px 0 rgba(255, 255, 255, .92); }
  .panel-header { margin-bottom: 7px; }
  .brand-name { margin-bottom: 3px; font-size: .62rem; }
  .panel-title { gap: 8px; }
  .panel-title h1 { font-size: 1.25rem; }
  .icon-anchor { width: 22px; height: 22px; }
  .maritime-divider { width: 58%; margin-top: 5px; gap: 6px; }
  .maritime-divider .icon-waves { width: 25px; height: 14px; }
  .hint { margin-bottom: 9px; font-size: .78rem; line-height: 1.2; }
  .zone-search { margin-bottom: 9px; }
  .input-shell input { min-height: 44px; font-size: 16px; }
  .search-shell input { padding-top: 9px; padding-bottom: 9px; }
  .coordinates { gap: 10px; margin-bottom: 10px; }
  .panel label { gap: 4px; font-size: .72rem; }
  .coordinate-shell input { padding-top: 8px; padding-bottom: 8px; }
  .neu-button { min-height: 46px; padding: 10px 14px; }
  .status { display: none; }
  .zone-result { min-height: 44px; padding: 8px 11px; }
  .leaflet-control-zoom { margin-top: 16px !important; margin-right: 14px !important; }
  .leaflet-control-zoom a { width: 36px !important; height: 36px !important; line-height: 35px !important; }
  .modal { padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); align-items: end; }
  .modal-card { width: 100%; max-height: calc(100dvh - max(10px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom))); border-radius: 22px 22px 10px 10px; }
  .modal-content { padding: 18px 14px; }
  .modal-close { top: 10px; right: 10px; }
  .features { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .delivery-view h2 { margin-right: 38px; margin-left: 38px; font-size: 1.2rem; }
  .delivery-summary { margin-bottom: 7px; font-size: .78rem; }
  .delivery-view .coord-card { padding: 7px 10px; }
  .delivery-view .ready-meta { gap: 5px; margin-top: 6px; padding: 6px; }
  .delivery-view .ready-meta span { min-height: 34px; padding: 4px 2px; font-size: .62rem; }
  .delivery-view .ready-meta strong { font-size: .72rem; }
  .delivery-primary { display: flex; flex-direction: column; min-height: calc(100dvh - 40px); }
  .delivery-view .preview { width: min(198px, 62vw); max-height: 280px; margin: 8px auto; }
  .asset-section { margin-top: 7px; }
  .delivery-primary .forecast-delivery { margin-top: auto; padding: 9px; }
  .tsm-delivery { margin-top: 10px; padding: 9px; }
  .tsm-assets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .asset-card { padding: 10px 8px; }
  .asset-card-copy { gap: 2px; margin-bottom: 7px; }
  .asset-card-copy strong { font-size: .78rem; }
  .asset-card-copy small { font-size: .68rem; }
  .asset-card-copy span { min-height: 2.5em; font-size: .66rem; }
  .asset-download { min-height: 44px; padding: 7px 4px; font-size: .68rem; }
  .asset-message { margin-top: 6px !important; font-size: .66rem; }
}

@media (max-width: 620px) and (max-height: 700px) {
  .panel { padding: 8px 16px 7px; }
  .panel-header { margin-bottom: 4px; }
  .panel-title h1 { font-size: 1.14rem; }
  .maritime-divider { margin-top: 2px; }
  .hint { margin-bottom: 5px; font-size: .73rem; }
  .zone-search { margin-bottom: 6px; }
  .input-shell input { min-height: 40px; padding-top: 7px; padding-bottom: 7px; }
  .coordinates { margin-bottom: 7px; }
  .panel label { gap: 2px; }
  .neu-button { min-height: 42px; padding-top: 8px; padding-bottom: 8px; }
}
