/* App Náutica — mapa a pantalla completa, navegación inferior, MOB a pantalla completa */
:root {
  --navy: #0B3A66;
  --blue: #1D6FB8;
  --sky: #4FA3E3;
  --ice: #E6F0FA;
  --line: #BFD6EE;
  --ink: #0B1F33;
  --muted: #4E6278;
  --white: #FFFFFF;
  --red: #C62828;
  --amber-bg: #FFF1D6;
  --amber-ink: #6B4200;
  --amber: #E8A400;
  --green: #2E7D32;
  --green-bg: #E3F2E5;
  --mob-bg: #0E1E30;
  --mob-card: #13283F;
  --f-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--f-body); color: var(--ink); background: var(--ice); -webkit-tap-highlight-color: transparent; overflow: hidden; }
button { font-family: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* Vistas */
.view { position: absolute; inset: 0 0 calc(var(--nav-h) + var(--safe-b)) 0; display: none; }
.view.active { display: block; }
#view-clima, #view-guia { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { padding: calc(16px + var(--safe-t)) max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin: 0 auto; }
.page-title { margin: 0; font-size: 22px; color: var(--navy); border-bottom: 3px solid var(--blue); padding-bottom: 6px; }

/* Barra superior del mapa */
.topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 500; background: var(--navy); color: var(--white); padding: calc(10px + var(--safe-t)) max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar h1 { margin: 0; font-size: 18px; letter-spacing: .2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1.5px solid var(--sky); background: transparent; display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--white); stroke-width: 2; }
.editor-badge { background: var(--amber); color: var(--ink); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: .5px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 12px; border-radius: 17px; border: 1.5px solid var(--sky); background: transparent; color: #CFE6FA; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.chip .dot { width: 10px; height: 10px; border-radius: 5px; }
.chip.on { background: var(--sky); color: var(--ink); border-color: var(--sky); }
.alert-banner { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--amber-bg); color: var(--amber-ink); font-size: 13px; font-weight: 600; }
.alert-banner.red { background: #FDE2E2; color: #7A1010; }
.alert-banner button { margin-left: auto; background: none; border: 0; color: inherit; font-size: 18px; line-height: 1; padding: 0 4px; }

/* Mapa */
#map { position: absolute; inset: 0; z-index: 1; background: #CFE3F2; }
.map-disclaimer { position: absolute; left: 8px; bottom: 4px; z-index: 400; margin: 0; font-size: 10px; background: rgba(255,255,255,.85); padding: 2px 6px; border-radius: 4px; color: var(--muted); }
.leaflet-control-attribution { font-size: 9px; }
.poi-icon { width: 30px; height: 30px; border-radius: 15px; border: 2px solid var(--white); display: grid; place-items: center; color: var(--white); font-size: 11px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.35); font-family: var(--f-body); }
.poi-icon.unverified { border-style: dashed; border-color: var(--amber); }
.me-icon { width: 18px; height: 18px; border-radius: 9px; background: #1E88E5; border: 3px solid var(--white); box-shadow: 0 0 0 8px rgba(30,136,229,.22); }
.mob-icon { width: 26px; height: 26px; border-radius: 13px; background: var(--red); border: 3px solid var(--white); box-shadow: 0 0 0 10px rgba(198,40,40,.25); }

.btn-mob { position: absolute; right: max(14px, env(safe-area-inset-right, 0px)); bottom: 28px; z-index: 600; width: 78px; height: 78px; border-radius: 39px; border: 4px solid var(--white); background: var(--red); color: var(--white); font-size: 18px; font-weight: 700; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.btn-mob:active { transform: scale(.96); }

/* Hoja inferior */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 700; background: var(--white); border-radius: 18px 18px 0 0; border-top: 3px solid var(--blue); box-shadow: 0 -4px 16px rgba(0,0,0,.15); padding: 8px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 10px; max-height: 60%; overflow-y: auto; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--blue); align-self: center; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-right: 36px; }
.sheet-title-wrap { min-width: 0; }
.sheet h2 { margin: 0; font-size: 17px; }
.sheet-head p { margin: 2px 0 0; font-size: 13px; }
.sheet-notes { margin: 0; font-size: 14px; color: var(--muted); }
.sheet-notes:empty { display: none; }
.sheet-actions, .sheet-editor { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sheet-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sheet-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border-radius: 18px; border: 0; background: var(--ice); font-size: 22px; color: var(--navy); }
.tag { flex: none; padding: 3px 8px; border-radius: 6px; background: var(--ice); color: var(--navy); font-size: 11px; font-weight: 700; }
.tag.warn { background: var(--amber-bg); color: var(--amber-ink); }

/* Botones */
.btn { min-height: 44px; border-radius: 10px; font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; padding: 0 10px; border: 0; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-outline { background: var(--white); color: var(--navy); border: 1.5px solid var(--blue); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-sm { min-height: 38px; font-size: 13px; }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.link-btn { background: none; border: 0; color: var(--blue); font-weight: 600; text-decoration: underline; padding: 6px 0; }

/* Editor */
.editor-panel { position: absolute; left: max(10px, env(safe-area-inset-left, 0px)); right: 100px; bottom: 16px; z-index: 650; background: var(--white); border: 2px solid var(--amber); border-radius: 14px; padding: 10px 12px; max-height: 38%; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.editor-head { display: flex; justify-content: space-between; align-items: center; }
.editor-hint { margin: 0; font-size: 13px; color: var(--muted); }
.editor-hint.active { color: var(--amber-ink); font-weight: 600; }
.editor-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pending-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pending-list button { width: 100%; text-align: left; background: var(--ice); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--ink); }
.pending-list button.sel { background: var(--amber-bg); border-color: var(--amber); }
.pending-list small { display: block; color: var(--muted); }
summary { font-size: 13px; font-weight: 600; cursor: pointer; }

/* Formularios (modal) */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(11,31,51,.55); display: flex; align-items: flex-end; justify-content: center; }
.modal-box { background: var(--white); width: 100%; max-width: 520px; max-height: 88%; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + var(--safe-b)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 12px; }
.modal-box h2 { margin: 0; font-size: 18px; color: var(--navy); }
.modal-box p { margin: 0; font-size: 14px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { font: 15px var(--f-body); padding: 10px; border: 1.5px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--white); }
.field textarea { min-height: 70px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: 20px; height: 20px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.export-box { width: 100%; min-height: 160px; font: 12px var(--f-mono); }

/* Tarjetas */
.card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card-title { margin: 0; font-size: 15px; color: var(--navy); }
.card p { margin: 0; }
.link-list { display: flex; flex-direction: column; gap: 6px; }
.link-list a { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 12px; border: 1.5px solid var(--blue); border-radius: 10px; color: var(--navy); font-weight: 600; text-decoration: none; font-size: 14px; }
.link-list a::after { content: "↗"; color: var(--blue); }

/* Clima */
.semaforo { border-radius: 16px; padding: 16px; display: flex; gap: 14px; align-items: center; background: var(--white); border: 1px solid var(--line); }
.semaforo .light { width: 56px; height: 56px; border-radius: 28px; flex: none; display: grid; place-items: center; color: var(--white); font-weight: 700; font-size: 26px; }
.semaforo h2 { margin: 0; font-size: 18px; }
.semaforo p { margin: 2px 0 0; font-size: 14px; line-height: 1.45; }
.semaforo.verde { background: var(--green-bg); border-color: #A9D3AE; } .semaforo.verde .light { background: var(--green); }
.semaforo.amarillo { background: var(--amber-bg); border-color: #F0CF8A; color: var(--amber-ink); } .semaforo.amarillo .light { background: var(--amber); }
.semaforo.rojo { background: #FDE2E2; border-color: #F2A9A9; color: #7A1010; } .semaforo.rojo .light { background: var(--red); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--white); border-radius: 12px; border-top: 3px solid var(--blue); padding: 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-family: var(--f-mono); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 11px; color: var(--muted); }
.hourly { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.hour { flex: none; width: 52px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; }
.hour .bar-wrap { height: 70px; width: 18px; display: flex; align-items: flex-end; background: var(--ice); border-radius: 4px; }
.hour .bar { width: 100%; border-radius: 4px; }
.hour .arrow { width: 16px; height: 16px; }
.hour .w { font-family: var(--f-mono); font-weight: 600; }

/* Guía */
.segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: #CFE1F4; position: sticky; top: 0; z-index: 5; }
.segmented button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--blue); font-weight: 600; font-size: 14px; }
.segmented button.active { background: var(--white); color: var(--navy); font-weight: 700; }
.tab { display: none; flex-direction: column; gap: 12px; }
.tab.active { display: flex; }
.sos { background: var(--red); color: var(--white); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.sos h2 { margin: 0; font-size: 16px; }
.sos p { margin: 0; font-size: 14px; line-height: 1.5; color: #FFE3E3; }
.sos .phone { font-family: var(--f-mono); font-size: 22px; font-weight: 600; color: var(--white); }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid #DCE9F6; }
.list-row:first-child { border-top: 0; }
.ch { width: 48px; flex: none; font-family: var(--f-mono); font-size: 21px; font-weight: 600; color: var(--navy); }
.ch.red { color: var(--red); }
.list-row p { margin: 0; font-size: 14px; }
.proc { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.45; }
details.proc-box { border: 1.5px solid var(--blue); border-radius: 10px; padding: 10px 12px; }
details.proc-box summary { font-size: 14px; color: var(--navy); }
details.proc-box[open] summary { margin-bottom: 8px; }
.buoy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.buoy { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: var(--white); }
.buoy svg { width: 76px; height: 110px; }
.buoy strong { font-size: 14px; color: var(--navy); }
.buoy span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.buoy .light-code { font-family: var(--f-mono); font-size: 11px; color: var(--blue); }
.sound-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid #DCE9F6; }
.sound-row:first-child { border-top: 0; }
.sound-row .txt { flex: 1; min-width: 0; font-size: 14px; }
.sound-row .txt small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.blasts { display: flex; gap: 3px; align-items: center; margin-bottom: 2px; }
.blasts i { display: block; height: 8px; border-radius: 4px; background: var(--navy); }
.blasts i.s { width: 10px; } .blasts i.l { width: 34px; } .blasts i.b { width: 10px; height: 10px; border-radius: 5px; background: var(--amber); }
.play { flex: none; width: 44px; height: 44px; border-radius: 22px; border: 1.5px solid var(--blue); background: var(--white); display: grid; place-items: center; }
.play svg { width: 18px; height: 18px; fill: var(--navy); }
.play.playing { background: var(--navy); } .play.playing svg { fill: var(--white); }
.gloss dt { font-weight: 700; color: var(--navy); font-size: 14px; margin-top: 10px; }
.gloss dt:first-child { margin-top: 0; }
.gloss dd { margin: 2px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink); }
.search { font: 15px var(--f-body); padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; width: 100%; }
.about { margin-top: 8px; }

/* Navegación inferior */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--white); border-top: 3px solid var(--blue); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.bottom-nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #5E7FA0; font-size: 11px; font-weight: 500; }
.bottom-nav button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.bottom-nav button.active { color: var(--navy); font-weight: 700; }

/* MOB */
.mob { position: fixed; inset: 0; z-index: 3000; background: var(--mob-bg); color: var(--white); display: flex; flex-direction: column; overflow-y: auto; }
.mob-head { background: var(--red); padding: calc(14px + var(--safe-t)) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); }
.mob-row { display: flex; justify-content: space-between; align-items: center; }
.mob-title { font-size: 21px; letter-spacing: .5px; }
.mob-timer { font-size: 22px; font-weight: 600; }
.mob-pos { margin: 4px 0 0; font-size: 13px; color: #FFE3E3; font-family: var(--f-mono); }
.mob-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: #2A3A4C; }
.mob-stats > div { background: var(--mob-bg); padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.mob-label { font-size: 12px; color: #A9BBCD; font-weight: 600; letter-spacing: .4px; }
.mob-big { font-size: 38px; font-weight: 600; }
.mob-body { padding: 12px 16px 0; display: flex; flex-direction: column; gap: 10px; }
.mob-man-btns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.mob-man-btns button { min-height: 42px; border-radius: 8px; border: 1px solid #3A4C60; background: transparent; color: #D6E2EE; font-size: 12px; font-weight: 500; }
.mob-man-btns button.active { background: var(--sky); color: var(--ink); border-color: var(--sky); font-weight: 700; }
.mob-draw { background: var(--mob-card); border-radius: 14px; }
.mob-draw svg { display: block; width: 100%; height: auto; }
.mob-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: #D6E2EE; line-height: 1.4; }
.mob-actions { margin-top: auto; padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(16px + var(--safe-b)) max(16px, env(safe-area-inset-left, 0px)); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mob-call { background: var(--white); color: var(--red); min-height: 54px; font-weight: 700; }
.mob-share { background: var(--green); color: var(--white); min-height: 54px; font-weight: 700; }
.mob-vhf { grid-column: span 2; margin: 0; text-align: center; font-size: 13px; color: #A9BBCD; }
.mob-end { grid-column: span 2; background: transparent; border: 1px solid #3A4C60; color: #D6E2EE; position: relative; overflow: hidden; }
.mob-end .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(255,255,255,.18); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 4000; background: var(--ink); color: var(--white); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90%; text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
