/* ════════════════════════════════════════════════════════════════════════
   SIMULADOR BCCH — SISTEMA VISUAL
   Identidad: violeta + lila + aqua (sin cambios de paleta).
   Reglas: el aqua es ACENTO (foco / estado activo / 1 filo de header), no decoración.
   Ver GUIA-ESTILO.md para "qué token/clase usar para cada cosa".
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Marca BCCH Qü ───────────────────────────────────
     Paleta oficial de marketing. El violeta principal es el CTA;
     el secundario es hover/íconos; los lilas son bordes y fondos. */
  --violeta:        #7C42EF;   /* principal · botones · CTAs · destacados */
  --violeta-2:      #986BF2;   /* secundario · hover · íconos · acentos   */
  --violeta-oscuro: #5E2BD6;   /* presión de botón / superficies legacy   */
  --lila:           #B59AEA;   /* lila medio · bordes / secundarios       */
  --lila-suave:     #C8B5EC;   /* lila suave · fondos de tarjetas         */
  --lila-bg:        #F6F3FB;   /* fondo general lila                      */
  --aqua:           #14E0C8;   /* solo dentro del logo (no decorativo)    */
  --gris-claro:     #F5F5F5;

  /* ── Superficies y texto ─────────────────────────── */
  --bg:        #F6F3FB;   /* fondo de la app (lila suave)*/
  --surface:   #ffffff;   /* cards, tablas, modales     */
  --surface-2: #FAF8FD;   /* zebra (fila par)           */
  --ink:       #1f1733;   /* texto primario / cifras    */
  --ink-2:     #5c5566;   /* texto secundario / labels  */
  --ink-3:     #8a8594;   /* placeholders / metadatos   */
  --line:      #ece6f6;   /* bordes / divisores         */
  --line-2:    #f3eefb;   /* divisores muy suaves       */

  /* ── Semánticos (colores ya usados en la app, ahora tokenizados) ── */
  --pos:    #0d7a52;  --pos-bg: #e3f5ec;   /* sube / compra / ganancia */
  --neg:    #c0392b;  --neg-bg: #fce4e1;   /* baja / venta / pérdida   */
  --info:   #1a5f99;  --info-bg:#e7f0f8;   /* USD / bonos / MEP        */

  /* ── Espaciado (escala de 8) ─────────────────────── */
  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;  --s5: 24px;  --s6: 32px;

  /* ── Tipografía (8 tamaños, ni uno más) ──────────── */
  --fz-11: .6875rem;  /* micro: pills, captions, sort   */
  --fz-12: .75rem;    /* labels, header de tabla        */
  --fz-13: .8125rem;  /* celdas de tabla densas         */
  --fz-14: .875rem;   /* cuerpo base, inputs            */
  --fz-16: 1rem;      /* subtítulos, total de modal     */
  --fz-20: 1.25rem;   /* título de modal, valor de card */
  --fz-24: 1.5rem;    /* cifra destacada                */
  --fz-30: 1.875rem;  /* cifra principal (hero)         */

  /* ── Pesos ───────────────────────────────────────── */
  --w-body: 400;  --w-num: 500;  --w-label: 600;  --w-bold: 700;

  /* ── Radios ──────────────────────────────────────── */
  --r:      6px;     /* base: tablas densas, pills internas        */
  --r-lg:   14px;    /* cards y superficies grandes                */
  --r-input:12px;    /* inputs y botones pill suaves               */
  --r-pill: 999px;

  /* ── Sombras (tinte violeta, solo 2 niveles) ─────── */
  --sh-1: 0 1px 4px rgba(94,43,214,.08);    /* reposo: cards, tablas    */
  --sh-2: 0 10px 30px rgba(94,43,214,.16);  /* flotante: modal, dropdown*/

  /* ── Foco (violeta = acento de marca) ────────────── */
  --focus: 0 0 0 3px rgba(124,66,239,.25);

  /* ── Transición estándar ─────────────────────────── */
  --t: .15s ease;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  font-family: 'Inter', 'Segoe UI', sans-serif;
  color: var(--ink);
  font-size: var(--fz-14);
  line-height: 1.5;
  margin: 0;
}

/* ── Helpers reutilizables ───────────────────────────────────────────── */
.num      { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "lnum" 1; }
.muted    { color: var(--ink-2); }
.muted-2  { color: var(--ink-3); }
.pos      { color: var(--pos); }
.neg      { color: var(--neg); }
.info     { color: var(--info); }
.caption  { font-size: var(--fz-11); color: var(--ink-3); }

/* Números tabulares en todo contexto de datos */
.market-table, .book-table, .inst-table,
.ms-card, .summary-card .value, .modal-monto, .op-row,
.modal-price, .saldo-badge, .book-spread {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* ════════════════════════════════════════════════════════════════════════
   BOTONES — sistema de 4 variantes (.btn + modificador)
   Usar en marcado nuevo. Las clases heredadas (abajo) ya comparten el estilo.
   ════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 34px; padding: 0 var(--s4);
  border: 1px solid transparent; border-radius: var(--r);
  font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label);
  line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background var(--t), color var(--t), border-color var(--t), opacity var(--t);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-sm { height: 28px; padding: 0 var(--s3); font-size: var(--fz-13); }

.btn-primario  { background: var(--violeta); color: #fff; }
.btn-primario:hover  { background: var(--violeta-2); }
.btn-secundario { background: transparent; color: var(--violeta); border-color: var(--lila); }
.btn-secundario:hover { background: #f3edf6; }
.btn-ghost     { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-peligro   { background: transparent; color: var(--neg); border-color: var(--neg); }
.btn-peligro:hover { background: var(--neg); color: #fff; }
.btn-compra    { background: var(--pos); color: #fff; }
.btn-venta     { background: var(--neg); color: #fff; }
.btn-compra:hover, .btn-venta:hover { opacity: .88; }

/* ════════════════════════════════════════════════════════════════════════
   TOP NAV — shell claro estilo BCCH Qü (logo · buscador · íconos · tabs · saldos)
   ════════════════════════════════════════════════════════════════════════ */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}

/* Fila 1: logo + buscador + íconos */
.topnav-main {
  display: flex; align-items: center; gap: var(--s5);
  padding: var(--s3) var(--s5);
}
.topnav-brand { display: flex; align-items: center; text-decoration: none; flex-shrink: 0; }
.topnav-logo { height: 30px; width: auto; object-fit: contain; display: block; }
.topnav-search {
  flex: 1; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: var(--s2);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: var(--s2) var(--s4);
  transition: border-color var(--t), box-shadow var(--t);
}
.topnav-search:focus-within { border-color: var(--violeta); box-shadow: var(--focus); }
.topnav-search svg { width: 18px; height: 18px; color: var(--ink-3); flex-shrink: 0; }
.topnav-search input {
  border: none; outline: none; background: transparent;
  width: 100%; font-family: inherit; font-size: var(--fz-14); color: var(--ink);
}
.topnav-icons { display: flex; align-items: center; gap: var(--s2); flex-shrink: 0; }
.topnav-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--violeta); cursor: pointer; transition: background var(--t), border-color var(--t);
}
.topnav-icon:hover { background: var(--lila-bg); border-color: var(--lila); }
.topnav-icon.active { background: var(--lila-bg); border-color: var(--lila); color: var(--violeta); }
.topnav-icon svg { width: 18px; height: 18px; }

/* Menú de cuenta (dropdown bajo la cabeza) */
.topnav-account { position: relative; }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-input);
  box-shadow: var(--sh-2); min-width: 200px; padding: var(--s2); z-index: 200;
}
.acct-menu-name {
  padding: var(--s2) var(--s3); font-weight: var(--w-label); color: var(--ink);
  font-size: var(--fz-13); border-bottom: 1px solid var(--line-2); margin-bottom: var(--s1);
}
.acct-menu-salir {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: var(--s2) var(--s3); border-radius: var(--r); font-family: inherit;
  font-size: var(--fz-13); color: var(--ink-2); transition: background var(--t), color var(--t);
}
.acct-menu-salir:hover { background: var(--lila-bg); color: var(--neg); }

/* Fila 2: tabs de navegación + chip de cuenta */
.topnav-tabs {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s5); gap: var(--s4);
  border-top: 1px solid var(--line-2);
}
.topnav-links { display: flex; align-items: stretch; gap: var(--s2); }
.topnav-links a {
  display: inline-flex; align-items: center;
  padding: var(--s3) var(--s2); margin: 0 var(--s1);
  color: var(--ink-2); text-decoration: none; font-size: var(--fz-14);
  font-weight: var(--w-label); border-bottom: 2px solid transparent;
  transition: color var(--t), border-color var(--t);
}
.topnav-links a:hover { color: var(--violeta); }
.topnav-links a.nav-active { color: var(--violeta); border-bottom-color: var(--violeta); }
.topnav-links a.nav-disabled { color: var(--ink-3); cursor: default; }
.topnav-links a.nav-disabled:hover { color: var(--ink-3); }
.acct-chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  border: 1px solid var(--lila); border-radius: var(--r-pill);
  padding: var(--s1) var(--s3); font-size: var(--fz-13); color: var(--violeta);
  font-weight: var(--w-label); white-space: nowrap;
}
.acct-chip svg { width: 14px; height: 14px; }
.navbar-salir {
  background: none; border: none; color: var(--ink-3); cursor: pointer;
  font-family: inherit; font-size: var(--fz-13); margin-left: var(--s3);
  transition: color var(--t);
}
.navbar-salir:hover { color: var(--neg); }

/* Fila 3: barra "Disponible para operar" */
.topnav-saldos {
  display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap;
  padding: var(--s2) var(--s5);
  background: var(--lila-bg); border-top: 1px solid var(--line-2);
  font-size: var(--fz-13); color: var(--ink-2);
}
.saldos-label { font-weight: var(--w-label); color: var(--ink-2); }
.plazo-pill {
  display: inline-flex; gap: 2px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 2px;
}
.plazo-pill button {
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: var(--fz-12); font-weight: var(--w-label);
  color: var(--ink-3); padding: 2px var(--s2); border-radius: var(--r-pill);
  transition: background var(--t), color var(--t);
}
.plazo-pill button.active { background: var(--violeta); color: #fff; }
.saldo-item { color: var(--ink-3); }
.saldo-item b { color: var(--ink); font-weight: var(--w-num); margin-left: 4px; }
.saldos-link { color: var(--violeta); font-weight: var(--w-label); text-decoration: none; }
.saldos-link:hover { text-decoration: underline; }
.saldos-toggle {
  margin-left: auto; display: inline-flex; align-items: center; gap: var(--s1);
  background: none; border: none; cursor: pointer; color: var(--ink-2);
  font-family: inherit; font-size: var(--fz-12); transition: color var(--t);
}
.saldos-toggle:hover { color: var(--violeta); }
.saldos-toggle svg { width: 16px; height: 16px; }
.saldos-hidden b { filter: blur(5px); user-select: none; }

/* Compatibilidad: badge de saldo legacy */
.saldo-badge {
  background: var(--violeta); color: #fff;
  padding: var(--s1) var(--s3); border-radius: var(--r-pill);
  font-weight: var(--w-label); font-size: var(--fz-13);
}

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s1);
  padding: var(--s2) var(--s5) 0;
  background: var(--violeta-oscuro);
}
.tab-btn {
  padding: var(--s2) var(--s4);
  border: none; border-radius: var(--r) var(--r) 0 0;
  background: transparent; color: var(--lila);
  font-family: inherit; font-size: var(--fz-13); font-weight: var(--w-label);
  cursor: pointer; transition: background var(--t), color var(--t);
}
.tab-btn:hover  { background: rgba(255,255,255,.1); color: #fff; }
.tab-btn.active { background: var(--bg); color: var(--violeta-oscuro); }

.plazo-switch {
  margin-left: auto; display: flex; gap: var(--s1); align-self: center;
  background: rgba(255,255,255,.12); border-radius: var(--r); padding: var(--s1); margin-bottom: 6px;
}
.plazo-btn {
  padding: 6px var(--s4); border: 1px solid rgba(255,255,255,.35); border-radius: var(--r);
  background: transparent; color: #fff; font-family: inherit;
  font-size: var(--fz-12); font-weight: var(--w-label); cursor: pointer;
  transition: background var(--t), color var(--t), box-shadow var(--t);
}
.plazo-btn:hover { background: rgba(255,255,255,.15); }
.plazo-btn.active { background: var(--aqua); color: var(--violeta-oscuro); border-color: var(--aqua); }

/* ── Tabla de mercado ─────────────────────────────────────────────────── */
.market-table-wrap { overflow-x: auto; padding: var(--s4) var(--s5); }
.market-table {
  width: 100%; border-collapse: collapse;
  font-size: var(--fz-13); background: var(--surface);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--sh-1);
}
.market-table thead th {
  background: var(--violeta); color: #fff;
  padding: var(--s2) var(--s3); text-align: right;
  font-weight: var(--w-label); font-size: var(--fz-12); white-space: nowrap;
}
.market-table thead th:first-child { text-align: left; }
.market-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background var(--t);
}
.market-table tbody tr:nth-child(even) { background: var(--surface-2); }   /* zebra sutil */
.market-table tbody tr:hover { background: #f3edf6; }
.market-table tbody tr.selected { background: #ede0f2; }
.market-table td {
  padding: var(--s2) var(--s3); text-align: right;
  white-space: nowrap; font-weight: var(--w-num);
}
.market-table td:first-child { text-align: left; }

/* Columnas de posición del usuario (Tenencia / Valorización / P&L) */
.market-table thead th.col-pos { background: #4e2457; }
.market-table td.td-tenencia,
.market-table td.td-valor,
.market-table td.td-pnl { background: rgba(109,57,118,.06); }
.market-table tbody tr:hover td.td-tenencia,
.market-table tbody tr:hover td.td-valor,
.market-table tbody tr:hover td.td-pnl { background: rgba(109,57,118,.13); }

.ticker-name { font-weight: var(--w-bold); color: var(--violeta-oscuro); }
.cell-sub { font-size: var(--fz-11); color: var(--ink-3); }   /* nombre bajo el ticker */

/* Pills de tipo de instrumento */
.inst-tipo {
  display: inline-block; font-size: var(--fz-11);
  padding: 2px 8px; border-radius: var(--r-pill);
  margin-left: var(--s1); font-weight: var(--w-label);
}
.tipo-accion { background: #e8d5f5;            color: var(--violeta); }
.tipo-bono   { background: var(--info-bg);     color: var(--info); }
.tipo-cedear { background: var(--pos-bg);      color: var(--pos); }
.tipo-etf    { background: rgba(109,57,118,.10); color: var(--violeta); }
.tipo-on     { background: #eceaef;            color: var(--ink-2); }
.tipo-dolar  { background: var(--info-bg);     color: var(--info); }

.price-up   { color: var(--pos); font-weight: var(--w-label); }
.price-down { color: var(--neg); font-weight: var(--w-label); }
.price-neu  { color: var(--ink-2); }

.flash-up   { animation: flash-green .6s ease; }
.flash-down { animation: flash-red   .6s ease; }
@keyframes flash-green { 0%,100%{background:transparent} 30%{background:#b8f5dd} }
@keyframes flash-red   { 0%,100%{background:transparent} 30%{background:#ffd6d6} }

/* Botón de gráfico (acción por fila) */
.btn-chart {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--lila); border-radius: var(--r);
  width: 26px; height: 24px; padding: 0;
  cursor: pointer; background: transparent; color: var(--violeta);
  transition: background var(--t), color var(--t);
}
.btn-chart:hover { background: #f3edf6; }
.btn-chart svg { width: 14px; height: 14px; display: block; pointer-events: none; }

/* Compra / Venta (botones de trading) */
.btn-c, .btn-v {
  border: none; border-radius: var(--r);
  padding: var(--s1) var(--s3); font-family: inherit;
  font-size: var(--fz-13); font-weight: var(--w-label);
  cursor: pointer; transition: opacity var(--t);
}
.btn-c { background: var(--pos); color: #fff; }
.btn-v { background: var(--neg); color: #fff; }
.btn-c:hover, .btn-v:hover { opacity: .88; }

/* ── Book panel (lateral) ─────────────────────────────────────────────── */
.book-panel {
  display: flex; flex-direction: column; height: 100%;
  width: 340px; min-width: 260px; flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);   /* sin filo aqua decorativo */
  border-radius: var(--r) 0 0 var(--r);
  padding: var(--s4); font-size: var(--fz-13);
  box-shadow: var(--sh-1); overflow: hidden;
}
.book-panel h3 {
  color: var(--violeta-oscuro); font-size: var(--fz-14); font-weight: var(--w-bold);
  margin: 0 0 var(--s2); border-bottom: 1px solid var(--line);
  padding-bottom: var(--s2); flex-shrink: 0;
}
.book-search-wrap { margin-bottom: var(--s2); flex-shrink: 0; }
.book-ac-wrap { position: relative; }
.book-search-input {
  width: 100%; padding: var(--s2) var(--s2);
  border: 1px solid var(--line); border-radius: var(--r);
  font-family: inherit; font-size: var(--fz-13); font-weight: var(--w-label);
  text-transform: uppercase; transition: border-color var(--t), box-shadow var(--t);
}
.book-search-input:focus { outline: none; border-color: var(--violeta); box-shadow: var(--focus); }
.book-ac-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  margin-top: 2px; max-height: 200px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh-2);
}
.book-ac-item { padding: var(--s2); cursor: pointer; font-weight: var(--w-label); font-size: var(--fz-13); }
.book-ac-item:hover, .book-ac-item.active { background: #f3edf6; color: var(--violeta-oscuro); }
.book-spread { font-size: var(--fz-12); color: var(--ink-2); margin-bottom: var(--s2); min-height: 1.1rem; flex-shrink: 0; }
.book-table-wrap { flex-shrink: 0; max-height: 240px; overflow-y: auto; }
.book-table-wrap:focus { outline: none; }
.book-empty-msg { text-align: center; padding: var(--s5) var(--s2); color: var(--ink-3); }
.book-actions { display: flex; gap: var(--s2); margin: var(--s2) 0; flex-shrink: 0; }
.book-actions .btn-c, .book-actions .btn-v { flex: 1; padding: var(--s2); }
.book-pend-panel {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  padding-top: var(--s3); border-top: 1px solid var(--line); overflow: hidden;
}
.book-pend-title { font-size: var(--fz-13); color: var(--violeta-oscuro); font-weight: var(--w-bold); margin: 0 0 var(--s2); flex-shrink: 0; }
.book-pend-list { flex: 1; min-height: 0; overflow-y: auto; font-size: var(--fz-13); color: var(--ink-2); }
.book-table { width: 100%; border-collapse: collapse; }
.book-table th {
  font-size: var(--fz-11); color: var(--ink-3); text-transform: uppercase;
  padding: var(--s1); text-align: right; border-bottom: 1px solid var(--line);
}
.book-table td { padding: var(--s1); text-align: right; border-bottom: 1px solid var(--line-2); }
.book-table .col-c { color: var(--pos); font-weight: var(--w-label); }
.book-table .col-v { color: var(--neg); font-weight: var(--w-label); }
.book-table .book-click { cursor: pointer; border-radius: var(--r); transition: background var(--t); }
.book-table .col-c.book-click:hover { background: var(--pos-bg); }
.book-table .col-v.book-click:hover { background: var(--neg-bg); }
.book-table .book-kb-active { outline: 2px solid var(--violeta); outline-offset: -2px; background: #ede0f2 !important; }
.book-off-pend { margin-top: 0; padding-top: 0; }
.book-off-sep { height: 1px; background: var(--line); margin: var(--s2) 0; }   /* antes: string de guiones */
.book-off-table td { font-size: var(--fz-12); padding: 2px var(--s1); border-bottom: 1px solid var(--line-2); }
.book-vol-grey { text-align: right; color: var(--ink-2); }
.book-off-mine { cursor: pointer; border-radius: var(--r); }
.book-off-mine:hover { background: #f5eef8; }
.book-off-empty { color: var(--line) !important; font-weight: 400; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(58,1,79,.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-box {
  background: var(--surface); border-radius: var(--r); padding: var(--s5);
  width: 380px; box-shadow: var(--sh-2);
}
.modal-box.modal-lg { width: 880px; max-width: 96%; }    /* admin */
.modal-box h2 {
  font-size: var(--fz-20); font-weight: var(--w-bold);
  color: var(--violeta-oscuro); margin: 0 0 var(--s4);
}
.modal-box h2.is-info  { color: var(--info); }
.modal-box h2.is-neg   { color: var(--neg); }
.modal-label { font-size: var(--fz-12); color: var(--ink-2); margin-bottom: var(--s1); }
.modal-price { font-size: var(--fz-24); font-weight: var(--w-bold); color: var(--violeta); margin-bottom: var(--s3); }
.modal-input {
  width: 100%; padding: var(--s2) var(--s3);
  border: 1px solid var(--lila); border-radius: var(--r);
  font-family: inherit; font-size: var(--fz-14); outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.modal-input:focus { border-color: var(--violeta); box-shadow: var(--focus); }
.modal-monto { font-size: var(--fz-14); color: var(--ink-2); margin-top: var(--s2); min-height: 1.1em; }
.op-row { display: flex; justify-content: space-between; padding: 2px 0; }
.op-row > span:first-child { color: var(--ink-2); }
.op-arancel { color: var(--neg); font-size: var(--fz-12); }
.op-total { border-top: 1px solid var(--line); margin-top: var(--s1); padding-top: var(--s2); font-weight: var(--w-bold); font-size: var(--fz-16); color: var(--ink); }
.modal-actions { display: flex; gap: var(--s3); margin-top: var(--s5); }
.modal-confirm {
  flex: 1; padding: var(--s2); border: none; border-radius: var(--r);
  font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label);
  cursor: pointer; transition: background var(--t), opacity var(--t);
  background: var(--violeta); color: #fff;
}
.modal-confirm:hover { background: var(--violeta-2); }
.modal-confirm.compra { background: var(--pos); }
.modal-confirm.venta  { background: var(--neg); }
.modal-confirm.is-info { background: var(--info); }
.modal-confirm.compra:hover { background: var(--pos); opacity: .88; }
.modal-confirm.venta:hover  { background: var(--neg); opacity: .88; }
.modal-confirm.is-info:hover { background: var(--info); opacity: .88; }
.modal-cancel {
  padding: var(--s2) var(--s4); border: 1px solid var(--lila);
  background: transparent; border-radius: var(--r); cursor: pointer;
  font-family: inherit; font-size: var(--fz-14); color: var(--violeta);
  transition: background var(--t);
}
.modal-cancel:hover { background: #f3edf6; }
.modal-error { color: var(--neg); font-size: var(--fz-13); margin-top: var(--s2); min-height: 1em; }

/* Toggle Mercado / Límite / Comprar-Vender (segmentado) */
.ot-switch { display: flex; gap: var(--s1); }
.ot-btn {
  flex: 1; padding: var(--s2); border: 1px solid var(--lila);
  background: transparent; color: var(--violeta); border-radius: var(--r);
  font-family: inherit; font-size: var(--fz-13); font-weight: var(--w-label);
  cursor: pointer; transition: background var(--t), color var(--t);
}
.ot-btn:hover { background: #f3edf6; }
.ot-btn.active { background: var(--violeta); color: #fff; border-color: var(--violeta); }

/* Órdenes pendientes */
.estado-pendiente { color: var(--violeta); font-weight: var(--w-bold); }
.btn-cancelar {
  border: 1px solid var(--neg); color: var(--neg); background: transparent;
  border-radius: var(--r); padding: 2px var(--s2); font-family: inherit;
  font-size: var(--fz-12); font-weight: var(--w-label); cursor: pointer; transition: background var(--t), color var(--t);
}
.btn-cancelar:hover { background: var(--neg); color: #fff; }
.book-pend { color: var(--violeta); font-weight: var(--w-bold); font-size: var(--fz-11); }
.book-pend-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--s1); padding: var(--s1) 0; border-bottom: 1px solid var(--line-2);
}
.book-pend-row-active { background: #f8f3fa; margin: 0 -4px; padding-left: 4px; padding-right: 4px; border-radius: var(--r); }
.book-pend-line { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; min-width: 0; }
.book-pend-ticker {
  border: none; background: none; padding: 0; font-weight: var(--w-bold); color: var(--violeta-oscuro);
  cursor: pointer; text-decoration: underline; font-size: inherit; font-family: inherit;
}
.book-pend-ticker:hover { color: var(--violeta); }
.book-pend-qty { color: var(--ink-2); font-size: var(--fz-13); }

/* ── Admin ────────────────────────────────────────────────────────────── */
.admin-form { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; padding: 0 var(--s5); }
.admin-form input {
  padding: var(--s2) var(--s2); border: 1px solid var(--line); border-radius: var(--r);
  font-family: inherit; font-size: var(--fz-14); transition: border-color var(--t), box-shadow var(--t);
}
.admin-form input:focus { outline: none; border-color: var(--violeta); box-shadow: var(--focus); }
.admin-btn {
  height: 34px; padding: 0 var(--s4); background: var(--violeta); color: #fff;
  border: none; border-radius: var(--r); font-family: inherit; font-weight: var(--w-label);
  font-size: var(--fz-14); cursor: pointer; transition: background var(--t);
  display: inline-flex; align-items: center; gap: var(--s1);
}
.admin-btn:hover { background: var(--violeta-2); }
.admin-btn-sm {
  height: 28px; padding: 0 var(--s2); background: var(--violeta); color: #fff;
  border: none; border-radius: var(--r); font-family: inherit; font-weight: var(--w-label);
  cursor: pointer; font-size: var(--fz-13); transition: background var(--t);
}
.admin-btn-sm:hover { background: var(--violeta-2); }
.admin-btn-sm:disabled { opacity: .4; cursor: not-allowed; }
.admin-msg { padding: var(--s2) var(--s5); font-size: var(--fz-14); min-height: 1.2em; }
.admin-select { padding: var(--s1); border: 1px solid var(--line); border-radius: var(--r); font-family: inherit; font-size: var(--fz-12); max-width: 220px; }
.admin-input-sm { width: 80px; padding: var(--s1); border: 1px solid var(--line); border-radius: var(--r); font-family: inherit; font-size: var(--fz-13); }
.btn-icon-x {
  background: var(--neg); color: #fff; border: none; border-radius: var(--r);
  width: 24px; height: 24px; cursor: pointer; font-weight: var(--w-bold); font-size: var(--fz-14); line-height: 1;
}

/* ── Resumen mercado (disponible / a liquidar) ────────────────────────── */
.ms-cards { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: stretch; padding: var(--s3) var(--s5) var(--s1); }
.ms-card { background: var(--surface); border-radius: var(--r); padding: var(--s2) var(--s4); min-width: 200px; box-shadow: var(--sh-1); }
.ms-card .ms-title { font-size: var(--fz-11); color: var(--ink-3); text-transform: uppercase; font-weight: var(--w-label); letter-spacing: .03em; }
.ms-card .ms-main { font-size: var(--fz-20); font-weight: var(--w-bold); color: var(--violeta-oscuro); margin-top: var(--s1); }
.ms-card .ms-lines { margin-top: var(--s2); font-size: var(--fz-13); color: var(--ink-2); line-height: 1.5; }
.ms-card .ms-lines span { display: block; }
.ms-card .ms-lines b { font-weight: var(--w-label); color: var(--violeta-oscuro); }
.ms-card .ms-lines .ms-neg { color: var(--neg); }
.ms-card .ms-lines .ms-pos { color: var(--pos); }
.market-feed-status { margin-left: auto; align-self: center; display: flex; align-items: center; gap: var(--s2); font-size: var(--fz-12); color: var(--ink-2); padding: var(--s1) var(--s2); }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.feed-dot.ok { background: var(--pos); box-shadow: 0 0 0 2px rgba(13,122,82,.2); }
.feed-dot.warn { background: var(--info); }
.feed-dot.err { background: var(--neg); }

/* ── Portfolio ────────────────────────────────────────────────────────── */
.summary-cards { display: flex; gap: var(--s4); padding: var(--s4) var(--s5); flex-wrap: wrap; }
.summary-card { background: var(--surface); border-radius: var(--r); padding: var(--s3) var(--s4); min-width: 160px; box-shadow: var(--sh-1); }
.summary-card .label { font-size: var(--fz-12); color: var(--ink-2); text-transform: uppercase; font-weight: var(--w-label); }
.summary-card .value { font-size: var(--fz-20); font-weight: var(--w-bold); color: var(--violeta-oscuro); margin-top: 2px; }
.summary-card-fee { box-shadow: var(--sh-1); }
.summary-card-fee .label { color: var(--ink-3); }
.summary-card-fee .value { color: var(--violeta); font-size: var(--fz-16); }
.summary-divider { width: 1px; background: var(--line); align-self: stretch; margin: 0 var(--s1); }
.meta-bar-track { height: 5px; background: var(--line); border-radius: var(--r-pill); overflow: hidden; }
.meta-bar-fill  { height: 100%; background: var(--violeta); border-radius: var(--r-pill); transition: width .4s; width: 0; }

/* ── Botón actualizar ─────────────────────────────────────────────────── */
#refresh-icon { display: inline-block; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Chart cards ──────────────────────────────────────────────────────── */
.chart-card { position: relative; background: var(--surface); border-radius: var(--r); padding: var(--s4); box-shadow: var(--sh-1); }
.chart-card-pie { flex: 0 0 250px; min-width: 0; height: 270px; }
.chart-card-bar { flex: 1 1 340px; min-width: 0; height: 270px; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: var(--fz-13); color: var(--ink-3); }

/* Cierre de gráfico inline TradingView */
.chart-inline-wrap { height: calc(100vh - 160px); position: relative; background: var(--surface); }
.chart-close-btn {
  position: absolute; top: 6px; right: 10px; z-index: 10;
  background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--r);
  padding: 2px var(--s2); cursor: pointer; color: var(--violeta); font-family: inherit; font-size: var(--fz-12);
}
.chart-close-btn:hover { background: #f3edf6; }

/* ── Login ────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--lila-bg); padding: var(--s5); }
.login-card { background: var(--surface); border-radius: var(--r-lg); padding: var(--s6) var(--s6); width: 400px; max-width: 100%; box-shadow: var(--sh-2); }
.login-logo { display: block; height: 54px; width: auto; margin: 0 auto var(--s4); object-fit: contain; }
.login-card h1 { font-size: var(--fz-24); font-weight: var(--w-bold); color: var(--ink); margin: 0 0 var(--s2); text-align: center; line-height: 1.25; }
.login-card .subtitle { font-size: var(--fz-13); color: var(--ink-2); margin-bottom: var(--s5); text-align: center; font-weight: var(--w-label); }
.login-field { margin-bottom: var(--s4); }
.login-field label { display: block; font-size: var(--fz-12); color: var(--violeta); margin-bottom: var(--s1); font-weight: var(--w-label); }
.login-field input {
  width: 100%; padding: var(--s3) var(--s4); border: 1px solid var(--lila);
  border-radius: var(--r-input); font-family: inherit; font-size: var(--fz-14);
  outline: none; transition: border-color var(--t), box-shadow var(--t);
}
.login-field input:focus { border-color: var(--violeta); box-shadow: var(--focus); }
.login-btn {
  width: 100%; padding: var(--s3); background: var(--violeta); color: #fff;
  border: none; border-radius: var(--r-pill); font-family: inherit;
  font-size: var(--fz-16); font-weight: var(--w-label); cursor: pointer;
  margin-top: var(--s3); transition: background var(--t);
}
.login-btn:hover { background: var(--violeta-2); }
.login-error { color: var(--neg); font-size: var(--fz-13); margin-top: var(--s2); }
.form-title { font-size: var(--fz-16); font-weight: var(--w-bold); color: var(--violeta); margin: 0 0 var(--s4); padding-bottom: var(--s2); border-bottom: 1px solid var(--line); }
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 2.6rem; }
.pw-toggle {
  position: absolute; right: var(--s2); top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: var(--s1);
  color: var(--ink-3); line-height: 0; transition: color var(--t);
}
.pw-toggle:hover { color: var(--violeta); }
.pw-toggle.is-visible { color: var(--violeta); }   /* contraseña revelada */
.pw-toggle svg { width: 18px; height: 18px; display: block; pointer-events: none; }
.login-aviso { color: var(--pos); font-size: var(--fz-13); margin-bottom: var(--s4); text-align: center; background: var(--pos-bg); padding: var(--s3); border-radius: var(--r); }
.login-switch { text-align: center; font-size: var(--fz-13); color: var(--ink-2); margin-top: var(--s4); }
.login-switch a { color: var(--violeta); font-weight: var(--w-label); text-decoration: none; }
.login-switch a:hover { text-decoration: underline; }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.section-title { font-size: var(--fz-12); font-weight: var(--w-bold); text-transform: uppercase; color: var(--violeta); letter-spacing: .05em; padding: var(--s2) var(--s5) var(--s1); }
.underline-aqua { border-bottom: 2px solid var(--violeta); display: inline-block; padding-bottom: 2px; }   /* acento de marca, no aqua */

/* ── Botón Dólar MEP (tab-bar) ────────────────────────────────────────── */
.mep-tab-btn {
  padding: 6px var(--s3); border: 1px solid var(--info); border-radius: var(--r);
  background: var(--info-bg); color: var(--info); font-family: inherit;
  font-size: var(--fz-12); font-weight: var(--w-bold); cursor: pointer;
  align-self: center; margin-left: var(--s2); transition: background var(--t), color var(--t); white-space: nowrap;
}
.mep-tab-btn:hover { background: var(--info); color: #fff; }

/* ── Reloj de mercado (tab-bar) ───────────────────────────────────────── */
.market-clock-widget { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2) var(--s1) var(--s3); margin-left: var(--s2); align-self: center; border-left: 1px solid rgba(255,255,255,.12); }
#market-clock-canvas { border-radius: 50%; display: block; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(109,57,118,.6); }
.clock-meta { display: flex; flex-direction: column; gap: 2px; }
.clock-status { font-size: var(--fz-11); font-weight: var(--w-bold); letter-spacing: .08em; text-transform: uppercase; }
.clock-open   { color: var(--aqua); }
.clock-closed { color: #e74c3c; }
.clock-countdown { font-size: var(--fz-11); color: var(--lila); white-space: nowrap; }

/* ════════════════════════════════════════════════════════════════════════
   MERCADOS — rediseño BCCH Qü (breadcrumb · título · pills · controles · tabla)
   ════════════════════════════════════════════════════════════════════════ */
.market-page { padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s4); }

.page-head { background: var(--surface); border-radius: var(--r-lg); padding: var(--s4) var(--s5); box-shadow: var(--sh-1); }
.breadcrumb { font-size: var(--fz-12); color: var(--ink-3); display: flex; align-items: center; gap: var(--s2); }
.breadcrumb a { color: var(--violeta); text-decoration: none; font-weight: var(--w-label); }
.breadcrumb a:hover { text-decoration: underline; }
.bc-sep { color: var(--ink-3); }
.page-title { font-size: var(--fz-30); font-weight: var(--w-bold); color: var(--ink); margin: var(--s2) 0 0; }

.market-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s4) 0 var(--s1); }

/* Pills de filtro */
.mkt-pills { display: flex; flex-wrap: wrap; gap: var(--s2); padding: 0 var(--s5) var(--s4); border-bottom: 1px solid var(--line-2); }
.mkt-pill {
  padding: var(--s2) var(--s4); border: 1px solid #ddd6e8; border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-2); font-family: inherit;
  font-size: var(--fz-13); font-weight: var(--w-label); cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.mkt-pill:hover { border-color: var(--lila); color: var(--violeta); background: var(--lila-bg); }
.mkt-pill.active {
  background: rgba(124,66,239,.13); border-color: transparent;
  color: var(--violeta); font-weight: var(--w-bold);
}
/* El Dólar MEP es una acción, no un filtro: nunca toma estado activo */
.mkt-pill-mep { white-space: nowrap; }

/* Controles */
.mkt-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); padding: var(--s4) var(--s5); }
.mkt-search {
  flex: 1; min-width: 220px; max-width: 360px;
  display: flex; align-items: center; gap: var(--s2);
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: var(--s2) var(--s4);
  transition: border-color var(--t), box-shadow var(--t);
}
.mkt-search:focus-within { border-color: var(--violeta); box-shadow: var(--focus); }
.mkt-search svg { width: 18px; height: 18px; color: var(--ink-3); flex-shrink: 0; }
.mkt-search input { border: none; outline: none; background: transparent; width: 100%; font-family: inherit; font-size: var(--fz-14); color: var(--ink); }
/* Select con label flotante sobre el borde (Plazo) */
.mkt-select { position: relative; display: inline-block; }
.mkt-select select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--lila); border-radius: var(--r-input);
  padding: var(--s3) 2.4rem var(--s3) var(--s4);
  font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label);
  color: var(--ink); background: var(--surface); cursor: pointer; min-width: 120px;
  transition: border-color var(--t), box-shadow var(--t);
}
.mkt-select select:focus { outline: none; border-color: var(--violeta); box-shadow: var(--focus); }
.mkt-select-label {
  position: absolute; top: 0; left: var(--s3); transform: translateY(-50%);
  background: var(--surface); padding: 0 4px;
  font-size: var(--fz-11); font-weight: var(--w-label); color: var(--violeta); pointer-events: none;
}
.mkt-select-chevron {
  position: absolute; right: var(--s3); top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--violeta); pointer-events: none;
}

/* Tabla */
.mkt-table-wrap { overflow-x: auto; padding: 0 var(--s5) var(--s2); }
.mkt-table { width: 100%; border-collapse: collapse; font-size: var(--fz-13); }
.mkt-table thead th { font-weight: var(--w-label); color: var(--ink-2); white-space: nowrap; }
.mkt-group-row th { font-size: var(--fz-11); letter-spacing: .06em; text-align: center; padding: var(--s2) var(--s3) var(--s1); color: var(--ink-3); }
.mkt-group-row .grp-vender,
.mkt-group-row .grp-comprar { background: var(--lila-bg); border-radius: var(--r) var(--r) 0 0; font-weight: var(--w-bold); color: var(--violeta); }
.mkt-head-row th { text-align: right; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.mkt-head-row th.th-esp { text-align: left; }
.mkt-head-row th:hover { color: var(--violeta); }
.mkt-table tbody td { text-align: right; padding: var(--s2) var(--s3); white-space: nowrap; font-weight: var(--w-num); border-bottom: 1px solid var(--line-2); }
.mkt-table tbody td.td-esp { text-align: left; }
.mkt-table tbody tr { cursor: pointer; transition: background var(--t); }
.mkt-table tbody tr:hover { background: var(--lila-bg); }
.mkt-table tbody tr.selected { background: #ede0f2; }

/* Tinte de las columnas VENDER / COMPRAR */
.mkt-table .col-vender,
.mkt-table .col-comprar { background: rgba(124,66,239,.045); }
.mkt-table thead .col-vender,
.mkt-table thead .col-comprar { background: var(--lila-bg); }
.mkt-table tbody tr:hover .col-vender,
.mkt-table tbody tr:hover .col-comprar { background: rgba(124,66,239,.10); }

.esp-ticker { font-weight: var(--w-bold); color: var(--ink); }
.esp-name { display: block; font-size: var(--fz-11); color: var(--ink-3); margin-top: 1px; }

.mkt-feed { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s5); font-size: var(--fz-12); color: var(--ink-3); }

/* ── Drawer lateral: caja de precios ──────────────────────────────────── */
.book-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(31,23,51,.35);
  opacity: 0; visibility: hidden; transition: opacity .25s; z-index: 140;
}
.book-drawer-backdrop.show { opacity: 1; visibility: visible; }
.book-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 380px; max-width: 92vw;
  background: var(--surface); box-shadow: var(--sh-2);
  transform: translateX(100%); transition: transform .25s ease; z-index: 150;
}
.book-drawer.open { transform: none; }
.book-drawer .book-panel { width: 100%; min-width: 0; height: 100%; border: none; border-radius: 0; box-shadow: none; }
.book-drawer-head { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.book-drawer-head h3 { border-bottom: none; padding-bottom: 0; margin-bottom: var(--s2); }
.book-drawer-close { background: none; border: none; font-size: var(--fz-20); color: var(--ink-3); cursor: pointer; line-height: 1; padding: 0 var(--s1); }
.book-drawer-close:hover { color: var(--neg); }

/* ════════════════════════════════════════════════════════════════════════
   DETALLE DE INSTRUMENTO + DRAWER DE OPERAR
   ════════════════════════════════════════════════════════════════════════ */
.inst-page { padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s4); }

/* Encabezado */
.inst-head { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s4) var(--s5); display: flex; align-items: center; gap: var(--s3); }
.inst-back { display: inline-flex; color: var(--ink-2); text-decoration: none; }
.inst-back svg { width: 22px; height: 22px; }
.inst-back:hover { color: var(--violeta); }
.inst-fav { font-size: var(--fz-20); color: var(--ink-3); cursor: pointer; }
.inst-id { display: flex; align-items: baseline; gap: var(--s3); min-width: 0; }
.inst-ticker { font-size: var(--fz-24); font-weight: var(--w-bold); color: var(--ink); }
.inst-name { font-size: var(--fz-12); color: var(--ink-3); font-weight: var(--w-label); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inst-quote { margin-left: auto; display: flex; align-items: center; gap: var(--s4); }
.inst-price { font-size: var(--fz-14); color: var(--ink); }
.inst-price b { font-size: var(--fz-20); font-weight: var(--w-bold); }
.inst-cur { color: var(--ink-3); font-size: var(--fz-12); font-weight: var(--w-label); }
.inst-var { font-weight: var(--w-bold); font-size: var(--fz-14); }

/* Toggle CI / 24h */
.inst-plazo { display: inline-flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 2px; }
.inst-plazo button { border: none; background: transparent; cursor: pointer; font-family: inherit; font-size: var(--fz-12); font-weight: var(--w-label); color: var(--ink-3); padding: 3px var(--s3); border-radius: var(--r-pill); transition: background var(--t), color var(--t); }
.inst-plazo button.active { background: var(--violeta); color: #fff; }

/* Grilla */
.inst-grid { display: grid; grid-template-columns: 1fr 360px; gap: var(--s4); align-items: start; }
@media (max-width: 1100px) { .inst-grid { grid-template-columns: 1fr; } }
.inst-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s4) var(--s5); }
.inst-card-title { font-size: var(--fz-16); font-weight: var(--w-bold); color: var(--violeta); margin: 0 0 var(--s3); }
.inst-chart-card { padding: 0; overflow: hidden; }
.inst-tabs { display: flex; gap: var(--s4); padding: var(--s3) var(--s5) 0; border-bottom: 1px solid var(--line); }
.inst-tab { background: none; border: none; border-bottom: 2px solid transparent; padding: var(--s2) 0 var(--s3); cursor: pointer; font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label); color: var(--ink-2); }
.inst-tab.active { color: var(--violeta); border-bottom-color: var(--violeta); }
.inst-tab:hover { color: var(--violeta); }
.inst-tv { height: 560px; }
.inst-side { display: flex; flex-direction: column; gap: var(--s4); }

/* Caja de puntas (página + drawer) */
.caja-table { width: 100%; border-collapse: collapse; font-size: var(--fz-13); font-variant-numeric: tabular-nums; }
.caja-table thead th { background: var(--lila-bg); color: var(--ink-2); font-weight: var(--w-label); font-size: var(--fz-12); padding: var(--s2); text-align: right; }
.caja-table thead th:first-child { border-radius: var(--r) 0 0 var(--r); }
.caja-table thead th:last-child { border-radius: 0 var(--r) var(--r) 0; }
.caja-table td { padding: var(--s2); text-align: right; border-bottom: 1px solid var(--line-2); font-weight: var(--w-num); }
.caja-vol { color: var(--ink-2); }
.caja-px { cursor: pointer; }
.caja-c { color: var(--pos); font-weight: var(--w-label); }
.caja-v { color: var(--neg); font-weight: var(--w-label); }
.caja-c:hover { background: var(--pos-bg); }
.caja-v:hover { background: var(--neg-bg); }
.caja-empty-cell { color: var(--ink-3); }
.caja-empty { text-align: center; color: var(--ink-3); padding: var(--s4); }
.caja-actions { display: flex; gap: var(--s3); margin-top: var(--s4); }
.op-vender, .op-comprar { flex: 1; padding: var(--s3); border-radius: var(--r-input); font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label); cursor: pointer; transition: background var(--t), opacity var(--t); }
.op-vender { background: var(--surface); border: 1px solid var(--violeta); color: var(--violeta); }
.op-vender:hover { background: var(--lila-bg); }
.op-comprar { background: var(--violeta); border: 1px solid var(--violeta); color: #fff; }
.op-comprar:hover { background: var(--violeta-2); }

/* Mi tenencia */
.tenencia-row { display: flex; align-items: center; gap: var(--s4); }
.tenencia-donut { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: conic-gradient(var(--line) 0, var(--line-2) 0); flex-shrink: 0; position: relative; }
.tenencia-donut::after { content: ''; position: absolute; inset: 9px; background: var(--surface); border-radius: 50%; }
.tenencia-donut span { position: relative; z-index: 1; font-size: var(--fz-12); font-weight: var(--w-bold); color: var(--ink); }
.tenencia-vals { flex: 1; }
.tenencia-val { display: flex; justify-content: space-between; padding: var(--s2) 0; border-bottom: 1px solid var(--line-2); }
.tenencia-val span { color: var(--ink-2); }
.tenencia-val b { font-weight: var(--w-bold); }

/* Drawer de operar */
.op-backdrop { position: fixed; inset: 0; background: rgba(31,23,51,.35); opacity: 0; visibility: hidden; transition: opacity .25s; z-index: 160; }
.op-backdrop.show { opacity: 1; visibility: visible; }
.op-drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 380px; max-width: 94vw; background: var(--surface); box-shadow: var(--sh-2); transform: translateX(100%); transition: transform .25s ease; z-index: 170; display: flex; flex-direction: column; }
.op-drawer.open { transform: none; }
.op-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.op-close { background: none; border: none; font-size: var(--fz-20); color: var(--violeta); cursor: pointer; line-height: 1; }
.op-head-title { font-weight: var(--w-bold); color: var(--violeta); font-size: var(--fz-16); }
.op-body { flex: 1; overflow-y: auto; padding: var(--s4) var(--s5); }
.op-id-row { display: flex; align-items: center; gap: var(--s2); }
.op-fav { color: var(--ink-3); }
.op-ticker { font-size: var(--fz-20); font-weight: var(--w-bold); color: var(--ink); }
.op-chart-ico { width: 18px; height: 18px; color: var(--violeta); margin-left: auto; }
.op-name { font-size: var(--fz-11); color: var(--ink-3); text-transform: uppercase; margin-bottom: var(--s3); }
.op-quote-row { display: flex; align-items: center; justify-content: space-between; padding-bottom: var(--s3); border-bottom: 1px solid var(--line); margin-bottom: var(--s3); }
.op-quote b { font-size: var(--fz-16); font-weight: var(--w-bold); }
.op-var { font-weight: var(--w-bold); font-size: var(--fz-13); }
.op-caja { margin-bottom: var(--s3); }
.op-line { display: flex; justify-content: space-between; padding: var(--s2) 0; border-bottom: 1px solid var(--line-2); font-size: var(--fz-13); }
.op-line span { color: var(--ink-2); }
.op-line b { font-weight: var(--w-bold); }
.op-lado { margin: var(--s4) 0 var(--s3); }
.op-field { position: relative; display: flex; align-items: center; border: 1px solid var(--lila); border-radius: var(--r-input); padding: var(--s3) var(--s4); margin-bottom: var(--s3); }
.op-field:focus-within { border-color: var(--violeta); box-shadow: var(--focus); }
.op-field-label { position: absolute; top: 0; left: var(--s3); transform: translateY(-50%); background: var(--surface); padding: 0 4px; font-size: var(--fz-11); font-weight: var(--w-label); color: var(--violeta); }
.op-prefix { color: var(--ink-3); font-size: var(--fz-13); margin-right: var(--s2); }
#op-precio { border: none; outline: none; background: transparent; width: 100%; font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label); color: var(--ink); }
.op-qty-row { display: flex; align-items: center; gap: var(--s2); }
#op-cantidad, .op-importe { flex: 1; width: 100%; border: 1px solid var(--lila); border-radius: var(--r-input); padding: var(--s3) var(--s4); font-family: inherit; font-size: var(--fz-14); outline: none; transition: border-color var(--t), box-shadow var(--t); }
#op-cantidad:focus, .op-importe:focus { border-color: var(--violeta); box-shadow: var(--focus); }
.op-importe { margin-top: var(--s2); }
.op-step { width: 34px; height: 40px; flex-shrink: 0; border: 1px solid var(--lila); border-radius: var(--r-pill); background: var(--surface); color: var(--violeta); font-size: var(--fz-16); cursor: pointer; transition: background var(--t); }
.op-step:hover { background: var(--lila-bg); }
.op-usartodo { display: block; text-align: right; font-size: var(--fz-12); color: var(--violeta); font-weight: var(--w-label); cursor: pointer; margin: var(--s2) 0; }
.op-usartodo:hover { text-decoration: underline; }
.op-total { display: flex; justify-content: space-between; align-items: center; background: var(--lila-bg); border-radius: var(--r-input); padding: var(--s3) var(--s4); margin-top: var(--s3); }
.op-total > span { color: var(--ink-2); font-size: var(--fz-13); }
.op-total b { font-size: var(--fz-16); font-weight: var(--w-bold); color: var(--ink); }
.op-error { color: var(--neg); font-size: var(--fz-13); margin-top: var(--s2); min-height: 1em; }
.op-foot { display: flex; gap: var(--s3); padding: var(--s4) var(--s5); border-top: 1px solid var(--line); flex-shrink: 0; }
.op-cancel { flex: 1; padding: var(--s3); border: 1px solid var(--violeta); background: transparent; color: var(--violeta); border-radius: var(--r-pill); font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label); cursor: pointer; transition: background var(--t); }
.op-cancel:hover { background: var(--lila-bg); }
.op-confirm { flex: 1; padding: var(--s3); border: none; border-radius: var(--r-pill); background: var(--violeta); color: #fff; font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label); cursor: pointer; transition: background var(--t); }
.op-confirm:hover:not(:disabled) { background: var(--violeta-2); }
.op-confirm:disabled { background: var(--lila-suave); cursor: not-allowed; }

/* ── Asistente IA ────────────────────────────────────────────────────── */
#ai-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 1200;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--violeta); color: #fff; border: none;
  box-shadow: var(--sh-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t), transform var(--t);
}
#ai-fab:hover { background: var(--violeta-2); transform: scale(1.07); }
#ai-fab svg  { width: 22px; height: 22px; flex-shrink: 0; }

#ai-panel {
  position: fixed; bottom: 92px; right: 28px; z-index: 1200;
  width: 360px; max-width: calc(100vw - 40px);
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-2); border: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: opacity var(--t), transform var(--t);
}
#ai-panel[hidden] { display: none; }

.ai-panel-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4);
  background: var(--violeta); color: #fff;
}
.ai-panel-head svg { width: 18px; height: 18px; flex-shrink: 0; }
.ai-panel-head span { flex: 1; font-weight: var(--w-label); font-size: var(--fz-14); }
.ai-panel-close {
  background: none; border: none; color: rgba(255,255,255,.8);
  cursor: pointer; padding: 2px; display: flex; line-height: 1;
  border-radius: 4px; transition: color var(--t);
}
.ai-panel-close:hover { color: #fff; }
.ai-panel-close svg { width: 16px; height: 16px; }

.ai-messages {
  flex: 1; overflow-y: auto; padding: var(--s3) var(--s4);
  display: flex; flex-direction: column; gap: var(--s3);
  max-height: 320px; min-height: 120px;
}

.ai-msg {
  max-width: 88%; line-height: 1.55;
  font-size: var(--fz-13); padding: var(--s2) var(--s3);
  border-radius: var(--r-lg); word-break: break-word;
}
.ai-msg.user {
  align-self: flex-end;
  background: var(--violeta); color: #fff;
  border-bottom-right-radius: var(--r);
}
.ai-msg.bot {
  align-self: flex-start;
  background: var(--lila-bg); color: var(--ink);
  border-bottom-left-radius: var(--r);
}
.ai-msg.error {
  align-self: flex-start;
  background: var(--neg-bg); color: var(--neg);
  border-bottom-left-radius: var(--r);
}
.ai-typing {
  align-self: flex-start;
  display: flex; align-items: center; gap: 4px;
  padding: var(--s2) var(--s3);
}
.ai-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--lila); display: inline-block;
  animation: ai-bounce 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

.ai-panel-foot {
  display: flex; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
}
#ai-input {
  flex: 1; border: 1px solid var(--line); border-radius: var(--r-input);
  padding: var(--s2) var(--s3); font-family: inherit; font-size: var(--fz-13);
  color: var(--ink); background: var(--bg); resize: none;
  outline: none; line-height: 1.4; transition: border-color var(--t);
}
#ai-input:focus { border-color: var(--violeta); box-shadow: var(--focus); }
#ai-send {
  flex-shrink: 0; width: 36px; height: 36px;
  background: var(--violeta); color: #fff; border: none;
  border-radius: 50%; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background var(--t); align-self: flex-end;
}
#ai-send:hover:not(:disabled) { background: var(--violeta-2); }
#ai-send:disabled { background: var(--lila-suave); cursor: not-allowed; }
#ai-send svg { width: 16px; height: 16px; }

/* ════════════════════════════════════════════════════════════════════════
   LICITACIONES — Managers y Traders
   ════════════════════════════════════════════════════════════════════════ */
.lic-acciones {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s4) var(--s5) var(--s3);
}
.lic-tabs {
  display: flex; gap: var(--s4); padding: var(--s2) var(--s5) 0;
  border-bottom: 1px solid var(--line);
}
.lic-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: var(--s2) 0 var(--s3); cursor: pointer;
  font-family: inherit; font-size: var(--fz-14); font-weight: var(--w-label);
  color: var(--ink-2);
}
.lic-tab:hover { color: var(--violeta); }
.lic-tab.active { color: var(--violeta); border-bottom-color: var(--violeta); }
.lic-panel { display: none; }
.lic-panel.active { display: block; }
.lic-badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-pill);
  font-size: var(--fz-11); font-weight: var(--w-label);
}
.lic-accion-enviada { background: var(--lila-bg); color: var(--violeta); }
.lic-accion-cancel { background: var(--neg-bg); color: var(--neg); }
.lic-btn-cancel-sel:not(:disabled) { color: var(--neg); border-color: var(--neg); }
.lic-btn-cancel-sel:not(:disabled):hover { background: var(--neg-bg); }
.lic-th-sel, .lic-td-sel { width: 36px; text-align: center; }
.lic-td-sel input, .lic-th-sel input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--violeta); }
.lic-inline-err { font-size: var(--fz-13); color: var(--neg); }
.lic-toast-wrap {
  position: fixed; right: var(--s5); bottom: var(--s5); z-index: 1100;
  pointer-events: none; opacity: 0; transform: translateY(12px);
  transition: opacity .3s, transform .3s;
}
.lic-toast-wrap.visible { opacity: 1; transform: translateY(0); }
.lic-toast {
  padding: var(--s3) var(--s5); border-radius: var(--r);
  box-shadow: var(--sh-2); font-size: var(--fz-14); font-weight: var(--w-label);
  max-width: 320px;
}
.lic-toast-ok { background: var(--pos); color: #fff; }
.lic-toast-cancel { background: #b54a45; color: #fff; }
.lic-toast-err { background: var(--neg); color: #fff; }
.lic-hint {
  margin: 0; padding: var(--s3) var(--s5) var(--s2);
  font-size: var(--fz-13); color: var(--ink-2);
}
.lic-horario-aviso {
  margin: 0;
  padding: var(--s2) var(--s5) 0;
  font-size: var(--fz-12);
  line-height: 1.2;
  color: var(--ink-2);
}
.lic-horario-aviso strong { color: var(--ink-1); font-weight: var(--w-label); }
.lic-table-sm td, .lic-table-sm th { font-size: var(--fz-12); }
.lic-drag-overlay {
  position: absolute; inset: 0; z-index: 900;
  background: rgba(15, 10, 30, 0.55);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-lg);
}
#lic-page { position: relative; }
.lic-drag-overlay[hidden] { display: none !important; }
.lic-drag-overlay-msg {
  color: #fff; font-size: var(--fz-lg); font-weight: var(--w-label);
  padding: var(--s5) var(--s6); border: 2px dashed rgba(255,255,255,.6);
  border-radius: var(--r-lg); background: rgba(255,255,255,.08);
}
.lic-table-wrap { overflow-x: auto; padding: 0 var(--s5) var(--s2); }
.lic-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--sh-1);
}
.lic-table thead th {
  background: var(--violeta); color: #fff; padding: var(--s2) var(--s3);
  font-size: var(--fz-12); font-weight: var(--w-label); text-align: left; white-space: nowrap;
}
.lic-table tbody tr { border-bottom: 1px solid var(--line); }
.lic-table tbody tr:last-child { border-bottom: none; }
.lic-table td { padding: var(--s2) var(--s3); vertical-align: middle; }
.lic-inp {
  width: 100%; padding: var(--s2); border: 1px solid var(--line);
  border-radius: var(--r); font-size: var(--fz-13); background: var(--surface);
  outline: none; box-sizing: border-box; font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
.lic-inp:focus { border-color: var(--violeta); box-shadow: var(--focus); }
.lic-inp.celda-activa { border-color: var(--violeta); box-shadow: var(--focus); }
.btn-del {
  background: none; border: none; color: var(--neg); font-size: 1.15rem;
  cursor: pointer; padding: var(--s1); border-radius: var(--r); line-height: 1;
}
.btn-del:hover { background: var(--neg-bg); }
.fila-vacia td { text-align: center; color: var(--ink-3); padding: var(--s6); font-size: var(--fz-14); }
.btn-enviar {
  padding: var(--s3) var(--s5); background: var(--pos); color: #fff; border: none;
  border-radius: var(--r); font-size: var(--fz-14); font-weight: var(--w-label);
  cursor: pointer; font-family: inherit; transition: opacity var(--t);
}
.btn-enviar:hover { opacity: .88; }
.btn-enviar:disabled { opacity: .45; cursor: not-allowed; }
.lic-foot { margin-top: 0; padding: var(--s3) var(--s5) var(--s4); display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.lic-td-inst { position: relative; }
.lic-td-inst.has-inst .sel-inst { padding-right: 18px; }
.lic-fill-handle {
  position: absolute; right: 3px; bottom: 3px; width: 10px; height: 10px;
  background: var(--violeta); border: 1px solid #fff; border-radius: 1px;
  cursor: crosshair; z-index: 4; box-shadow: 0 0 0 1px var(--violeta);
  display: none;
}
.lic-td-inst.has-inst .lic-fill-handle { display: block; }
.lic-td-inst.is-filling { cursor: crosshair; }
.lic-td-inst.is-filling .lic-fill-handle { background: var(--violeta-oscuro); }
.lic-table tbody tr.fila-usd { background: var(--pos-bg); }
.lic-table tbody tr.fila-usd:hover { background: #d4f0e4; }
.lic-table tbody tr.fila-fill-target { outline: 2px dashed var(--violeta); outline-offset: -2px; }
.msg-ok  { color: var(--pos); font-weight: var(--w-label); font-size: var(--fz-13); }
.msg-err { color: var(--neg); font-weight: var(--w-label); font-size: var(--fz-13); }
.lic-spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--line); border-top-color: var(--violeta);
  border-radius: 50%; animation: lic-spin .6s linear infinite;
  vertical-align: middle; margin-right: var(--s1);
}
@keyframes lic-spin { to { transform: rotate(360deg); } }
.ac-lista {
  position: fixed; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh-2); max-height: 210px;
  overflow-y: auto; z-index: 1000; display: none;
}
.ac-item { padding: var(--s2) var(--s3); font-size: var(--fz-13); cursor: pointer; }
.ac-item:hover, .ac-item.ac-hl { background: var(--lila-bg); color: var(--violeta-oscuro); }
.ac-item-fuera { color: var(--neg); cursor: not-allowed; }
.ac-item-fuera:hover, .ac-item-fuera.ac-hl { background: var(--neg-bg); color: var(--neg); }
.lic-fuera-tag {
  display: block; margin-top: 2px;
  font-size: var(--fz-11); font-weight: var(--w-label); color: var(--neg);
}
.lic-table tbody tr.fila-fuera-horario { background: var(--neg-bg) !important; }
.lic-table tbody tr.fila-fuera-horario:hover { background: #f9d4cf !important; }
.lic-table tbody tr.fila-fuera-horario .sel-inst { color: var(--neg); }
.com-bloqueado { background: var(--surface); cursor: default; color: var(--ink); }
.monto-wrap {
  display: flex; align-items: center; border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; background: var(--surface);
  transition: border-color var(--t), box-shadow var(--t);
}
.monto-wrap:focus-within { border-color: var(--violeta); box-shadow: var(--focus); }
.monto-prefix {
  padding: var(--s2) 0 var(--s2) var(--s3); font-weight: var(--w-label);
  color: var(--violeta); font-size: var(--fz-13); user-select: none; flex-shrink: 0;
}
.monto-wrap .inp-monto { border: none; border-radius: 0; flex: 1; min-width: 0; width: auto; }
.monto-wrap .inp-monto:focus { border: none; box-shadow: none; }

/* ── Nav agrupado (dropdowns) ───────────────────────────────────────── */
.nav-dropdown { position: relative; align-self: stretch; display: flex; }
.nav-dropdown-btn {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: var(--s3) var(--s2); margin: 0 var(--s1);
  border: none; border-bottom: 2px solid transparent;
  background: transparent; cursor: pointer;
  color: var(--ink-2); font-family: inherit; font-size: var(--fz-14);
  font-weight: var(--w-label); transition: color var(--t), border-color var(--t);
}
.nav-dropdown-btn:hover { color: var(--violeta); }
.nav-dropdown-btn.nav-active { color: var(--violeta); border-bottom-color: var(--violeta); }
.nav-chevron { width: 14px; height: 14px; opacity: .7; }
.nav-dropdown-menu {
  position: absolute; left: 0; top: calc(100% + 2px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-input); box-shadow: var(--sh-2);
  min-width: 200px; padding: var(--s1); z-index: 200;
}
.nav-dropdown-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) var(--s3); border-radius: var(--r);
  color: var(--ink); text-decoration: none; font-size: var(--fz-13);
  font-weight: var(--w-label); transition: background var(--t), color var(--t);
}
.nav-dropdown-item:hover { background: var(--lila-bg); color: var(--violeta); }
.nav-dropdown-item-active { background: var(--lila-bg); color: var(--violeta); }
.nav-dropdown-item-soon { color: var(--ink-2); }
.nav-soon-tag {
  font-size: var(--fz-11); color: var(--ink-3); font-weight: var(--w-body);
  white-space: nowrap;
}
.placeholder-msg { padding: var(--s6) var(--s5); text-align: center; font-size: var(--fz-16); margin: 0; }
