:root {
  --bg: #050b0a;
  --panel: rgba(8, 18, 16, 0.78);
  --panel-strong: rgba(8, 18, 16, 0.94);
  --line: rgba(183, 255, 218, 0.12);
  --line-strong: rgba(183, 255, 218, 0.26);
  --text: #e9fff5;
  --muted: #8ea79b;
  --mint: #78ffc0;
  --cyan: #67d9ff;
  --amber: #ffc56a;
  --red: #ff6f78;
  --violet: #bd8cff;
  --blue: #7ea6ff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 10%, rgba(86, 255, 184, 0.08), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(103, 217, 255, 0.06), transparent 26%),
    linear-gradient(135deg, #07100e 0%, #050a09 48%, #08100f 100%);
}

.glass {
  background: linear-gradient(180deg, rgba(13, 28, 24, 0.84), rgba(6, 13, 12, 0.78));
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  box-shadow: var(--shadow);
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: 66px 1fr 34px;
  gap: 10px;
  width: 100%;
  height: 100dvh;
  padding: calc(10px + var(--safe-top)) 10px calc(10px + var(--safe-bottom));
}

.topbar {
  position: relative;
  z-index: 500;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  min-height: 66px;
  padding: 0 14px;
  border-radius: var(--radius);
}

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; display: grid; place-content: center; gap: 3px; transform: rotate(-18deg); }
.brand-mark span { display: block; width: 23px; height: 2px; background: linear-gradient(90deg, transparent, var(--mint)); box-shadow: 0 0 10px rgba(120,255,192,.55); }
.brand-mark span:nth-child(2) { width: 31px; }
.brand-mark span:nth-child(3) { width: 17px; justify-self: end; }
.brand { font-size: 17px; font-weight: 850; letter-spacing: .16em; line-height: 1; white-space: nowrap; }
.brand span { color: var(--mint); }
.brand-sub { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pulse-line { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: #b9d5c8; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 13px var(--mint); animation: pulse 1.8s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.7); } }

.top-actions { display: flex; justify-content: flex-end; gap: 7px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); cursor: pointer; transition: .18s ease; }
.icon-btn:hover { border-color: var(--line-strong); background: rgba(120,255,192,.08); transform: translateY(-1px); }

.stage { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 348px; gap: 10px; }
.map-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); background: #07100e; }
#map { width: 100%; height: 100%; background: #07100e; }
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { background: rgba(3,8,7,.6) !important; color: #6f897e !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #91b6a6 !important; }
.leaflet-control-zoom { border: 0 !important; box-shadow: none !important; }
.leaflet-control-zoom a { background: rgba(7,16,14,.82) !important; color: var(--text) !important; border-color: var(--line) !important; }

.map-vignette { position: absolute; inset: 0; z-index: 400; pointer-events: none; box-shadow: inset 0 0 90px rgba(0,0,0,.46); }
.scanline { position: absolute; z-index: 399; left: 0; right: 0; height: 1px; top: 35%; pointer-events: none; background: linear-gradient(90deg, transparent 8%, rgba(120,255,192,.14), transparent 92%); animation: scan 8s linear infinite; opacity: .7; }
@keyframes scan { from { transform: translateY(-35vh); } to { transform: translateY(80vh); } }

.hero-readout { position: absolute; z-index: 450; left: 16px; bottom: 16px; width: 206px; padding: 14px 16px; border-radius: 16px; pointer-events: none; }
.hero-kicker, .eyebrow { color: var(--mint); font-size: 8px; font-weight: 750; letter-spacing: .18em; text-transform: uppercase; }
.hero-time { margin-top: 4px; font-size: clamp(34px, 4vw, 54px); line-height: .95; font-weight: 760; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.hero-date, .hero-coord { margin-top: 7px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.hero-coord { margin-top: 3px; color: #b8d0c5; }

.map-legend { position: absolute; z-index: 450; top: 16px; left: 16px; width: 180px; max-height: 48%; overflow: auto; padding: 11px; border-radius: 15px; }
.legend-title { color: var(--muted); font-size: 8px; letter-spacing: .16em; margin-bottom: 7px; }
.legend-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 10px; color: #d4e9df; }
.legend-swatch { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 9px currentColor; }

.signal-rail { min-height: 0; display: flex; flex-direction: column; overflow: hidden; border-radius: 22px; }
.rail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 17px 16px 13px; }
.rail-header h1, .intel-header h2 { margin: 4px 0 0; font-size: 18px; line-height: 1.1; font-weight: 730; letter-spacing: -.02em; }
.source-score { padding: 6px 8px; min-width: 42px; text-align: center; border-radius: 9px; border: 1px solid var(--line); color: #b7d0c5; font-size: 10px; font-variant-numeric: tabular-nums; }
.layer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 0 12px 12px; }
.layer-card { position: relative; min-height: 82px; border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: rgba(255,255,255,.018); cursor: pointer; transition: .18s ease; overflow: hidden; text-align: left; }
.layer-card::after { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; right: -36px; top: -36px; background: radial-gradient(circle, var(--accent-soft), transparent 68%); opacity: 0; transition: .18s ease; }
.layer-card:hover, .layer-card.active { border-color: var(--accent-border); background: var(--accent-bg); transform: translateY(-1px); }
.layer-card:hover::after, .layer-card.active::after { opacity: 1; }
.layer-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.layer-icon { font-size: 17px; line-height: 1; color: var(--accent); text-shadow: 0 0 12px var(--accent-soft); }
.layer-state { width: 7px; height: 7px; border-radius: 50%; background: #4c5a54; }
.layer-card.ready .layer-state { background: var(--mint); box-shadow: 0 0 8px rgba(120,255,192,.6); }
.layer-card.error .layer-state { background: var(--red); }
.layer-name { margin-top: 10px; font-size: 11px; font-weight: 680; }
.layer-meta { margin-top: 3px; color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }

.divider { height: 1px; background: var(--line); margin: 0 12px; }
.intel-panel { min-height: 0; display: flex; flex-direction: column; padding: 13px 14px 14px; }
.intel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.intel-header h2 { font-size: 15px; }
.freshness { color: var(--muted); font-size: 8px; white-space: nowrap; padding-top: 2px; }
.intel-body { min-height: 0; overflow: auto; margin-top: 11px; padding-right: 3px; }
.empty-state { color: var(--muted); font-size: 11px; line-height: 1.55; padding: 8px 0; }
.intel-list { display: grid; gap: 7px; }
.intel-item { padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.018); }
.intel-item-title { font-size: 10px; font-weight: 700; line-height: 1.25; }
.intel-item-meta { margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.stat { padding: 9px 7px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); }
.stat-value { font-size: 16px; font-weight: 740; font-variant-numeric: tabular-nums; }
.stat-label { margin-top: 3px; color: var(--muted); font-size: 7px; text-transform: uppercase; letter-spacing: .08em; }
.media-button { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.02); cursor: pointer; text-align: left; }
.media-button:hover { border-color: var(--line-strong); }

.ticker { position: relative; z-index: 500; display: grid; grid-template-columns: 54px 1fr auto; align-items: center; min-height: 34px; border-radius: 12px; overflow: hidden; }
.ticker-label { align-self: stretch; display: grid; place-items: center; color: #04100c; background: var(--mint); font-size: 8px; font-weight: 900; letter-spacing: .15em; }
.ticker-track { min-width: 0; overflow: hidden; white-space: nowrap; color: #a9c1b6; font-size: 9px; letter-spacing: .04em; }
.ticker-track span { display: inline-block; padding-left: 100%; animation: ticker 28s linear infinite; }
@keyframes ticker { to { transform: translateX(-100%); } }
.ticker-clock { padding: 0 11px; color: #cce2d8; font-size: 9px; font-variant-numeric: tabular-nums; }

.signal-marker { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255,255,255,.5); color: #07100e; font-size: 9px; font-weight: 900; box-shadow: 0 0 0 4px rgba(255,255,255,.05), 0 0 18px currentColor; }
.leaflet-div-icon { background: none !important; border: none !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #0b1513 !important; color: var(--text) !important; border: 1px solid var(--line); box-shadow: var(--shadow) !important; }
.leaflet-popup-content { margin: 11px 13px !important; font-size: 10px; line-height: 1.45; }
.popup-title { font-size: 11px; font-weight: 740; margin-bottom: 4px; }
.popup-meta { color: var(--muted); }

.mobile-panel-toggle { display: none; }

.media-modal { position: fixed; inset: 0; z-index: 2000; display: none; place-items: center; padding: 18px; }
.media-modal.open { display: grid; }
.media-backdrop { position: absolute; inset: 0; background: rgba(1,4,3,.76); backdrop-filter: blur(8px); }
.media-card { position: relative; width: min(920px, 94vw); max-height: 90vh; overflow: auto; border-radius: 22px; padding: 18px; }
.modal-close { position: absolute; right: 12px; top: 10px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.04); cursor: pointer; font-size: 20px; }
.media-card h2 { margin: 5px 44px 13px 0; font-size: 22px; }
.media-frame { min-height: 240px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; background: #050907; }
.media-frame img { display: block; max-width: 100%; width: 100%; height: auto; object-fit: contain; }
.media-error { padding: 30px; color: var(--muted); text-align: center; }

/* Modo monitor: reduce elementos de interacción y maximiza información. */
.app-shell.kiosk { grid-template-rows: 54px 1fr 30px; padding: 6px; gap: 6px; }
.app-shell.kiosk .topbar { min-height: 54px; }
.app-shell.kiosk .brand-sub, .app-shell.kiosk .top-actions { display: none; }
.app-shell.kiosk .stage { grid-template-columns: minmax(0, 1fr) 310px; gap: 6px; }
.app-shell.kiosk .map-stage, .app-shell.kiosk .signal-rail { border-radius: 14px; }
.app-shell.kiosk .hero-readout { bottom: 10px; left: 10px; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; }
  .pulse-line { display: none; }
  .stage { grid-template-columns: 1fr 310px; }
  .signal-rail { min-width: 0; }
}

@media (max-width: 760px) {
  html, body { overflow: hidden; }
  .app-shell { padding: calc(7px + var(--safe-top)) 7px calc(7px + var(--safe-bottom)); grid-template-rows: 56px 1fr 30px; gap: 7px; }
  .topbar { min-height: 56px; padding: 0 10px; border-radius: 15px; }
  .brand { font-size: 14px; }
  .brand-sub { display: none; }
  .brand-mark { width: 28px; height: 28px; }
  .top-actions .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
  #kioskBtn { display: none; }
  .stage { display: block; position: relative; }
  .map-stage { width: 100%; height: 100%; border-radius: 17px; }
  .signal-rail { position: absolute; z-index: 900; left: 8px; right: 8px; bottom: 8px; max-height: 72%; transform: translateY(calc(100% + 18px)); transition: transform .28s cubic-bezier(.2,.8,.2,1); border-radius: 18px; }
  .signal-rail.open { transform: translateY(0); }
  .layer-grid { grid-template-columns: repeat(3, 1fr); max-height: 210px; overflow: auto; }
  .layer-card { min-height: 72px; padding: 8px; }
  .layer-name { font-size: 9px; }
  .layer-meta { display: none; }
  .hero-readout { left: 10px; bottom: 10px; width: 176px; padding: 11px 12px; }
  .hero-time { font-size: 34px; }
  .map-legend { top: 10px; left: 10px; width: 150px; max-height: 36%; }
  .mobile-panel-toggle { display: grid; place-items: center; position: absolute; z-index: 910; right: 12px; bottom: 12px; width: 46px; height: 46px; border: 1px solid var(--line-strong); border-radius: 50%; background: rgba(7,16,14,.9); color: var(--mint); box-shadow: var(--shadow); font-size: 20px; }
  .signal-rail.open + * { display: none; }
  .ticker { grid-template-columns: 46px 1fr; }
  .ticker-clock { display: none; }
  .ticker-label { font-size: 7px; }
}

@media (max-width: 420px) {
  .top-actions #recenterBtn { display: none; }
  .layer-grid { grid-template-columns: repeat(2, 1fr); }
  .map-legend { display: none; }
}
