/* MentatFinance v2 — Bloomberg/IB Dark Theme — Responsive */

:root {
  --bg:        #0A0A0F;
  --surface:   #111118;
  --surface-2: #181820;
  --surface-3: #0D0D14;
  --border:    #252535;
  --border-2:  #1A1A28;

  --cyan:   #00B4D8;
  --gold:   #C9A84C;
  --green:  #00C896;
  --red:    #FF4040;
  --yellow: #FFD700;
  --purple: #9B72CF;

  --text:   #E0E0F0;
  --text-2: #9898B8;
  --text-3: #55556A;
  --white:  #FFFFFF;

  --font-mono: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
  --font-ui:   'Inter', system-ui, -apple-system, sans-serif;

  /* Tamaños base — legibles */
  --sz-price:    24px;
  --sz-ticker:   16px;
  --sz-data:     15px;
  --sz-label:    12px;
  --sz-tiny:     11px;
  --row-h:       42px;
  --cell-pad:    8px 14px;
}

/* ══ THEMES ════════════════════════════════════════════════════════════════ */
[data-theme="dark"], :root {
  --bg:        #0A0A0F;
  --surface:   #111118;
  --surface-2: #181820;
  --surface-3: #0D0D14;
  --border:    #252535;
  --border-2:  #1A1A28;
  --text:   #E0E0F0;
  --text-2: #9898B8;
  --text-3: #55556A;
  --white:  #FFFFFF;
}

[data-theme="light"] {
  --bg:        #EEEEF6;
  --surface:   #FFFFFF;
  --surface-2: #F4F4FC;
  --surface-3: #FAFAFF;
  --border:    #C4C4DC;
  --border-2:  #D8D8EC;
  --text:      #12122A;
  --text-2:    #3A3A60;
  --text-3:    #7070A0;
  --white:     #12122A;
  --cyan:      #006EAA;
  --gold:      #8A5C10;
  --green:     #006840;
  --red:       #C41010;
  --yellow:    #8A5C00;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--sz-data);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ══ HEADER ════════════════════════════════════════════════════════════════ */
.mf-header {
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 100px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 200;
}

/* Logo area — ancho fijo, nunca se comprime */
.mf-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  min-width: 164px;
  width: 164px;
}

.mf-logo-img {
  width: 84px;
  height: 84px;
  border-radius: 6px;
  object-fit: contain;
  background: #000;
  flex-shrink: 0;
}

.mf-logo-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.mf-logo-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.08em;
  color: var(--white);
  white-space: nowrap;
}

/* Light mode: invert logo — desaturate to eliminate JPEG color cast */
[data-theme="light"] .mf-logo-img {
  filter: invert(1) grayscale(1) brightness(1.08) contrast(1.05);
  background: #FFF;
  border: 1px solid var(--border);
}

.mf-logo-tagline {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse-live 2s ease-in-out infinite;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0,200,150,.5); }
  50%       { opacity: .7; box-shadow: 0 0 0 5px rgba(0,200,150,0); }
}

.mf-header-clock {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  margin-left: auto;  /* push to far right of flex header */
  order: 99;
}

.mf-header-sep { flex: 1; }

.mf-header-nav {
  display: flex;
  gap: 4px;
}

.mf-header-nav a {
  color: var(--text-2);
  text-decoration: none;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.mf-header-nav a:hover,
.mf-header-nav a.active {
  color: var(--cyan);
  border-color: var(--border);
  background: var(--surface);
}

.mf-header-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 16px;
  width: 32px; height: 32px;
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.mf-header-btn:hover { color: var(--cyan); border-color: var(--cyan); }

/* ══ MAIN GRID ═════════════════════════════════════════════════════════════ */
.mf-grid {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  grid-template-areas:
    "indices   movers    crypto"
    "options   news      news"
    "radar     radar     radar"
    "gems      gems      gems"
    "watchlist watchlist watchlist";
  gap: 2px;
  padding: 2px;
  background: var(--border-2);
}

/* ══ PANELS ════════════════════════════════════════════════════════════════ */
.mf-panel {
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mf-panel-hdr {
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: var(--sz-tiny);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cyan);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.mf-panel-hdr-right {
  font-size: var(--sz-tiny);
  color: var(--text-3);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  font-family: var(--font-mono);
}

/* Grid areas */
.mf-indices   { grid-area: indices; }
.mf-movers    { grid-area: movers; }
.mf-crypto    { grid-area: crypto; }
.mf-options   { grid-area: options; }
.mf-news      { grid-area: news; }
.mf-radar     { grid-area: radar; }
.mf-gems      { grid-area: gems; }
.mf-watchlist { grid-area: watchlist; }

/* ══ INDICES PANEL ════════════════════════════════════════════════════════ */
.idx-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-2);
  transition: background .1s;
}
.idx-row:last-child { border-bottom: none; }
.idx-row:hover { background: var(--surface-2); }

.idx-info { display: flex; flex-direction: column; gap: 2px; }

.idx-ticker {
  font-family: var(--font-mono);
  font-size: var(--sz-ticker);
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.06em;
}

.idx-label {
  font-size: var(--sz-tiny);
  color: var(--text-3);
}

.idx-nums { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

.idx-price {
  font-family: var(--font-mono);
  font-size: var(--sz-price);
  font-weight: 700;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.idx-change {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Sparkline SVG container */
.idx-spark { width: 80px; height: 36px; flex-shrink: 0; }

/* ══ CRYPTO PANEL ═════════════════════════════════════════════════════════ */
.crypto-card {
  padding: 14px 14px;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crypto-card:last-child { border-bottom: none; }

.crypto-sym {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.14em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crypto-price {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.crypto-change {
  font-family: var(--font-mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.crypto-name { font-size: var(--sz-tiny); color: var(--text-3); }

.crypto-spark { width: 100%; height: 42px; margin-top: 4px; }

/* ══ TOP MOVERS ═══════════════════════════════════════════════════════════ */
.movers-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  flex: 1;
}

.movers-side { display: flex; flex-direction: column; }

.movers-side-hdr {
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: var(--sz-tiny);
  font-weight: 700;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
  background: var(--surface-3);
}
.movers-side-hdr.up   { color: var(--green); }
.movers-side-hdr.down { color: var(--red); }
.movers-side:first-child { border-right: 1px solid var(--border); }

.mover-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-2);
  transition: background .1s;
}
.mover-row:hover { background: var(--surface-2); }
.mover-row:last-child { border-bottom: none; }

.mover-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.mover-ticker {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--cyan);
}

.mover-name {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.mover-price {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.mover-pct {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ══ NEWS PANEL ═══════════════════════════════════════════════════════════ */
.news-list { display: flex; flex-direction: column; }

.news-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-2);
  transition: background .1s;
  align-items: flex-start;
  cursor: pointer;
  text-decoration: none;
}
.news-item:hover { background: var(--surface-2); }
.news-item:last-child { border-bottom: none; }

.news-arrow {
  color: var(--cyan);
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

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

.news-title {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 3px;
  /* truncate long titles */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-meta {
  font-size: var(--sz-tiny);
  color: var(--text-3);
  display: flex;
  gap: 6px;
}

.news-source { color: var(--gold); }

/* ══ OPTIONS PANEL ════════════════════════════════════════════════════════ */
.opts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--sz-data);
  font-family: var(--font-mono);
}

.opts-table th {
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--sz-tiny);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.opts-table th:first-child { text-align: left; }

.opts-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.opts-table td:first-child { text-align: left; }
.opts-table tr:last-child td { border-bottom: none; }
.opts-table tr:hover td { background: var(--surface-2); }

/* ══ RADAR ════════════════════════════════════════════════════════════════ */
.radar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  background: var(--border-2);
}

.radar-card {
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-right: 1px solid var(--border-2);
  transition: background .1s;
}
.radar-card:last-child { border-right: none; }
.radar-card:hover { background: var(--surface-2); }

.radar-ticker {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.06em;
}

.radar-name {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-top: -2px;
  margin-bottom: 2px;
}

.radar-price {
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.radar-change {
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.radar-rsi {
  font-size: var(--sz-label);
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}

.radar-rsi-val { color: var(--gold); font-family: var(--font-mono); }

.radar-spark { width: 100%; height: 34px; margin-top: 2px; }

/* ══ HIDDEN GEMS ══════════════════════════════════════════════════════════ */
.gems-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  background: var(--border-2);
}
.gems-skeleton {
  grid-column: span 5;
  padding: 16px 14px;
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.gems-card {
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid var(--border-2);
  transition: background .1s;
  cursor: pointer;
}
.gems-card:last-child { border-right: none; }
.gems-card:hover { background: var(--surface-2); }
.gems-ticker {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.06em;
}
.gems-name {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: -2px;
}
.gems-price {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  margin-top: 3px;
}
.gems-ytd {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.gems-rsi {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
}
.gems-why {
  font-size: 9px;
  color: var(--text-3);
  margin-top: 4px;
  border-top: 1px solid var(--border-2);
  padding-top: 4px;
  line-height: 1.4;
}
@media (max-width: 1100px) {
  .gems-grid { grid-template-columns: repeat(3, 1fr); }
  .gems-skeleton { grid-column: span 3; }
}
@media (max-width: 640px) {
  .gems-grid { grid-template-columns: repeat(2, 1fr); }
  .gems-skeleton { grid-column: span 2; }
}

/* ══ BADGES ══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
  text-transform: uppercase;
}
.badge-call     { background: rgba(0,200,150,.12); color: var(--green); }
.badge-put      { background: rgba(255,64,64,.12);  color: var(--red); }
.badge-alcista  { background: rgba(0,200,150,.12); color: var(--green);  padding: 2px 7px; border-radius: 3px; }
.badge-bajista  { background: rgba(255,64,64,.12);  color: var(--red);   padding: 2px 7px; border-radius: 3px; }
.badge-rango    { background: rgba(255,215,0,.1);   color: var(--yellow); padding: 2px 7px; border-radius: 3px; }
.badge-neutral  { background: rgba(255,215,0,.1);   color: var(--yellow); padding: 2px 7px; border-radius: 3px; }
.badge-sobreventa { background: rgba(155,114,207,.12); color: var(--purple); padding: 2px 7px; border-radius: 3px; }

/* ══ COLOR UTILS ═════════════════════════════════════════════════════════ */
.pos { color: var(--green); }
.neg { color: var(--red); }
.neu { color: var(--text-2); }

/* ══ FOOTER ══════════════════════════════════════════════════════════════ */
.mf-footer {
  background: var(--surface-3);
  border-top: 1px solid var(--border);
  padding: 0 16px;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  bottom: 0;
  z-index: 200;
}

.footer-refresh { display: flex; flex-direction: column; gap: 3px; }

.footer-refresh-label {
  font-size: var(--sz-tiny);
  color: var(--text-3);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.refresh-track {
  width: 140px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.refresh-fill {
  height: 100%;
  background: var(--cyan);
  border-radius: 2px;
  transition: width .5s linear;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  transition: all .15s;
  white-space: nowrap;
}
.btn-ghost:hover { color: var(--white); border-color: var(--text-2); background: var(--surface); }
.btn-ghost:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-cta {
  background: rgba(0,180,216,.1);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: all .15s;
  white-space: nowrap;
}
.btn-cta:hover { background: var(--cyan); color: var(--bg); }
.btn-cta:disabled { opacity: 0.35; cursor: not-allowed; }

.footer-tokens {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--sz-tiny);
  color: var(--text-2);
  padding-left: 14px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.footer-token-val { color: var(--gold); font-size: 13px; }
.footer-model { color: var(--text-3); }

/* ══ SKELETON ════════════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 3px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-row { height: 38px; margin: 2px 8px; }

/* ══ MODAL ═══════════════════════════════════════════════════════════════ */
.mf-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}
.mf-overlay.open { display: flex; }

.mf-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
}

.mf-modal-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.1em;
  margin-bottom: 18px;
}

.mf-field { margin-bottom: 14px; }

.mf-label {
  display: block;
  font-size: var(--sz-tiny);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
  font-family: var(--font-mono);
}

.mf-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 3px;
  outline: none;
  transition: border-color .15s;
}
.mf-input:focus { border-color: var(--cyan); }

.mf-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.mf-modal-err {
  color: var(--red);
  font-size: var(--sz-tiny);
  margin-top: 8px;
  display: none;
}

.mf-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ══ TOAST ════════════════════════════════════════════════════════════════ */
.mf-toast {
  position: fixed;
  bottom: 70px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  color: var(--text);
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 4px;
  z-index: 2000;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .25s, transform .25s;
  max-width: 360px;
  pointer-events: none;
}
.mf-toast.show { opacity: 1; transform: translateX(0); }
.mf-toast.err  { border-left-color: var(--red); }
.mf-toast.ok   { border-left-color: var(--green); }

/* ══ RESEARCH PAGE ════════════════════════════════════════════════════════ */
.res-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2px;
  background: var(--border-2);
  padding: 2px;
  min-height: calc(100vh - 48px - 54px);
}

.res-sidebar {
  background: var(--surface);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.res-result {
  background: var(--surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.res-ticker-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  text-transform: uppercase;
  transition: border-color .15s;
}
.res-ticker-input:focus { border-color: var(--cyan); }
.res-ticker-input::placeholder { color: var(--text-3); font-size: 16px; }

.res-section-label {
  font-family: var(--font-mono);
  font-size: var(--sz-tiny);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.steps-list { display: flex; flex-direction: column; gap: 10px; }

.step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-3);
}
.step-row.active { color: var(--cyan); }
.step-row.done   { color: var(--green); }

.step-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.step-row.active .step-dot { background: var(--cyan); animation: pulse-live 1.5s infinite; }
.step-row.done   .step-dot { background: var(--green); }

.res-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  letter-spacing: 0.06em;
  transition: background .1s;
}
.res-chip:hover { background: var(--border); }

/* ══ THEME TOGGLE ══════════════════════════════════════════════════════════ */
.theme-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  flex-shrink: 0;
}
.theme-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all .15s;
}
.theme-btn:hover   { color: var(--text); }
.theme-btn.active  { background: var(--surface-3); color: var(--cyan); border: 1px solid var(--border); }

/* Chart period buttons */
.chart-period-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: .08em;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all .15s;
}
.chart-period-btn:hover { color: var(--text-2); border-color: var(--text-3); }
.chart-period-btn.active { background: var(--surface-3); color: var(--cyan); border-color: var(--cyan); }

/* ══ ANALYSIS META BAR ════════════════════════════════════════════════════ */
.an-meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 16px 6px 0;
}
.an-meta-label {
  font-size: 9px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-family: var(--font-mono);
}
.an-meta-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.an-meta-sep {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  margin: 4px 16px 4px 0;
}

/* ══ RECOMMENDATION CARD ══════════════════════════════════════════════════ */
.an-rec-section { background: linear-gradient(135deg, rgba(0,180,216,.04) 0%, transparent 60%); }
.an-rec-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: 4px;
  padding: 16px 20px;
}
.an-rec-strategy {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 900;
  color: var(--cyan);
  letter-spacing: .1em;
  margin-bottom: 8px;
}
.an-rec-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 10px;
}
.an-rec-meta {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

/* ══ SCENARIOS + PAYOFF ═══════════════════════════════════════════════════ */
.an-scenarios-payoff {
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 800px) { .an-scenarios-payoff { grid-template-columns: 1fr; } }

.an-scenarios-col { display: flex; flex-direction: column; gap: 8px; }
.an-payoff-col { display: flex; flex-direction: column; }

.an-scenario-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
}

/* ══ MOBILE BOTTOM NAV ════════════════════════════════════════════════════ */
.mf-mobile-nav {
  display: none; /* hidden on desktop */
}

/* ══ RESPONSIVE ═══════════════════════════════════════════════════════════ */

/* Tablet: 2 columnas */
@media (max-width: 1100px) {
  .mf-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "indices  crypto"
      "movers   movers"
      "options  news"
      "radar    radar"
      "gems     gems";
  }
  .radar-grid { grid-template-columns: repeat(3, 1fr); }
  .mf-logo-tagline { display: none; }
  :root { --sz-price: 20px; }
}

/* iPhone / móvil: 1 columna */
@media (max-width: 640px) {
  :root {
    --sz-price: 20px;
    --sz-ticker: 15px;
    --sz-data: 13px;
    --sz-label: 11px;
    --sz-tiny: 10px;
  }

  /* ── Header mobile ─────────────────────────────── */
  .mf-header {
    height: 52px;
    padding: 0 12px;
    gap: 8px;
  }
  .mf-logo {
    min-width: auto;
    width: auto;
  }
  .mf-logo-img {
    width: 38px;
    height: 38px;
  }
  .mf-logo-wordmark { display: none; }
  .mf-header-nav    { display: none; }
  .theme-toggle     { display: none; }
  .mf-header-clock  { display: none; } /* libera espacio para botones en header mobile */

  /* ── Bottom nav (mobile only) ──────────────────── */
  .mf-mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--surface-3);
    border-top: 2px solid var(--border);
    z-index: 300;
    justify-content: space-around;
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mf-mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-3);
    font-size: 9px;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    border-top: 2px solid transparent;
    transition: color .15s, border-color .15s;
    padding-top: 2px;
  }
  .mf-mobile-nav-item.active {
    color: var(--cyan);
    border-top-color: var(--cyan);
  }
  .mf-mobile-nav-item span.mbn-icon {
    font-size: 18px;
    line-height: 1;
  }

  /* ── Content padding-bottom for nav overlap ────── */
  .mf-grid,
  .res-layout,
  .mnt-grid,
  .sig-grid,
  .mf-main-wrap {
    padding-bottom: 68px !important;
  }

  /* ── Dashboard grid ────────────────────────────── */
  .mf-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "indices"
      "crypto"
      "movers"
      "news"
      "options"
      "radar";
  }

  .radar-grid { grid-template-columns: repeat(2, 1fr); }
  .movers-cols { grid-template-columns: 1fr; }
  .movers-side:first-child { border-right: none; border-bottom: 1px solid var(--border); }

  .mf-footer { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .footer-refresh { width: 100%; }
  .refresh-track { width: 100%; }
  .footer-actions { margin-left: 0; width: 100%; justify-content: space-between; }
  .footer-tokens { display: none; }

  /* ── Research layout ───────────────────────────── */
  .res-layout { grid-template-columns: 1fr; }
  .res-sidebar { padding: 14px; }

  /* ── Analysis page mobile ──────────────────────── */
  .an-header { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .an-ticker-block { width: 100%; }
  .an-price-block  { flex: 1; }
  .an-rating-block { flex: 1; min-width: 100px; }
  .an-section { padding: 12px; }
  .an-ind-grid { grid-template-columns: repeat(3, 1fr); }
  .an-table { font-size: 12px; }
  .an-pnl-grid { grid-template-columns: repeat(2, 1fr); }
  .an-meta-item { padding: 6px 10px; }
  .chart-period-btn { font-size: 9px; padding: 3px 6px; }

  /* mnt-grid and sig-grid handle their own mobile padding via inline CSS */

  /* ── Prevent horizontal overflow ───────────────── */
  body { overflow-x: hidden; }
  .mf-panel, .mnt-panel, .sig-panel { overflow: hidden; }
  table { overflow-x: auto; display: block; }
  svg   { max-width: 100%; }
}

/* iOS input zoom prevention — font-size must be ≥ 16px */
@media (max-width: 640px) {
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ══ SCROLLBAR ════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ══ MISC ════════════════════════════════════════════════════════════════ */
.divider { height: 1px; background: var(--border); margin: 4px 0; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Reporte modal steps */
.rpt-step-text {
  font-size: 13px;
  color: var(--text-2);
  font-family: var(--font-mono);
  min-height: 20px;
}


/* ══ MI WATCHLIST ════════════════════════════════════════════════════════ */

.wl-add-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.wl-input {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  text-transform: uppercase;
  transition: border-color .15s;
}
.wl-input:focus { border-color: var(--cyan); }
.wl-input::placeholder { text-transform: none; color: var(--text-3); }

.wl-add-btn {
  background: var(--cyan);
  border: none;
  border-radius: 5px;
  color: #000;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: opacity .15s;
}
.wl-add-btn:hover { opacity: .85; }

/* ══ WATCHLIST — vertical rows ══════════════════════════════════════════ */
.wl-grid {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
}

.wl-empty {
  padding: 24px 16px;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  background: var(--surface);
}

/* ── Row ── */
.wl-row {
  border-bottom: 1px solid var(--border-2);
  background: var(--surface);
  transition: background .1s;
}
.wl-row:last-child { border-bottom: none; }
.wl-row.expanded { background: var(--surface-2); }

/* ── Row header (clickable) ── */
.wl-row-hdr {
  display: grid;
  grid-template-columns: 52px 1fr auto 56px 72px 24px;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.wl-row-hdr:hover { background: var(--surface-2); }
.wl-row.expanded .wl-row-hdr { background: var(--surface-2); }

.wl-row-ticker {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: .03em;
}
.wl-row-name {
  font-size: 10px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wl-row-spark { /* sparkline column */ }
.wl-row-price {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.wl-row-chg {
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.wl-row-chevron {
  font-size: 10px;
  color: var(--text-3);
  text-align: center;
  transition: transform .2s;
  flex-shrink: 0;
}
.wl-row.expanded .wl-row-chevron { transform: rotate(180deg); }

/* ── Expanded fundamentals panel ── */
.wl-fundamentals {
  display: none;
  padding: 0 12px 14px 12px;
  animation: wlFadeIn .15s ease;
}
@keyframes wlFadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
.wl-row.expanded .wl-fundamentals { display: block; }

.wl-fund-loading {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  padding: 8px 0;
  letter-spacing: .06em;
}

.wl-fund-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
@media (max-width: 640px) {
  .wl-fund-grid { grid-template-columns: repeat(2, 1fr); }
}

.wl-fund-item {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 10px;
}
.wl-fund-lbl {
  font-size: 9px;
  color: var(--text-3);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.wl-fund-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
}

.wl-fund-desc {
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.5;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--surface-3);
  border-radius: 4px;
  border-left: 2px solid var(--border);
}

.wl-fund-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-wl-analyze {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #000;
  background: var(--cyan);
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
}
.btn-wl-analyze:hover { opacity: .85; }
.btn-wl-remove {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-wl-remove:hover { color: var(--red); border-color: var(--red); }

/* Cursor pointer en todas las cards clickables */
.idx-row, .mover-row, .radar-card, .crypto-card { cursor: pointer; }


/* ══ CHART MODAL ════════════════════════════════════════════════════════ */

.chart-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.chart-overlay.open { display: flex; }

.chart-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.chart-modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-3);
  flex-shrink: 0;
  gap: 16px;
}

.chart-hdr-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.chart-ticker {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: .06em;
}
.chart-name {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.chart-hdr-center {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.chart-price {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.chart-change {
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.chart-hdr-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chart-periods {
  display: flex;
  gap: 4px;
}
.cp-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all .15s;
}
.cp-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.cp-btn.active { background: var(--cyan); border-color: var(--cyan); color: #000; font-weight: 700; }

.chart-close-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-2);
  font-size: 14px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-close-btn:hover { border-color: var(--red); color: var(--red); }

/* Body */
.chart-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-2);
  font-size: 13px;
  background: var(--surface);
  z-index: 2;
}
.chart-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.chart-pane { width: 100%; }
.chart-pane-main  { height: 340px; }
.chart-pane-vol   { height: 80px; border-top: 1px solid var(--border-2); }
.chart-pane-rsi   { height: 90px; border-top: 1px solid var(--border-2); }

/* Legend */
.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-3);
  flex-shrink: 0;
}
.cl-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
}
.cl-dot {
  width: 10px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
}

/* Cursor en índices clickables */
.idx-row { cursor: pointer; }

/* Responsive chart */
@media (max-width: 640px) {
  .chart-pane-main { height: 220px; }
  .chart-pane-vol  { height: 60px; }
  .chart-pane-rsi  { height: 70px; }
  .chart-name { display: none; }
}

/* Responsive grid watchlist */
@media (max-width: 1100px) {
  .mf-grid {
    grid-template-areas:
      "indices   crypto"
      "movers    movers"
      "options   news"
      "radar     radar"
      "gems      gems"
      "watchlist watchlist";
  }
}
@media (max-width: 640px) {
  .mf-grid {
    grid-template-areas:
      "indices"
      "crypto"
      "movers"
      "news"
      "options"
      "radar"
      "gems"
      "watchlist";
  }
}

/* ═══════════════════════════════════════════ ADMIN MODAL ══ */
.mf-modal--wide {
  width: min(960px, 96vw);
  max-width: 96vw;
  max-height: 92vh;
  overflow-y: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 12px;
  font-size: 13px;
  table-layout: fixed;
}
.admin-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }

.admin-td-user {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--cyan);
}
.admin-td-actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}
.admin-td-actions .btn-ghost {
  font-size: 11px;
  padding: 2px 8px;
  min-height: unset;
  height: 24px;
}
.admin-td-actions .btn-ghost.danger { color: var(--red); border-color: var(--red); }

.admin-add-form {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin: 8px 0;
}
.admin-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
@media (max-width: 500px) {
  .admin-add-grid { grid-template-columns: 1fr; }
}

/* Role & status badges */
.badge-role-admin  { background: rgba(0,180,216,.15); color: #00B4D8; border: 1px solid rgba(0,180,216,.3); }
.badge-role-user   { background: rgba(139,146,154,.1); color: var(--text-2); border: 1px solid var(--border); }
.badge-status-active   { background: rgba(0,200,150,.15); color: #00C896; border: 1px solid rgba(0,200,150,.3); }
.badge-status-expired  { background: rgba(255,64,64,.12);  color: var(--red);  border: 1px solid rgba(255,64,64,.3); }
.badge-status-inactive { background: rgba(139,146,154,.1); color: var(--text-3); border: 1px solid var(--border); }

/* Inline edit inputs inside the table */
.admin-table .mf-input, .admin-table .mf-select {
  font-size: 11px;
  padding: 3px 6px;
  height: 26px;
}
