/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* BBVA brand */
  --bbva-dark:    #004481;
  --bbva-mid:     #1973B8;
  --bbva-light:   #049EDB;
  --bbva-teal:    #2DCCCD;
  /* Dark theme */
  --bg:           #0D1117;
  --bg-white:     #161B22;
  --bg-card:      #1C2333;
  --bg-hover:     #21283A;
  --border:       #30363D;
  --text:         #E6EDF3;
  --text-muted:   #8B949E;
  --text-light:   #6E7681;
  --green:        #3FB950;
  --red:          #F85149;
  --yellow:       #D29922;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.30);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.40);
  --radius:       8px;
  --radius-sm:    5px;
  --font:         'Inter', -apple-system, sans-serif;
  --font-mono:    'SF Mono', 'Roboto Mono', 'Courier New', monospace;
}

html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === HEADER === */
.header {
  background: var(--bbva-dark);
  color: white;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.20);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.bbva-logo { display: flex; align-items: center; }
.logo-bbva {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  color: white;
  font-family: var(--font);
}

.header-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.25);
}

.header-title { display: flex; flex-direction: column; }
.header-main  { font-size: 14px; font-weight: 600; color: white; line-height: 1.2; }
.header-sub   { font-size: 11px; color: rgba(255,255,255,0.65); line-height: 1.2; }

.header-right { display: flex; align-items: center; gap: 20px; }

.market-status {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.10);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ccc;
  transition: background 0.3s;
}
.status-dot.open   { background: #00E676; box-shadow: 0 0 6px #00E676; animation: pulse 2s infinite; }
.status-dot.closed { background: #FF5252; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.header-datetime {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  line-height: 1.4;
}

.last-update-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}
.update-icon { font-size: 13px; }

/* === LAYOUT === */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* === SIDE PANEL === */
.side-panel {
  width: 200px;
  min-width: 200px;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  flex-shrink: 0;
}

.panel-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--bbva-dark);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.panel-dates { display: flex; flex-direction: column; gap: 5px; }
.panel-date-row { display: flex; justify-content: space-between; align-items: center; }
.pd-label { font-size: 11px; color: var(--text-muted); }
.pd-value  { font-size: 12px; font-weight: 500; font-family: var(--font-mono); }
.pd-value.accent { color: var(--bbva-mid); font-weight: 600; }

.panel-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}
.panel-metric:last-child { margin-bottom: 0; }
.pm-name  { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.pm-value {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text);
}
.pm-value.highlight { color: var(--bbva-mid); }

.panel-footer {
  padding: 12px 16px;
  margin-top: auto;
}
.pf-source  { font-size: 10px; color: var(--text-light); margin-bottom: 3px; }
.pf-refresh { font-size: 10px; color: var(--text-light); }

/* === CONTENT === */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100vh - 56px);
}

/* === NAV TABS === */
.nav-tabs {
  display: flex;
  background: var(--bg-white);
  border-bottom: 2px solid var(--border);
  padding: 0 20px;
  gap: 2px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  overflow-x: auto;
}

.nav-tab {
  background: none;
  border: none;
  padding: 14px 16px 12px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
}
.nav-tab:hover  { color: var(--bbva-mid); background: var(--bg-hover); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.nav-tab.active { color: var(--bbva-light); border-bottom-color: var(--bbva-light); font-weight: 600; }

/* === TAB PANELS === */
.tab-panel { display: none; padding: 20px; flex-direction: column; gap: 20px; }
.tab-panel.active { display: flex; }

/* === SECTION BLOCKS === */
.section-block {
  background: var(--bg-white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: linear-gradient(135deg, #1C2333 0%, #21283A 100%);
  border-bottom: 1px solid var(--border);
}

.sh-left { display: flex; align-items: center; gap: 10px; }

.sh-icon {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.lecap-icon    { background: var(--bbva-dark); }
.boncap-icon   { background: var(--bbva-mid); }
.bote-icon     { background: #6B48D9; }
.cer-icon      { background: #E05C00; }
.tamar-icon    { background: #007A5E; }
.dlk-icon      { background: #1A6B3C; }
.dual-icon     { background: #7B3FA0; }
.dual-cer-icon { background: #E05C00; }
.ny-icon       { background: var(--bbva-dark); font-size: 8px; }
.ar-icon       { background: #39ACDC; font-size: 8px; }
.bcra-icon     { background: #6B7A99; font-size: 8px; }
.be-icon       { background: #E05C00; font-size: 14px; }

.sh-title { font-size: 13px; font-weight: 600; color: var(--text); }
.sh-count {
  background: var(--bbva-light);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}
.sh-convention { font-size: 10px; color: var(--text-muted); font-style: italic; }

/* === TABLES === */
.table-wrapper { overflow-x: auto; }

/* === FORWARDS HEATMAP MATRIX === */
.fwd-matrix-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
}

.fwd-matrix {
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--font-mono);
  width: auto;          /* no estira a 100% — la tabla tiene el ancho justo */
}

/* Cabecera de columnas (tickers destino) */
.fwd-matrix thead tr { background: #161B22; }
.fwd-matrix th.fwd-corner {
  position: sticky; left: 0; z-index: 3;
  background: #0D1117;
  color: var(--text-muted);
  font-size: 9px; font-style: italic;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  min-width: 80px;
}
.fwd-matrix th.fwd-col-head {
  padding: 6px 8px;
  text-align: center;
  color: var(--bbva-light);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid #1C2333;
  white-space: nowrap;
  min-width: 72px;
}

/* Etiqueta de fila (ticker origen) */
.fwd-matrix td.fwd-row-label {
  position: sticky; left: 0; z-index: 2;
  background: #0D1117;
  color: var(--bbva-light);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 5px 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid #1C2333;
  white-space: nowrap;
  cursor: default;
}

/* Celda de dato (valor forward) */
.fwd-matrix td.fwd-cell {
  text-align: center;
  padding: 5px 6px;
  border-bottom: 1px solid #1C2333;
  border-left: 1px solid #1C2333;
  white-space: nowrap;
  font-size: 11px;
  color: rgba(240, 246, 252, 0.92);
  font-weight: 500;
  transition: filter 0.1s;
  cursor: default;
}
.fwd-matrix td.fwd-cell:hover { filter: brightness(1.3); }
.fwd-matrix td.fwd-cell.fwd-neg  { color: #FFB3B3; }
.fwd-matrix td.fwd-cell.fwd-high { color: #D0FFD8; }

/* Celda vacía (triángulo inferior) */
.fwd-matrix td.fwd-empty {
  background: #0A0E14;
  border-bottom: 1px solid #1C2333;
  border-left: 1px solid #1C2333;
}

/* Hover de fila completa */
.fwd-matrix tbody tr:hover td { filter: brightness(1.15); }
.fwd-matrix tbody tr:hover td.fwd-row-label { filter: none; color: #fff; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead tr {
  background: #1C2333;
  border-bottom: 1px solid var(--border);
}

th {
  padding: 9px 12px;
  text-align: right;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
th:first-child { text-align: left; }
th:hover { color: var(--bbva-light); background: #21283A; }
th.sort-asc::after  { content: ' ↑'; color: var(--bbva-light); }
th.sort-desc::after { content: ' ↓'; color: var(--bbva-light); }

td {
  padding: 8px 12px;
  text-align: right;
  color: var(--text);
  border-bottom: 1px solid #21283A;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
}
td:first-child { text-align: left; font-family: var(--font); font-weight: 600; font-size: 12px; }

tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* Type badge (L=Lecap, B=Boncap) in combined table */
.type-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  font-size: 11px; font-weight: 700; margin-right: 6px;
  vertical-align: middle; flex-shrink: 0;
}
.lecap-badge  { background: var(--bbva-dark);  color: #fff; }
.boncap-badge { background: #1a6b3f;           color: #fff; }

/* Ticker cell */
.ticker-cell { display: inline-flex; flex-direction: column; gap: 1px; vertical-align: middle; }
.ticker-name { font-weight: 700; color: var(--bbva-light); font-size: 12px; font-family: var(--font); }
.ticker-desc { font-weight: 400; color: var(--text-muted); font-size: 10px; font-family: var(--font); }

/* Number formatting */
.num-positive { color: var(--green); font-weight: 500; }
.num-negative { color: var(--red);   font-weight: 500; }
.num-neutral  { color: var(--text);  }
.num-muted    { color: var(--text-muted); }

/* Paridad badges */
.paridad-high { color: var(--green); }
.paridad-low  { color: var(--yellow); }
.paridad-vlow { color: var(--red); }

/* Rate badges */
.rate-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.rate-green  { background: rgba(63,185,80,0.15);   color: var(--green); }
.rate-red    { background: rgba(248,81,73,0.15);   color: var(--red); }
.rate-blue   { background: rgba(25,115,184,0.15);  color: var(--bbva-light); }
.rate-orange { background: rgba(210,153,34,0.15);  color: var(--yellow); }

/* Dias pill */
.dias-pill {
  background: rgba(4,158,219,0.15);
  color: var(--bbva-light);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}

/* === CHARTS === */
.chart-block {
  background: var(--bg-white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px 12px;
}
.chart-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* === MACRO CARDS === */
.macro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.macro-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.macro-card:hover { box-shadow: var(--shadow-md); }
.mc-label { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.mc-value { font-size: 28px; font-weight: 300; color: var(--bbva-light); font-family: var(--font-mono); line-height: 1; }
.mc-sub   { font-size: 11px; color: var(--text-light); margin-top: 5px; }

/* === LOADING === */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
  gap: 10px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--bbva-mid);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === EMPTY STATE === */
.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* === FOOTER === */
.footer {
  background: var(--bbva-dark);
  color: rgba(255,255,255,0.45);
  font-size: 10px;
  padding: 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

/* Fila del equipo */
.footer-team {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ft-group {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.ft-role {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.35);
}
.ft-name {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.70);
}
.ft-separator {
  color: rgba(255,255,255,0.2);
  font-size: 10px;
}

/* Fila legal */
.footer-legal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(255,255,255,0.35);
  font-size: 9px;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bbva-light); }

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .side-panel { display: none; }
  .nav-tab { padding: 10px 10px; font-size: 11px; }
  .macro-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 600px) {
  .header-datetime { display: none; }
  .last-update-badge { display: none; }
}

/* === BANDAS BCRA === */
.banda-icon  { background: linear-gradient(135deg,#F5A623,#F42534); }
.rem-icon    { background: linear-gradient(135deg,#2DCCCD,#049EDB); }
.vto-icon    { background: linear-gradient(135deg,#6B48D9,#004481); }

.band-low  { color: var(--green) !important; }
.band-high { color: var(--red)   !important; }

.bandas-info { padding: 8px 16px 0; }
.bandas-row  { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.banda-chip {
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.banda-chip.low     { background: rgba(0,166,80,0.12);   color: var(--green); }
.banda-chip.high    { background: rgba(244,37,52,0.12);  color: var(--red); }
.banda-chip.ccl     { background: rgba(4,158,219,0.15);  color: var(--bbva-light); }
.banda-chip.mep     { background: rgba(25,115,184,0.12); color: var(--bbva-mid); }
.banda-chip.neutral { background: var(--bg-hover);       color: var(--text-muted); font-weight: 400; }

/* === BREAKEVEN TABLE EXTRAS === */
.be-legend  { padding: 6px 12px; font-size: 11px; color: var(--text-muted); background: #1C2333; }
.be-scen    { font-weight: 700; color: var(--bbva-mid); }
.badge-exact  { display:inline-block; padding:1px 5px; background:rgba(0,166,80,0.15); color:var(--green); border-radius:4px; font-size:10px; font-weight:700; margin-left:4px; }
.badge-close  { display:inline-block; padding:1px 5px; background:rgba(245,166,35,0.15); color:#B8820A; border-radius:4px; font-size:10px; font-weight:700; margin-left:4px; }
.breakeven-val { color: var(--bbva-mid); font-size: 13px; }
