:root {
  --bg: #0e1117;
  --panel: #161b22;
  --border: #2a2f3a;
  --text: #e6e6e6;
  --muted: #8b949e;
  --accent: #3fb950;
  --flash: #1f6feb55;
  --hover: #373a44;
  --icon: #6e7681;
  --icon-hover: #c9d1d9;
  --row-border: #0e1117; /* borde inferior de cada <tr> en las tablas -> cambialo aca */
  --disabled: #30363d; /* color "apagado" del boton Aplicar cuando no hay cambios sin confirmar */
  --exclude: #f0883e; /* color de acento para la exclusion de tickers (distinto del verde de los filtros de rango) */
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  padding: 24px;
}
h1 { font-size: 18px; margin: 0 0 4px 0; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

h2 {
  font-size: 15px;
  margin: 32px 0 12px 0;
  color: var(--text);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #f85149;
}
.dot.on { background: var(--accent); }

button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { border-color: var(--accent); }
button.active { border-color: #f0883e; color: #f0883e; }

.card-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cog-btn,
.exclude-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--panel);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.cog-btn:hover,
.exclude-btn:hover {
  border-color: var(--panel);
  background: transparent;
}
.cog-btn:active,
.exclude-btn:active {
  background: transparent;
  border-color: var(--panel);
}
.cog-btn svg,
.exclude-btn svg {
  display: block;
  fill: currentColor;
  color: var(--icon);
  transition: color 0.15s ease;
}
.cog-btn:hover svg,
.exclude-btn:hover svg {
  color: var(--icon-hover);
}

/* Indicador visual de que una Top List tiene filtros activos: el
   engranaje pasa a color acento y le agregamos un punto en la esquina,
   asi se nota incluso sin abrir el modal. */
.cog-btn.has-filters svg {
  color: var(--accent);
}
.cog-btn.has-filters::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--panel);
}

/* Mismo indicador para la exclusion de tickers de una alert window, pero
   en naranja (--exclude) para distinguirlo a simple vista del verde de
   los filtros de rango. */
.exclude-btn.has-exclusions svg {
  color: var(--exclude);
}
.exclude-btn.has-exclusions::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--exclude);
  box-shadow: 0 0 0 2px var(--panel);
}


html, body {
  scrollbar-width: thin;                     /* Firefox */
  scrollbar-color: var(--muted) var(--bg);   /* Firefox */
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 10px;
}
html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: var(--bg);
}
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
  background: var(--hover);
}

/* --- Scrollbar personalizado para las tablas con overflow (dentro de cada card) --- */
.top-list-body-wrap,
.alert-table-wrap {
  scrollbar-width: thin;                       
  scrollbar-color: var(--muted) var(--panel);  
}
.top-list-body-wrap::-webkit-scrollbar,
.alert-table-wrap::-webkit-scrollbar {
  width: 8px;
}
.top-list-body-wrap::-webkit-scrollbar-track,
.alert-table-wrap::-webkit-scrollbar-track {
  background: #d29922;
}
.top-list-body-wrap::-webkit-scrollbar-thumb,
.alert-table-wrap::-webkit-scrollbar-thumb {
  background: #3fb950;
  border-radius: 4px;
}
.top-list-body-wrap::-webkit-scrollbar-thumb:hover,
.alert-table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--hover);
}

.label-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #21262d;
  border: 1px solid var(--border);
  color: var(--muted);
}

@keyframes flashRow {
  from { background: var(--flash); }
  to   { background: transparent; }
}
tr.flash { animation: flashRow 1.6s ease-out; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* --- Top Lists (snapshot en vivo) --- */

.top-lists-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.top-list-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.top-list-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.top-list-card-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.top-list-body-wrap {
  max-height: 322px; /* ~10 filas visibles + header, el resto hace scroll */
  overflow-y: auto;
}

.top-list-table {
  width: 100%;
  border-collapse: collapse;
}

.top-list-table th, .top-list-table td {
  text-align: left;
  padding: 6px 14px;
  font-size: 12px;
  border-bottom: 1px solid var(--row-border);
  white-space: nowrap;
}

.top-list-table th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--panel);
}

.top-list-table tbody tr:hover { background: #1c2129; }
.top-list-table tbody tr:last-child td { border-bottom: none; }

.top-list-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* --- Colores de magnitud (porcentajes, %VWAP Dist) --- */
.pct-pos { color: #3fb950; font-variant-numeric: tabular-nums; }
.pct-neg { color: #f85149; font-variant-numeric: tabular-nums; }
.pct-neutral { color: #d29922; font-variant-numeric: tabular-nums; }

/* Signo "%" mas chico que el numero al que acompaña. */
.pct-sign { font-size: 0.75em; }

/* --- Alertas: una card/tabla por ventana --- */

.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.alert-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.alert-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.alert-card-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.alert-table-wrap {
  max-height: 320px;
  overflow-y: auto;
}

.alert-table {
  width: 100%;
  border-collapse: collapse;
}

.alert-table th, .alert-table td {
  text-align: left;
  padding: 6px 14px;
  font-size: 12px;
  border-bottom: 1px solid var(--row-border);
  white-space: nowrap;
}

.alert-table th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--panel);
}

.alert-table tbody tr:hover { background: #1c2129; }
.alert-table tbody tr:last-child td { border-bottom: none; }

/* Celdas con escala de color por intensidad (%Chg 1m, %Volume 1m, Hits).
   El color en si llega por la variable --cell-bg (inline, calculada en JS
   por cada valor); esta clase es la que efectivamente lo pinta, para que
   el hover de la fila pueda aclarar la celda con un filter sin que haga
   falta recalcular nada. */
.alert-table td.cell-scale {
  background-color: var(--cell-bg);
  color: var(--text);
}
.alert-table tbody tr:hover td.cell-scale {
  filter: brightness(1.2);
}

.alert-card-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* Bloquea el scroll de la pagina de fondo mientras el modal de filtros
   esta abierto (ver openTopListFilterModal / closeFilterModal en app.js). */
body.modal-open {
  overflow: hidden;
}

/* --- Modal de filtros por columna (Top Lists) -------------------------
   Overlay unico (singleton) centrado en pantalla. Se muestra agregando
   la clase .open (ver app.js); por defecto queda oculto con display:none
   para no interferir con el layout ni el tab-order del resto de la
   pagina. */

.filter-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.7);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.filter-modal-overlay.open {
  display: flex;
}

.filter-modal {
  width: min(420px, 100%);
  max-height: min(560px, 85vh);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: filterModalPop 0.15s ease-out;
}

@keyframes filterModalPop {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.filter-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.filter-modal-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.filter-modal-close {
  background: transparent;
  border: none;
  padding: 0;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.filter-modal-close:hover {
  color: var(--icon-hover);
  border-color: transparent;
  background: #1c2129;
}

.filter-modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) var(--panel);
}
.filter-modal-body::-webkit-scrollbar { width: 8px; }
.filter-modal-body::-webkit-scrollbar-track { background: var(--panel); }
.filter-modal-body::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 4px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-field-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.filter-field-sep {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}

/* Checkbox "Aplicar a todo el tablero", como tercera columna a la derecha
   de los inputs min/max (ver commitFilterModalDraft en app.js): marca esa
   columna como filtro global, afectando tambien otras Top Lists y las
   cards de Alertas que tengan esa misma columna. Sin texto -> el tooltip
   nativo (atributo title del label) explica que hace al pasar el cursor. */
.filter-field-global {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.filter-global-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

/* type="text" (no "number") a proposito: permite mostrar comas de miles
   mientras el usuario escribe (ver formatFilterInputInPlace en app.js). */
.filter-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.filter-input::placeholder { color: var(--muted); }
.filter-input:hover { border-color: var(--hover); }
.filter-input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-modal-empty {
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.filter-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Contador "X tickers": previsualiza cuantas filas van a quedar con el
   borrador actual, ANTES de confirmar con "Aplicar" (ver
   updateFilterModalCount en app.js). */
.filter-modal-count {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.filter-modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-modal-clear {
  font-size: 12px;
  padding: 6px 12px;
}
.filter-modal-clear:hover {
  border-color: #f0883e;
  color: #f0883e;
}

/* "Aplicar" arranca con el color apagado (--disabled) y solo pasa al verde
   de acento cuando el borrador difiere de como estaba al abrir el modal
   (ver updateApplyButtonState / updateExclusionApplyButtonState en
   app.js) -> asi se ve claramente que no hay nada pendiente por confirmar. */
.filter-modal-apply {
  font-size: 12px;
  padding: 6px 14px;
  font-weight: 600;
  background: var(--disabled);
  border-color: var(--disabled);
  color: var(--muted);
  cursor: not-allowed;
}
.filter-modal-apply.has-changes {
  background: var(--accent);
  border-color: var(--accent);
  color: #06210f;
  cursor: pointer;
}
.filter-modal-apply.has-changes:hover {
  filter: brightness(1.08);
}

/* --- Modal de exclusion de tickers (alert windows) ---------------------
   Reusa el overlay/estructura del modal de filtros de columna
   (.filter-modal-overlay / .filter-modal / .filter-modal-header / etc),
   solo se agregan los estilos puntuales de esta variante: el toggle
   "global" arriba del body, y la lista de tickers tildables. */

.exclusion-modal-global {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.exclusion-modal-global:hover {
  color: var(--icon-hover);
}
.exclusion-global-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--exclude);
  cursor: pointer;
  margin: 0;
}

.exclusion-ticker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.exclusion-ticker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.exclusion-ticker-item:hover {
  background: #1c2129;
}
.exclusion-ticker-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--exclude);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}