/* ==================================================================
   GŁØWO MARKET TERMINAL
   Design tokens
   ------------------------------------------------------------------
   Color:
     --bg-0   #0A0B0D   fondo general (casi negro, cálido, no #000)
     --bg-1   #111318   fondo de panel
     --bg-2   #171A20   fondo de fila hover / cabeceras internas
     --line   #23262E   bordes y separadores
     --line-2 #2C303A   bordes ligeramente más visibles (hover)
     --ink-0  #E7E9ED   texto primario
     --ink-1  #9AA0AC   texto secundario
     --ink-2  #5B6270   texto terciario / labels
     --up     #21C17C   verde (subidas)
     --up-dim #163C2C   verde fondo tenue
     --down   #E5484D   rojo (bajadas)
     --down-dim #3C1A1C fondo tenue rojo
     --accent #C9A15C   acento ámbar/oro — único color no semántico
   Type:
     Display / labels → Inter (tracking amplio, mayúsculas)
     Data / numbers   → JetBrains Mono (tabular, distingue 0/O)
   ================================================================== */

:root {
  --bg-0: #0A0B0D;
  --bg-1: #111318;
  --bg-2: #171A20;
  --line: #23262E;
  --line-2: #2C303A;
  --ink-0: #E7E9ED;
  --ink-1: #9AA0AC;
  --ink-2: #5B6270;
  --up: #21C17C;
  --up-dim: rgba(33, 193, 124, 0.12);
  --down: #E5484D;
  --down-dim: rgba(229, 72, 77, 0.12);
  --accent: #C9A15C;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: var(--font-ui);
  height: 100%;
  overflow: hidden;
}

::selection { background: var(--accent); color: #0A0B0D; }

/* ------------------------------------------------------------------
   Terminal shell — diseñado en unidades vh/vw fijas para llenar
   exactamente una pantalla 3440x1440 (21:9) sin scroll.
   ------------------------------------------------------------------ */

.terminal {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: 44px 1fr 30px;
  background: var(--bg-0);
}

/* ==================================================================
   HEADER
   ================================================================== */

.hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}

.hdr-left, .hdr-right {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
}

.hdr-logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.hdr-logo-mark {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--ink-0);
}

.hdr-logo-o { color: var(--accent); }

.hdr-logo-sub {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--ink-2);
}

.hdr-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
}

.hdr-nav {
  display: flex;
  gap: 18px;
}

.hdr-nav-item {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  cursor: default;
  padding: 4px 0;
  border-bottom: 1.5px solid transparent;
  transition: color 0.15s ease;
}

.hdr-nav-item.is-active {
  color: var(--ink-0);
  border-bottom-color: var(--accent);
}

.hdr-city {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hdr-city-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-2);
}

.hdr-city-time {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-0);
  font-variant-numeric: tabular-nums;
  min-width: 72px;
}

.hdr-status {
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 3px var(--up-dim);
}

.hdr-status.is-closed .status-dot {
  background: var(--down);
  box-shadow: 0 0 0 3px var(--down-dim);
}

.status-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-0);
}

/* ==================================================================
   GRID 2x2
   ================================================================== */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  overflow: hidden;
}

.panel {
  background: var(--bg-1);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  overflow: hidden;
}

.panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.panel-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-0);
}

.panel-subtitle {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}

.panel-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--up);
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.live-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-2);
}

.panel-body {
  padding: 10px 20px;
  overflow: hidden;
  min-height: 0;
}

.panel-ftr {
  padding: 7px 20px;
  border-top: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  font-family: var(--font-mono);
}

/* ==================================================================
   PANEL 1 — MARKETS
   ================================================================== */

.markets-head-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.85fr 0.75fr 0.75fr;
  padding: 6px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}

.col-num { text-align: right; }
.col-spark { text-align: center; }

.markets-list {
  display: flex;
  flex-direction: column;
}

.markets-breadth {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.breadth-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.breadth-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-2);
}

.breadth-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
}

.breadth-bar {
  flex: 1;
  height: 4px;
  display: flex;
  overflow: hidden;
  background: var(--line);
}

.breadth-bar-up { background: var(--up); }
.breadth-bar-down { background: var(--down); }

.market-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.85fr 0.75fr 0.75fr;
  align-items: center;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s ease;
}

.market-row:hover { background: var(--bg-2); }

.market-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-0);
}

.market-region {
  font-size: 8.5px;
  color: var(--ink-2);
  letter-spacing: 0.06em;
  margin-left: 6px;
}

/* ------------------------------------------------------------------
   INDICADOR DE ESTADO DE DATO (V2) — único añadido visual sobre la
   V1, usado en Markets, Bonds y Macro para distinguir datos LIVE de
   STALE/SIMULATED sin texto permanente en pantalla (el detalle va en
   el atributo title, como tooltip nativo del navegador).
   Deliberadamente SIN animación: la V1 ya usa el pulso (.live-dot,
   ver pulse-dot más abajo) para significar "esto se está
   actualizando en vivo" — reutilizar esa animación aquí mandaría el
   mensaje contrario a un dato que precisamente NO es fresco.
   ------------------------------------------------------------------ */
.status-dot-inline {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  cursor: help;
}

.status-dot-stale {
  background: var(--accent);
}

.status-dot-simulated {
  background: var(--ink-2);
}

.market-spark {
  display: flex;
  justify-content: center;
}

.market-price, .market-chg, .market-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.market-chg, .market-pct {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-weight: 500;
}

.is-up { color: var(--up); }
.is-down { color: var(--down); }
.is-flat { color: var(--ink-1); }

.flash-up { animation: flashUp 0.9s ease-out; }
.flash-down { animation: flashDown 0.9s ease-out; }

@keyframes flashUp {
  0% { background: var(--up-dim); }
  100% { background: transparent; }
}
@keyframes flashDown {
  0% { background: var(--down-dim); }
  100% { background: transparent; }
}

/* ==================================================================
   PANEL 2 — NEWS
   ================================================================== */

.news-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.news-item {
  display: flex;
  gap: 12px;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.news-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  min-width: 38px;
  padding-top: 1px;
}

.news-body { flex: 1; min-width: 0; }

.news-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.news-category {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.news-source {
  font-size: 8.5px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

.news-source::before {
  content: '·';
  margin-right: 6px;
  color: var(--ink-2);
}

.news-headline {
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-0);
  font-weight: 400;
}

/* ==================================================================
   PANEL 3 — BONDS
   ================================================================== */

.panel-body-split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  min-height: 0;
  overflow: hidden;
}

.bonds-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.bonds-col::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 18px;
  background: linear-gradient(to bottom, transparent, var(--bg-1));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.bonds-col.has-overflow::after {
  opacity: 1;
}

.bonds-list {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.bonds-list::-webkit-scrollbar { width: 4px; }
.bonds-list::-webkit-scrollbar-thumb { background: var(--line-2); }
.bonds-list::-webkit-scrollbar-track { background: transparent; }

.bonds-head-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  padding: 6px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}

.bond-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  align-items: center;
  padding: 15px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.bond-row.is-highlight {
  background: rgba(201, 161, 92, 0.05);
}

.bond-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-0);
}

.bond-row.is-highlight .bond-name {
  color: var(--accent);
}

.bond-yield, .bond-chg {
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bond-chg { font-weight: 500; }

.bonds-curve-col {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  padding-left: 18px;
  min-height: 0;
  overflow: hidden;
}

.curve-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.curve-svg {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  max-height: 100%;
  display: block;
  overflow: visible;
}

.curve-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-2);
}

/* ==================================================================
   PANEL 4 — MACRO
   ================================================================== */

.panel-body-macro {
  display: grid;
  grid-template-rows: auto minmax(140px, 1fr);
  gap: 22px;
  overflow: hidden;
  min-height: 0;
}

.macro-regions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.macro-region-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-1);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.macro-rows {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.macro-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.macro-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.macro-label {
  font-size: 11px;
  color: var(--ink-1);
  letter-spacing: 0.02em;
}

.macro-value-group {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.macro-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-0);
}

.macro-prior {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
}

.macro-trend {
  font-size: 10px;
}

.macro-trend.up { color: var(--up); }
.macro-trend.down { color: var(--down); }
.macro-trend.flat { color: var(--ink-2); }

.macro-range {
  position: relative;
  height: 3px;
  background: var(--line);
  border-radius: 0;
}

.macro-range-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: var(--line-2);
}

.macro-range-marker {
  position: absolute;
  top: -2.5px;
  width: 2px;
  height: 8px;
  background: var(--accent);
  transform: translateX(-1px);
}

.macro-range-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--ink-2);
}

.macro-events {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.macro-events::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 18px;
  background: linear-gradient(to bottom, transparent, var(--bg-1));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.macro-events.has-overflow::after {
  opacity: 1;
}

.macro-events-hdr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.next-event-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(201, 161, 92, 0.06);
  border: 1px solid rgba(201, 161, 92, 0.22);
  margin-bottom: 4px;
}

.next-event-tag {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  padding: 3px 6px;
  border: 1px solid rgba(201, 161, 92, 0.35);
}

.next-event-text {
  font-size: 12px;
  color: var(--ink-0);
  font-weight: 500;
}

.next-event-countdown {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  justify-content: space-evenly;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.events-list::-webkit-scrollbar { width: 4px; }
.events-list::-webkit-scrollbar-thumb { background: var(--line-2); }
.events-list::-webkit-scrollbar-track { background: transparent; }

.event-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  padding: 8px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.event-date {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 600;
  min-width: 52px;
}

.event-time {
  font-family: var(--font-mono);
  color: var(--ink-2);
  min-width: 40px;
}

.event-label {
  color: var(--ink-1);
  letter-spacing: 0.03em;
}

.event-countdown {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

/* ==================================================================
   TICKER
   ================================================================== */

.ticker-bar {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  overflow: hidden;
  height: 30px;
}

.ticker-label {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  padding: 0 16px;
  border-right: 1px solid var(--line);
  height: 100%;
  display: flex;
  align-items: center;
  background: var(--bg-2);
}

.ticker-track-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 100%;
}

.ticker-track {
  display: flex;
  align-items: center;
  gap: 32px;
  white-space: nowrap;
  position: absolute;
  animation: ticker-scroll 45s linear infinite;
  padding-left: 100%;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

.ticker-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.ticker-name {
  color: var(--ink-1);
  font-weight: 500;
}

.ticker-price {
  color: var(--ink-0);
  font-weight: 600;
}

.ticker-chg { font-weight: 600; }

/* ==================================================================
   ACCESIBILIDAD — respeta prefers-reduced-motion
   ================================================================== */

@media (prefers-reduced-motion: reduce) {
  .live-dot, .ticker-track, .flash-up, .flash-down {
    animation: none !important;
  }
}

/* ==================================================================
   RESPONSIVE — la prioridad es 3440x1440, pero se degrada con
   gracia en pantallas más pequeñas.
   ================================================================== */

@media (max-width: 1600px) {
  .panel-body-split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .bonds-curve-col { border-left: none; border-top: 1px solid var(--line); padding-left: 0; padding-top: 14px; }
}

@media (max-width: 1100px) {
  html, body { overflow: auto; height: auto; min-height: 100%; }
  .terminal { height: auto; min-height: 100vh; grid-template-rows: auto auto auto; }
  .grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .panel { height: 560px; min-height: 560px; }
  .hdr-nav { display: none; }
  .macro-regions { grid-template-columns: 1fr; gap: 14px; }
  /* En modo apilado, panel-body-split pasa a filas (ver breakpoint
     de 1600px), pero un grid-template-rows: 1fr 1fr no tiene altura
     propia salvo la que le da el contenido — así que el SVG de la
     yield curve, con flex:1, podía crecer sin límite y arrastrar la
     altura de todo el panel con él. Techo absoluto de seguridad. */
  .curve-svg { flex: none; height: 140px; max-height: 140px; }
  /* macro-regions también pasa a una sola columna aquí (US + EU
     apilados en vez de lado a lado), lo que duplica su altura y deja
     casi sin espacio a "upcoming events". Ocultamos las barras de
     rango histórico (informativas, no esenciales) para recuperar
     esa altura y que la lista de eventos siga siendo legible. */
  .macro-range, .macro-range-labels { display: none; }
  .macro-row { gap: 0; }
  .macro-rows { gap: 8px; }
}

/* Viewports de poca altura (ventana no maximizada, portátil pequeño):
   el banner de "próximo evento" duplica la primera fila de la lista
   de abajo, así que lo ocultamos primero para devolver ese espacio
   a la lista real en vez de dejarla comprimida a un scroll ilegible. */
@media (max-height: 950px) {
  .next-event-banner { display: none; }
  .macro-events-hdr, #nextEventBanner { margin-bottom: 0; }
  .panel-body-macro { grid-template-rows: auto minmax(110px, 1fr); }
}

@media (max-height: 760px) {
  .macro-regions .macro-row { gap: 4px; }
  .macro-rows { gap: 10px; }
  .bond-row { padding: 8px 6px; }
}
