.main-page {
  min-height: 100dvh;
}

.dashboard-main {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  position: relative;
  z-index: 1;
  transition: grid-template-columns 0.32s cubic-bezier(0.4, 0, 0.2, 1), column-gap 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-main.sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
  column-gap: 0;
}

.dashboard-sidebar-shell,
.dashboard-content-shell,
.dashboard-card,
.dashboard-hero-card {
  background: linear-gradient(180deg, rgba(12, 12, 15, 0.96), rgba(8, 8, 10, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.dashboard-sidebar-shell {
  border-radius: 28px;
  padding: 24px;
  display: grid;
  gap: 20px;
  align-content: start;
  position: sticky;
  top: 24px;
  height: calc(100dvh - 48px);
  overflow: hidden;
  min-width: 0;
  transition: padding 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease, border-color 0.22s ease, left 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-main.sidebar-collapsed .dashboard-sidebar-shell {
  padding: 0;
  opacity: 0;
  border-color: transparent;
  pointer-events: none;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Shared styles for both toggle buttons */
.sidebar-toggle-btn,
.sidebar-close-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.sidebar-toggle-btn:hover,
.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.09);
}

.sidebar-toggle-btn .bar,
.sidebar-close-btn .bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease, width 0.25s ease;
}

/* Close button (X) — always shows X, lives inside the sidebar */
.sidebar-close-btn .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar-close-btn .bar:nth-child(2) { opacity: 0; width: 0; }
.sidebar-close-btn .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Open button (hamburger) — lives in topbar, hidden when sidebar is open */
.sidebar-toggle-btn {
  display: none;
}
.dashboard-main.sidebar-collapsed .sidebar-toggle-btn {
  display: flex;
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dashboard-brand {
  margin-bottom: 0;
}

.dashboard-user-card,
.mini-status-card,
.summary-item {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.dashboard-user-card {
  padding: 18px;
  display: grid;
  gap: 8px;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  cursor: default;
}

.user-card-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-card-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: linear-gradient(135deg, #6f86ff, #39d0ff);
  color: #fff;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.user-avatar--sm {
  width: 30px;
  height: 30px;
  font-size: 0.95rem;
}

.user-avatar--lg {
  width: 56px;
  height: 56px;
  font-size: 1.7rem;
}

.mini-status-card--account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-avatar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.settings-avatar-display {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-picker-panel {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.avatar-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.avatar-picker-option {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  border: 2px solid transparent;
  color: #fff;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.avatar-picker-option:hover {
  transform: translateY(-2px);
}

.avatar-picker-option.is-selected {
  border-color: var(--primary, #6f86ff);
}

.dashboard-user-card:hover {
  background: rgba(var(--primary-rgb), 0.07);
  border-color: rgba(var(--primary-rgb), 0.18);
  box-shadow: 0 4px 24px rgba(var(--primary-rgb), 0.08);
}

.dashboard-user-card strong,
.mini-status-card strong,
.summary-item strong {
  font-size: 1.04rem;
}

.dashboard-user-card span:not(.eyebrow),
.mini-status-card span,
.summary-item span,
.card-header span,
.dashboard-copy,
.idea-list,
.tracker-table th,
.tracker-table td {
  color: var(--muted);
}

.dashboard-nav {
  display: grid;
  gap: 10px;
}

.dashboard-nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.dashboard-nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #6f86ff, #39d0ff);
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
}

.dashboard-nav-item:hover {
  transform: translateX(4px);
  color: var(--text);
  background: rgba(var(--primary-rgb), 0.08);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.07);
}

.dashboard-nav-item:hover::before {
  transform: translateY(-50%) scaleY(1);
  opacity: 1;
}

.dashboard-nav-item.active {
  background: linear-gradient(135deg, rgba(85, 110, 255, 0.22), rgba(var(--accent-rgb), 0.08));
  border-color: rgba(var(--primary-rgb), 0.24);
  color: var(--text);
}

.dashboard-sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.dashboard-sidebar-footer .button.secondary {
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.dashboard-sidebar-footer .button.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.dashboard-sidebar-footer .button.ghost {
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.dashboard-sidebar-footer .button.ghost:hover {
  background: rgba(255, 107, 129, 0.08);
  border-color: rgba(255, 107, 129, 0.28);
  color: #ff8ca4;
  box-shadow: 0 4px 20px rgba(255, 107, 129, 0.08);
  transform: translateY(-2px);
}

.dashboard-content-shell {
  border-radius: 28px;
  padding: 28px;
  min-height: calc(100dvh - 48px);
  position: relative;
}

/* ── Plan restriction styles ─────────────────────────────────────────────── */
.nav-item-locked {
  opacity: 0.45;
  cursor: not-allowed !important;
}
.nav-item-locked:hover {
  transform: none !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
  color: var(--muted) !important;
}
.nav-item-locked:hover::before {
  transform: translateY(-50%) scaleY(0) !important;
  opacity: 0 !important;
}
.nav-lock-icon {
  float: right;
  width: 12px;
  height: 12px;
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center/contain no-repeat;
  opacity: 0.6;
  margin-top: 3px;
}
.menu-item-locked {
  opacity: 0.3;
  cursor: not-allowed !important;
  pointer-events: none;
  text-decoration: line-through;
}
.ind-row-locked {
  opacity: 0.3;
  cursor: not-allowed !important;
  pointer-events: none;
}
.ind-row-locked .ind-name::after {
  content: " 🔒";
  font-size: 0.65rem;
}
.plan-upgrade-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 20, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  border-radius: 28px;
}
.plan-upgrade-card {
  background: var(--surface, rgba(255,255,255,0.04));
  border: 1px solid rgba(var(--primary-rgb), 0.3);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}
.plan-upgrade-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 1rem;
}
.plan-upgrade-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  color: var(--text);
}
.plan-upgrade-card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}
.plan-toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 14, 28, 0.96);
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  color: var(--text);
  padding: 0.7rem 1.4rem;
  border-radius: 14px;
  font-size: 0.875rem;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
/* ─────────────────────────────────────────────────────────────────────────── */

.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  margin-bottom: 26px;
}

.dashboard-topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.1rem);
  letter-spacing: -0.04em;
}

.dashboard-topbar-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 14px;
}

.mini-status-card {
  padding: 16px;
}

.dashboard-section {
  display: none;
}

.dashboard-section.active {
  display: block;
  animation: section-fade-in 0.32s ease both;
}

@keyframes section-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-section.active { animation: none; }
}

.dashboard-hero-card {
  border-radius: 24px;
  padding: 30px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 24px;
  margin-bottom: 24px;
}

.dashboard-hero-card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  letter-spacing: -0.04em;
}

.dashboard-hero-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.dashboard-hero-aside,
.action-stack {
  display: grid;
  gap: 14px;
}

.hero-kpi-card {
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.hero-kpi-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.hero-kpi-card strong {
  font-size: 1.05rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.dashboard-card {
  border-radius: 24px;
  padding: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.card-header h2,
.card-header h3 {
  margin: 0;
}

.summary-grid,
.tracker-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.summary-item {
  padding: 16px;
  position: relative;
}

.summary-item span {
  display: block;
  margin-bottom: 8px;
}

.kpi-info-wrap {
  position: absolute;
  top: 10px;
  right: 10px;
}

.kpi-info-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

/* 44px tap target for touch devices */
.kpi-info-btn::after {
  content: "";
  position: absolute;
  inset: -11px;
}

.kpi-info-btn:hover,
.kpi-info-btn:focus,
.kpi-info-btn.is-active {
  background: rgba(var(--primary-rgb), 0.18);
  border-color: rgba(var(--primary-rgb), 0.4);
  color: #a0aaff;
  outline: none;
}

.kpi-info-wrap .kpi-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 220px;
  background: #1a1d2e;
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 400;
  color: #c8cde8;
  line-height: 1.5;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  white-space: normal;
  text-align: left;
}

.kpi-info-btn:hover + .kpi-tooltip,
.kpi-info-btn:focus + .kpi-tooltip,
.kpi-info-btn.is-active + .kpi-tooltip {
  display: block;
}

body.light-mode .kpi-info-btn {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.15);
  color: #888;
}

body.light-mode .kpi-info-btn:hover {
  background: rgba(var(--primary-rgb), 0.12);
  border-color: rgba(var(--primary-rgb), 0.35);
  color: #5566cc;
}

body.light-mode .kpi-tooltip {
  background: #fff;
  border-color: rgba(var(--primary-rgb), 0.3);
  color: #444;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.dashboard-form {
  display: grid;
  gap: 14px;
}

.tracker-table-shell {
  margin-top: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.tracker-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: rgba(255, 255, 255, 0.02);
}

.tracker-table th,
.tracker-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: left;
}

.tracker-table th {
  color: #d5ddf5;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.02);
}

.dashboard-copy {
  line-height: 1.8;
  margin: 0;
}

.idea-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.9;
}

.market-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  row-gap: 10px;
  overflow: visible;
  padding: 14px 18px;
  border-radius: 20px;
  background: rgba(8, 8, 10, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.market-search-shell {
  position: relative;
  min-width: min(360px, 100%);
}

.market-input-pill {
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.15s, background 0.15s;
}
.market-input-pill:focus-within {
  border-color: rgba(111, 134, 255, 0.45);
  background: rgba(111, 134, 255, 0.08);
}

.market-input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  outline: none;
}

.market-input-action,
.market-circle-button,
.market-menu-button {
  border: 0;
  cursor: pointer;
}

.market-input-action,
.market-circle-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: #f3f6ff;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.market-input-action:hover,
.market-circle-button:hover,
.market-menu-button:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--primary-rgb), 0.28);
}

.market-input-action svg,
.market-circle-button svg,
.market-menu-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.market-circle-button.active {
  background: linear-gradient(135deg, rgba(85, 110, 255, 0.24), rgba(var(--accent-rgb), 0.08));
  border-color: rgba(var(--primary-rgb), 0.32);
}

.market-divider {
  width: 1px;
  height: 34px;
  background: rgba(255, 255, 255, 0.14);
}

.market-menu-group {
  position: relative;
}

.market-menu-group-wide {
  min-width: 190px;
}

.market-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
}

.market-menu-button.wide-button {
  min-width: 170px;
  justify-content: space-between;
}

.market-menu-button.icon-button {
  min-width: 58px;
  justify-content: center;
}

.market-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.market-icon-wrap svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.market-bars-icon svg {
  width: 20px;
  height: 20px;
}

.market-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 170px;
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(10, 10, 12, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  z-index: 12;
}

.market-menu.hidden,
.ticker-suggestions.hidden {
  display: none;
}

.market-menu-item,
.market-menu-check {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.market-menu-item {
  cursor: pointer;
  text-align: left;
}

.market-menu-item:hover,
.market-menu-check:hover {
  color: var(--text);
  border-color: rgba(var(--primary-rgb), 0.2);
}

.market-menu-check input {
  accent-color: var(--primary);
}

.pos-ticker-shell {
  position: relative;
}

.pos-ticker-shell input {
  width: 100%;
}

.ticker-suggestions {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  border-radius: 16px;
  background: rgba(10, 10, 12, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  z-index: 14;
}

.ticker-suggestion-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
}

.ticker-logo-wrap {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ticker-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  transition: opacity 0.2s ease;
}

.ticker-logo.loaded {
  opacity: 1;
}

.ticker-logo-fallback {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0;
  line-height: 1;
}

.ticker-info {
  flex: 1;
  min-width: 0;
}

.ticker-suggestion-item + .ticker-suggestion-item {
  margin-top: 8px;
}

.ticker-suggestion-item:hover {
  border-color: rgba(var(--primary-rgb), 0.2);
}

.ticker-symbol {
  font-weight: 700;
}

.ticker-name {
  color: var(--muted);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticker-exchange {
  color: var(--muted);
  font-size: 0.92rem;
}

.market-toolbar-spacer {
  flex: 1;
}

.market-info-button {
  flex-shrink: 0;
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  background: rgba(var(--primary-rgb), 0.1);
  color: #a8b4ff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
}

.market-info-button:hover {
  background: rgba(var(--primary-rgb), 0.22);
  border-color: rgba(var(--primary-rgb), 0.6);
  color: #dce5ff;
  transform: translateY(-1px);
}

.market-info-button.active {
  background: linear-gradient(135deg, rgba(85, 110, 255, 0.28), rgba(var(--accent-rgb), 0.1));
  border-color: rgba(var(--primary-rgb), 0.55);
  color: #dce5ff;
}

.company-info-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 24px;
  background: rgba(4, 4, 5, 0.97);
  overflow-y: auto;
  z-index: 10;
  animation: infoPanelSlideDown 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.company-info-panel.hidden {
  display: none;
}

@keyframes infoPanelSlideDown {
  from { opacity: 0; transform: translateY(-18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.company-info-content {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.company-info-loading {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 60px 0;
}

.company-info-animation {
  width: 100%;
  min-height: 380px;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(4, 4, 5, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.company-info-animation.small {
  min-height: 280px;
}

.company-info-animation iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  border: 0;
  background: transparent;
}

.bond-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(var(--primary-rgb), 0.18);
  color: #6f86ff;
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.bond-isin-badge {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.bond-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  margin-top: 18px;
}

.bond-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}

.bond-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bond-value {
  font-size: 0.95rem;
  font-weight: 600;
}

.company-info-error {
  color: #ff8ca4;
  font-size: 0.95rem;
  text-align: center;
  padding: 60px 0;
}

.company-info-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.company-info-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #dce5ff;
  margin: 0;
}

.company-info-header .company-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.company-meta-tag {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(var(--primary-rgb), 0.12);
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  color: #a8b4ff;
}

.company-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.company-stat-card {
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.company-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.company-stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #dce5ff;
}

.company-stat-value.positive { color: #32d6a2; }
.company-stat-value.negative { color: #ff8ca4; }

.company-description {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.company-description h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #dce5ff;
  margin: 0;
}

.company-description p {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.75;
  margin: 0;
}

.company-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.company-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255,255,255,0.06);
  padding: 4px;
  flex-shrink: 0;
}

/* ── Valor razonable ─────────────────────────────────────────────────────── */

.fv-section {
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  border-radius: 14px;
  padding: 20px;
  background: rgba(16, 18, 30, 0.85);
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 4px;
}

.fv-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #dce5ff;
  margin: 0;
}

.fv-kpi-row {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.fv-kpi {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 24px;
}

.fv-kpi-sep {
  padding-left: 24px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.fv-kpi-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fv-kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}

.fv-kpi-sub {
  font-size: 0.8rem;
  font-weight: 500;
}

.fv-pos  { color: #32d6a2; }
.fv-neg  { color: #ff8ca4; }

.fv-risk-low  { color: #32d6a2; }
.fv-risk-mid  { color: #f5b84c; }
.fv-risk-high { color: #ff8ca4; }

.fv-spread { font-size: 1.1rem; }

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

.fv-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  align-items: center;
}

.fv-row-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fv-row-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.fv-row-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.fv-row-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fv-bar-current {
  font-size: 0.85rem;
  font-weight: 600;
  color: #dce5ff;
  text-align: center;
}

.fv-bar-track {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}

.fv-bar-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dce5ff;
  border: 2px solid rgba(0, 0, 0, 0.4);
}

.fv-bar-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 560px) {
  .fv-row {
    grid-template-columns: 1fr;
  }
  .fv-kpi-value { font-size: 1.15rem; }
}

.financials-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 8px;
}

.financials-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.financials-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #dce5ff;
  margin: 0;
}

.financials-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fin-period-toggle {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(var(--primary-rgb),0.15);
  border-radius: 20px;
  padding: 3px;
}

.fin-period {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.fin-period:hover {
  color: #a8b4ff;
}

.fin-period.active {
  background: rgba(var(--primary-rgb),0.22);
  color: #dce5ff;
}

.financials-tabs {
  display: flex;
  gap: 6px;
}

.fin-tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.fin-tab:hover {
  background: rgba(var(--primary-rgb), 0.1);
  color: #a8b4ff;
}

.fin-tab.active {
  background: rgba(var(--primary-rgb), 0.18);
  border-color: rgba(var(--primary-rgb), 0.45);
  color: #dce5ff;
}

.financials-content {
  overflow-x: auto;
}

.fin-table-wrap {
  overflow-x: auto;
}

.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 420px;
}

.fin-table thead th {
  text-align: right;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.fin-table thead th:first-child {
  text-align: left;
}

.fin-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.1s;
}

.fin-table tbody tr:last-child {
  border-bottom: none;
}

.fin-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.fin-table tbody td {
  padding: 10px 14px;
  text-align: right;
  color: #dce5ff;
  font-weight: 500;
}

.fin-row-label {
  text-align: left !important;
  color: rgba(200, 210, 240, 0.75) !important;
  font-weight: 400 !important;
  white-space: nowrap;
  min-width: 190px;
}

.fin-row-bold td {
  color: #dce5ff;
  font-weight: 600;
}

.fin-row-bold .fin-row-label {
  color: #dce5ff !important;
  font-weight: 600 !important;
}

.fin-th-ttm {
  color: #8fa3ff !important;
}

.fin-th-label {
  text-align: left !important;
  min-width: 190px;
}

.fin-note {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.3);
  margin-bottom: 8px;
}

.etf-holdings-content {
  padding: 8px 0 0;
}

.etf-holdings-chart-wrap {
  position: relative;
  width: 100%;
}

.etf-tooltip {
  display: none;
  position: absolute;
  pointer-events: none;
  background: rgba(18, 20, 40, 0.95);
  border: 1px solid rgba(var(--primary-rgb), 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: rgba(220, 229, 255, 0.9);
  white-space: nowrap;
  z-index: 10;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.fin-neg {
  color: #ff6b81;
}

.fin-eps {
  color: #dce5ff;
}

.fin-null {
  color: rgba(255,255,255,0.2);
}

/* ── Seasonality ──────────────────────────────────────────────── */
.seasonal-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.seasonal-view-toggle {
  display: flex;
  gap: 3px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(var(--primary-rgb),0.15);
  border-radius: 8px;
  padding: 3px;
}

.seas-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seas-view-btn:hover { color: #a8b4ff; }
.seas-view-btn.active { background: rgba(var(--primary-rgb),0.22); color: #dce5ff; }

.seasonal-period-btns {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(var(--primary-rgb),0.15);
  border-radius: 20px;
  padding: 3px;
}

.seas-period-btn {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.seas-period-btn:hover { color: #a8b4ff; }
.seas-period-btn.active { background: rgba(var(--primary-rgb),0.22); color: #dce5ff; }

.seasonal-canvas-wrap {
  position: relative;
  width: 100%;
  background: rgba(255,255,255,0.015);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
  cursor: crosshair;
}

.seas-tooltip {
  display: none;
  position: absolute;
  pointer-events: none;
  background: rgba(13,15,28,0.97);
  border: 1px solid rgba(var(--primary-rgb),0.25);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 0.78rem;
  color: rgba(220,229,255,0.9);
  white-space: nowrap;
  z-index: 20;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  min-width: 160px;
}

.seas-tt-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(160,175,240,0.55);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 7px;
}

.seas-tt-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 0;
  opacity: 0.55;
  font-size: 0.78rem;
  transition: opacity 0.1s;
}

.seas-tt-row.seas-tt-hl { opacity: 1; font-weight: 600; }
.seas-tt-avg { border-bottom: 1px solid rgba(255,209,102,0.18); margin-bottom: 4px; padding-bottom: 5px; }

.seas-tt-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.seas-table td, .seas-table th { white-space: nowrap; }

.seas-pos { color: #06d6a0; }
.seas-neg { color: #ff6b81; }

.seas-avg-col {
  background: rgba(255,209,102,0.06);
  font-weight: 600;
}

.seas-total-row td {
  border-top: 1px solid rgba(255,255,255,0.1);
}

body.light-mode .seasonal-canvas-wrap { background: rgba(0,0,0,0.02); border-color: rgba(0,0,0,0.07); }
body.light-mode .seas-pos { color: #05a57d; }
body.light-mode .seas-neg { color: #d93a52; }

.fin-table thead th {
  text-align: right;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.market-chart-shell {
  padding: 0;
  border-radius: 16px;
  background: #131722;
  border: 1px solid #2a2e39;
  box-shadow: 0 4px 32px rgba(0,0,0,0.45);
  position: relative;
  overflow: hidden;
}

.market-chart-header strong {
  display: block;
  font-size: 1.1rem;
  color: #d1d4dc;
  letter-spacing: 0.02em;
}

.market-chart-header span,
.market-chart-status {
  color: #787b86;
}

.crosshair-ohlc {
  display: inline-flex;
  gap: 10px;
  margin-left: 10px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.crosshair-ohlc span { color: #787b86; }
.crosshair-ohlc b { font-weight: 600; }
.crosshair-ohlc b.pos { color: #00c894; }
.crosshair-ohlc b.neg { color: #ff4d6a; }

.chart-price-label {
  font-size: 1.15rem;
  font-weight: 600;
  color: #d1d4dc;
  font-variant-numeric: tabular-nums;
}

.market-chart-status {
  padding: 4px 18px 6px;
  min-height: 22px;
  font-size: 0.8rem;
  color: #787b86;
  background: #1c2030;
  border-bottom: 1px solid #2a2e39;
  margin-bottom: 0;
}

.market-chart {
  width: 100%;
  height: 680px;
  overflow: hidden;
  background: #131722;
  position: relative;
}

.market-chart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(19, 23, 34, 0.9);
  z-index: 10;
  text-align: center;
  padding: 24px;
}

.market-chart-overlay svg {
  width: 40px;
  height: 40px;
  fill: #ff8ca4;
  opacity: 0.8;
}

.market-chart-overlay p {
  color: #787b86;
  font-size: 0.95rem;
  max-width: 420px;
  line-height: 1.6;
}

.market-chart-overlay.hidden {
  display: none;
}

/* ── Market Overview Bar ──────────────────────────────────────────────────── */
.market-overview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.market-overview-row .market-overview-bar { flex: 1; margin-bottom: 0; min-width: 0; }
.market-updated {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fng-gauge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
}
.fng-gauge-svg { width: 56px; height: 32px; }
.fng-gauge-label { display: flex; flex-direction: column; line-height: 1.1; }
.fng-gauge-value { font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fng-gauge-text { font-size: 0.65rem; color: var(--muted); white-space: nowrap; }
.market-overview-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  margin-bottom: 4px;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.market-overview-bar::-webkit-scrollbar { display: none; }

/* ── Range segmented control (inline) ──────────────────────────────────────── */
.market-range-seg {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.market-range-seg::-webkit-scrollbar { display: none; }
.market-range-btn {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.market-range-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.market-range-btn.active {
  color: #f3f6ff;
  background: rgba(111, 134, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(111, 134, 255, 0.4);
}
.market-range-btn.menu-item-locked,
.market-range-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── News empty / error state ──────────────────────────────────────────────── */
.ticker-news-empty {
  padding: 18px 4px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.mkt-index-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 14px;
  padding-right: 56px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
  color: var(--text);
}
.mkt-index-tile:hover {
  background: rgba(111,134,255,0.12);
  border-color: rgba(111,134,255,0.35);
}
.mkt-index-tile.active-tile {
  border-color: rgba(111,134,255,0.55);
  background: rgba(111,134,255,0.15);
}
.mkt-index-label { font-size: 0.72rem; color: var(--muted); }
.mkt-index-price { font-size: 0.88rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.mkt-index-chg   { font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.mkt-index-chg.pos { color: #00c894; }
.mkt-index-chg.neg { color: #ff4d6a; }
.mkt-index-spark {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 22px;
  pointer-events: none;
}
.mkt-index-spark polyline {
  fill: none;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.mkt-index-spark polyline.pos { stroke: #00c894; }
.mkt-index-spark polyline.neg { stroke: #ff4d6a; }

/* ── Market Workspace (2-col: sidebar + main) ─────────────────────────────── */
.market-workspace {
  display: grid;
  grid-template-columns: 200px 1fr 220px;
  gap: 14px;
  align-items: start;
}
.market-main-col {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

/* ── Stats Rail (right) ───────────────────────────────────────────────────── */
.market-stats-rail {
  border-radius: 16px;
  background: rgba(8,8,10,0.98);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow);
  position: sticky;
  top: 20px;
  max-height: calc(100dvh - 160px);
  overflow-y: auto;
}
.stats-rail-head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.stats-rail-body { padding: 6px 4px; }
.stats-rail-empty { padding: 14px; font-size: 0.82rem; color: var(--muted); text-align: center; }
.stats-rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.stats-rail-item:last-child { border-bottom: 0; }
.stats-rail-label { font-size: 0.78rem; color: var(--muted); }
.stats-rail-value { font-size: 0.84rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-rail-value.pos { color: #00c894; }
.stats-rail-value.neg { color: #ff4d6a; }

@media (max-width: 1280px) {
  .market-workspace { grid-template-columns: 200px 1fr; }
  .market-stats-rail { display: none; }
}

/* ── Technical Rating Card ───────────────────────────────────────────────── */
.tech-rating-card { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.tech-rating-card:empty { display: none; }
.tr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tr-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.tr-badge { font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.tr-badge.tr-strong-buy  { background: rgba(0,200,148,0.18); color: #32d6a2; }
.tr-badge.tr-buy         { background: rgba(0,200,148,0.12); color: #00c894; }
.tr-badge.tr-neutral     { background: rgba(255,255,255,0.1); color: var(--muted); }
.tr-badge.tr-sell        { background: rgba(255,77,106,0.12); color: #ff6b81; }
.tr-badge.tr-strong-sell { background: rgba(255,77,106,0.18); color: #ff4d6a; }
.tr-gauge-track { position: relative; height: 6px; border-radius: 4px; background: linear-gradient(90deg, #ff4d6a, rgba(255,255,255,0.12), #32d6a2); overflow: visible; }
.tr-gauge-marker { position: absolute; top: -3px; width: 2px; height: 12px; background: #fff; border-radius: 1px; transform: translateX(-1px); box-shadow: 0 0 4px rgba(255,255,255,0.6); }
.tr-gauge-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.68rem; color: var(--muted); }
.tr-breakdown { margin-top: 10px; }
.tr-bd-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; font-size: 0.76rem; }
.tr-bd-row span { color: var(--muted); }
.tr-bd-row strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Watchlist Sidebar ─────────────────────────────────────────────────────── */
.market-wl-sidebar {
  border-radius: 16px;
  background: rgba(8,8,10,0.98);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 20px;
  max-height: calc(100dvh - 160px);
}
.market-wl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.market-wl-add-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.market-wl-add-btn:hover { background: rgba(111,134,255,0.2); color: #6f86ff; border-color: #6f86ff; }
.market-wl-add-btn svg { width: 12px; height: 12px; }
.market-wl-items {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.market-wl-empty {
  padding: 20px 14px;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.market-wl-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  position: relative;
}
.market-wl-item:hover { background: rgba(255,255,255,0.04); }
.market-wl-item.active { background: rgba(111,134,255,0.12); }
.market-wl-sym {
  font-size: 0.82rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.market-wl-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex-shrink: 0;
}
.market-wl-price {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.market-wl-chg {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.market-wl-chg.pos { color: #00c894; }
.market-wl-chg.neg { color: #ff4d6a; }
.market-wl-rm {
  opacity: 0;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(255,77,106,0.15);
  color: #ff4d6a;
  border-radius: 4px;
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.12s, background 0.12s;
}
.market-wl-item:hover .market-wl-rm { opacity: 1; }
.market-wl-rm:hover { background: rgba(255,77,106,0.35); }

/* ── Compare Toggle & Bar ─────────────────────────────────────────────────── */
.compare-toggle-btn {
  gap: 6px;
}
.compare-toggle-btn svg { width: 16px; height: 16px; }
.compare-toggle-btn.active { background: rgba(111,134,255,0.18); border-color: rgba(111,134,255,0.4); color: #6f86ff; }

.market-compare-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(8,8,10,0.95);
  border: 1px solid rgba(111,134,255,0.2);
  border-top: none;
  border-radius: 0 0 12px 12px;
  flex-wrap: wrap;
}
.market-compare-bar.hidden { display: none; }
.compare-bar-label {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.compare-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid rgba(111,134,255,0.35);
  background: rgba(111,134,255,0.12);
  color: #a5b4ff;
}
.compare-chip:nth-child(2) { border-color: rgba(245,184,76,0.35); background: rgba(245,184,76,0.12); color: #f5b84c; }
.compare-chip:nth-child(3) { border-color: rgba(50,214,162,0.35); background: rgba(50,214,162,0.12); color: #32d6a2; }
.compare-chip:nth-child(4) { border-color: rgba(255,107,129,0.35); background: rgba(255,107,129,0.12); color: #ff6b81; }
.compare-chip-rm {
  border: none;
  background: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 0;
  font-size: 0.7rem;
  line-height: 1;
}
.compare-chip-rm:hover { opacity: 1; }
.compare-input {
  flex: 1;
  min-width: 100px;
  max-width: 160px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 4px 10px;
  text-transform: uppercase;
  outline: none;
}
.compare-input:focus { border-color: rgba(111,134,255,0.5); }
.compare-add-btn {
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid rgba(111,134,255,0.4);
  background: rgba(111,134,255,0.15);
  color: #6f86ff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.compare-add-btn:hover { background: rgba(111,134,255,0.3); }
.compare-close-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
}
.compare-close-btn:hover { color: #ff4d6a; }

/* ── Enriched Chart Header ─────────────────────────────────────────────────── */
.market-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid #2a2e39;
  background: #1c2030;
  flex-wrap: wrap;
}
.chart-header-left { display: flex; flex-direction: column; gap: 2px; }
.chart-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chart-change-pct {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 6px;
}
.chart-change-pct.pos { color: #00c894; background: rgba(0,200,148,0.1); }
.chart-change-pct.neg { color: #ff4d6a; background: rgba(255,77,106,0.1); }
.chart-52w-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}
.chart-52w-bar.hidden { display: none; }
.chart-52w-label { font-weight: 600; color: #787b86; }
.chart-52w-track {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.1);
}
.chart-fullscreen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.chart-fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}
.chart-fullscreen-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
}
.market-chart-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 9999;
  background: #0a0a0d;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  padding: 14px;
  gap: 14px;
  box-sizing: border-box;
}
.market-chart-fullscreen .market-chart-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}
.market-chart-fullscreen .market-chart {
  flex: 1;
}
.market-chart-fullscreen .chart-fullscreen-btn svg {
  transform: scale(-1) scaleY(-1);
}

.chart-52w-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff4d6a, #f5b84c, #00c894);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.chart-52w-val { font-variant-numeric: tabular-nums; }

/* ── Live Price Flash ─────────────────────────────────────────────────────── */
@keyframes flash-up {
  0%   { background: rgba(0,200,148,0.25); color: #00c894; }
  100% { background: transparent; color: #d1d4dc; }
}
@keyframes flash-down {
  0%   { background: rgba(255,77,106,0.25); color: #ff4d6a; }
  100% { background: transparent; color: #d1d4dc; }
}
.chart-price-label.flash-up  { animation: flash-up  0.7s ease-out forwards; border-radius: 4px; padding: 0 4px; }
.chart-price-label.flash-down { animation: flash-down 0.7s ease-out forwards; border-radius: 4px; padding: 0 4px; }

@media (max-width: 1100px) {
  .dashboard-main {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .dashboard-sidebar-shell {
    position: fixed;
    left: 0;
    top: 0;
    height: 100dvh;
    width: 290px;
    z-index: 50;
    border-radius: 0 28px 28px 0;
    overflow-y: auto;
    padding: 24px;
    opacity: 1;
    pointer-events: none;
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateX(-110%);
  }

  /* Always show the hamburger toggle button on mobile */
  .sidebar-toggle-btn {
    display: flex;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    z-index: 199;
  }

  .sidebar-backdrop.active {
    display: block;
  }
}

.dashboard-sidebar-shell {
  /* Ensure sidebar is always above backdrop on mobile */
}

@media (max-width: 1100px) {
  .dashboard-sidebar-shell {
    z-index: 200;
  }
}

@media (max-width: 860px) {
  .dashboard-topbar,
  .dashboard-hero-card,
  .dashboard-grid,
  .dashboard-topbar-meta,
  .summary-grid,
  .tracker-metrics {
    grid-template-columns: 1fr;
  }

  .dashboard-topbar {
    display: grid;
  }

  .market-chart-header {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .dashboard-main {
    padding: 16px;
  }

  .dashboard-sidebar-shell,
  .dashboard-content-shell,
  .dashboard-card,
  .dashboard-hero-card {
    padding: 20px;
  }

  .market-toolbar {
    align-items: stretch;
  }

  .market-search-shell,
  .market-menu-group,
  .market-menu-group-wide {
    width: 100%;
    min-width: 100%;
  }

  .market-menu-button,
  .market-input-pill {
    width: 100%;
  }

  .market-divider {
    display: none;
  }

  .market-circle-button {
    align-self: start;
  }

  .market-chart {
    height: 420px;
  }

  /* Reduce border-radius on content shell for small screens */
  .dashboard-content-shell {
    border-radius: 18px;
    padding: 16px;
  }

  .dashboard-topbar {
    margin-bottom: 18px;
  }

  .dashboard-topbar h1 {
    font-size: 1.7rem;
  }

  /* Hub toolbar wraps on small screens */
  .hub-toolbar {
    flex-wrap: wrap;
    padding: 8px;
    gap: 4px;
  }
  .hub-toolbar-spacer {
    display: none;
  }
  .hub-toolbar-actions {
    flex-wrap: wrap;
  }

  /* Tracker tab navigation: horizontal scroll on mobile */
  .tracker-tab-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tracker-tab-nav::-webkit-scrollbar {
    display: none;
  }
  .tracker-tab-btn {
    flex-shrink: 0;
    padding: 7px 14px;
    min-height: 44px;
    font-size: 0.82rem;
  }

  /* Performance period buttons */
  .perf-period-nav {
    flex-wrap: wrap;
    gap: 4px;
  }

  /* Back button + portfolio name */
  .tracker-dash-topbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* KPI grid on very small screens */
  .tracker-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .tracker-kpi-hero {
    grid-column: span 2;
  }

  /* Refresh prices button full-width */
  .tracker-price-status-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .tracker-refresh-btn {
    align-self: stretch;
    text-align: center;
  }

  /* Markowitz preset buttons wrap */
  .mkw-presets {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Analyzer run row vertical on mobile */
  .anlz-run-row {
    gap: 8px;
  }

  /* Markets: let toolbar/chart shrink below ~360px (overflowed on small phones) */
  .market-toolbar,
  .market-workspace,
  .market-main-col,
  .market-chart-shell,
  .market-chart,
  .market-chart-header,
  .market-chart-status {
    min-width: 0;
  }
  .market-input-pill,
  .market-menu-button.wide-button {
    min-width: 0;
  }
}

/* ── Indicator Panel ──────────────────────────────────────────────────────── */
.indicator-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 3, 8, 0.62);
  backdrop-filter: blur(4px);
  z-index: 998;
  animation: indicator-fade-in 0.18s ease-out;
}

.indicator-backdrop.hidden {
  display: none;
}

.indicator-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: rgba(10, 11, 18, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 40px 96px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(var(--primary-rgb), 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
  z-index: 999;
  overflow-y: auto;
  overflow-x: hidden;
  animation: indicator-pop-in 0.2s ease-out;
}

.indicator-panel .indicator-panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
}

.indicator-panel.hidden,
.indicator-panel.hidden + .indicator-backdrop {
  display: none;
}

.indicator-panel.hidden {
  display: none;
}

@keyframes indicator-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes indicator-pop-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.indicator-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 8px;
  padding: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  color: rgba(220, 229, 255, 0.6);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.indicator-close-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
}

.indicator-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.14);
}

.indicator-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.indicator-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(220, 229, 255, 0.55);
}

.indicator-clear-btn {
  font-size: 0.76rem;
  font-weight: 500;
  color: rgba(var(--primary-rgb), 0.7);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 8px;
  transition: background 0.18s, color 0.18s;
}

.indicator-clear-btn:hover {
  background: rgba(var(--primary-rgb), 0.12);
  color: #6f86ff;
}

.indicator-section {
  padding: 8px 8px 4px;
}

.indicator-section + .indicator-section {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.indicator-section[data-cat="ma"]     { --cat-color: #39d0ff; }
.indicator-section[data-cat="trend"]  { --cat-color: #00c894; }
.indicator-section[data-cat="bands"]  { --cat-color: #6f86ff; }
.indicator-section[data-cat="osc"]    { --cat-color: #f5a623; }
.indicator-section[data-cat="price"]  { --cat-color: #f5b84c; }
.indicator-section[data-cat="vol"]    { --cat-color: #c084fc; }
.indicator-section { border-left: 2px solid var(--cat-color, transparent); }

.indicator-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cat-color, rgba(255, 255, 255, 0.25));
  opacity: 0.75;
  padding: 6px 10px 6px;
}

.indicator-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 3px;
  position: relative;
}

.indicator-row:hover {
  background: rgba(255, 255, 255, 0.035);
}

.indicator-row.active {
  background: linear-gradient(135deg, rgba(85, 110, 255, 0.13), rgba(var(--accent-rgb), 0.04));
  border-color: rgba(var(--primary-rgb), 0.18);
}

.ind-cb {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ind-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--dot, #6f86ff);
  box-shadow: 0 0 7px var(--dot, #6f86ff);
  transition: box-shadow 0.2s;
}

.indicator-row.active .ind-dot {
  box-shadow: 0 0 10px var(--dot, #6f86ff), 0 0 20px var(--dot, rgba(var(--primary-rgb),0.4));
}

.ind-info {
  display: grid;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.ind-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.ind-desc {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
}

.ind-badge {
  font-size: 0.72rem;
  width: 20px;
  height: 20px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(var(--primary-rgb), 0.15);
  color: #6f86ff;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.18s, transform 0.18s;
}

.indicator-row.active .ind-badge {
  opacity: 1;
  transform: scale(1);
}

.indicator-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: linear-gradient(135deg, #556eff, #39d0ff);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  margin-left: -4px;
}

.indicator-count.hidden {
  display: none;
}

/* ── Tracker Module ───────────────────────────────────────────────────────── */

#trackerListView,
#trackerDashView.hidden,
#newPortfolioModal.hidden,
#addPositionModal.hidden,
#deletePortfolioModal.hidden,
#reportRangeModal.hidden,
#cashModal.hidden,
#cashError.hidden,
#noPortfoliosMsg.hidden,
#noPositionsMsg.hidden,
#noPositionsSummaryMsg.hidden,
#noTxMsg.hidden,
#posIvaRateRow.hidden,
#withdrawIvaRateRow.hidden,
#withdrawPositionModal.hidden,
#editTxModal.hidden,
#editTxError.hidden,
#feedbackModal.hidden,
#shareModal.hidden,
#mkwCompareModal.hidden,
#betaWelcomeModal.hidden,
#mainTotpBackupView.hidden,
#mainBackupRegenModal.hidden,
#mainBackupRegenForm.hidden,
#mainBackupRegenResult.hidden,
#consolidatedBar.hidden,
#dividendModal.hidden,
#dividendError.hidden,
#editPortfolioModal.hidden,
#positionNoteModal.hidden,
#splitNoticeBar.hidden,
#positionsTableShell.hidden {
  display: none;
}

#trackerListView:not(.hidden) {
  display: block;
}

/* ── Tracker Tabs ─────────────────────────────────────────────────────────── */

.tracker-tab-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 3px;
  /* Nunca desbordar horizontalmente el contenedor (fix tablet 720–1100px): la
     barra se limita al ancho disponible y hace scroll interno si no cabe. */
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  /* Fija la barra al hacer scroll también en desktop (rediseño visual #3). */
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  scroll-padding-inline: 6px;
  /* Indicio de que hay más pestañas por scrollear (móvil/tablet #5). */
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(to right, black calc(100% - 22px), transparent 100%);
}

.tracker-tab-nav::-webkit-scrollbar {
  display: none;
}

/* Contador por pestaña (Transacciones · N, Dividendos · N) */
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  margin-left: 7px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.tracker-tab-btn.active .tab-count {
  background: rgba(var(--primary-rgb), 0.32);
  color: #fff;
}

body.light-mode .tracker-tab-nav {
  background: rgba(0, 0, 0, 0.04);
}

body.light-mode .tab-count {
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.6);
}

.tracker-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 7px 18px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  font-family: Inter, sans-serif;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
  outline-offset: 2px;
}

.tracker-tab-btn:hover {
  color: rgba(255, 255, 255, 0.7);
}

.tracker-tab-btn.active {
  background: #1a1f2e;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
}

/* ── Desempeño tab ────────────────────────────────────────────────────────── */

.perf-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.perf-metric-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.perf-metric-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.perf-metric-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}

.perf-metric-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.perf-metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.perf-info-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  cursor: pointer;
  font-family: Inter, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}

.perf-info-btn:hover {
  background: rgba(var(--primary-rgb), 0.12);
  color: #6f86ff;
  border-color: rgba(var(--primary-rgb), 0.3);
}

/* Perf info overlay */
.perf-info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.perf-info-overlay.hidden {
  display: none;
}

.perf-info-popup {
  background: linear-gradient(160deg, rgba(18, 18, 24, 0.99) 0%, rgba(11, 11, 16, 0.99) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 28px;
  max-width: 560px;
  width: 92%;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7), 0 0 0 0.5px rgba(var(--primary-rgb), 0.08) inset;
}

.perf-info-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.perf-info-popup-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(143, 160, 255, 0.7);
}

.perf-info-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  font-family: Inter, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}

.perf-info-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.perf-info-popup-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.perf-info-formula {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  background: rgba(var(--primary-rgb), 0.07);
  border: 1px solid rgba(var(--primary-rgb), 0.16);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 0.84rem;
  line-height: 1.8;
  color: #9fb0ff;
  white-space: pre-wrap;
  letter-spacing: 0.01em;
}

.perf-info-values {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  overflow: hidden;
}

.perf-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.83rem;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.12s;
}

.perf-info-row:hover {
  background: rgba(255, 255, 255, 0.025);
}

.perf-info-row:last-child {
  border-bottom: none;
}

.perf-info-row-label {
  color: rgba(180, 190, 220, 0.65);
  font-size: 0.82rem;
}

.perf-info-row-val {
  font-weight: 600;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.perf-info-result {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(var(--primary-rgb), 0.06));
  border: 1px solid rgba(var(--primary-rgb), 0.22);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 0.88rem;
  color: #8fa0ff;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.perf-info-note {
  font-size: 0.76rem;
  color: rgba(160, 170, 200, 0.55);
  line-height: 1.6;
  font-style: italic;
}

/* Beta per-asset table */
.perf-beta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.81rem;
}

.perf-beta-table th {
  text-align: left;
  color: rgba(160, 175, 215, 0.6);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: Inter, sans-serif;
}

.perf-beta-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.perf-beta-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

.perf-beta-table td:first-child {
  font-family: Inter, sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

.perf-beta-table tr:last-child td {
  border-bottom: none;
}

.perf-beta-table tfoot td {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 700;
  color: #8fa0ff;
  padding-top: 10px;
  font-size: 0.83rem;
}

body.light-mode .perf-info-btn {
  border-color: rgba(0, 0, 0, 0.12);
}

body.light-mode .perf-info-btn:hover {
  background: rgba(var(--primary-rgb), 0.1);
}

body.light-mode .perf-info-popup {
  background: linear-gradient(180deg, rgba(245, 247, 251, 0.98), rgba(238, 240, 245, 0.99));
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .perf-info-formula {
  background: rgba(var(--primary-rgb), 0.07);
  color: #5060d0;
}

body.light-mode .perf-info-close {
  border-color: rgba(0, 0, 0, 0.1);
}

.var-conf-btns {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.var-conf-btn {
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  font-family: Inter, sans-serif;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.var-conf-btn:hover {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--text);
  border-color: rgba(var(--primary-rgb), 0.22);
}

.var-conf-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.perf-period-nav {
  display: flex;
  gap: 4px;
}

.perf-period-btn {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: Inter, sans-serif;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.perf-period-btn:hover {
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--text);
  border-color: rgba(var(--primary-rgb), 0.22);
}

.perf-period-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.perf-chart-wrap {
  position: relative;
  margin-top: 16px;
}

#perfLineChart {
  display: block;
  width: 100%;
}

.perf-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(14, 14, 24, 0.88);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.75rem;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  min-width: 9.5rem;
  z-index: 10;
  white-space: nowrap;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 0.1s, left 0.1s cubic-bezier(0.4,0,0.2,1);
}

.perf-chart-tooltip.hidden { opacity: 0; pointer-events: none; }

.perf-tooltip-date {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}

.perf-tooltip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}

.perf-tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.perf-tooltip-label { color: var(--muted); flex: 1; font-size: 0.73rem; }
.perf-tooltip-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.73rem;
}
.perf-pos { color: #34d399; }
.perf-neg { color: #f87171; }

body.light-mode .perf-chart-tooltip {
  background: rgba(252, 252, 255, 0.92);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
}

.perf-date-pill {
  position: absolute;
  pointer-events: none;
  background: #1c1c2e;
  color: rgba(255,255,255,0.88);
  border-radius: 99px;
  padding: 3px 12px;
  font-size: 0.71rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 20;
  bottom: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
  transition: left 0.1s cubic-bezier(0.4,0,0.2,1), opacity 0.1s;
}

.perf-date-pill.hidden {
  opacity: 0;
  pointer-events: none;
}

body.light-mode .perf-date-pill {
  background: #e4e4f0;
  color: rgba(0,0,0,0.75);
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.perf-chart-status {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
  min-height: 18px;
}

@media (max-width: 860px) {
  .perf-metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .perf-metrics-grid {
    grid-template-columns: 1fr;
  }
}

.allocation-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

.alloc-donut-wrap {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.alloc-geo-map {
  flex: 1 1 300px;
  min-width: 240px;
  max-width: 420px;
}

.alloc-geo-map .geo-world-map-svg {
  width: 100%;
  height: auto;
  display: block;
}

.alloc-geo-map .geo-lit {
  filter: drop-shadow(0 0 5px rgba(120,150,255,0.55));
}

.alloc-geo-map .geo-map-empty {
  width: 100%;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.25);
  font-size: 11px;
  font-weight: 600;
}

.alloc-legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.alloc-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.alloc-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.alloc-legend-label {
  flex: 1;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alloc-legend-pct {
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .allocation-row {
    grid-template-columns: 1fr;
  }
}

.allocation-row--three {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1100px) {
  .allocation-row--three {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .allocation-row--three {
    grid-template-columns: 1fr;
  }
}

/* ── Gráfica de valor del portafolio (Resumen, #1) ─────────────────────────── */
.portfolio-value-card {
  margin-bottom: 20px;
}

.value-chart-header {
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.value-chart-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.value-chart-readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.value-chart-readout strong {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.value-chart-delta {
  font-size: 0.9rem;
  font-weight: 600;
}

.value-chart-delta.return-pos { color: var(--success, #32d6a2); }
.value-chart-delta.return-neg { color: var(--danger, #ff6b81); }

.value-chart-wrap {
  position: relative;
  width: 100%;
  margin-top: 12px;
}

.value-chart-wrap canvas {
  display: block;
  width: 100%;
  touch-action: none;
}

/* ── Operaciones cerradas (round-trips, #7) ────────────────────────────────── */
.closed-trades-card {
  margin-top: 20px;
}

.closed-trades-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 4px 0 16px;
}

.closed-trades-summary .cts-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.closed-trades-summary .cts-item span {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.closed-trades-summary .cts-item strong {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.closed-trades-table td .cts-days {
  color: var(--muted);
  font-size: 0.82rem;
}

body.light-mode .closed-trades-summary .cts-item {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.08);
}

.tracker-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tracker-list-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.portfolio-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.portfolio-card {
  background: linear-gradient(180deg, rgba(12, 12, 15, 0.96), rgba(8, 8, 10, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  border-radius: 22px;
  padding: 22px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: grid;
  gap: 12px;
}

.portfolio-card:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--primary-rgb), 0.28);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(var(--primary-rgb), 0.1);
}

.portfolio-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.portfolio-card-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.portfolio-card-delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.portfolio-card-delete:hover {
  background: rgba(255, 107, 129, 0.14);
  color: #ff8ca4;
  border-color: rgba(255, 107, 129, 0.3);
}

.portfolio-card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.portfolio-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.9rem;
}

.portfolio-card-meta span:last-child {
  color: var(--text);
  font-weight: 600;
}

.portfolio-card-value {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.portfolio-card-value strong {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.pc-day {
  font-size: 0.82rem;
  font-weight: 600;
}

.portfolio-card-stats {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.portfolio-card-stats .pc-stat em {
  font-style: normal;
}

.portfolio-card-stats .pc-curr {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
}

body.light-mode .portfolio-card-stats .pc-curr {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

.portfolio-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

body.light-mode .portfolio-card-footer {
  border-top-color: rgba(0, 0, 0, 0.06);
}

/* ── Barra de patrimonio consolidado ──────────────────────────────────────── */
.consolidated-bar {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 18px 24px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.12), rgba(var(--primary-rgb), 0.03));
  border: 1px solid rgba(var(--primary-rgb), 0.18);
}

body.light-mode .consolidated-bar {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.08), rgba(var(--primary-rgb), 0.02));
  border-color: rgba(var(--primary-rgb), 0.16);
}

.cbar-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cbar-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cbar-value {
  font-size: 1.05rem;
  font-weight: 600;
}

.cbar-value--lg {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.cbar-value--lg small {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.cbar-value em {
  font-style: normal;
  font-size: 0.85em;
}

.cbar-note {
  font-size: 0.74rem;
  color: var(--muted);
  margin-left: auto;
  align-self: center;
}

@media (max-width: 600px) {
  .consolidated-bar { gap: 18px 28px; padding: 16px 18px; }
  .cbar-value--lg { font-size: 1.4rem; }
}

.portfolio-card-date {
  color: var(--muted);
  font-size: 0.82rem;
}

.portfolio-card-cta {
  color: rgba(var(--primary-rgb), 0.7);
  font-size: 0.88rem;
  font-weight: 500;
  transition: color 0.18s;
}

.portfolio-card:hover .portfolio-card-cta {
  color: #6f86ff;
}

.tracker-empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.tracker-empty-state svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 14px;
}

.tracker-empty-state p {
  margin: 0;
  font-size: 0.95rem;
}

.tracker-dash-topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tracker-export-btns {
  display: flex;
  gap: 6px;
  margin-left: auto;
  align-items: center;
  /* Los botones internos llevan `min-width:max-content`, así que la fila se
     quedaba en su ancho intrínseco (406px) dentro de una pista de 308px: el
     borde derecho —y con él el degradado que indica que scrollea— caía fuera
     de la pantalla. max-width la ata a la pista; el scroll interno se conserva. */
  min-width: 0;
  max-width: 100%;
}

/* ── Acciones de la lista de portafolios (importar / nuevo) ── */
.tracker-list-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; max-width: 100%; }

/* ── Controles de rebalanceo ── */
.rebal-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}
.rebal-cash-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.rebal-cash-label input {
  width: 120px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--input-bg, rgba(255,255,255,0.04));
  color: inherit;
}
.rebal-weight-sum { margin-left: auto; font-size: 0.85rem; font-weight: 600; }
.rebal-opt-mode {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--input-bg, rgba(255,255,255,0.04));
  color: inherit;
  font-size: 0.85rem;
}
#rebalOptimizeBtn { display: inline-flex; align-items: center; gap: 6px; }
.mkw-spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: currentColor;
  border-radius: 50%; animation: mkwspin 0.7s linear infinite; vertical-align: -1px;
}
@keyframes mkwspin { to { transform: rotate(360deg); } }
.rebal-opt-summary {
  margin: 4px 0 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--input-bg, rgba(255,255,255,0.04));
}
.rebal-opt-summary.rebal-opt-warn {
  border-color: var(--danger, #ff6b81);
  background: rgba(255,107,129,0.08);
}
.rebal-opt-msg { font-size: 0.88rem; color: var(--muted); }
.rebal-opt-summary-title { font-size: 0.82rem; color: var(--muted); margin-bottom: 10px; }
.rebal-opt-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.rebal-opt-table th, .rebal-opt-table td { text-align: right; padding: 6px 10px; }
.rebal-opt-table th:first-child, .rebal-opt-table td:first-child { text-align: left; color: var(--muted); }
.rebal-opt-table thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.rebal-opt-table td:last-child { font-weight: 700; color: var(--success, #32d6a2); }
.rebal-ai-panel {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(111,134,255,0.3);
  background: rgba(111,134,255,0.07);
}
.rebal-ai-head { font-size: 0.82rem; font-weight: 700; color: #8ea0ff; margin-bottom: 8px; }
.rebal-ai-body { font-size: 0.9rem; line-height: 1.6; }
.rebal-ai-body .ai-h { font-weight: 700; margin: 8px 0 4px; }
.rebal-ai-locked { font-size: 0.88rem; color: var(--muted); margin: 0; }
.rebal-ai-disclaimer {
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--muted);
  border-left: 3px solid var(--border, rgba(255,255,255,0.18));
  padding: 8px 0 8px 12px;
  margin: 0 0 4px;
}
.rebal-target-input {
  width: 84px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--input-bg, rgba(255,255,255,0.04));
  color: inherit;
  text-align: right;
}

.tracker-export-btn {
  font-size: 11px !important;
  padding: 6px 11px !important;
  display: flex;
  align-items: center;
  gap: 5px;
  height: auto !important;
  line-height: 1 !important;
  border-radius: 10px !important;
}

.tracker-back-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: var(--muted);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  flex-shrink: 0;
}

.tracker-back-btn:hover {
  color: var(--text);
  border-color: rgba(var(--primary-rgb), 0.24);
  background: rgba(var(--primary-rgb), 0.07);
}

.tracker-price-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 4px;
}

.tracker-price-status-msg {
  font-size: 0.78rem;
  color: var(--muted);
}

.tracker-price-status-msg.loading { color: var(--muted); }
.tracker-price-status-msg.ok      { color: #32d6a2; }
.tracker-price-status-msg.warn    { color: #f5b84c; }
.tracker-price-status-msg.error   { color: #ff6b81; }

/* Los hex de arriba están calibrados para fondo oscuro: sobre blanco el verde
   daba 1.8:1. En claro se usan los tokens ya oscurecidos (ver --gain/--loss). */
/* --gain (#16a34a) da 3.1:1 y esto es texto de 12px, no una cifra grande */
body.light-mode .tracker-price-status-msg.ok    { color: #15803d; }
body.light-mode .tracker-price-status-msg.warn  { color: #a16207; }
body.light-mode .tracker-price-status-msg.error { color: var(--loss); }

.tracker-refresh-btn {
  font-size: 0.8rem;
  padding: 6px 14px;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tracker-refresh-btn svg { flex-shrink: 0; }

/* Botones con icono de la cabecera de lista (Importar CSV / Nuevo portafolio) */
.tracker-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.tracker-icon-btn svg { flex-shrink: 0; }

/* ── Menú desplegable de exportación (agrupación #3) ───────────────────────── */
.tracker-export-menu {
  position: relative;
  display: inline-flex;
}

.export-menu-chevron {
  margin-left: 2px;
  transition: transform 0.18s ease;
  opacity: 0.75;
}

#exportMenuTrigger[aria-expanded="true"] .export-menu-chevron {
  transform: rotate(180deg);
}

.tracker-export-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 248px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(18, 21, 32, 0.98);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: exportMenuIn 0.14s ease-out;
}

@keyframes exportMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.tracker-export-dropdown[hidden] { display: none; }

.tracker-export-dropdown button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: Inter, sans-serif;
  transition: background 0.13s ease;
}

.tracker-export-dropdown button:hover {
  background: rgba(var(--primary-rgb), 0.14);
}

.tracker-export-dropdown button svg {
  flex-shrink: 0;
  color: #8ea0ff;
}

.tracker-export-dropdown button span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tracker-export-dropdown button strong {
  font-size: 0.83rem;
  font-weight: 650;
}

.tracker-export-dropdown button small {
  font-size: 0.7rem;
  color: var(--muted);
}

body.light-mode .tracker-export-dropdown {
  background: rgba(255, 255, 255, 0.99);
  border-color: rgba(0, 0, 0, 0.1);
}

/* ── KPIs terciarios colapsables (Comisiones/IVA/Referencia) #2 ────────────── */
.kpi-details {
  grid-column: 1 / -1;
  margin-top: 2px;
}

.kpi-details-summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.13s ease, color 0.13s ease;
}

.kpi-details-summary::-webkit-details-marker { display: none; }

.kpi-details-summary:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.kpi-details-chevron {
  transition: transform 0.18s ease;
  opacity: 0.8;
}

.kpi-details[open] .kpi-details-chevron {
  transform: rotate(180deg);
}

.kpi-details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

body.light-mode .kpi-details-summary {
  background: rgba(0, 0, 0, 0.03);
}

/* ── Tabla de posiciones: columna vs benchmark (#8) ────────────────────────── */
.th-vs-bench, .td-vs-bench {
  white-space: nowrap;
  text-align: right;
}

.td-vs-bench span { font-weight: 600; font-size: 0.82rem; }

/* ── Tabla de posiciones: ticker fijo al hacer scroll horizontal (visual #4) ─ */
.tracker-table--positions .th-ticker-sticky,
.tracker-table--positions td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card, #12151f);
}

.tracker-table--positions thead .th-ticker-sticky {
  z-index: 3;
}

/* ── Tabla de posiciones: acciones fijas a la derecha (bug #6) ─────────────
   La tabla desborda incluso en desktop y el menú "⋯" quedaba tras un scroll
   horizontal poco visible; se fija a la derecha igual que el ticker a la
   izquierda, así siempre queda alcanzable sin desplazar. */
.tracker-table--positions th:last-child,
.tracker-table--positions td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--card, #12151f);
  box-shadow: -6px 0 10px -6px rgba(0, 0, 0, 0.4);
}

.tracker-table--positions thead th:last-child {
  z-index: 3;
}

body.light-mode .tracker-table--positions th:last-child,
body.light-mode .tracker-table--positions td:last-child {
  background: var(--card, #fff);
}

/* Solo se muestra el chevron cuando hay lotes que expandir; en móvil siempre
   se muestra (ver bloque responsive) para revelar los campos secundarios. */
@media (min-width: 721px) {
  .pos-expand-btn[data-has-lots="0"] {
    display: none;
  }
}

/* Indicio de scroll horizontal cuando la tabla realmente desborda (bug #6):
   clase .has-h-scroll agregada por JS tras medir scrollWidth/clientWidth. */
.tracker-table-shell.has-h-scroll {
  box-shadow: inset -22px 0 14px -14px rgba(0, 0, 0, 0.35);
}
body.light-mode .tracker-table-shell.has-h-scroll {
  box-shadow: inset -22px 0 14px -14px rgba(0, 0, 0, 0.12);
}

/* ── Transacciones: encabezado de mes + paginación (P0) ────────────────────── */
.tx-month-header td {
  padding: 8px 16px !important;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
body.light-mode .tx-month-header td {
  background: rgba(0, 0, 0, 0.03);
}

.tx-load-more-row td {
  padding: 14px 16px !important;
  text-align: center;
}
.tx-load-more-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tx-load-more-btn:hover {
  background: rgba(var(--primary-rgb), 0.14);
  border-color: rgba(var(--primary-rgb), 0.3);
}
body.light-mode .tx-load-more-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.14);
}

/* ── Toggle de densidad de la tabla (visual #4) ────────────────────────────── */
.positions-density-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.13s ease, color 0.13s ease, border-color 0.13s ease;
}

.positions-density-btn:hover,
.positions-density-btn.is-active {
  background: rgba(var(--primary-rgb), 0.14);
  color: #8ea0ff;
  border-color: rgba(var(--primary-rgb), 0.3);
}

.tracker-table-shell.is-compact .tracker-table--positions td,
.tracker-table-shell.is-compact .tracker-table--positions th {
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 0.8rem;
}

.tracker-table-shell.is-compact .pos-sparkline { height: 20px; }

body.light-mode .positions-density-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.12);
}

body.light-mode .tracker-table--positions .th-ticker-sticky,
body.light-mode .tracker-table--positions td:first-child {
  background: var(--card, #fff);
}

/* ── Overlay drag & drop de CSV (#12) ──────────────────────────────────────── */
#trackerListView { position: relative; }

/* Dígitos de ancho fijo en todo el tracker (rediseño visual #3): sin esto,
   los números "bailaban" al actualizar precios y las columnas de las tablas
   no alineaban dígitos entre filas. font-variant-numeric hereda a todo el
   contenido de texto de estas vistas. */
#trackerListView,
#trackerDashView {
  font-variant-numeric: tabular-nums;
}

.csv-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  border: 2px dashed rgba(var(--primary-rgb), 0.55);
  background: rgba(10, 12, 20, 0.86);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

#trackerListView.is-dragging-csv .csv-drop-overlay { display: flex; }

.csv-drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #cdd6ff;
  text-align: center;
  padding: 20px;
}

.csv-drop-inner svg { color: #8ea0ff; }
.csv-drop-inner strong { font-size: 1.05rem; }
.csv-drop-inner span { font-size: 0.8rem; color: var(--muted); }

body.light-mode .csv-drop-overlay {
  background: rgba(240, 243, 252, 0.92);
}
body.light-mode .csv-drop-inner { color: #1a2340; }

.tracker-dash-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  letter-spacing: -0.03em;
}

.tracker-dash-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.portfolio-rename-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.portfolio-rename-btn:hover {
  background: rgba(var(--primary-rgb), 0.12);
  color: #6f86ff;
  border-color: rgba(var(--primary-rgb), 0.28);
}

.portfolio-rename-input {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(var(--primary-rgb), 0.4);
  border-radius: 10px;
  color: var(--text);
  padding: 2px 10px;
  outline: none;
  min-width: 0;
  width: 280px;
  max-width: 100%;
}

.tracker-modal--sm {
  max-width: 420px;
}

.delete-confirm-msg {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.delete-confirm-msg strong {
  color: var(--text);
}

.delete-confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.button.danger {
  background: rgba(255, 107, 129, 0.15);
  border: 1px solid rgba(255, 107, 129, 0.35);
  color: #ff8ca4;
}

.button.danger:hover {
  background: rgba(255, 107, 129, 0.25);
  border-color: rgba(255, 107, 129, 0.55);
}

.tracker-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.tracker-kpi-hero {
  grid-column: span 2;
}

.tracker-kpi-hero strong {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
}

.tracker-kpi-hero em {
  display: block;
  font-style: normal;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 7px;
  opacity: 0.85;
}

.kpi-hero-label-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-right: 22px;
}

.kpi-alt-currency-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
  opacity: 0.85;
}

.kpi-alt-currency-select:hover,
.kpi-alt-currency-select:focus {
  opacity: 1;
}

.tracker-kpi-hero em.kpi-alt-value {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.6;
  margin-top: 4px;
}

.tracker-kpi-hero em.kpi-alt-value:empty {
  display: none;
}

.tracker-kpi-hero em.kpi-fx-rate {
  font-size: 0.74rem;
  opacity: 0.5;
  margin-top: 2px;
}

body.light-mode .kpi-alt-currency-select {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}

/* ── Strip compacto de KPIs secundarios (rediseño visual #1) ─────────────────
   Antes cada KPI secundario era una tarjeta igual a los heroes, diluyendo la
   jerarquía visual. Ahora es una sola franja "label: valor" separada por
   divisores, liberando ~150px verticales para los heroes y el primer gráfico. */
/* Conciliacion bajo el registro de KPIs (P1.9). */
.kpi-reconcile-note {
  margin: -12px 0 20px;
  padding: 0 4px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}
.kpi-reconcile-note:empty { display: none; }

.kpi-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  margin: 0 0 20px;
  padding: 2px 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
}

.summary-item.kpi-strip-item {
  background: none;
  border: none;
  border-radius: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  padding: 10px 16px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex: 0 0 auto;
}

.summary-item.kpi-strip-item:last-of-type {
  border-right: none;
}

/* ">" en vez de descendiente: .kpi-tooltip también es un <span> anidado
   dentro de .kpi-info-wrap y NO debe heredar este display (rompía el
   hover-to-show del tooltip, quedaba siempre visible). */
.summary-item.kpi-strip-item > span {
  display: inline;
  margin-bottom: 0;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.summary-item.kpi-strip-item strong {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.summary-item.kpi-strip-item .kpi-info-wrap {
  top: 4px;
  right: 2px;
}

.summary-item.kpi-strip-item .kpi-hero-label-row {
  padding-right: 0;
  gap: 6px;
}

.kpi-strip .kpi-details {
  flex: 1 1 100%;
  order: 99;
}

body.light-mode .kpi-strip {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.07);
}
body.light-mode .summary-item.kpi-strip-item {
  border-right-color: rgba(0, 0, 0, 0.08);
}

@media (max-width: 720px) {
  .kpi-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    padding: 4px 10px;
  }
  .summary-item.kpi-strip-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 6px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .summary-item.kpi-strip-item:nth-last-child(-n+2) {
    border-bottom: none;
  }
  .kpi-strip .kpi-details {
    grid-column: 1 / -1;
  }
  body.light-mode .summary-item.kpi-strip-item {
    border-bottom-color: rgba(0, 0, 0, 0.07);
  }
}

/* Flash animation on KPI value update */
@keyframes kpiFlashPos {
  0%   { background-color: transparent; }
  25%  { background-color: rgba(50, 214, 162, 0.14); }
  100% { background-color: transparent; }
}
@keyframes kpiFlashNeg {
  0%   { background-color: transparent; }
  25%  { background-color: rgba(255, 107, 129, 0.14); }
  100% { background-color: transparent; }
}
.kpi-flash-pos { animation: kpiFlashPos 0.75s ease-out; border-radius: 18px; }
.kpi-flash-neg { animation: kpiFlashNeg 0.75s ease-out; border-radius: 18px; }

/* Skeleton shimmer for price-loading cells */
@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.is-loading-prices .muted-val {
  display: inline-block;
  min-width: 56px;
  height: 13px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.05) 25%,
    rgba(255,255,255,0.13) 50%,
    rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s infinite;
  border-radius: 4px;
  color: transparent;
  vertical-align: middle;
}

/* Skeleton de tarjetas de portafolio mientras el bootstrap a Postgres resuelve,
   para no mostrar "Aún no tienes portafolios" de forma prematura (bug #5). */
.portfolio-card-skeleton {
  cursor: default;
  pointer-events: none;
}
.portfolio-card-skeleton:hover {
  transform: none;
  box-shadow: var(--shadow);
  border-color: rgba(255, 255, 255, 0.08);
}
.skel-line {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.13) 50%,
    rgba(255, 255, 255, 0.05) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s infinite;
}
.skel-line--title { width: 55%; height: 18px; }
.skel-line--value { width: 70%; height: 28px; }
.skel-line--stats { width: 85%; height: 14px; }
body.light-mode .skel-line {
  background: linear-gradient(90deg,
    rgba(0, 0, 0, 0.05) 25%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.05) 75%);
  background-size: 200% 100%;
}

/* Tab group separators and labels */
.tab-group-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 3px;
  align-self: center;
  flex-shrink: 0;
}
.tab-group-label {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  /* 0.22 era casi invisible (rediseño visual #5) */
  color: rgba(255, 255, 255, 0.5);
  padding: 0 3px;
  align-self: center;
  white-space: nowrap;
  flex-shrink: 0;
}

body.light-mode .tab-group-label {
  color: rgba(15, 23, 42, 0.62);
}

body.light-mode .tab-group-sep {
  background: rgba(0, 0, 0, 0.12);
}

.tracker-main-grid {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 20px;
  align-items: start;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.donut-legend {
  display: grid;
  gap: 9px;
  flex: 1;
  min-width: 0;
}

.donut-legend-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.donut-legend-item:hover,
.donut-legend-item:focus-visible,
.donut-legend-item.is-highlighted {
  border-color: rgba(var(--primary-rgb), 0.18);
  background: rgba(var(--primary-rgb), 0.075);
  outline: none;
  transform: translateX(2px);
}

.donut-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-ticker {
  font-size: 0.88rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-legend-weight {
  min-width: 40px;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.tracker-positions-section {
  margin-top: 0;
}

/* ── Sparklines ──────────────────────────────────────────────────────────── */
.td-sparkline {
  padding: 10px 12px !important;
  width: 96px;
  min-width: 96px;
}
.th-sparkline {
  width: 96px;
}
.pos-sparkline {
  display: block;
}

/* ── Position expand (lots drill-down) ───────────────────────────────────── */
.pos-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-right: 5px;
  vertical-align: middle;
  color: var(--muted);
  opacity: 0.45;
  transition: opacity 0.15s;
  line-height: 0;
}
.pos-expand-btn:hover { opacity: 1; }
.pos-expand-icon {
  transition: transform 0.2s ease;
  display: block;
}
.pos-expand-btn.is-expanded .pos-expand-icon {
  transform: rotate(90deg);
}

.pos-lots-row > td { padding: 0 !important; border-bottom: none; }
.pos-lots-cell { padding: 0 !important; }
.pos-lots-inner {
  padding: 0 0 0 40px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.pos-lots-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  background: rgba(255,255,255,0.015);
}
.pos-lots-table th,
.pos-lots-table td {
  padding: 9px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.82rem;
  color: var(--muted);
  text-align: left;
}
.pos-lots-table th { font-weight: 600; font-size: 0.75rem; }
.pos-lots-table tbody tr:last-child td { border-bottom: none; }

.lot-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.lot-type-compra   { background: rgba(74,222,128,0.1);  color: #4ade80; }
.lot-type-venta    { background: rgba(255,107,129,0.1); color: #ff6b81; }
.lot-type-dividendo{ background: rgba(111,134,255,0.1); color: #7c9aff; }

/* positions table needs wider min-width for the sparkline column */
.tracker-table--positions { min-width: 900px; }

.pos-ticker-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.pos-ticker-logo {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  background: #fff;
  overflow: hidden;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fff;
  text-transform: uppercase;
  user-select: none;
}
.pos-ticker-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pos-ticker-logo.pos-ticker-logo--fallback { background: var(--pos-logo-bg, #4ade80); padding: 0; }

.pos-delete-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  color: var(--muted);
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.pos-delete-btn:hover {
  background: rgba(255, 107, 129, 0.14);
  color: #ff8ca4;
  border-color: rgba(255, 107, 129, 0.3);
}

.pos-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pos-withdraw-btn {
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: 9px;
  color: #4ade80;
  padding: 0 10px;
  height: 28px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s;
}

.pos-withdraw-btn:hover {
  background: rgba(74, 222, 128, 0.18);
  border-color: rgba(74, 222, 128, 0.45);
}

.withdraw-ticker-display {
  font-weight: 700;
  color: var(--text);
  padding: 6px 0;
  font-size: 0.95rem;
}

.withdraw-net-preview {
  background: rgba(74, 222, 128, 0.06);
  border: 1px solid rgba(74, 222, 128, 0.18);
  border-radius: 10px;
  padding: 10px 14px !important;
}

.withdraw-net-amount {
  font-weight: 700;
  font-size: 1.05rem;
  color: #4ade80;
}

.form-hint {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
  display: block;
}
/* `display:block` de arriba gana sobre la hoja del navegador, asi que sin esta
   regla el atributo `hidden` no oculta nada. */
.form-hint[hidden] { display: none; }
.form-hint--warn { color: var(--warning); }

.pos-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.95rem;
}

.pos-checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── Tracker Modals ───────────────────────────────────────────────────────── */

.tracker-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.tracker-modal {
  background: linear-gradient(180deg, rgba(14, 14, 18, 0.99), rgba(8, 8, 12, 0.99));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  padding: 28px;
  width: min(480px, 100%);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(var(--primary-rgb), 0.07);
}

.tracker-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.tracker-modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.tracker-modal-close {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  color: var(--muted);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  transition: background 0.18s, color 0.18s;
  flex-shrink: 0;
}

.tracker-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* ── Custom Select Dropdowns ─────────────────────────────────────────────── */
.custom-select {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 14px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  font-family: Inter, sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.custom-select-trigger span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-trigger svg {
  flex-shrink: 0;
  color: rgba(143, 163, 255, 0.8);
  transition: transform 0.2s ease;
}

.custom-select-trigger:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(var(--primary-rgb), 0.25);
}

.custom-select.is-open .custom-select-trigger {
  border-color: rgba(var(--primary-rgb), 0.45);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px 14px 0 0;
}

.custom-select.is-open .custom-select-trigger svg {
  transform: rotate(180deg);
}

.custom-select-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(12, 12, 18, 0.98);
  border: 1px solid rgba(var(--primary-rgb), 0.3);
  border-top: none;
  border-radius: 0 0 14px 14px;
  list-style: none;
  margin: 0;
  padding: 4px 0 6px;
  max-height: 220px;
  overflow-y: auto;
  backdrop-filter: blur(24px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.custom-select.is-open .custom-select-list {
  display: block;
}

.custom-select-list li {
  padding: 10px 16px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.custom-select-list li:hover {
  background: rgba(var(--primary-rgb), 0.1);
  color: rgba(255, 255, 255, 0.9);
}

.custom-select-list li.is-active {
  color: #8fa3ff;
  background: rgba(var(--primary-rgb), 0.08);
}

.custom-select-list::-webkit-scrollbar { width: 4px; }
.custom-select-list::-webkit-scrollbar-track { background: transparent; }
.custom-select-list::-webkit-scrollbar-thumb { background: rgba(var(--primary-rgb), 0.3); border-radius: 2px; }

.return-pos { color: var(--gain, #32d6a2); font-weight: 600; }
.return-neg { color: var(--loss, #ff6b81); font-weight: 600; }
.return-pos small, .return-neg small { font-weight: 400; opacity: 0.8; }
.muted-val { color: var(--muted); font-size: 0.82rem; }
.fx-tag { font-size: 0.72rem; font-weight: 600; color: var(--accent); opacity: 0.75; margin-left: 4px; vertical-align: middle; }

/* Textarea dentro de .form-row (styles.css no la estiliza, solo input/select) */
.form-row textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm, 10px);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  outline: none;
  font-family: Inter, sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  transition: all 0.2s ease;
}
.form-row textarea:focus { border-color: var(--primary); }
body.light-mode .form-row textarea {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--text);
}

/* Indicador de nota/tesis por posición (P1.4) */
.pos-note-dot {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.72rem;
  color: var(--accent, #7892ff);
  opacity: 0.75;
  cursor: help;
  vertical-align: middle;
}

.portfolio-card-badges {
  display: flex;
  gap: 6px;
  margin: 4px 0 8px;
  flex-wrap: wrap;
}

.portfolio-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(var(--primary-rgb), 0.15);
  color: #8fa3ff;
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  letter-spacing: 0.03em;
}

.holdings-bar-wrap {
  margin-top: 16px;
  width: 100%;
  overflow: hidden;
}

.holdings-bar-wrap canvas {
  display: block;
}

/* ── Contribución al retorno (attribution) #1 ──────────────────────────────── */
.attribution-wrap {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.attrib-row {
  display: grid;
  grid-template-columns: 72px 1fr 82px;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
}
.attrib-ticker {
  font-weight: 600;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attrib-track {
  position: relative;
  height: 20px;
}
.attrib-track::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: rgba(140, 150, 190, 0.35);
}
.attrib-bar {
  position: absolute;
  top: 2px;
  height: 16px;
  border-radius: 3px;
  min-width: 2px;
  opacity: 0.9;
}
.attrib-bar.pos { left: 50%; background: #00a870; }
.attrib-bar.neg { right: 50%; background: #d94040; }
.attrib-val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: left;
}
.attrib-val.pos { color: #00a870; }
.attrib-val.neg { color: #d94040; }

/* ── Mapa de calor (treemap) #4 ────────────────────────────────────────────── */
.holdings-treemap {
  position: relative;
  width: 100%;
  height: 280px;
  margin-top: 16px;
  border-radius: 12px;
  overflow: hidden;
}
.treemap-tile {
  position: absolute;
  overflow: hidden;
  border-radius: 6px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  box-sizing: border-box;
  outline: 1.5px solid rgba(0, 0, 0, 0.18);
  outline-offset: -1.5px;
  transition: outline-color 0.12s ease;
  cursor: default;
}
.treemap-tile:hover {
  outline: 2px solid rgba(255, 255, 255, 0.75);
  z-index: 3;
}
.treemap-tile-ticker {
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.05;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
.treemap-tile-chg {
  font-size: 0.72rem;
  opacity: 0.96;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  font-variant-numeric: tabular-nums;
}
.treemap-tile.is-small { padding: 4px 5px; }
.treemap-tile.is-small .treemap-tile-chg { display: none; }
.treemap-tile.is-tiny .treemap-tile-ticker { font-size: 0.68rem; }

/* ── Contribución al riesgo #7 ─────────────────────────────────────────────── */
.risk-contrib-wrap {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rc-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.rc-kpi {
  background: rgba(var(--primary-rgb), 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rc-kpi-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.rc-kpi strong {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rc-kpi-sub { font-size: 0.7rem; color: var(--muted); }
.rc-kpi-good strong { color: var(--up); }
.rc-list { display: flex; flex-direction: column; }
.rc-row {
  display: grid;
  grid-template-columns: 108px 1fr 128px;
  gap: 14px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 10px;
  transition: background 0.12s ease;
}
.rc-row:hover { background: rgba(var(--primary-rgb), 0.06); }
.rc-id { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.rc-ticker-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rc-ticker {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rc-sigma {
  font-size: 0.66rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rc-badge {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--warning);
  background: rgba(255, 181, 71, 0.13);
  border: 1px solid rgba(255, 181, 71, 0.3);
  border-radius: 6px;
  padding: 1px 5px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.rc-track {
  position: relative;
  height: 8px;
  background: rgba(140, 150, 190, 0.13);
  border-radius: 5px;
}
.rc-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 5px;
  min-width: 2px;
  background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.55), var(--primary));
}
.rc-fill.hedge { background: linear-gradient(90deg, rgba(var(--up-rgb), 0.5), var(--up)); }
.rc-alert .rc-fill { background: linear-gradient(90deg, rgba(255, 181, 71, 0.5), var(--warning)); }
.rc-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 1px;
  background: var(--text);
  opacity: 0.55;
  transform: translateX(-1px);
}
.rc-nums {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rc-nums strong { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.rc-nums span { font-size: 0.7rem; color: var(--muted); }
.rc-warn {
  font-size: 0.74rem;
  color: var(--warning);
  background: rgba(255, 181, 71, 0.08);
  border: 1px solid rgba(255, 181, 71, 0.22);
  border-radius: 8px;
  padding: 7px 12px;
}
.rc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.72rem;
  color: var(--muted);
}
.rc-legend i {
  display: inline-block;
  margin-right: 5px;
  vertical-align: -1px;
  border-radius: 2px;
}
.rc-legend i.rc-i-fill { width: 13px; height: 8px; background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.55), var(--primary)); }
.rc-legend i.rc-i-warn { width: 13px; height: 8px; background: linear-gradient(90deg, rgba(255, 181, 71, 0.5), var(--warning)); }
.rc-legend i.rc-i-marker { width: 2px; height: 11px; background: var(--text); opacity: 0.55; vertical-align: -2px; }
.rc-note { font-size: 0.68rem; color: var(--muted); opacity: 0.85; }
@media (max-width: 640px) {
  .rc-row { grid-template-columns: 86px 1fr; gap: 10px; }
  .rc-nums { grid-column: 2; justify-content: flex-start; margin-top: -2px; }
}
body.light-mode .rc-kpi { border-color: rgba(0, 0, 0, 0.07); background: rgba(var(--primary-rgb), 0.06); }
body.light-mode .rc-track { background: rgba(20, 30, 60, 0.09); }
body.light-mode .rc-badge { color: #b07414; background: rgba(224, 160, 48, 0.12); border-color: rgba(224, 160, 48, 0.35); }
body.light-mode .rc-warn { color: #9a660f; background: rgba(224, 160, 48, 0.08); border-color: rgba(224, 160, 48, 0.28); }
body.light-mode .rc-kpi-good strong { color: #05a57d; }

/* ── Tracker responsive ───────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .tracker-kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .tracker-kpi-hero {
    grid-column: span 2;
  }

  .tracker-main-grid {
    grid-template-columns: 1fr;
  }

  .tracker-list-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .tracker-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tracker-kpi-hero {
    grid-column: span 2;
  }

  .portfolio-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* Theme Toggle Button */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.theme-icon {
  font-size: 1.2rem;
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s ease;
  transform-origin: center;
}

.theme-toggle:hover .theme-icon {
  animation: spin-icon 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes spin-icon {
  0% { transform: rotate(0deg) scale(1); opacity: 1; }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); opacity: 1; }
}

.theme-label {
  transition: color 0.3s ease;
}

.theme-toggle:hover {
  background: rgba(85, 110, 255, 0.15);
  border-color: rgba(var(--primary-rgb), 0.3);
}

/* Light Mode Theme */
body.light-mode {
  --bg: #f8f9fa;
  --bg-deep: #f0f2f5;
  --bg-soft: rgba(240, 242, 245, 0.95);
  --surface: rgba(245, 247, 251, 0.98);
  --surface-strong: rgba(235, 238, 245, 0.99);
  --border: rgba(0, 0, 0, 0.08);
  --text: #1a1a1e;
  --muted: #6b7280;
  /* Tokens de ganancia/pérdida oscurecidos para contraste sobre fondo claro
     (bug #8): los valores oscuros (--gain/--loss #32d6a2/#ff6b81) casi no se
     leían en blanco. Mismos hex que ya usan los badges de transacciones. */
  --gain: #16a34a;
  --gain-rgb: 22, 163, 74;
  --loss: #dc2626;
  --loss-rgb: 220, 38, 38;
  --success: #16a34a;
  --danger: #dc2626;
  --up: #16a34a;
  --up-rgb: 22, 163, 74;
  --down: #dc2626;
  --down-rgb: 220, 38, 38;
  background:
    radial-gradient(circle at top left, rgba(var(--primary-rgb), 0.04), transparent 26%),
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.03), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f9fafb 32%, #f5f7fb 100%);
  color: var(--text);
}

body.light-mode .theme-icon {
  opacity: 0;
  transform: rotate(-180deg) scale(0.8);
}

body.light-mode .theme-toggle .theme-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

body.light-mode .dashboard-sidebar-shell,
body.light-mode .dashboard-content-shell,
body.light-mode .dashboard-card,
body.light-mode .dashboard-hero-card {
  background: linear-gradient(180deg, rgba(245, 247, 251, 0.95), rgba(240, 242, 245, 0.98));
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.08);
}

body.light-mode .dashboard-nav-item {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.02);
  color: var(--muted);
}

body.light-mode .dashboard-nav-item:hover {
  color: var(--text);
  background: rgba(85, 110, 255, 0.07);
  border-color: rgba(85, 110, 255, 0.18);
  box-shadow: 0 4px 20px rgba(85, 110, 255, 0.07);
}

body.light-mode .dashboard-nav-item.active {
  background: linear-gradient(135deg, rgba(85, 110, 255, 0.12), rgba(var(--accent-rgb), 0.05));
  border-color: rgba(var(--primary-rgb), 0.2);
  color: var(--text);
}

body.light-mode .dashboard-user-card,
body.light-mode .mini-status-card,
body.light-mode .summary-item {
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .button.primary {
  background: linear-gradient(135deg, #556eff, #6f86ff);
}

body.light-mode .button.secondary {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--text);
}

body.light-mode .button.secondary:hover {
  background: rgba(0, 0, 0, 0.12);
}

body.light-mode .button.ghost {
  color: var(--muted);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .button.ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

body.light-mode input,
body.light-mode select {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text);
}

body.light-mode input::placeholder {
  color: var(--muted);
}

body.light-mode .eyebrow {
  color: var(--muted);
}

/* ── Light Mode: Markets section ──────────────────────────────────────────── */
body.light-mode .market-toolbar {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

body.light-mode .market-input-pill {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .market-input-action,
body.light-mode .market-circle-button {
  color: #1a1d2e;
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .market-input-action:hover,
body.light-mode .market-circle-button:hover,
body.light-mode .market-menu-button:hover {
  border-color: rgba(var(--primary-rgb), 0.35);
  background: rgba(var(--primary-rgb), 0.08);
}

body.light-mode .market-divider {
  background: rgba(0, 0, 0, 0.1);
}

body.light-mode .market-menu-button {
  color: #1a1d2e;
}

body.light-mode .market-info-button {
  color: #556eff;
  border-color: rgba(var(--primary-rgb), 0.3);
  background: rgba(var(--primary-rgb), 0.07);
}

body.light-mode .market-info-button:hover {
  color: #3d54e8;
  background: rgba(var(--primary-rgb), 0.14);
}

/* Dropdowns */
body.light-mode .market-menu {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
}

body.light-mode .market-menu-item,
body.light-mode .market-menu-check {
  background: rgba(0, 0, 0, 0.02);
  color: #444;
}

body.light-mode .market-menu-item:hover,
body.light-mode .market-menu-check:hover {
  background: rgba(var(--primary-rgb), 0.07);
  color: #1a1d2e;
  border-color: rgba(var(--primary-rgb), 0.2);
}

body.light-mode .market-menu-item.active-range {
  background: rgba(var(--primary-rgb), 0.1);
  color: #556eff;
}

/* Ticker suggestions */
body.light-mode .ticker-suggestions {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
}

body.light-mode .ticker-suggestion-item {
  background: rgba(0, 0, 0, 0.02);
}

body.light-mode .ticker-suggestion-item:hover {
  background: rgba(var(--primary-rgb), 0.06);
  border-color: rgba(var(--primary-rgb), 0.2);
}

/* Chart shell */
body.light-mode .market-chart-shell {
  background: #f0f3fa;
  border-color: #d0d4e0;
}

body.light-mode .market-chart-header {
  background: #e8ecf5;
  border-bottom-color: #d0d4e0;
}

body.light-mode .market-chart-header strong {
  color: #1a1d2e;
}

body.light-mode .market-chart-header span,
body.light-mode .market-chart-status {
  color: #666;
}

body.light-mode .market-chart-status {
  background: #e8ecf5;
  border-bottom-color: #d0d4e0;
}

body.light-mode .market-chart {
  background: #f0f3fa;
}

body.light-mode .chart-price-label {
  color: #1a1d2e;
}

/* Indicator panel dropdown */
body.light-mode .indicator-panel {
  background: rgba(255, 255, 255, 0.99);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.14);
}

body.light-mode .indicator-panel-head {
  background: rgba(0, 0, 0, 0.02);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .indicator-panel-title {
  color: rgba(30, 30, 50, 0.5);
}

body.light-mode .indicator-section + .indicator-section {
  border-top-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .indicator-section-label {
  color: rgba(0, 0, 0, 0.35);
}

body.light-mode .indicator-row:hover {
  background: rgba(0, 0, 0, 0.04);
}

body.light-mode .indicator-row.active {
  background: linear-gradient(135deg, rgba(85, 110, 255, 0.09), rgba(var(--accent-rgb), 0.03));
  border-color: rgba(var(--primary-rgb), 0.2);
}

body.light-mode .ind-info .ind-name {
  color: #1a1d2e;
}

body.light-mode .ind-info .ind-desc {
  color: #777;
}

body.light-mode .ind-badge {
  color: rgba(0, 0, 0, 0.2);
}

body.light-mode .indicator-row.active .ind-badge {
  color: #6f86ff;
}

/* Drawing toolbar — keep dark so icons stay readable over the dark chart */
body.light-mode .chart-drawing-toolbar {
  background: rgba(22, 22, 32, 0.92);
  border-right-color: rgba(255, 255, 255, 0.12);
}

body.light-mode .cdt-btn {
  color: rgba(255, 255, 255, 0.45);
}

body.light-mode .cdt-btn:hover {
  background: rgba(var(--primary-rgb), 0.18);
  color: rgba(255, 255, 255, 0.9);
}

body.light-mode .cdt-btn.cdt-active {
  background: rgba(var(--primary-rgb), 0.28);
  color: #a0b0ff;
}

body.light-mode .cdt-btn::after {
  background: rgba(20, 20, 30, 0.97);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.88);
}

/* Indicator legend */
body.light-mode .ind-leg-item {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.1);
  color: #1a1d2e;
}

body.light-mode .ind-leg-name {
  color: #555;
}

body.light-mode .ind-leg-val {
  color: #1a1d2e;
}

body.light-mode .ind-leg-settings {
  color: rgba(0, 0, 0, 0.3);
}

body.light-mode .ind-leg-settings:hover {
  color: #556eff;
}

body.light-mode .ind-leg-remove:hover {
  color: #e03050;
}

/* Indicator settings panel */
body.light-mode .ind-settings-panel {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
}

body.light-mode .ind-settings-head {
  color: #1a1d2e;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .ind-settings-close-btn {
  color: rgba(0, 0, 0, 0.35);
}

body.light-mode .ind-settings-close-btn:hover {
  color: #e03050;
}

body.light-mode .ind-sf-label {
  color: #555;
}

body.light-mode .ind-sf-num {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1a1d2e;
}

body.light-mode .ind-sf-num:focus {
  border-color: rgba(var(--primary-rgb), 0.5);
}

body.light-mode .ind-sf-color {
  border-color: rgba(0, 0, 0, 0.12);
}

body.light-mode .ind-settings-footer {
  border-top-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .ind-settings-reset-btn {
  background: rgba(0, 0, 0, 0.06);
  color: #555;
}

body.light-mode .ind-settings-reset-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Market Chart Loader Animation */
.market-chart-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(4, 4, 5, 0.95), rgba(4, 4, 5, 0.98));
  z-index: 10;
  border-radius: 16px;
}

.market-chart-loader.hidden {
  display: none;
}

/* ── Chart Drawing Toolbar ─────────────────────────────────────────────────── */
.drawing-canvas {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: 18px;
  touch-action: none;
}

.chart-drawing-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 44px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 10px 4px;
  background: rgba(6, 6, 10, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px 0 0 18px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  box-sizing: border-box;
}

.chart-drawing-toolbar::-webkit-scrollbar {
  display: none;
}

.cdt-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
}

.cdt-sep {
  width: 28px;
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 4px 0;
  flex-shrink: 0;
}

.cdt-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.38);
  cursor: pointer;
  padding: 0;
  transition: background 0.13s, color 0.13s;
  flex-shrink: 0;
  position: relative;
}

.cdt-btn svg {
  width: 17px;
  height: 17px;
  pointer-events: none;
  flex-shrink: 0;
}

.cdt-btn:hover {
  background: rgba(var(--primary-rgb), 0.13);
  color: rgba(255, 255, 255, 0.82);
}

.cdt-btn.cdt-active {
  background: rgba(var(--primary-rgb), 0.2);
  color: #6f86ff;
}

.cdt-btn.cdt-long { color: rgba(0, 200, 148, 0.55); }
.cdt-btn.cdt-long:hover,
.cdt-btn.cdt-long.cdt-active {
  color: #00c894;
  background: rgba(0, 200, 148, 0.14);
}

.cdt-btn.cdt-short { color: rgba(255, 77, 106, 0.55); }
.cdt-btn.cdt-short:hover,
.cdt-btn.cdt-short.cdt-active {
  color: #ff4d6a;
  background: rgba(255, 77, 106, 0.14);
}

.cdt-btn.cdt-danger { color: rgba(255, 90, 90, 0.45); }
.cdt-btn.cdt-danger:hover {
  color: #ff6060;
  background: rgba(255, 90, 90, 0.12);
}

.cdt-btn::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(10, 10, 16, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
  font-family: system-ui, sans-serif;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 200;
}

.cdt-btn:hover::after {
  opacity: 1;
}

#marketChartLoaderCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* ── Indicator Legend (TradingView-style) ───────────────────────────────────── */
.indicator-legend {
  position: absolute;
  top: 8px;
  left: 54px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}

.ind-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(6, 6, 10, 0.78);
  backdrop-filter: blur(6px);
  border: 1px solid var(--chip-accent, rgba(255, 255, 255, 0.07));
  border-radius: 999px;
  padding: 3px 8px 3px 6px;
  pointer-events: auto;
  font-size: 11.5px;
  font-family: system-ui, sans-serif;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.ind-leg-item:hover {
  background: rgba(20, 20, 28, 0.9);
}

.ind-leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ind-leg-name {
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
}

.ind-leg-val {
  color: rgba(220, 229, 255, 0.9);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.ind-leg-settings,
.ind-leg-remove {
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.3);
  transition: color 0.12s;
  border-radius: 3px;
  line-height: 1;
}

.ind-leg-settings { margin-left: 2px; }
.ind-leg-settings svg { width: 12px; height: 12px; }

.ind-leg-settings:hover { color: #6f86ff; }
.ind-leg-remove { font-size: 14px; }
.ind-leg-remove:hover { color: #ff4d6a; }

/* ── Indicator Settings Panel ────────────────────────────────────────────────── */
.ind-settings-panel {
  position: fixed;
  z-index: 9000;
  min-width: 240px;
  max-width: 300px;
  background: rgba(10, 10, 16, 0.97);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  font-family: system-ui, sans-serif;
  backdrop-filter: blur(14px);
}

.ind-settings-panel.hidden { display: none; }

.ind-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 13px;
  font-weight: 600;
  color: #dce5ff;
}

.ind-settings-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.12s;
}
.ind-settings-close-btn:hover { color: #ff4d6a; }

.ind-settings-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.ind-sf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ind-sf-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  flex: 1;
}

.ind-sf-num {
  width: 72px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #dce5ff;
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  text-align: right;
}
.ind-sf-num:focus { border-color: rgba(var(--primary-rgb), 0.5); }

.ind-sf-color {
  width: 36px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  padding: 1px;
}

.ind-settings-footer {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  justify-content: flex-end;
}

.ind-settings-apply-btn,
.ind-settings-reset-btn {
  border: none;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.13s;
}

.ind-settings-apply-btn {
  background: #6f86ff;
  color: #fff;
}
.ind-settings-apply-btn:hover { background: #556eff; }

.ind-settings-reset-btn {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.6);
}
.ind-settings-reset-btn:hover { background: rgba(255, 255, 255, 0.12); }


/* ── Ticker News Section ─────────────────────────────────────────────── */
.ticker-news-section {
  padding: 0 0 32px;
}

.ticker-news-title {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin: 0 0 14px;
  padding: 0 4px;
}

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

.news-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
  transition: background .18s, border-color .18s;
}

.news-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.13);
}

.news-thumb {
  width: 80px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.news-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.news-source {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent, #6c8fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-headline {
  font-size: .88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.88);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-time {
  font-size: .72rem;
  color: rgba(255,255,255,0.35);
}

body.light-mode .ticker-news-title { color: rgba(0,0,0,0.4); }
body.light-mode .news-card { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.07); }
body.light-mode .news-card:hover { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.12); }
body.light-mode .news-headline { color: rgba(0,0,0,0.85); }
body.light-mode .news-time { color: rgba(0,0,0,0.35); }

/* ── Dividends Tab ───────────────────────────────────────────────────── */
.div-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 0 14px;
}

.div-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 12px 18px;
  min-width: 130px;
  flex: 1;
}

.div-kpi-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,0.4);
}

.div-kpi-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
}

body.light-mode .div-kpi { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.07); }
body.light-mode .div-kpi-label { color: rgba(0,0,0,0.4); }
body.light-mode .div-kpi-value { color: rgba(0,0,0,0.85); }

/* ── Transacciones tab ─────────────────────────────────────────────────── */
.tx-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 4px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.07);
}
.tx-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tx-filter-group label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}
.tx-filter-group input,
.tx-filter-group select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.tx-filter-group input { min-width: 130px; }
.tx-filter-group select { min-width: 130px; cursor: pointer; }
.tx-filter-group input:focus,
.tx-filter-group select:focus { border-color: var(--primary); }
.tx-filter-group input[type="date"] { color-scheme: dark; }
.tx-filter-clear {
  align-self: flex-end;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  transition: border-color 0.15s, color 0.15s;
}
.tx-filter-clear:hover { border-color: var(--primary); color: var(--text); }
body.light-mode .tx-filters {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
}
body.light-mode .tx-filter-group input,
body.light-mode .tx-filter-group select {
  background: #fff;
  border-color: rgba(0,0,0,0.15);
  color: var(--text);
}
body.light-mode .tx-filter-group input[type="date"] { color-scheme: light; }
body.light-mode .tx-filter-clear { border-color: rgba(0,0,0,0.2); }

/* ── Botón "Filtros" colapsable (solo móvil, móvil/tablet #7) ──────────────── */
.tx-filters-toggle-btn {
  display: none;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tx-filters-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(var(--primary-rgb), 0.3);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}
body.light-mode .tx-filters-toggle-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.14);
}

@media (max-width: 720px) {
  .tx-filters-toggle-btn { display: inline-flex; }
  .tx-filters.is-collapsed { display: none; }
}

.tx-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.tx-buy  { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.tx-sell { background: rgba(248, 113, 113, 0.15); color: #f87171; }
.tx-dividend { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
body.light-mode .tx-buy  { background: rgba(22, 163, 74, 0.12); color: #16a34a; }
body.light-mode .tx-sell { background: rgba(220, 38, 38, 0.12); color: #dc2626; }
body.light-mode .tx-dividend { background: rgba(37, 99, 235, 0.12); color: #2563eb; }

.tx-actions-cell { white-space: nowrap; }
.tx-action-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 8px;
  font-size: .85rem;
  line-height: 1;
  transition: background .15s, color .15s, border-color .15s;
}
.tx-action-btn + .tx-action-btn { margin-left: 6px; }
.tx-action-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); border-color: rgba(255,255,255,0.24); }
.tx-action-del:hover { background: rgba(248, 113, 113, 0.15); color: #f87171; border-color: rgba(248, 113, 113, 0.4); }
body.light-mode .tx-action-btn { border-color: rgba(0,0,0,0.12); }
body.light-mode .tx-action-btn:hover { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.24); }

/* ── Hub: customizable home with spaces + free-drag widgets ─────────────── */
#section-home { padding: 0; }
.hub-shell {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 140px);
  min-height: 600px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(10, 12, 20, 0.55);
  overflow: hidden;
}
body.light-mode .hub-shell {
  background: rgba(248, 250, 252, 0.65);
  border-color: rgba(15, 23, 42, 0.08);
}
.hub-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.25);
  flex-shrink: 0;
}
body.light-mode .hub-toolbar {
  background: rgba(255,255,255,0.6);
  border-bottom-color: rgba(15,23,42,0.08);
}
.hub-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}
.hub-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.hub-tab:hover { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.85); }
.hub-tab.active {
  background: rgba(var(--primary-rgb), 0.12);
  color: #fff;
  border-color: rgba(var(--primary-rgb), 0.3);
}
body.light-mode .hub-tab { color: rgba(15,23,42,0.6); }
body.light-mode .hub-tab:hover { background: rgba(15,23,42,0.04); color: rgba(15,23,42,0.9); }
body.light-mode .hub-tab.active { background: rgba(var(--primary-rgb),0.12); color: #1e293b; }
.hub-tab-name {
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  outline: none;
  padding: 0;
  min-width: 50px;
  max-width: 140px;
}
.hub-tab-close {
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}
.hub-tab-close:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.hub-tab-add {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.hub-tab-add:hover { background: rgba(255,255,255,0.06); color: #fff; }
body.light-mode .hub-tab-add { color: rgba(15,23,42,0.6); border-color: rgba(15,23,42,0.1); }
.hub-toolbar-spacer { flex: 1; }
.hub-toolbar-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.hub-icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.hub-icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.hub-icon-btn.primary {
  background: linear-gradient(135deg, #6f86ff, #9f7aea);
  color: #fff;
  border-color: transparent;
}
body.light-mode .hub-icon-btn { color: rgba(15,23,42,0.7); border-color: rgba(15,23,42,0.1); background: rgba(15,23,42,0.03); }
body.light-mode .hub-icon-btn:hover { background: rgba(15,23,42,0.08); color: #1e293b; }

.hub-add-widget-wrap { position: relative; }
.hub-add-widget-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: rgba(20, 24, 38, 0.98);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hub-add-widget-menu.hidden { display: none; }
.hub-add-widget-menu button {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
}
.hub-add-widget-menu button:hover { background: rgba(var(--primary-rgb),0.15); }
.hub-menu-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; color: var(--accent); }
body.light-mode .hub-add-widget-menu { background: #fff; border-color: rgba(15,23,42,0.1); }
body.light-mode .hub-add-widget-menu button { color: #1e293b; }

.hub-canvas {
  position: relative;
  flex: 1;
  overflow: auto;
  background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 0;
}
body.light-mode .hub-canvas {
  background-image: radial-gradient(circle, rgba(15,23,42,0.06) 1px, transparent 1px);
}
.hub-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.55);
  gap: 6px;
  text-align: center;
  padding: 24px;
}
.hub-empty .hub-empty-icon {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 22px;
  margin-bottom: 10px;
  color: var(--accent);
  background: rgba(var(--primary-rgb), 0.08);
  border: 1px solid rgba(var(--primary-rgb), 0.18);
}
.hub-empty h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
}
.hub-empty p {
  margin: 0;
  font-size: 13px;
  max-width: 320px;
  line-height: 1.55;
  color: rgba(255,255,255,0.5);
}
.hub-empty-cta {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(var(--primary-rgb), 0.4);
  background: rgba(var(--primary-rgb), 0.14);
  color: #d8e0ff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.hub-empty-cta:hover {
  background: rgba(var(--primary-rgb), 0.24);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(var(--primary-rgb), 0.22);
}
.hub-empty.hidden { display: none; }
body.light-mode .hub-empty { color: rgba(15,23,42,0.5); }
body.light-mode .hub-empty h4 { color: #1e293b; }
body.light-mode .hub-empty p { color: rgba(15,23,42,0.55); }

/* ── Tooltips (replaces native title=) ──────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  color: #f5f7fb;
  background: rgba(18, 18, 24, 0.98);
  border: 1px solid rgba(var(--primary-rgb), 0.3);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
body.light-mode [data-tooltip]::after {
  color: #1e293b;
  background: #ffffff;
  border-color: rgba(15,23,42,0.12);
}

.hub-widget {
  position: absolute;
  background: rgba(15, 18, 30, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
  min-width: 220px;
  min-height: 140px;
  user-select: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.hub-widget:hover { border-color: rgba(var(--primary-rgb),0.3); }
.hub-widget.dragging { z-index: 100; box-shadow: 0 12px 36px rgba(0,0,0,0.55); cursor: grabbing; }
.hub-widget.resizing { z-index: 100; }
body.light-mode .hub-widget { background: #fff; border-color: rgba(15,23,42,0.1); box-shadow: 0 4px 18px rgba(15,23,42,0.08); }

.hub-widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.2);
  cursor: grab;
  flex-shrink: 0;
}
.hub-widget.dragging .hub-widget-header { cursor: grabbing; }
body.light-mode .hub-widget-header { background: rgba(15,23,42,0.03); border-bottom-color: rgba(15,23,42,0.06); }
.hub-widget-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  background: transparent;
  border: none;
  outline: none;
  padding: 2px 4px;
  border-radius: 4px;
  min-width: 0;
}
.hub-widget-title:focus { background: rgba(var(--primary-rgb),0.15); }
body.light-mode .hub-widget-title { color: #1e293b; }
.hub-widget-controls { display: flex; align-items: center; gap: 2px; }
.hub-widget-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hub-widget-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.hub-widget-btn.danger:hover { background: rgba(239,68,68,0.15); color: #f87171; }
body.light-mode .hub-widget-btn { color: rgba(15,23,42,0.5); }
body.light-mode .hub-widget-btn:hover { background: rgba(15,23,42,0.08); color: #1e293b; }

.hub-widget-body {
  flex: 1;
  overflow: auto;
  padding: 10px 12px;
  font-size: 12.5px;
  color: rgba(255,255,255,0.85);
  min-height: 0;
}
body.light-mode .hub-widget-body { color: #1e293b; }
.hub-widget-body.no-padding { padding: 0; }

.hub-resize-handle {
  position: absolute;
  bottom: 0; right: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(var(--primary-rgb),0.5) 50%);
  border-bottom-right-radius: 12px;
  z-index: 5;
}
.hub-widget:hover .hub-resize-handle { background: linear-gradient(135deg, transparent 50%, rgba(var(--primary-rgb),0.85) 50%); }

/* Widget content variants */
.hw-chart-canvas { width: 100%; height: 100%; min-height: 100px; }
.hw-chart-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 12px 0;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}
.hw-chart-price { font-size: 16px; font-weight: 700; color: #fff; }
.hw-chart-change.up { color: #00c894; }
.hw-chart-change.down { color: #ff4d6a; }
body.light-mode .hw-chart-meta { color: rgba(15,23,42,0.6); }
body.light-mode .hw-chart-price { color: #1e293b; }

/* ── Watchlist v2 ──────────────────────────────────────────────────── */
.hw-watchlist-toolbar {
  display: flex; gap: 6px; margin-bottom: 8px; position: relative; align-items: center;
}
.hw-wl-input-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}
.hw-watchlist-toolbar input {
  width: 100%; background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  padding: 6px 8px; color: #fff; font-size: 12px; outline: none;
  box-sizing: border-box;
}
.hw-watchlist-toolbar input:focus { border-color: rgba(var(--primary-rgb),0.5); }
body.light-mode .hw-watchlist-toolbar input { background: rgba(15,23,42,0.04); border-color: rgba(15,23,42,0.1); color: #1e293b; }
body.light-mode .hw-watchlist-toolbar input:focus { border-color: rgba(var(--primary-rgb),0.5); }
.hw-wl-add-btn {
  background: linear-gradient(135deg, #6f86ff, #9f7aea);
  color: #fff; border: none; border-radius: 6px;
  padding: 0 12px; cursor: pointer; font-size: 13px; font-weight: 700;
  height: 30px; flex-shrink: 0; transition: opacity 0.15s;
}
.hw-wl-add-btn:hover { opacity: 0.85; }
.hw-wl-cfg-btn {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.55); border-radius: 6px;
  padding: 0 8px; cursor: pointer; height: 30px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.hw-wl-cfg-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
body.light-mode .hw-wl-cfg-btn { background: rgba(15,23,42,0.04); border-color: rgba(15,23,42,0.1); color: rgba(15,23,42,0.5); }
body.light-mode .hw-wl-cfg-btn:hover { background: rgba(15,23,42,0.08); color: #1e293b; }

/* Config panel (inline expanded section) */
.hw-wl-cfg-section {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
.hw-wl-cfg-section.hidden { display: none; }
body.light-mode .hw-wl-cfg-section { background: rgba(15,23,42,0.03); border-color: rgba(15,23,42,0.08); }
.hw-wl-cfg-title {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: rgba(255,255,255,0.35); margin-bottom: 8px;
}
body.light-mode .hw-wl-cfg-title { color: rgba(15,23,42,0.4); }
.hw-wl-cfg-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; font-size: 12px;
  color: rgba(255,255,255,0.8);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer; user-select: none;
}
.hw-wl-cfg-row:last-child { border-bottom: none; padding-bottom: 0; }
body.light-mode .hw-wl-cfg-row { color: #1e293b; border-bottom-color: rgba(15,23,42,0.06); }
.hw-wl-cfg-disabled { cursor: default; opacity: 0.5; }
.hw-wl-cfg-lock {
  margin-left: auto; font-size: 9.5px; color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 4px;
}
body.light-mode .hw-wl-cfg-lock { color: rgba(15,23,42,0.4); background: rgba(15,23,42,0.06); }
.hw-wl-cfg-row input[type="checkbox"] { accent-color: #6f86ff; cursor: pointer; }

/* List */
.hw-watchlist { display: flex; flex-direction: column; gap: 3px; }
.hw-wl-empty { opacity: 0.5; font-size: 11px; padding: 12px 8px; text-align: center; }

.hw-watchlist-row {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 8px;
  background: rgba(255,255,255,0.025);
  border: 1px solid transparent;
  font-size: 12px; transition: background 0.15s, border-color 0.15s;
}
.hw-watchlist-row:hover { background: rgba(255,255,255,0.055); border-color: rgba(255,255,255,0.07); }
body.light-mode .hw-watchlist-row { background: rgba(15,23,42,0.025); }
body.light-mode .hw-watchlist-row:hover { background: rgba(15,23,42,0.055); border-color: rgba(15,23,42,0.09); }

/* Logo / ticker avatar */
.hw-wl-logo {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; letter-spacing: 0.04em;
  color: #fff; flex-shrink: 0; text-transform: uppercase; user-select: none;
}
.hw-wl-logo--img { background: #fff; padding: 2px; overflow: hidden; }
.hw-wl-logo--flag { background: transparent; padding: 0; overflow: hidden; }
.hw-wl-logo--img img, .hw-wl-logo--flag img { width: 100%; height: 100%; display: block; }
.hw-wl-logo--img img { object-fit: contain; border-radius: 4px; }
.hw-wl-logo--flag img { object-fit: cover; border-radius: 5px; }

/* Info block */
.hw-wl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hw-wl-sym { font-weight: 700; font-size: 12px; }
.hw-wl-name {
  font-size: 9.5px; color: rgba(255,255,255,0.38);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.light-mode .hw-wl-name { color: rgba(15,23,42,0.42); }

/* Optional columns */
.hw-wl-col { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex-shrink: 0; }
.hw-wl-col-label {
  font-size: 8.5px; color: rgba(255,255,255,0.3);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
body.light-mode .hw-wl-col-label { color: rgba(15,23,42,0.35); }
.hw-wl-price-val { font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }
.hw-wl-mktcap-val { font-weight: 600; font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* Badges (YTD, daily change) */
.hw-wl-badge {
  display: inline-flex; align-items: center;
  padding: 2px 6px; border-radius: 5px;
  font-size: 10.5px; font-weight: 600; border: 1px solid;
  white-space: nowrap; font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.hw-wl-badge.positive { background: rgba(0,200,148,0.12); color: #00c894; border-color: rgba(0,200,148,0.3); }
.hw-wl-badge.negative { background: rgba(248,113,113,0.1); color: #f87171; border-color: rgba(248,113,113,0.28); }
.hw-wl-badge.neutral { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.38); border-color: rgba(255,255,255,0.08); }
body.light-mode .hw-wl-badge.positive { background: #dcfce7; color: #16a34a; border-color: #bbf7d0; }
body.light-mode .hw-wl-badge.negative { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
body.light-mode .hw-wl-badge.neutral { background: rgba(15,23,42,0.05); color: rgba(15,23,42,0.42); border-color: rgba(15,23,42,0.1); }

.hw-wl-del {
  background: transparent; border: none; color: rgba(255,255,255,0.22);
  cursor: pointer; font-size: 14px; padding: 2px 5px; flex-shrink: 0;
  border-radius: 4px; transition: color 0.15s, background 0.15s;
}
.hw-wl-del:hover { color: #f87171; background: rgba(248,113,113,0.1); }
body.light-mode .hw-wl-del { color: rgba(15,23,42,0.22); }
body.light-mode .hw-wl-del:hover { color: #dc2626; background: rgba(220,38,38,0.08); }

.hw-calendar-list { display: flex; flex-direction: column; gap: 6px; }
.hw-calendar-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  font-size: 11.5px;
}
body.light-mode .hw-calendar-row { background: rgba(15,23,42,0.02); }
.hw-cal-date {
  font-weight: 600;
  text-align: center;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(var(--primary-rgb),0.15);
  color: #9fb0ff;
  font-size: 11px;
  line-height: 1.2;
}
.hw-cal-title { font-weight: 500; }
.hw-cal-cat { font-size: 10.5px; color: rgba(255,255,255,0.4); margin-top: 2px; }
body.light-mode .hw-cal-cat { color: rgba(15,23,42,0.5); }
.hw-cal-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
}
.hw-cal-badge.high { background: rgba(239,68,68,0.18); color: #f87171; }
.hw-cal-badge.medium { background: rgba(245,158,11,0.18); color: #fbbf24; }
.hw-cal-badge.low { background: rgba(34,197,94,0.18); color: #4ade80; }
.hw-cal-tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.hw-cal-tab {
  flex: 1;
  padding: 5px 8px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  cursor: pointer;
  font-weight: 500;
}
.hw-cal-tab.active { background: rgba(var(--primary-rgb),0.15); color: #fff; border-color: rgba(var(--primary-rgb),0.4); }
body.light-mode .hw-cal-tab { color: rgba(15,23,42,0.6); border-color: rgba(15,23,42,0.1); }

.hw-note-textarea {
  width: 100%; height: 100%;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  resize: none;
  outline: none;
  font-size: 13px;
  line-height: 1.5;
}

/* Additional hub insight widgets */
.hw-insight-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hw-insight-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}
.hw-insight-select {
  width: 100%;
  min-width: 0;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
}
.hw-insight-select:focus {
  border-color: rgba(var(--primary-rgb),0.45);
}
body.light-mode .hw-insight-select {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.1);
  color: #1e293b;
}
.hw-insight-empty {
  display: grid;
  place-items: center;
  min-height: 74px;
  color: rgba(255,255,255,0.42);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 10px;
  text-align: center;
  padding: 12px;
  line-height: 1.45;
}
body.light-mode .hw-insight-empty {
  color: rgba(15,23,42,0.46);
  border-color: rgba(15,23,42,0.12);
}
.hw-insight-note {
  margin: auto 0 0;
  color: rgba(255,255,255,0.38);
  font-size: 10.5px;
  line-height: 1.45;
}
body.light-mode .hw-insight-note { color: rgba(15,23,42,0.45); }

.hw-risk-score,
.hw-sentiment-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(var(--primary-rgb),0.16), rgba(57,208,255,0.06));
  border: 1px solid rgba(var(--primary-rgb),0.22);
}
.hw-risk-score span,
.hw-sentiment-head span,
.hw-dividend-hero span {
  display: block;
  color: rgba(255,255,255,0.46);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
body.light-mode .hw-risk-score span,
body.light-mode .hw-sentiment-head span,
body.light-mode .hw-dividend-hero span { color: rgba(15,23,42,0.5); }
.hw-risk-score strong,
.hw-sentiment-head strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  line-height: 1;
}
.hw-risk-score em,
.hw-sentiment-head em {
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.hw-risk-score em.ok,
.hw-sentiment-head em.ok { color: #32d6a2; background: rgba(50,214,162,0.12); }
.hw-risk-score em.warn { color: #fbbf24; background: rgba(251,191,36,0.12); }
.hw-risk-score em.bad,
.hw-sentiment-head em.bad { color: #ff6b81; background: rgba(255,107,129,0.12); }
.hw-risk-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 8px;
}
.hw-risk-grid div {
  min-width: 0;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.07);
}
body.light-mode .hw-risk-grid div { background: rgba(15,23,42,0.03); border-color: rgba(15,23,42,0.08); }
.hw-risk-grid span,
.hw-risk-grid small {
  display: block;
  color: rgba(255,255,255,0.42);
  font-size: 10px;
}
body.light-mode .hw-risk-grid span,
body.light-mode .hw-risk-grid small { color: rgba(15,23,42,0.45); }
.hw-risk-grid strong {
  display: block;
  margin: 4px 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hw-risk-bars {
  display: grid;
  gap: 7px;
}
.hw-risk-bar-row {
  display: grid;
  grid-template-columns: 58px 1fr 44px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}
.hw-risk-bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,0.62);
}
body.light-mode .hw-risk-bar-row span { color: rgba(15,23,42,0.62); }
.hw-risk-bar-row div {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.07);
}
body.light-mode .hw-risk-bar-row div { background: rgba(15,23,42,0.08); }
.hw-risk-bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.hw-risk-bar-row strong {
  text-align: right;
  font-size: 11px;
}

.hw-dividend-hero {
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(50,214,162,0.14), rgba(var(--primary-rgb),0.06));
  border: 1px solid rgba(50,214,162,0.18);
}
.hw-dividend-hero strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  line-height: 1;
}
.hw-dividend-hero small {
  display: block;
  margin-top: 6px;
  color: #32d6a2;
  font-weight: 700;
}
.hw-dividend-list,
.hw-sentiment-list {
  display: grid;
  gap: 7px;
}
.hw-dividend-row,
.hw-sentiment-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.hw-sentiment-row { grid-template-columns: minmax(0,1fr) auto; }
body.light-mode .hw-dividend-row,
body.light-mode .hw-sentiment-row { background: rgba(15,23,42,0.025); border-color: rgba(15,23,42,0.07); }
.hw-dividend-row strong,
.hw-sentiment-row strong {
  display: block;
  font-size: 12px;
}
.hw-dividend-row span,
.hw-sentiment-row span {
  display: block;
  margin-top: 2px;
  color: rgba(255,255,255,0.42);
  font-size: 10.5px;
}
body.light-mode .hw-dividend-row span,
body.light-mode .hw-sentiment-row span { color: rgba(15,23,42,0.48); }
.hw-dividend-row em,
.hw-sentiment-row em {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}
.hw-dividend-row b {
  color: #32d6a2;
  font-size: 11.5px;
}
.hw-sentiment-row em.positive { color: #32d6a2; }
.hw-sentiment-row em.negative { color: #ff6b81; }

.hw-macro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 9px;
}
.hw-macro-card {
  min-width: 0;
  padding: 11px;
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.07);
}
body.light-mode .hw-macro-card { background: rgba(15,23,42,0.03); border-color: rgba(15,23,42,0.08); }
.hw-macro-card span,
.hw-macro-card small,
.hw-macro-card em {
  display: block;
}
.hw-macro-card span {
  color: rgba(255,255,255,0.5);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.hw-macro-card strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}
.hw-macro-card small {
  color: rgba(255,255,255,0.38);
  font-size: 10px;
}
body.light-mode .hw-macro-card span,
body.light-mode .hw-macro-card small { color: rgba(15,23,42,0.45); }
.hw-macro-card em {
  margin-top: 8px;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 800;
}
.hw-macro-card em.positive { color: #32d6a2; }
.hw-macro-card em.negative { color: #ff6b81; }
.hw-macro-card em.neutral { color: #9fb0ff; }

.hub-suggest-popup {
  position: absolute;
  top: 100%;
  left: 0;
  right: 40px;
  background: rgba(20,24,38,0.98);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  z-index: 20;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
}
.hub-suggest-popup div {
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
}
.hub-suggest-popup div:hover { background: rgba(var(--primary-rgb),0.15); }
body.light-mode .hub-suggest-popup { background: #fff; border-color: rgba(15,23,42,0.1); }

/* ══════════════════════════════════════════════════════════════════
   MARKOWITZ — Creación de portafolio
   ══════════════════════════════════════════════════════════════════ */

/* Layout ─────────────────────────────────────────────────────────── */
.mkw-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1000px) {
  .mkw-layout { grid-template-columns: 1fr; }
}

.mkw-left-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 24px;
}

.mkw-right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Config card ────────────────────────────────────────────────────── */
.mkw-config-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mkw-asset-count {
  font-size: 12px;
  color: rgba(255,255,255,0.38);
  font-variant-numeric: tabular-nums;
}

/* Preset buttons ─────────────────────────────────────────────────── */
.mkw-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.mkw-presets-label {
  font-size: 11px;
  color: rgba(255,255,255,0.38);
  white-space: nowrap;
}
.mkw-preset-btn {
  background: rgba(var(--primary-rgb),0.1);
  border: 1px solid rgba(var(--primary-rgb),0.22);
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.mkw-preset-btn:hover {
  background: rgba(var(--primary-rgb),0.22);
  border-color: rgba(var(--primary-rgb),0.5);
  color: #fff;
}

/* Step badge (wizard) ─────────────────────────────────────────────── */
.mkw-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(var(--primary-rgb),0.16);
  border: 1px solid rgba(var(--primary-rgb),0.4);
  color: #aeb9ff;
  font-size: 11px;
  font-weight: 700;
  margin-right: 9px;
  flex-shrink: 0;
}
.mkw-config-card h3, .mkw-strategy-card h3, .mkw-params-card h3 {
  display: flex;
  align-items: center;
}
.mkw-step-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.42);
  margin: 0 0 12px;
  line-height: 1.4;
}

/* Preset cards (rich) ─────────────────────────────────────────────── */
.mkw-preset-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.mkw-preset-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  background: rgba(var(--primary-rgb),0.07);
  border: 1px solid rgba(var(--primary-rgb),0.2);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.mkw-preset-card:hover {
  background: rgba(var(--primary-rgb),0.16);
  border-color: rgba(var(--primary-rgb),0.5);
  transform: translateY(-1px);
}
.mkw-preset-card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
}
.mkw-preset-card-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  line-height: 1.3;
}
@media (max-width: 560px) {
  .mkw-preset-cards { grid-template-columns: 1fr; }
}

/* Recommended badge on mode tab ───────────────────────────────────── */
.mkw-mode-rec {
  display: inline-block;
  margin-left: 6px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #32d6a2;
  background: rgba(50,214,162,0.14);
  border-radius: 4px;
  padding: 1px 4px;
  vertical-align: middle;
}
.mkw-mode-tab.mkw-mode-active .mkw-mode-rec { color: #d7fff1; background: rgba(255,255,255,0.18); }

/* Mode description line ────────────────────────────────────────────── */
.mkw-mode-desc {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  line-height: 1.45;
  margin: 0 0 4px;
}

/* Advanced params toggle ──────────────────────────────────────────── */
.mkw-adv-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin-top: 14px;
  padding: 12px 0 0;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
}
.mkw-adv-toggle:hover { color: #fff; }
.mkw-adv-caret { transition: transform 0.18s; flex-shrink: 0; }
.mkw-adv-toggle[aria-expanded="true"] .mkw-adv-caret { transform: rotate(90deg); }
.mkw-adv-hint {
  font-size: 10.5px;
  font-weight: 400;
  color: rgba(255,255,255,0.32);
  margin-left: auto;
}
.mkw-adv-grid { margin-top: 12px; }

/* Run button disabled state ───────────────────────────────────────── */
.mkw-run-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.6);
}

/* Input row ──────────────────────────────────────────────────────── */
.mkw-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.mkw-ticker-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  color: #fff;
  outline: none;
  transition: border-color 0.18s;
}
.mkw-ticker-input:focus { border-color: rgba(var(--primary-rgb),0.6); }
.mkw-ticker-input.mkw-input-flash { border-color: #f5b84c; }
.mkw-add-btn { white-space: nowrap; flex-shrink: 0; }

/* Asset chips ────────────────────────────────────────────────────── */
.mkw-asset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}
.mkw-empty-assets {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  margin: 0;
  padding: 22px 16px;
  text-align: center;
  border: 1px dashed rgba(var(--primary-rgb, 111,134,255), 0.28);
  border-radius: 12px;
  background: rgba(var(--primary-rgb, 111,134,255), 0.04);
  line-height: 1.55;
  align-self: center;
}
.mkw-asset-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 4px 10px 4px 8px;
  font-size: 12px;
}
.mkw-chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mkw-chip-label { color: rgba(255,255,255,0.85); font-weight: 500; }
.mkw-chip-remove {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.3);
  font-size: 15px; line-height: 1;
  padding: 0 0 0 2px;
  transition: color 0.15s;
}
.mkw-chip-remove:hover { color: #ff6b8a; }

/* Chip RF badge ──────────────────────────────────────────────────── */
.mkw-chip-fi {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #32d6a2;
  background: rgba(50, 214, 162, 0.12);
  border: 1px solid rgba(50, 214, 162, 0.35);
  border-radius: 3px;
  padding: 1px 4px;
  line-height: 1.4;
}

/* Chip company name ───────────────────────────────────────────────── */
.mkw-chip-name {
  font-size: 10.5px;
  color: rgba(255,255,255,0.4);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inline ticker validation message ────────────────────────────────── */
.mkw-input-msg {
  font-size: 11.5px;
  line-height: 1.4;
  margin: -4px 0 10px;
}
.mkw-input-msg-warn  { color: #f5b84c; }
.mkw-input-msg-error { color: #ff6b8a; }

/* Constraints group header ────────────────────────────────────────── */
.mkw-constraints-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.mkw-constraints-title {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
}
.mkw-constraints-opt {
  font-size: 10px;
  color: rgba(255,255,255,0.32);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px;
  padding: 1px 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Info card → collapsible secondary ───────────────────────────────── */
.mkw-info-card {
  background: rgba(255,255,255,0.025);
}
.mkw-info-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
}
.mkw-info-summary::-webkit-details-marker { display: none; }
.mkw-info-summary:hover { color: #fff; }
.mkw-info-icon { color: rgba(var(--primary-rgb),0.85); flex-shrink: 0; }
.mkw-info-caret { margin-left: auto; transition: transform 0.18s; }
.mkw-info-card[open] .mkw-info-caret { transform: rotate(90deg); }
.mkw-info-card .mkw-info-text { margin-top: 14px; }

/* Params card ────────────────────────────────────────────────────── */
.mkw-params-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

/* Fixed-income constraints ───────────────────────────────────────── */
.mkw-fi-section {
  margin-bottom: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.025);
}
.mkw-fi-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  user-select: none;
}
.mkw-fi-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #6f86ff;
  cursor: pointer;
  flex-shrink: 0;
}
.mkw-fi-options {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mkw-fi-options.hidden { display: none; }
.mkw-fi-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mkw-fi-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mkw-fi-field label {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
}
.mkw-fi-field input {
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  width: 100%;
  box-sizing: border-box;
}
.mkw-fi-note {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin: 0;
  line-height: 1.4;
}

.mkw-run-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 0;
}
.mkw-spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mkwSpin 0.7s linear infinite;
}
@keyframes mkwSpin { to { transform: rotate(360deg); } }

/* Status ─────────────────────────────────────────────────────────── */
.mkw-status {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.4;
}
.mkw-rfr-label {
  font-size: 11px;
  color: rgba(255,255,255,0.38);
  margin-top: 4px;
}

.mkw-status-loading {
  background: rgba(var(--primary-rgb),0.1);
  border: 1px solid rgba(var(--primary-rgb),0.25);
  color: rgba(var(--primary-rgb),0.9);
}
.mkw-status-error {
  background: rgba(255,77,106,0.1);
  border: 1px solid rgba(255,77,106,0.3);
  color: #ff6b8a;
}
.mkw-status-warn {
  background: rgba(245,184,76,0.1);
  border: 1px solid rgba(245,184,76,0.3);
  color: #f5b84c;
}
.mkw-status-success {
  background: rgba(0,200,148,0.1);
  border: 1px solid rgba(0,200,148,0.3);
  color: #00c894;
}

/* Saved portfolios bar ─────────────────────────────────────────────── */
.mkw-saved-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.mkw-saved-select {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 7px 10px;
}
.mkw-saved-btn {
  font-size: 12px;
  padding: 7px 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.mkw-saved-del {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255,77,106,0.3);
  background: rgba(255,77,106,0.08);
  color: #ff6b8a;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}
.mkw-saved-del:hover { background: rgba(255,77,106,0.2); }
.mkw-results-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}
body.light-mode .mkw-saved-bar { border-top-color: rgba(0,0,0,0.08); }

/* #8 Comparador de portafolios ─────────────────────────────────────── */
.mkw-compare-modal { max-width: 760px; width: 100%; }
.mkw-compare-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}
.mkw-compare-count { font-size: 12px; color: var(--muted, rgba(255,255,255,0.55)); }
.mkw-compare-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.mkw-compare-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mkw-compare-item:hover { border-color: rgba(255,255,255,0.2); }
.mkw-compare-item input { grid-row: 1 / 3; width: 16px; height: 16px; }
.mkw-compare-item-name { font-weight: 600; font-size: 13px; }
.mkw-compare-item-sub { grid-column: 2; font-size: 11px; color: var(--muted, rgba(255,255,255,0.5)); }
.mkw-compare-actions { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.mkw-compare-warn { font-size: 13px; color: #ffb454; padding: 8px 0; }
.mkw-cmp-table th.mkw-cmp-col { text-align: center; vertical-align: bottom; }
.mkw-cmp-name { display: block; font-weight: 700; }
.mkw-cmp-badge {
  display: inline-block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(50,214,162,0.16);
  color: #32d6a2;
}
.mkw-cmp-err { display: block; font-size: 10px; color: #ffb454; font-weight: 500; }
.mkw-cmp-table td { text-align: center; }
.mkw-cmp-table td:first-child, .mkw-cmp-table th:first-child { text-align: left; }
.mkw-cmp-best { color: #32d6a2; }
.mkw-cmp-top { font-size: 11px; line-height: 1.5; }
body.light-mode .mkw-compare-item { border-color: rgba(0,0,0,0.1); }

/* #3 Onboarding / tour de bienvenida ───────────────────────────────── */
#bpOnbOverlay { position: fixed; inset: 0; z-index: 100000; }
#bpOnbRing {
  position: fixed;
  border-radius: 10px;
  border: 2px solid var(--accent, #6f86ff);
  box-shadow: 0 0 0 9999px rgba(5,8,18,0.74);
  pointer-events: none;
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
#bpOnbRing.bp-onb-ring-center {
  top: 50%; left: 50%; width: 0; height: 0; border-color: transparent;
}
#bpOnbTip {
  position: fixed;
  width: 320px;
  max-width: calc(100vw - 24px);
  background: var(--card-bg, #11151f);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  z-index: 100001;
}
#bpOnbStepCount { font-size: 11px; color: var(--accent, #6f86ff); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
#bpOnbTip h3 { margin: 0 0 8px; font-size: 16px; }
#bpOnbTip p { margin: 0 0 16px; font-size: 13px; line-height: 1.55; color: var(--muted, rgba(255,255,255,0.7)); }
.bp-onb-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bp-onb-nav { display: flex; gap: 8px; }
.bp-onb-skip { background: none; border: none; color: var(--muted, rgba(255,255,255,0.5)); font-size: 12px; cursor: pointer; padding: 6px 2px; }
.bp-onb-skip:hover { color: var(--text, #fff); }
.bp-onb-nav .button { font-size: 12px; padding: 7px 14px; }
body.light-mode #bpOnbRing { box-shadow: 0 0 0 9999px rgba(15,23,42,0.5); }
body.light-mode #bpOnbTip { background: #fff; border-color: rgba(0,0,0,0.1); }

/* μ estimation warning ─────────────────────────────────────────────── */
.mkw-mu-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(245,184,76,0.25);
  background: rgba(245,184,76,0.07);
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.mkw-mu-warning strong { color: #f5b84c; }
.mkw-mu-icon {
  font-size: 15px;
  line-height: 1.4;
  color: #f5b84c;
  flex-shrink: 0;
}
body.light-mode .mkw-mu-warning {
  color: rgba(0,0,0,0.65);
  border-color: rgba(200,140,0,0.3);
  background: rgba(245,184,76,0.08);
}
body.light-mode .mkw-mu-warning strong { color: #a07000; }
body.light-mode .mkw-mu-icon { color: #a07000; }

/* Info card ──────────────────────────────────────────────────────── */
.mkw-info-text {
  font-size: 12.5px;
  color: rgba(255,255,255,0.6);
  line-height: 1.55;
  margin: 0 0 12px;
}
.mkw-info-points { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.mkw-info-point {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  line-height: 1.4;
}
.mkw-info-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}
.mkw-info-dot-gradient {
  background: linear-gradient(90deg, #f23445, #00c894);
}
.mkw-info-note {
  font-size: 11px;
  color: rgba(255,255,255,0.28);
  margin: 0;
  font-style: italic;
}

/* Frontier chart ─────────────────────────────────────────────────── */
.mkw-frontier-wrap {
  width: 100%;
  position: relative;
}
#mkwFrontierCanvas {
  width: 100%;
  display: block;
  border-radius: 6px;
}

#mkwForecastCanvas {
  width: 100%;
  display: block;
  border-radius: 6px;
}

/* Optimal cards ──────────────────────────────────────────────────── */
.mkw-optimal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 680px) { .mkw-optimal-row { grid-template-columns: 1fr; } }

.mkw-optimal-card { padding: 18px; }
.mkw-optimal-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: 0.01em;
}
.mkw-optimal-metrics {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.mkw-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
}
.mkw-metric strong { color: #fff; font-size: 14px; }
.mkw-pos { color: #00c894 !important; }
.mkw-neg { color: #ff6b8a !important; }
.mkw-select-btn { width: 100%; text-align: center; }

/* Weights panel ──────────────────────────────────────────────────── */
.mkw-weights-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
@media (max-width: 700px) {
  .mkw-weights-layout { flex-direction: column; align-items: center; }
}
#mkwWeightsPie { flex-shrink: 0; }
.mkw-weights-table-shell { flex: 1; overflow-x: auto; }

.mkw-table-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
}
.mkw-bar-cell { min-width: 120px; }
.mkw-weight-bar-bg {
  height: 6px;
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  overflow: hidden;
}
.mkw-weight-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ── Calc card ──────────────────────────────────────────────────── */
.mkw-calc-card { margin-top: 0; }

.mkw-calc-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding-bottom: 0;
}
.mkw-calc-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px 10px;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.mkw-calc-tab:hover { color: rgba(255,255,255,0.75); }
.mkw-calc-tab-active { color: #6f86ff !important; border-bottom-color: #6f86ff !important; }

.mkw-calc-panel { display: none; }
.mkw-calc-panel-active { display: block; }

.mkw-calc-placeholder {
  color: rgba(255,255,255,0.35);
  font-size: 13px;
  padding: 20px 0;
  text-align: center;
}

/* Methodology grid */
.mkw-methodology-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 700px) { .mkw-methodology-grid { grid-template-columns: 1fr; } }

.mkw-method-block {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 14px 16px;
}
.mkw-method-title {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.mkw-method-formula {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #6f86ff;
  background: rgba(var(--primary-rgb),0.08);
  border-radius: 5px;
  padding: 6px 10px;
  margin-bottom: 8px;
  line-height: 1.6;
}
.mkw-method-desc {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  line-height: 1.6;
}

/* Stats table */
.mkw-calc-table th, .mkw-calc-table td { font-size: 12px; }

/* Matrix */
.mkw-calc-matrix-note {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-bottom: 12px;
  line-height: 1.5;
}
.mkw-matrix-wrap {
  overflow-x: auto;
  border-radius: 6px;
}
.mkw-matrix-table {
  border-collapse: collapse;
  font-size: 11px;
  min-width: 100%;
}
.mkw-matrix-table th {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.55);
  font-weight: 600;
  padding: 7px 10px;
  text-align: center;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.07);
}
.mkw-matrix-table td {
  padding: 7px 10px;
  text-align: center;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.05);
  font-family: 'Courier New', monospace;
  font-size: 11px;
  transition: filter 0.1s;
}
.mkw-matrix-table td:hover { filter: brightness(1.3); }

/* VaR */
.mkw-var-method-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
@media (max-width: 700px) { .mkw-var-method-row { grid-template-columns: 1fr; } }

.mkw-var-metric span { display: flex; align-items: center; gap: 5px; }

.mkw-var-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(var(--primary-rgb),0.18);
  color: #6f86ff;
  border-radius: 3px;
  padding: 1px 5px;
  text-transform: uppercase;
}
.mkw-var-badge-hist {
  background: rgba(245,184,76,0.18);
  color: #f5b84c;
}

.mkw-var-table-wrap { overflow-x: auto; }
.mkw-var-table thead th { text-align: center; font-size: 11px; }
.mkw-var-conf-header {
  background: rgba(var(--primary-rgb),0.08);
  border-bottom: 1px solid rgba(var(--primary-rgb),0.2);
}
.mkw-var-sub { color: rgba(255,255,255,0.4); font-weight: 400; font-size: 10px; }

.mkw-forecast-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
  font-size: 0.73rem;
  color: var(--muted);
}
.mkw-bt-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 6px 0 4px;
}
.mkw-bt-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mkw-bt-control label {
  font-size: 0.7rem;
  color: var(--muted);
}
.mkw-bt-control select {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text, #fff);
  font-size: 0.8rem;
}
.mkw-forecast-gradient-swatch {
  display: inline-block;
  width: 40px;
  height: 8px;
  border-radius: 3px;
  background: linear-gradient(to right, rgb(242,77,106), rgb(0,200,148));
  flex-shrink: 0;
  align-self: center;
}

/* ── Monte Carlo tab ──────────────────────────────────────────────────────── */
.mc-year-nav { display: flex; gap: 5px; flex-wrap: wrap; }

.mc-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 14px 0 6px;
  padding: 14px;
  background: rgba(var(--primary-rgb), 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.mc-ctrl { display: flex; flex-direction: column; gap: 5px; }
.mc-ctrl > label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mc-ctrl input,
.mc-ctrl select {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.85rem;
  width: 100%;
}
.mc-ctrl-infl { justify-content: flex-end; }
.mc-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.mc-check input { width: auto; }
.mc-infl-row { display: flex; align-items: center; gap: 8px; }
.mc-infl-row input { max-width: 80px; }
.mc-infl-row input:disabled { opacity: 0.45; }
.mc-infl-pct { font-size: 0.78rem; color: var(--muted); }

.mc-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
  font-size: 0.73rem;
  color: var(--muted);
}
.mc-legend-item { display: flex; align-items: center; gap: 6px; }
.mc-legend-swatch {
  display: inline-block;
  width: 22px;
  height: 8px;
  border-radius: 3px;
  flex-shrink: 0;
}

.mc-chart-wrap {
  position: relative;
  width: 100%;
  margin: 8px 0 4px;
}

.mc-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.mc-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.mc-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mc-stat-value {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}
.mc-stat-sub {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 3px;
}
.mc-stat-value.pos { color: #4ade80; }
.mc-stat-value.neg { color: #f87171; }

@media (max-width: 600px) {
  .mc-stats-grid { grid-template-columns: 1fr 1fr; }
  .mc-legend { gap: 10px; font-size: 0.68rem; }
}

/* ── Metas financieras (#6) ─────────────────────────────────────────── */
.goal-form { margin-top: 8px; }
.goal-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.goal-field { display: flex; flex-direction: column; gap: 5px; }
.goal-field-wide { grid-column: 1 / -1; }
.goal-field > label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.goal-field input {
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.88rem;
  width: 100%;
}
.goal-field-check { justify-content: flex-end; }
.goal-form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.goal-result { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.goal-progress-card { padding: 18px 20px; }
.goal-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.goal-progress-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.goal-progress-amounts { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.goal-progress-amounts strong { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.goal-progress-amounts span { font-size: 0.9rem; color: var(--muted); }

.goal-prob-badge {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.goal-prob-badge.is-high { background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.35); }
.goal-prob-badge.is-mid  { background: rgba(245, 184, 76, 0.12); border-color: rgba(245, 184, 76, 0.35); }
.goal-prob-badge.is-low  { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.35); }
.goal-prob-value { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.goal-prob-badge.is-high .goal-prob-value { color: #4ade80; }
.goal-prob-badge.is-mid  .goal-prob-value { color: #f5b84c; }
.goal-prob-badge.is-low  .goal-prob-value { color: #f87171; }
.goal-prob-cap { font-size: 0.66rem; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.04em; }

.goal-progress-bar {
  height: 10px;
  border-radius: 6px;
  background: rgba(var(--primary-rgb), 0.08);
  overflow: hidden;
  margin: 16px 0 10px;
}
.goal-progress-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #6f86ff, #32d6a2);
  transition: width 0.6s ease;
}
.goal-progress-meta { font-size: 0.78rem; color: var(--muted); }

@media (max-width: 600px) {
  .goal-form-grid { grid-template-columns: 1fr 1fr; }
  .goal-field-wide { grid-column: 1 / -1; }
  .goal-progress-head { flex-direction: column; }
  .goal-prob-badge { align-self: stretch; align-items: flex-start; text-align: left; }
  .goal-form-actions .button { flex: 1; }
}

/* ── Compartir portafolio (#12) ─────────────────────────────────────── */
.share-modal-desc { font-size: 0.85rem; color: var(--muted); margin: 4px 0 16px; line-height: 1.5; }
.share-link-row { display: flex; gap: 8px; }
.share-link-row input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(var(--primary-rgb), 0.04);
  color: var(--text);
  font-size: 0.82rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.share-modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.share-revoke { color: #f87171; }

@media (max-width: 600px) {
  .share-link-row { flex-direction: column; }
  .share-modal-actions { flex-direction: column; }
  .share-modal-actions .button { width: 100%; text-align: center; }
}

/* ── Notificaciones (#5) ────────────────────────────────────────────── */
.notif-wrap { position: relative; display: flex; align-items: center; }
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.notif-bell:hover { border-color: rgba(var(--primary-rgb), 0.4); background: rgba(var(--primary-rgb), 0.06); }
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px;
  background: #f87171; color: #fff;
  font-size: 0.64rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
/* Author `display:flex` above overrides the UA `[hidden]` rule, so the badge
   must be explicitly hidden when there are no unread notifications. */
.notif-badge[hidden] { display: none; }
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; max-width: 86vw; max-height: 70vh; overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  z-index: 1200;
  padding: 6px;
}
.notif-panel.hidden { display: none; }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; }
.notif-panel-head strong { font-size: 0.9rem; }
.notif-mark-read { background: none; border: none; color: #6f86ff; font-size: 0.76rem; cursor: pointer; }
.notif-list { display: flex; flex-direction: column; }
.notif-item { padding: 10px 12px; border-radius: 10px; }
.notif-item:hover { background: rgba(var(--primary-rgb), 0.05); }
.notif-item.is-unread { background: rgba(111,134,255,0.08); }
.notif-item-title { font-size: 0.85rem; font-weight: 600; }
.notif-item-body { font-size: 0.78rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.notif-item-time { font-size: 0.68rem; color: var(--muted); margin-top: 4px; }
.notif-empty { padding: 18px 12px; text-align: center; color: var(--muted); font-size: 0.82rem; }

/* ── Alertas de precio (#5) ─────────────────────────────────────────── */
.alert-form { margin-bottom: 14px; }
.alert-form-grid { display: grid; grid-template-columns: 1.6fr 1.2fr 1fr auto; gap: 10px; align-items: end; }
.alert-field { display: flex; flex-direction: column; gap: 5px; }
.alert-field > label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.alert-field input, .alert-field select {
  padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card-bg); color: var(--text); font-size: 0.86rem; width: 100%;
}
.alert-field-submit .button { white-space: nowrap; }
.alerts-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: rgba(var(--primary-rgb), 0.03);
}
.alert-item.is-triggered { opacity: 0.65; }
.alert-item-main { display: flex; flex-direction: column; gap: 2px; }
.alert-item-label { font-weight: 600; font-size: 0.9rem; }
.alert-item-status { font-size: 0.72rem; color: var(--muted); }
.alert-del-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 4px 8px; border-radius: 6px;
}
.alert-del-btn:hover { color: #f87171; background: rgba(248,113,113,0.1); }

@media (max-width: 700px) {
  .alert-form-grid { grid-template-columns: 1fr 1fr; }
  .alert-field-submit { grid-column: 1 / -1; }
  .alert-field-submit .button { width: 100%; }
}

body.light-mode .hub-suggest-popup div { color: #1e293b; }

/* ═══════════════════════════════════════════════════════════
   CORRELACIÓN / DIVERSIFICACIÓN
   ═══════════════════════════════════════════════════════════ */
.corr-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

/* Matrix card header helpers */
.corr-matrix-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.corr-matrix-info {
  position: relative;
}
.corr-matrix-info .kpi-info-btn:hover + .corr-matrix-tooltip,
.corr-matrix-info .kpi-info-btn:focus + .corr-matrix-tooltip {
  display: block;
}
.corr-matrix-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  background: #1a1d2e;
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 12px;
  font-weight: 400;
  color: #c8cde8;
  line-height: 1.55;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  white-space: normal;
}
body.light-mode .corr-matrix-tooltip {
  background: #fff;
  border-color: rgba(var(--primary-rgb), 0.3);
  color: #444;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

/* Matrix wrap & table */
.corr-matrix-wrap { overflow-x: auto; margin: 4px 0; border-radius: 12px; }
table.corr-matrix {
  border-collapse: separate;
  border-spacing: 3px;
  width: 100%;
  font-size: 0.8rem;
}
table.corr-matrix th {
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.73rem;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
table.corr-matrix thead th {
  background: var(--card-bg);
  top: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 12px;
}
table.corr-matrix thead th:first-child { min-width: 80px; }
table.corr-matrix tbody th {
  text-align: right;
  left: 0;
  background: var(--card-bg);
  padding-right: 14px;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-right: 1px solid rgba(255,255,255,0.06);
}
table.corr-matrix td {
  padding: 10px 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: 8px;
  min-width: 62px;
  transition: filter 0.12s ease, transform 0.12s ease;
  cursor: default;
  position: relative;
}
table.corr-matrix td:hover {
  filter: brightness(1.25);
  transform: scale(1.06);
  z-index: 2;
}
table.corr-matrix td.corr-diag {
  opacity: 0.55;
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}
table.corr-matrix td.corr-high-pos { color: #fff; }
table.corr-matrix td.corr-high-neg { color: #fff; }

/* Scale bar */
.corr-scale {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0 2px;
}
.corr-scale-bar {
  flex: 1;
  height: 8px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    rgba(88,124,240,0.85) 0%,
    rgba(88,124,240,0.35) 30%,
    rgba(134,142,158,0.2) 50%,
    rgba(232,104,126,0.35) 70%,
    rgba(232,104,126,0.88) 100%);
}
.corr-scale-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 4px;
  padding: 0 2px;
  opacity: 0.7;
}

/* light mode overrides */
body.light-mode table.corr-matrix thead th,
body.light-mode table.corr-matrix tbody th { background: #fff; }

/* ═══════════════════════════════════════════════════════════
   WHAT-IF (backtest comparativo)
   ═══════════════════════════════════════════════════════════ */
.whatif-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  margin: 14px 0 10px;
  padding: 14px;
  background: rgba(var(--primary-rgb), 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.whatif-controls .mc-ctrl input {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.85rem;
  width: 100%;
}
.whatif-controls .button { height: 38px; }
.whatif-chart-wrap { position: relative; width: 100%; margin: 10px 0 4px; min-height: 300px; }
.whatif-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

/* ═══════════════════════════════════════════════════════════
   WATCHLIST
   ═══════════════════════════════════════════════════════════ */
.watchlist-card { margin-top: 20px; }
.watchlist-add { display: flex; gap: 10px; margin: 10px 0 14px; }
.watchlist-add input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.88rem;
}
.wl-row { cursor: pointer; transition: background 0.15s ease; }
.wl-row:hover { background: rgba(var(--primary-rgb), 0.07); }
.wl-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 5px;
}
.wl-remove:hover { color: #f87171; background: rgba(248, 113, 113, 0.12); }

@media (max-width: 700px) {
  .corr-metrics-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   ANALYZER MODULE
   ═══════════════════════════════════════════════════════════ */

#section-analyzer { overflow-y: auto; }

.anlz-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1200px;
  padding: 4px 0 40px;
}

/* ── Search ── */
.anlz-search-area { position: relative; }

.anlz-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 10px 14px;
  transition: border-color 0.2s;
}
.anlz-search-wrap:focus-within { border-color: rgba(var(--primary-rgb),0.55); }

.anlz-search-icon { color: #5a6478; flex-shrink: 0; }

#analyzerInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  font-family: Inter, sans-serif;
}
#analyzerInput::placeholder { color: #4a5568; }

.anlz-add-btn {
  background: rgba(var(--primary-rgb),0.15);
  border: 1px solid rgba(var(--primary-rgb),0.35);
  color: #6f86ff;
  border-radius: 9px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.anlz-add-btn:hover { background: rgba(var(--primary-rgb),0.28); }

.anlz-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #141418;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.anlz-suggestions.hidden { display: none; }

.anlz-sugg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.anlz-sugg-item:hover { background: rgba(255,255,255,0.06); }
.anlz-sugg-sym  { font-weight: 700; font-size: 0.9rem; color: #6f86ff; min-width: 60px; }
.anlz-sugg-name { flex: 1; font-size: 0.83rem; color: #8892a4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anlz-sugg-type { font-size: 0.72rem; color: #4a5568; background: rgba(255,255,255,0.06); padding: 2px 7px; border-radius: 6px; }

/* ── Asset cards ── */
.anlz-asset-cards {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.analyzer-empty-hint {
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  padding: 20px 16px;
  text-align: center;
  border: 1px dashed rgba(var(--primary-rgb, 111,134,255), 0.25);
  border-radius: 12px;
  background: rgba(var(--primary-rgb, 111,134,255), 0.04);
  line-height: 1.55;
}
body.light-mode .analyzer-empty-hint {
  color: rgba(0,0,0,0.5);
}

.anlz-asset-card {
  position: relative;
  background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid var(--ac, rgba(255,255,255,0.12));
  border-top-width: 3px;
  border-radius: 16px;
  padding: 14px 16px 12px;
  min-width: 155px;
  max-width: 200px;
  flex: 1;
  transition: transform 0.18s;
}
.anlz-asset-card:hover { transform: translateY(-2px); }

.anlz-asset-rm {
  position: absolute;
  top: 8px; right: 10px;
  background: none;
  border: none;
  color: #4a5568;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 5px;
  transition: color 0.15s;
}
.anlz-asset-rm:hover { color: #ff4d6d; }

.anlz-asset-sym   { font-weight: 800; font-size: 1.1rem; color: var(--ac, var(--text)); margin-bottom: 2px; }
.anlz-asset-name  { font-size: 0.75rem; color: #6b7280; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.anlz-asset-price { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.anlz-asset-chg   { font-size: 0.82rem; font-weight: 600; margin: 2px 0 6px; }
.anlz-asset-chg.pos { color: #32d6a2; }
.anlz-asset-chg.neg { color: #ff4d6d; }
.anlz-asset-meta  { font-size: 0.7rem; color: #4a5568; }

/* ── Run row ── */
.anlz-run-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.anlz-run-btn {
  background: linear-gradient(135deg, #6f86ff, #5870d4);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 0.93rem;
  font-weight: 700;
  padding: 12px 28px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  white-space: nowrap;
}
.anlz-run-btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.anlz-run-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.anlz-run-hint { font-size: 0.78rem; color: #4a5568; }

/* ── Loading ── */
.anlz-loading {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 20px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 16px;
}
.anlz-loading.hidden { display: none; }
.anlz-loading > div { display: flex; flex-direction: column; gap: 3px; }
.anlz-loading strong { font-size: 0.95rem; color: var(--text); }
.anlz-loading span   { font-size: 0.8rem; color: #6b7280; }

.anlz-spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(var(--primary-rgb),0.2);
  border-top-color: #6f86ff;
  border-radius: 50%;
  animation: anlzSpin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes anlzSpin { to { transform: rotate(360deg); } }

/* ── Results ── */
.anlz-results { display: flex; flex-direction: column; gap: 20px; }
.anlz-results.hidden { display: none; }

/* ── Cards ── */
.anlz-card {
  background: linear-gradient(180deg, rgba(12,12,15,0.96), rgba(8,8,10,0.98));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 22px 24px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.anlz-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.anlz-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 3px;
}
.anlz-card-sub { font-size: 0.75rem; color: #4a5568; margin: 0; }

.anlz-badge {
  background: rgba(var(--primary-rgb),0.12);
  border: 1px solid rgba(var(--primary-rgb),0.3);
  color: #6f86ff;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

/* ── Scenario tabs ── */
.anlz-scen-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 3px;
}
.anlz-scen-tab {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.anlz-scen-tab.active { background: rgba(var(--primary-rgb),0.22); color: #6f86ff; }

/* ── DCF cards ── */
.anlz-dcf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.anlz-dcf-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--ac, rgba(255,255,255,0.08));
  border-top: 3px solid var(--ac, rgba(255,255,255,0.12));
  border-radius: 14px;
  padding: 14px 16px;
}
.anlz-dcf-sym  { font-weight: 800; font-size: 1.1rem; color: var(--ac, var(--text)); margin-bottom: 10px; }
.anlz-dcf-err  { font-size: 0.8rem; color: #6b7280; font-style: italic; }

.anlz-dcf-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.anlz-dcf-block span   { font-size: 0.72rem; color: #6b7280; display: block; margin-bottom: 2px; }
.anlz-dcf-block strong { font-size: 1.05rem; font-weight: 700; color: var(--text); }

.anlz-dcf-upside {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.anlz-dcf-upside.pos { color: #32d6a2; }
.anlz-dcf-upside.neg { color: #ff4d6d; }
.anlz-dcf-upside.neutral { color: #f5b84c; }

.anlz-dcf-meta-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.anlz-tag {
  font-size: 0.72rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #8892a4;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.anlz-tag-sm { font-size: 0.68rem; }
.anlz-tag .pos { color: #32d6a2; }
.anlz-tag .neg { color: #ff4d6d; }

.anlz-dcf-tv-split { margin-top: 6px; }
.anlz-tv-bar-wrap {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 5px;
}
.anlz-tv-bar-proj {
  height: 100%;
  background: var(--ac, #6f86ff);
  border-radius: 3px;
  opacity: 0.7;
  transition: width 0.4s ease;
}
.anlz-tv-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: #4a5568;
}

/* ── Monte Carlo cards ── */
.anlz-mc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.anlz-mc-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--ac, rgba(255,255,255,0.08));
  border-top: 3px solid var(--ac, rgba(255,255,255,0.12));
  border-radius: 14px;
  padding: 14px 16px;
}
.anlz-mc-sym  { font-weight: 800; font-size: 1rem; color: var(--ac, var(--text)); margin-bottom: 8px; }
.anlz-mc-prob {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.anlz-mc-prob span { font-size: 0.75rem; font-weight: 500; color: #6b7280; }
.anlz-mc-prob.pos { color: #32d6a2; }
.anlz-mc-prob.neg { color: #ff4d6d; }
.anlz-mc-prob.neutral { color: #f5b84c; }

.anlz-mc-pcts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin: 10px 0;
  padding: 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
}
.anlz-mc-pct { text-align: center; }
.anlz-mc-pct span  { font-size: 0.68rem; color: #4a5568; display: block; }
.anlz-mc-pct strong{ font-size: 0.88rem; color: var(--text); }
.anlz-mc-mid strong { color: var(--ac, var(--text)); }

.anlz-mc-meta-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Chart wrapper ── */
.anlz-chart-wrap {
  position: relative;
  width: 100%;
}

/* ── Comparison table ── */
.anlz-cmp-wrap { overflow-x: auto; }

.cmp-table {
  width: 100%;
  min-width: 360px;
  border-collapse: collapse;
}

.cmp-row {
  display: grid;
  grid-template-columns: 180px repeat(var(--cols, 1), 1fr);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}
.cmp-row:last-child { border-bottom: none; }
.cmp-row:hover:not(.cmp-header) { background: rgba(255,255,255,0.03); }
.cmp-header { background: rgba(255,255,255,0.04); border-radius: 10px 10px 0 0; }

.cmp-cell {
  padding: 9px 12px;
  font-size: 0.83rem;
  color: #8892a4;
  display: flex;
  align-items: center;
}
.cmp-metric-cell { color: #6b7280; font-size: 0.78rem; }
.cmp-header .cmp-cell { font-size: 0.82rem; font-weight: 700; }

.cmp-best {
  color: #32d6a2 !important;
  font-weight: 700;
  background: rgba(50,214,162,0.06);
  border-radius: 6px;
}

/* Dynamic grid columns for comparison table */
.anlz-cmp-wrap:has([data-cols="1"]) .cmp-row { grid-template-columns: 180px 1fr; }
.anlz-cmp-wrap:has([data-cols="2"]) .cmp-row { grid-template-columns: 180px 1fr 1fr; }
.anlz-cmp-wrap:has([data-cols="3"]) .cmp-row { grid-template-columns: 180px 1fr 1fr 1fr; }

/* ── Decision panel ── */
.anlz-decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.anlz-decision-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--ac, rgba(255,255,255,0.08));
  border-left: 3px solid var(--ac, rgba(255,255,255,0.2));
  border-radius: 14px;
  padding: 16px 18px;
}

.anlz-dec-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.anlz-dec-sym  { font-size: 1.1rem; font-weight: 800; color: var(--ac, var(--text)); }
.anlz-dec-name { font-size: 0.76rem; color: #6b7280; margin-top: 2px; }

.anlz-rec-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 11px;
  border: 1px solid;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.anlz-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.anlz-score-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  overflow: hidden;
}
.anlz-score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.anlz-score-num { font-size: 0.78rem; color: #6b7280; white-space: nowrap; }

.anlz-signals { display: flex; flex-direction: column; gap: 5px; }
.anlz-signal {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #8892a4;
}
.anlz-sig-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.anlz-signal-positive .anlz-sig-dot { background: #32d6a2; }
.anlz-signal-negative .anlz-sig-dot { background: #ff4d6d; }
.anlz-signal-neutral  .anlz-sig-dot { background: #f5b84c; }
.anlz-signal-positive { color: #9de8c9; }
.anlz-signal-negative { color: #ffaab8; }
.anlz-signal-neutral  { color: #f9d584; }

/* ── Consolidated target (decision panel) ── */
.anlz-dec-target {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.anlz-dec-target-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.anlz-dec-target-main span { font-size: 0.72rem; color: #6b7280; }
.anlz-dec-target-main strong { font-size: 1.05rem; font-weight: 800; color: var(--text); white-space: nowrap; }
.anlz-dec-target-main em { font-style: normal; font-size: 0.82rem; font-weight: 700; margin-left: 4px; }
.anlz-dec-target-main em.pos { color: #32d6a2; }
.anlz-dec-target-main em.neg { color: #ff4d6d; }
.anlz-dec-target-srcs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 7px;
}
.anlz-dec-target-srcs span {
  font-size: 0.66rem; color: #8892a4;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px; padding: 2px 7px;
}

/* ── Analyst & technical card ── */
.anlz-at-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.anlz-at-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--ac, rgba(255,255,255,0.08));
  border-top: 3px solid var(--ac, rgba(255,255,255,0.12));
  border-radius: 14px;
  padding: 15px 16px;
}
.anlz-at-sym { font-weight: 800; font-size: 1.1rem; color: var(--ac, var(--text)); margin-bottom: 12px; }
.anlz-at-label {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #6b7280;
  margin: 14px 0 8px; padding-bottom: 5px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.anlz-at-label:first-of-type { margin-top: 0; }
.anlz-at-empty { font-size: 0.78rem; color: #6b7280; font-style: italic; }

.anlz-at-rec {
  display: inline-flex; align-items: center;
  font-size: 0.8rem; font-weight: 700;
  padding: 5px 12px; border: 1px solid; border-radius: 9px;
  margin-bottom: 12px;
}
.anlz-at-target { margin-bottom: 8px; }
.anlz-at-bar {
  position: relative; height: 7px;
  background: linear-gradient(90deg, rgba(255,77,109,0.35), rgba(245,184,76,0.35), rgba(50,214,162,0.45));
  border-radius: 4px; margin: 4px 0 6px;
}
.anlz-at-bar-mean, .anlz-at-bar-price {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  border-radius: 50%;
}
.anlz-at-bar-mean { width: 12px; height: 12px; background: #fff; border: 2px solid var(--ac, #6f86ff); box-shadow: 0 0 0 2px rgba(0,0,0,0.35); }
.anlz-at-bar-price { width: 0; height: 14px; border-left: 2px dashed rgba(255,255,255,0.85); border-radius: 0; }
.anlz-at-bar-labels {
  display: flex; justify-content: space-between;
  font-size: 0.66rem; color: #8892a4;
}
.anlz-at-bar-labels .anlz-at-bar-mid { color: var(--text); font-weight: 600; }
.anlz-at-upside { font-size: 0.8rem; font-weight: 700; }
.anlz-at-upside.pos { color: #32d6a2; }
.anlz-at-upside.neg { color: #ff4d6d; }

.anlz-at-tech {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
  margin-bottom: 12px;
}
.anlz-at-ti { display: flex; flex-direction: column; gap: 1px; }
.anlz-at-ti span { font-size: 0.68rem; color: #6b7280; }
.anlz-at-ti strong { font-size: 0.86rem; font-weight: 700; color: var(--text); }
.anlz-at-ti strong.pos { color: #32d6a2; }
.anlz-at-ti strong.neg { color: #ff4d6d; }

.anlz-at-52-track {
  height: 6px; background: rgba(255,255,255,0.07);
  border-radius: 3px; overflow: hidden; margin-bottom: 5px;
}
.anlz-at-52-fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--ac, #6f86ff), rgba(50,214,162,0.85));
  border-radius: 3px;
}
.anlz-at-52-labels { display: flex; justify-content: space-between; font-size: 0.66rem; color: #8892a4; }
.anlz-at-52-labels .anlz-at-52-pos { color: var(--text); font-weight: 600; }

@media (max-width: 860px) {
  .anlz-at-grid { grid-template-columns: 1fr; }
}

/* ── Toast ── */
.anlz-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1a1a22;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  font-size: 0.85rem;
  padding: 10px 20px;
  border-radius: 12px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  pointer-events: none;
}
.anlz-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ── */
@media (max-width: 860px) {
  .anlz-dcf-grid, .anlz-mc-grid { grid-template-columns: 1fr; }
  .anlz-decision-grid { grid-template-columns: 1fr; }
  .cmp-row { grid-template-columns: 130px repeat(3, 1fr) !important; }
  .cmp-metric-cell { font-size: 0.72rem; }
}
@media (max-width: 560px) {
  .anlz-run-row { flex-direction: column; align-items: flex-start; }
  .anlz-asset-card { min-width: 120px; }
}

/* ══════════════════════════════════════════════════════
   TOP-DOWN ANALYSIS
   ══════════════════════════════════════════════════════ */

.topdown-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px;
  max-width: 1400px;
}

.topdown-macro-card  { grid-column: 1 / -1; }
.topdown-heatmap-card { grid-column: 1 / -1; }
.topdown-flow-card   { grid-column: 1 / -1; }
.topdown-rotation-card { grid-column: 1 / -1; }

.topdown-macro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.td-macro-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.td-macro-label {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.td-macro-value {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.td-macro-trend {
  font-size: 11px;
  font-weight: 500;
}
.td-trend-up   { color: #00c894; }
.td-trend-down { color: #ff6b8a; }
.td-trend-flat { color: rgba(255,255,255,0.4); }

.td-macro-loading {
  color: rgba(255,255,255,0.35);
  font-size: 13px;
  padding: 12px 0;
  grid-column: 1 / -1;
}

.td-macro-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
}

.td-spark {
  width: 100%;
  height: 22px;
  margin-top: 6px;
  opacity: 0.7;
}

/* Banner de régimen macro */
.td-regime-banner { margin-top: 14px; }
.td-regime-banner:empty { display: none; }
.td-regime-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.td-regime-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.td-regime-ok   { color: #00c894; background: rgba(0,200,148,0.08); }
.td-regime-warn { color: #f5b84c; background: rgba(245,184,76,0.08); }
.td-regime-bad  { color: #ff6b8a; background: rgba(255,107,138,0.08); }
.td-regime-flat { color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.05); }
.td-regime-meta { font-size: 12px; color: rgba(255,255,255,0.45); }
.td-regime-sectors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.td-regime-chip {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  background: rgba(var(--primary-rgb),0.12);
  border: 1px solid rgba(var(--primary-rgb),0.3);
  border-radius: 6px;
  padding: 3px 9px;
}

/* Fuerza relativa y favoritos en heatmap */
.td-heatmap-rs { font-size: 10px; font-weight: 600; }
.td-heatmap-cell { position: relative; }
.td-heatmap-fav { border-color: rgba(245,184,76,0.55); box-shadow: 0 0 0 1px rgba(245,184,76,0.25) inset; }
.td-fav-badge {
  position: absolute;
  top: 8px; right: 9px;
  font-size: 12px;
  color: #f5b84c;
}
.td-fav-inline { color: #f5b84c; font-size: 11px; }

/* Ticker clickeable en el ranking */
.td-rank-ticker { cursor: pointer; color: #6f86ff; font-weight: 600; }
.td-rank-ticker:hover { text-decoration: underline; }

/* Period nav */
.td-period-nav {
  display: flex;
  gap: 4px;
}
.td-period-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.td-period-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.td-period-btn.active { background: #6f86ff; border-color: #6f86ff; color: #fff; }

/* Heatmap grid */
.topdown-heatmap-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin: 4px 0 10px;
}

.topdown-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.td-heatmap-cell {
  border-radius: 10px;
  padding: 14px 12px 10px;
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.td-heatmap-cell:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,.4); }

.td-heatmap-sector { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.85); }
.td-heatmap-etf    { font-size: 10px; color: rgba(255,255,255,0.35); letter-spacing:.06em; }
.td-heatmap-ret    { font-size: 20px; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.td-heatmap-vol    { font-size: 10px; color: rgba(255,255,255,0.4); }
.td-heatmap-bar-bg { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.td-heatmap-bar-fill { height: 100%; border-radius: 2px; }

/* Flow chart — horizontal en desktop */
.topdown-flow {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  margin-top: 12px;
}

.td-flow-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
  transition: border-color .2s;
  flex: 1;
}
.td-flow-step.td-flow-active { border-color: rgba(var(--primary-rgb),.4); background: rgba(var(--primary-rgb),.06); }

.td-flow-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.td-flow-active .td-flow-num { background: #6f86ff; color: #fff; }

.td-flow-body { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.td-flow-body strong { font-size: 14px; color: #fff; }
.td-flow-body > span { font-size: 11px; color: rgba(255,255,255,0.62); }

.td-flow-verdict { font-size: 12px; font-weight: 600; margin-top: 4px; color: rgba(255,255,255,0.55); }
.td-verdict-ok   { color: #00c894; }
.td-verdict-warn { color: #f5b84c; }
.td-verdict-bad  { color: #ff6b8a; }

.td-flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.25);
  font-size: 18px;
  padding: 0 6px;
  transform: rotate(-90deg);
}

/* ── Top-Down: mejoras (timestamp, picks, confianza, scatter, tooltips) ── */
.td-last-updated { font-size: 11px; color: rgba(255,255,255,0.4); }

.td-regime-conf { font-size: 12px; color: rgba(255,255,255,0.55); }
.td-conf-ok   { color: #00c894; }
.td-conf-warn { color: #f5b84c; }
.td-conf-flat { color: rgba(255,255,255,0.55); }
.td-regime-play { margin-top: 10px; }
.td-play-list { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.td-play-list li { font-size: 12px; color: rgba(255,255,255,0.72); line-height: 1.4; }

/* Top picks */
.td-top-picks:empty { display: none; }
.td-top-picks { margin-top: 16px; }
.td-picks-head { font-size: 12px; font-weight: 700; color: #f5b84c; margin-bottom: 10px; }
.td-picks-empty { font-size: 12px; color: rgba(245,184,76,0.85); background: rgba(245,184,76,0.06); border: 1px solid rgba(245,184,76,0.25); border-radius: 8px; padding: 10px 12px; }
.td-picks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.td-pick-card {
  background: rgba(245,184,76,0.05);
  border: 1px solid rgba(245,184,76,0.28);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.td-pick-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.td-pick-top { display: flex; align-items: center; gap: 6px; }
.td-pick-star { color: #f5b84c; font-size: 12px; }
.td-pick-name { font-size: 13px; font-weight: 700; color: #fff; flex: 1; }
.td-pick-etf { font-size: 10px; color: rgba(255,255,255,0.4); letter-spacing: .06em; }
.td-pick-ret { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.td-pick-meta { display: flex; justify-content: space-between; font-size: 11px; color: rgba(255,255,255,0.5); }

/* Tooltips de cabecera */
.td-th-info, .td-scatter-legend { cursor: help; border-bottom: 1px dotted rgba(255,255,255,0.3); }
.td-scatter-legend { font-size: 12px; color: rgba(255,255,255,0.5); }

/* Scatter riesgo/retorno */
.topdown-scatter-card { grid-column: 1 / -1; }
.td-scatter { margin-top: 8px; }
.td-scatter-svg { width: 100%; height: auto; display: block; }
.td-scatter-tick { font-size: 10px; fill: rgba(255,255,255,0.4); }
.td-scatter-axis { font-size: 11px; fill: rgba(255,255,255,0.5); }
.td-scatter-lbl  { font-size: 10px; fill: rgba(255,255,255,0.7); font-weight: 600; }
.td-scatter-star { font-size: 11px; fill: #f5b84c; }
.td-scatter-pt:hover circle { stroke: #fff; stroke-width: 2; }

/* Ranking table */
.td-ranking-table { margin-top: 12px; overflow-x: auto; }

/* ══════════════════════════════════════════════════════
   MARKOWITZ MODE TABS
   ══════════════════════════════════════════════════════ */

.mkw-mode-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}

.mkw-mode-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: rgba(255,255,255,0.45);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: center;
}
.mkw-mode-tab:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.05); }
.mkw-mode-tab.mkw-mode-active { background: #6f86ff; color: #fff; }

.mkw-mode-panel { margin-bottom: 12px; }

/* Smart Beta */
.mkw-sb-header { margin-bottom: 8px; }
.mkw-sb-title { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.8); display: block; }
.mkw-sb-hint  { font-size: 11px; color: rgba(255,255,255,0.35); display: block; }

.mkw-sb-factors { display: flex; flex-direction: column; gap: 6px; }
.mkw-sb-factor {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}
.mkw-sb-factor input[type="checkbox"] { flex-shrink: 0; }
.mkw-sb-factor-info { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.mkw-sb-factor-info strong { font-size: 12px; color: #fff; }
.mkw-sb-factor-info span  { font-size: 10px; color: rgba(255,255,255,0.38); }
.mkw-sb-weight { width: 52px; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 5px; color: #fff; font-size: 12px; padding: 4px 6px; text-align: right; }
.mkw-sb-pct { font-size: 11px; color: rgba(255,255,255,0.4); }

/* Black-Litterman */
.mkw-bl-views { display: flex; flex-direction: column; gap: 8px; }
.mkw-bl-view {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
}
.mkw-bl-view-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bl-type-sel, .bl-asset1-sel, .bl-asset2-sel {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color: #fff;
  font-size: 12px;
  padding: 4px 6px;
}
.bl-view-op { font-size: 11px; color: rgba(255,255,255,0.4); white-space: nowrap; }
.bl-conf-range { accent-color: #6f86ff; }
.bl-conf-label { font-size: 11px; color: rgba(255,255,255,0.5); min-width: 30px; text-align: right; }

@media (max-width: 900px) {
  .topdown-layout { grid-template-columns: 1fr; }
  .topdown-flow-card, .topdown-rotation-card { grid-column: 1; }
  .topdown-flow { flex-direction: column; }
  .td-flow-arrow { transform: rotate(0deg); margin-left: 28px; }
}
@media (max-width: 600px) {
  .topdown-heatmap-grid { grid-template-columns: repeat(2, 1fr); }
  .topdown-macro-grid   { grid-template-columns: repeat(2, 1fr); }
}

/* ── Analyzer news feed ── */
.anlz-news-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.anlz-news-list .news-card {
  border-radius: 8px;
}
.anlz-news-ticker-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 7px;
  letter-spacing: .4px;
  vertical-align: middle;
}
.anlz-news-loading {
  color: rgba(255,255,255,0.35);
  font-size: 13px;
  padding: 8px 0;
}
body.light-mode .anlz-news-loading { color: rgba(0,0,0,0.35); }

/* Veredicto IA (#1) */
.anlz-ai-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid rgba(111,134,255,0.45);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(111,134,255,0.18), rgba(50,214,162,0.14));
  color: #cfd6ff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease, opacity .15s ease;
}
.anlz-ai-btn:hover:not(:disabled) { filter: brightness(1.18); }
.anlz-ai-btn:disabled { opacity: 0.5; cursor: default; }
.anlz-ai-body { margin-top: 6px; }
.anlz-ai-empty { margin: 0; font-size: 13px; color: rgba(255,255,255,0.4); line-height: 1.6; }
.anlz-ai-h {
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #8ea0ff;
}
.anlz-ai-h:first-child { margin-top: 2px; }
.anlz-ai-p { margin: 0 0 8px; font-size: 13px; line-height: 1.65; color: rgba(255,255,255,0.78); }
.anlz-ai-ul { margin: 4px 0 10px; padding-left: 18px; }
.anlz-ai-ul li { font-size: 13px; line-height: 1.65; color: rgba(255,255,255,0.78); margin-bottom: 4px; }
.anlz-ai-body strong { color: rgba(255,255,255,0.95); font-weight: 600; }
body.light-mode .anlz-ai-empty { color: rgba(0,0,0,0.4); }
body.light-mode .anlz-ai-p,
body.light-mode .anlz-ai-ul li { color: rgba(0,0,0,0.72); }
body.light-mode .anlz-ai-body strong { color: rgba(0,0,0,0.9); }
body.light-mode .anlz-ai-btn { color: #4a5bd6; }

/* Disclaimer (#2) */
.anlz-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(245,184,76,0.28);
  border-left: 3px solid #f5b84c;
  border-radius: 10px;
  background: rgba(245,184,76,0.06);
}
.anlz-disclaimer-icon {
  flex: 0 0 auto;
  font-size: 15px;
  line-height: 1.5;
  color: #f5b84c;
}
.anlz-disclaimer p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(255,255,255,0.62);
}
.anlz-disclaimer strong { color: rgba(255,255,255,0.85); font-weight: 600; }
body.light-mode .anlz-disclaimer { background: rgba(245,184,76,0.1); }
body.light-mode .anlz-disclaimer p { color: rgba(0,0,0,0.6); }
body.light-mode .anlz-disclaimer strong { color: rgba(0,0,0,0.82); }

/* ── Editable assumptions panel (#5) ─────────────────────────── */
.anlz-asm-toggle {
  margin-left: auto;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.72);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.anlz-asm-toggle:hover, .anlz-asm-toggle.open {
  background: rgba(var(--primary-rgb),0.14);
  border-color: rgba(var(--primary-rgb),0.4);
  color: #c7d0ff;
}
.anlz-asm-panel {
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
}
.anlz-asm-head { font-size: 12.5px; color: rgba(255,255,255,0.5); margin-bottom: 14px; }
.anlz-asm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.anlz-asm-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.62);
}
.anlz-asm-field span { color: rgba(255,255,255,0.38); font-weight: 500; }
.anlz-asm-field input {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 7px;
  color: #e8ecf4;
  font-size: 14px;
  padding: 8px 10px;
  width: 100%;
}
.anlz-asm-field input:focus { outline: none; border-color: rgba(var(--primary-rgb),0.6); }
.anlz-asm-actions { display: flex; gap: 10px; margin-top: 14px; }
.anlz-asm-apply {
  background: linear-gradient(135deg, #6f86ff, #5a6fe0);
  border: none; color: #fff; font-weight: 600; font-size: 13px;
  padding: 9px 18px; border-radius: 8px; cursor: pointer;
}
.anlz-asm-reset {
  background: transparent; border: 1px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.6); font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: 8px; cursor: pointer;
}
.anlz-asm-apply:hover { filter: brightness(1.08); }
.anlz-asm-reset:hover { border-color: rgba(255,255,255,0.32); color: #e8ecf4; }
body.light-mode .anlz-asm-panel { background: rgba(0,0,0,0.02); border-color: rgba(0,0,0,0.08); }
body.light-mode .anlz-asm-field input { background: #fff; border-color: rgba(0,0,0,0.14); color: #1a1f2b; }
body.light-mode .anlz-asm-field, body.light-mode .anlz-asm-toggle { color: rgba(0,0,0,0.65); }

/* ── DCF sensitivity matrix (#3) ─────────────────────────────── */
.anlz-sens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 14px;
}
.anlz-sens-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-top: 2px solid var(--ac);
  border-radius: 10px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
}
.anlz-sens-sym { font-weight: 700; font-size: 15px; color: #e8ecf4; margin-bottom: 10px; }
.anlz-sens-cur { font-weight: 500; font-size: 11.5px; color: rgba(255,255,255,0.45); margin-left: 6px; }
.anlz-sens-scroll { overflow-x: auto; }
.anlz-sens-table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
.anlz-sens-table th {
  color: rgba(255,255,255,0.5); font-weight: 600; padding: 5px 6px; text-align: center; white-space: nowrap;
}
.anlz-sens-table th.sens-corner { color: rgba(255,255,255,0.35); font-size: 10.5px; text-align: left; }
.anlz-sens-table th.sens-wacc { text-align: right; padding-right: 8px; color: rgba(255,255,255,0.6); }
.anlz-sens-table td {
  text-align: center; padding: 6px 6px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.04);
}
.anlz-sens-table td strong { display: block; color: #f0f3fa; font-size: 12px; }
.anlz-sens-table td span { font-size: 10px; color: rgba(255,255,255,0.6); }
.anlz-sens-table td.sens-na { color: rgba(255,255,255,0.25); }
body.light-mode .anlz-sens-card { background: rgba(0,0,0,0.015); border-color: rgba(0,0,0,0.08); }
body.light-mode .anlz-sens-sym { color: #1a1f2b; }
body.light-mode .anlz-sens-table td strong { color: #1a1f2b; }
body.light-mode .anlz-sens-table th { color: rgba(0,0,0,0.5); }

/* ── Correlation & portfolio MC (#4) ─────────────────────────── */
.anlz-corr-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) 1.1fr;
  gap: 20px;
  margin-top: 14px;
  align-items: start;
}
.anlz-corr-table { border-collapse: collapse; font-size: 13px; }
.anlz-corr-table th { padding: 7px 10px; font-weight: 700; text-align: center; }
.anlz-corr-table th.corr-corner { background: transparent; }
.anlz-corr-table td {
  text-align: center; padding: 9px 12px; font-weight: 600; color: #e8ecf4;
  border: 1px solid rgba(255,255,255,0.05); border-radius: 4px; min-width: 52px;
}
.anlz-corr-table td.corr-diag { color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.03); }
.anlz-corr-hint { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 8px; max-width: 320px; line-height: 1.5; }
.anlz-port-stats { display: flex; flex-direction: column; gap: 12px; }
.anlz-port-stat {
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 3px solid #6f86ff;
  border-radius: 9px; padding: 12px 14px; background: rgba(255,255,255,0.02);
}
.anlz-port-stat span { display: block; font-size: 12px; color: rgba(255,255,255,0.5); margin-bottom: 4px; }
.anlz-port-stat strong { font-size: 19px; font-weight: 700; }
.anlz-port-stat small { display: block; font-size: 11.5px; color: rgba(255,255,255,0.45); margin-top: 4px; }
.anlz-port-stat .pos { color: #32d6a2; }
.anlz-port-stat .neg { color: #ff4d6d; }
.anlz-port-stat .neutral { color: #f5b84c; }
body.light-mode .anlz-corr-table td { color: #1a1f2b; }
body.light-mode .anlz-port-stat { background: rgba(0,0,0,0.015); border-color: rgba(0,0,0,0.08); }
@media (max-width: 720px) { .anlz-corr-grid { grid-template-columns: 1fr; } }

/* ═══════════════════════════════════════════════════════════════
   MOBILE APP EXPERIENCE  ≤ 480px
   Full-bleed layout, bigger KPI values, smooth scrollable tabs
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  /* ── Frame: remove outer padding for full-bleed feel ── */
  .dashboard-main {
    padding: 0;
    gap: 0;
  }

  .dashboard-content-shell {
    border-radius: 0;
    padding: 0;
    min-height: 100svh;
  }

  /* ── Topbar: compact, hide meta cards (already visible in sidebar) ── */
  .dashboard-topbar {
    padding: 16px 16px 0;
    margin-bottom: 16px;
  }

  .dashboard-topbar h1 {
    font-size: 1.35rem;
    letter-spacing: -0.02em;
  }

  .dashboard-topbar-meta {
    display: none;
  }

  /* ── Cards: smaller padding, tight radius ── */
  .dashboard-card {
    padding: 16px;
    border-radius: 18px;
  }

  /* ── Tracker: back button + portfolio name row ── */
  .tracker-dash-topbar {
    padding: 0 16px;
    margin-bottom: 14px;
    gap: 10px;
  }

  .tracker-back-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
    border-radius: 12px;
  }

  .tracker-dash-title {
    font-size: 1.45rem;
    letter-spacing: -0.025em;
  }

  /* ── KPI grid: larger values, better hierarchy ── */
  .tracker-kpi-grid {
    padding: 0 16px;
    gap: 10px;
    margin-bottom: 16px;
  }

  .summary-item {
    padding: 14px 12px;
    border-radius: 14px;
  }

  .summary-item span {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
  }

  .summary-item strong {
    font-size: 1.25rem;
    letter-spacing: -0.025em;
    line-height: 1.1;
  }

  .kpi-info-wrap {
    top: 8px;
    right: 8px;
  }

  /* ── Price status bar: styled as a pill card ── */
  .tracker-price-status-bar {
    margin: 0 16px 16px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    padding: 10px 14px;
  }

  .tracker-price-status-msg {
    font-size: 0.8rem;
  }

  .tracker-refresh-btn {
    padding: 10px 14px;
    font-size: 0.88rem;
    border-radius: 10px;
  }

  /* ── Tab navigation: horizontal scroll, no wrap, bigger touch targets ── */
  .tracker-tab-nav {
    margin-bottom: 20px;
  }

  .tracker-tab-btn {
    padding: 9px 18px;
    min-height: 44px;
    font-size: 0.88rem;
  }

  /* ── Tab panels: horizontal padding ── */
  .tracker-tab-panel {
    padding: 0 16px 20px;
  }

  /* ── Summary tab: stack main grid, bigger donut ── */
  .tracker-main-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .donut-wrap {
    flex-direction: column;
    align-items: center;
    gap: 18px;
    margin-top: 14px;
  }

  .donut-wrap canvas {
    width: 168px !important;
    height: 168px !important;
  }

  .donut-legend {
    width: 100%;
    gap: 10px;
  }

  .donut-legend-item {
    gap: 10px;
  }

  .donut-legend-ticker {
    font-size: 0.92rem;
  }

  .donut-legend-weight {
    font-size: 0.88rem;
  }

  /* ── Card headers: tighter ── */
  .card-header {
    margin-bottom: 12px;
    gap: 8px;
  }

  .card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
  }

  .card-header > span {
    font-size: 0.76rem;
  }

  /* ── Tables: more readable cells ── */
  .tracker-table-shell {
    margin-top: 12px;
    border-radius: 12px;
  }

  .tracker-table th,
  .tracker-table td {
    padding: 11px 10px;
    font-size: 0.84rem;
  }

  /* ── Positions section: full-width add button ── */
  .tracker-positions-section .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  #addPositionBtn {
    width: 100%;
    text-align: center;
    padding: 12px;
  }

  /* ── Desempeño tab: 2-col perf metrics, bigger values ── */
  .perf-metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .perf-metric-value {
    font-size: 1.55rem;
    letter-spacing: -0.03em;
  }

  .perf-metric-label {
    font-size: 0.72rem;
  }

  /* ── Holdings bar ── */
  .holdings-bar-wrap {
    margin-top: 10px;
  }

  /* ── Tracker list view ── */
  .tracker-list-header {
    padding: 0 16px;
  }

  #newPortfolioBtn {
    width: 100%;
    text-align: center;
    padding: 12px;
  }

  .portfolio-cards-grid {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  /* ── Modals: full-width friendly ── */
  .tracker-modal {
    padding: 22px 18px;
    border-radius: 22px;
  }

  .tracker-modal-backdrop {
    padding: 12px;
    align-items: flex-end;
  }

  .tracker-modal {
    border-radius: 22px 22px 16px 16px;
  }

  /* ── MC / VaR buttons: wrap nicely ── */
  .var-conf-btns,
  .mc-year-nav {
    flex-wrap: wrap;
    gap: 6px;
  }

  .var-conf-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  /* ── Performance chart period buttons ── */
  .perf-period-nav {
    gap: 4px;
    flex-wrap: wrap;
  }

  .perf-period-btn {
    padding: 6px 11px;
    font-size: 0.78rem;
  }

  /* ── Markets section on mobile ── */
  .market-workspace {
    grid-template-columns: 1fr;
  }
  /* Watchlist becomes a horizontal scrollable strip instead of hidden */
  .market-wl-sidebar {
    position: static;
    max-height: none;
    margin: 0 16px;
    flex-direction: column;
  }
  .market-wl-sidebar .market-wl-items {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    scrollbar-width: none;
  }
  .market-wl-sidebar .market-wl-items::-webkit-scrollbar { display: none; }
  .market-wl-sidebar .market-wl-item {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 110px;
    border-bottom: 0;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 8px 10px;
  }
  .market-wl-sidebar .market-wl-right {
    flex-direction: row;
    gap: 6px;
    align-items: baseline;
  }
  .market-wl-sidebar .market-wl-empty { padding: 12px; }
  .market-wl-sidebar .market-wl-rm { opacity: 1; top: 6px; right: 6px; transform: none; }
  .market-toolbar {
    flex-direction: column;
    padding: 12px;
    gap: 10px;
    border-radius: 0;
    margin: 0 16px;
    border-radius: 16px;
  }

  .market-search-shell,
  .market-menu-group,
  .market-menu-group-wide {
    width: 100%;
  }

  .market-input-pill,
  .market-menu-button {
    width: 100%;
  }

  .market-chart {
    height: 380px;
  }

  /* ── Allocation row (Desempeño) ── */
  .allocation-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* ══════════════════════════════════════════════════════════════════
   LIGHT MODE — Comprehensive fixes for hardcoded dark colors
   ══════════════════════════════════════════════════════════════════ */

/* ── Sidebar & topbar controls ─────────────────────────────────────── */
body.light-mode .sidebar-toggle-btn,
body.light-mode .sidebar-close-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.09);
}
body.light-mode .sidebar-toggle-btn:hover,
body.light-mode .sidebar-close-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* ── Plan toast & upgrade overlay ──────────────────────────────────── */
body.light-mode .plan-toast {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(var(--primary-rgb), 0.28);
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
body.light-mode .plan-upgrade-overlay {
  background: rgba(240, 242, 248, 0.82);
}
body.light-mode .plan-upgrade-card {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.12);
}

/* ── Tracker table ──────────────────────────────────────────────────── */
body.light-mode .tracker-table-shell {
  border-color: rgba(0, 0, 0, 0.07);
}
body.light-mode .tracker-table {
  background: rgba(0, 0, 0, 0.01);
}
body.light-mode .tracker-table th {
  color: #3a4060;
  background: rgba(0, 0, 0, 0.025);
}
body.light-mode .tracker-table th,
body.light-mode .tracker-table td {
  border-bottom-color: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
body.light-mode .tracker-table td {
  color: var(--text);
}

/* ── Portfolio cards ────────────────────────────────────────────────── */
body.light-mode .portfolio-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 250, 255, 0.98));
  border-color: rgba(0, 0, 0, 0.07);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.07);
}
body.light-mode .portfolio-card:hover {
  border-color: rgba(var(--primary-rgb), 0.28);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(var(--primary-rgb), 0.1);
}
body.light-mode .portfolio-card-delete,
body.light-mode .portfolio-rename-btn,
body.light-mode .pos-delete-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
body.light-mode .portfolio-card-meta {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}
body.light-mode .tracker-back-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
body.light-mode .portfolio-rename-input {
  background: rgba(var(--primary-rgb), 0.04);
  border-color: rgba(var(--primary-rgb), 0.4);
}

/* ── Tracker empty state ────────────────────────────────────────────── */
body.light-mode .tracker-empty-state svg {
  stroke: rgba(0, 0, 0, 0.18);
}

/* ── Company info panel ─────────────────────────────────────────────── */
body.light-mode .company-info-panel {
  background: rgba(248, 250, 255, 0.99);
}
body.light-mode .company-info-header {
  border-bottom-color: rgba(0, 0, 0, 0.07);
}
body.light-mode .company-info-header h2 {
  color: var(--text);
}
body.light-mode .company-info-header .company-meta-tag {
  background: rgba(var(--primary-rgb), 0.08);
  border-color: rgba(var(--primary-rgb), 0.18);
  color: #4a5cc0;
}
body.light-mode .company-stat-card {
  background: rgba(0, 0, 0, 0.025);
  border-color: rgba(0, 0, 0, 0.06);
}
body.light-mode .company-stat-label {
  color: var(--muted);
}
body.light-mode .company-stat-value {
  color: var(--text);
}
body.light-mode .company-description h3 {
  color: var(--text);
}
body.light-mode .company-description p {
  color: var(--muted);
}
body.light-mode .company-logo {
  background: rgba(0, 0, 0, 0.05);
}
body.light-mode .company-info-animation {
  background: rgba(240, 242, 248, 0.96);
  border-color: rgba(0, 0, 0, 0.07);
}

/* ── Fair-value section (fv-*) ──────────────────────────────────────── */
body.light-mode .fv-section {
  background: rgba(248, 250, 255, 0.95);
  border-color: rgba(var(--primary-rgb), 0.15);
}
body.light-mode .fv-header h3,
body.light-mode .fv-kpi-value {
  color: var(--text);
}
body.light-mode .fv-kpi-sep {
  border-left-color: rgba(0, 0, 0, 0.08);
}
body.light-mode .fv-bar-current {
  color: #2a3060;
}
body.light-mode .fv-bar-track {
  background: rgba(0, 0, 0, 0.08);
}
body.light-mode .fv-bar-dot {
  background: #3a4070;
  border-color: rgba(255, 255, 255, 0.7);
}
body.light-mode .fv-row-name {
  color: var(--text);
}

/* ── Bond details ───────────────────────────────────────────────────── */
body.light-mode .bond-row {
  background: rgba(0, 0, 0, 0.025);
  border-color: rgba(0, 0, 0, 0.06);
}
body.light-mode .bond-badge {
  background: rgba(var(--primary-rgb), 0.1);
  color: #4a5cc0;
  border-color: rgba(var(--primary-rgb), 0.25);
}

/* ── Financials tables ──────────────────────────────────────────────── */
body.light-mode .financials-header h3 {
  color: var(--text);
}
body.light-mode .fin-period-toggle {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(var(--primary-rgb), 0.15);
}
body.light-mode .fin-period.active {
  background: rgba(var(--primary-rgb), 0.15);
  color: #3b4cb8;
}
body.light-mode .fin-tab {
  color: var(--muted);
  border-color: rgba(var(--primary-rgb), 0.18);
}
body.light-mode .fin-tab.active {
  background: rgba(var(--primary-rgb), 0.12);
  border-color: rgba(var(--primary-rgb), 0.35);
  color: #3b4cb8;
}
body.light-mode .fin-table thead th {
  color: var(--muted);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}
body.light-mode .fin-table tbody tr {
  border-bottom-color: rgba(0, 0, 0, 0.04);
}
body.light-mode .fin-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.025);
}
body.light-mode .fin-table tbody td {
  color: var(--text);
}
body.light-mode .fin-row-label {
  color: rgba(30, 40, 80, 0.7) !important;
}
body.light-mode .fin-row-bold td,
body.light-mode .fin-row-bold .fin-row-label {
  color: var(--text) !important;
}
body.light-mode .fin-th-ttm {
  color: #4a5cc0 !important;
}
body.light-mode .fin-note {
  color: rgba(0, 0, 0, 0.38);
}
body.light-mode .fin-null {
  color: rgba(0, 0, 0, 0.2);
}
body.light-mode .fin-eps {
  color: var(--text);
}

/* ── ETF tooltip ────────────────────────────────────────────────────── */
body.light-mode .etf-tooltip {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(var(--primary-rgb), 0.2);
  color: #1a1d2e;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* ── Markowitz section ──────────────────────────────────────────────── */
body.light-mode .mkw-ticker-input {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text);
}
body.light-mode .mkw-asset-chip {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}
body.light-mode .mkw-chip-label {
  color: var(--text);
}
body.light-mode .mkw-chip-remove {
  color: rgba(0, 0, 0, 0.3);
}
body.light-mode .mkw-fi-section {
  background: rgba(0, 0, 0, 0.025);
  border-color: rgba(0, 0, 0, 0.08);
}
body.light-mode .mkw-fi-toggle {
  color: var(--text);
}
body.light-mode .mkw-fi-field label {
  color: var(--muted);
}
body.light-mode .mkw-fi-field input {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text);
}
body.light-mode .mkw-fi-note {
  color: rgba(0, 0, 0, 0.4);
}
body.light-mode .mkw-info-text {
  color: var(--muted);
}
body.light-mode .mkw-presets-label,
body.light-mode .mkw-asset-count,
body.light-mode .mkw-rfr-label {
  color: rgba(0, 0, 0, 0.4);
}
body.light-mode .mkw-preset-btn {
  color: #3b4cb8;
  border-color: rgba(var(--primary-rgb), 0.22);
}
body.light-mode .mkw-preset-btn:hover {
  color: #2a3598;
}
body.light-mode .mkw-empty-assets {
  color: rgba(0, 0, 0, 0.3);
}

/* ── Seasonality ─────────────────────────────────────────────────────── */
body.light-mode .seas-view-btn.active,
body.light-mode .seas-period-btn.active {
  background: rgba(var(--primary-rgb), 0.15);
  color: #3b4cb8;
}
body.light-mode .seas-tooltip {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(var(--primary-rgb), 0.18);
  color: #1a1d2e;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}
body.light-mode .seas-tt-label {
  color: rgba(40, 50, 100, 0.45);
}
body.light-mode .seas-avg-col {
  background: rgba(255, 209, 102, 0.04);
}
body.light-mode .seas-total-row td {
  border-top-color: rgba(0, 0, 0, 0.08);
}

/* ── KPI tooltip ─────────────────────────────────────────────────────── */
body.light-mode .kpi-info-wrap .kpi-tooltip {
  background: #fff;
  border-color: rgba(var(--primary-rgb), 0.2);
  color: #3a4060;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ── Var confidence buttons ──────────────────────────────────────────── */
body.light-mode .var-conf-btn {
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--muted);
}

/* ── Perf info popup light extras ────────────────────────────────────── */
body.light-mode .perf-info-popup-title {
  color: #6070b0;
}
body.light-mode .perf-info-values {
  border-color: rgba(0, 0, 0, 0.06);
}
body.light-mode .perf-info-row {
  border-bottom-color: rgba(0, 0, 0, 0.04);
}
body.light-mode .perf-info-row:hover {
  background: rgba(0, 0, 0, 0.02);
}
body.light-mode .perf-info-row-label {
  color: rgba(40, 50, 90, 0.6);
}
body.light-mode .perf-info-result {
  color: #4a5cc0;
}
body.light-mode .perf-info-note {
  color: rgba(40, 50, 90, 0.45);
}
body.light-mode .perf-beta-table th {
  color: rgba(40, 50, 90, 0.55);
  border-bottom-color: rgba(0, 0, 0, 0.07);
}
body.light-mode .perf-beta-table td {
  border-bottom-color: rgba(0, 0, 0, 0.04);
  color: var(--text);
}
body.light-mode .perf-beta-table tbody tr:hover td {
  background: rgba(0, 0, 0, 0.025);
}
body.light-mode .perf-beta-table tfoot td {
  border-top-color: rgba(0, 0, 0, 0.08);
  color: #4a5cc0;
}

/* ── Perf info popup header border ───────────────────────────────────── */
body.light-mode .perf-info-popup-header {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

/* ── Market chart loader ──────────────────────────────────────────────── */
body.light-mode .market-chart-loader {
  background: linear-gradient(180deg, rgba(240, 243, 250, 0.97), rgba(235, 238, 248, 0.99));
}

/* ── Hero KPI cards in dashboard ──────────────────────────────────────── */
body.light-mode .hero-kpi-card {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}

/* ── Tracker tab buttons ──────────────────────────────────────────────── */
body.light-mode .tracker-tab-nav {
  background: rgba(15, 23, 42, 0.07);
}
body.light-mode .tracker-tab-btn {
  /* 0.45 daba 2.9:1 sobre blanco en texto de 14px */
  color: rgba(15, 23, 42, 0.62);
}
body.light-mode .tracker-tab-btn:hover {
  color: rgba(15, 23, 42, 0.85);
}
body.light-mode .tracker-tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

/* ── Perf period & var buttons ────────────────────────────────────────── */
body.light-mode .perf-period-btn {
  border-color: rgba(0, 0, 0, 0.1);
}

/* Blanco sobre --primary (#6f86ff) da 3.2:1; en claro se usa un azul más
   profundo para el estado activo (~6.8:1) sin cambiar el token global. */
body.light-mode .perf-period-btn.active {
  background: #3f4fbf;
  border-color: #3f4fbf;
  color: #fff;
}

/* ── Ticker suggestion item additional ───────────────────────────────── */
body.light-mode .ticker-logo-wrap {
  background: rgba(0, 0, 0, 0.05);
}

/* ── Modal backdrop in light mode ────────────────────────────────────── */
body.light-mode .tracker-modal-backdrop {
  background: rgba(20, 22, 40, 0.45);
}

/* ── Hub widget additional ───────────────────────────────────────────── */
body.light-mode .hw-cal-title {
  color: #1e293b;
}
body.light-mode .hw-cal-date {
  background: rgba(var(--primary-rgb), 0.1);
  color: #4a5cc0;
}

/* ── Dashboard topbar title ──────────────────────────────────────────── */
body.light-mode .dashboard-topbar h1 {
  color: var(--text);
}
body.light-mode .dashboard-hero-card h2 {
  color: var(--text);
}

/* ── Company info panel close/back ───────────────────────────────────── */
body.light-mode .indicator-backdrop {
  background: rgba(30, 35, 60, 0.45);
}
body.light-mode .indicator-close-btn {
  color: rgba(20, 30, 60, 0.5);
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.07);
}
body.light-mode .indicator-close-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #1a1d2e;
  border-color: rgba(0, 0, 0, 0.14);
}

/* ── Portfolio summary widget ──────────────────────────────────────────── */
.hub-widget-body.hw-portfolio-body {
  display: flex; flex-direction: column; gap: 0;
  padding: 16px 18px 14px;
}

.hw-pb-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.hw-pb-label {
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.55);
}
body.light-mode .hw-pb-label { color: rgba(15,23,42,0.45); }

.hw-pb-sel {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 4px 10px;
  color: inherit; font-size: 11px; font-family: inherit;
  cursor: pointer; max-width: 160px;
}
.hw-pb-sel:focus { outline: none; border-color: rgba(var(--primary-rgb),0.5); }
body.light-mode .hw-pb-sel { background: rgba(15,23,42,0.05); border-color: rgba(15,23,42,0.12); color: #1e293b; }

.hw-pb-amount-row {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 16px;
}
.hw-pb-amount {
  font-size: 28px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
body.light-mode .hw-pb-amount { color: #0f172a; }
.hw-pb-return {
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.hw-pb-return.pos { color: #00c894; }
.hw-pb-return.neg { color: #ff4d6a; }

.hw-pb-bar {
  display: flex; gap: 3px; height: 8px; border-radius: 6px;
  overflow: hidden; margin-bottom: 14px; flex-shrink: 0;
}
.hw-pb-bar-seg { border-radius: 4px; min-width: 3px; transition: opacity 0.15s; }
.hw-pb-bar-seg:hover { opacity: 0.8; cursor: default; }

.hw-pb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  align-content: flex-start;
}
.hw-pb-grid-item {
  display: flex; flex-direction: column; gap: 1px; min-width: 44px;
}
.hw-pb-grid-ticker {
  font-size: 11px; font-weight: 500;
  color: rgba(255,255,255,0.5); white-space: nowrap;
}
body.light-mode .hw-pb-grid-ticker { color: rgba(15,23,42,0.45); }
.hw-pb-grid-pct {
  font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1;
}

/* Tooltip over bar segments */
.hw-pb-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: rgba(10,10,18,0.96);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 20;
}
.hw-pb-tip.visible { opacity: 1; }
body.light-mode .hw-pb-tip { background: #fff; border-color: rgba(15,23,42,0.12); }

.hw-pb-empty { font-size: 11px; color: rgba(255,255,255,0.35); }
body.light-mode .hw-pb-empty { color: rgba(15,23,42,0.35); }

/* ── Mobile touch-target polish ──────────────────────────────────────────────
   Placed at end of file so these override the compact base button styles
   defined earlier (media queries do not add specificity). */
@media (max-width: 640px) {
  .mkw-preset-btn,
  .td-period-btn {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .anlz-add-btn {
    padding-top: 9px;
    padding-bottom: 9px;
  }
}

/* ── Settings Enhancements ────────────────────────────────────────────────── */

/* Active button state for lang & currency selectors */
.settings-overview-card {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.45fr);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 18px;
  overflow: hidden;
  position: relative;
}

.settings-overview-card::before,
.settings-security-center::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 12% 10%, rgba(var(--primary-rgb), 0.2), transparent 34%),
              radial-gradient(circle at 88% 20%, rgba(var(--accent-rgb), 0.13), transparent 30%);
  pointer-events: none;
}

.settings-overview-copy,
.settings-overview-grid,
.settings-security-center > * {
  position: relative;
  z-index: 1;
}

.settings-kicker {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(var(--primary-rgb), 0.28);
  background: rgba(var(--primary-rgb), 0.1);
  color: #9fb0ff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* #9fb0ff sobre el fondo lavanda claro daba 1.9:1 */
body.light-mode .settings-kicker {
  color: #3f4fbf;
  border-color: rgba(var(--primary-rgb), 0.38);
}

.settings-overview-copy h2 {
  margin: 0 0 10px;
  font-size: clamp(1.55rem, 2.4vw, 2.2rem);
  letter-spacing: -0.035em;
}

.settings-overview-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  max-width: 48ch;
}

.settings-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.settings-overview-metric {
  min-width: 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
}

.settings-overview-metric--accent {
  border-color: rgba(var(--primary-rgb), 0.34);
  background: linear-gradient(145deg, rgba(var(--primary-rgb), 0.16), rgba(var(--accent-rgb), 0.07));
}

.settings-overview-metric span,
.settings-overview-metric small {
  display: block;
  color: var(--muted);
}

.settings-overview-metric span {
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-overview-metric strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.02rem;
}

.settings-overview-metric small {
  margin-top: 8px;
  font-size: 0.76rem;
}

.settings-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  padding: 6px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
  width: fit-content;
  max-width: 100%;
}

.settings-tab {
  border: 0;
  border-radius: 14px;
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.settings-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.settings-tab.active {
  color: var(--text);
  background: rgba(var(--primary-rgb), 0.2);
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.22);
}

.settings-grid > .dashboard-card {
  display: none;
}

.settings-grid.settings-view-account > .dashboard-card:nth-of-type(2),
.settings-grid.settings-view-account > .dashboard-card:nth-of-type(3),
.settings-grid.settings-view-security > .dashboard-card:nth-of-type(1),
.settings-grid.settings-view-security > .dashboard-card:nth-of-type(4),
.settings-grid.settings-view-security > .dashboard-card:nth-of-type(5),
.settings-grid.settings-view-security > .dashboard-card:nth-of-type(8),
.settings-grid.settings-view-security > .dashboard-card:nth-of-type(9),
.settings-grid.settings-view-preferences > .dashboard-card:nth-of-type(4),
.settings-grid.settings-view-preferences > .dashboard-card:nth-of-type(6),
.settings-grid.settings-view-preferences > .dashboard-card:nth-of-type(7),
.settings-grid.settings-view-investor > .dashboard-card:nth-of-type(10) {
  display: block;
}

.settings-grid.settings-view-security > .dashboard-card:nth-of-type(4) {
  border-color: rgba(255,140,164,0.2);
}

.settings-security-center {
  position: relative;
  overflow: hidden;
  border-color: rgba(var(--primary-rgb), 0.2);
}

.security-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.security-score-row strong {
  display: block;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.06em;
}

.security-level-pill {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  background: rgba(var(--primary-rgb), 0.1);
  color: #9fb0ff;
  font-size: 0.78rem;
  font-weight: 800;
}

.security-checklist {
  display: grid;
  gap: 10px;
}

.security-check-item {
  display: flex;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
}

.security-check-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 5px rgba(250,176,5,0.12);
}

.security-check-item.is-ok .security-check-dot {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(74,222,128,0.12);
}

.security-check-item strong,
.security-check-item small {
  display: block;
}

.security-check-item small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.settings-status-copy {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.settings-grid .dashboard-card {
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.settings-grid .dashboard-card:hover {
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 18px 50px rgba(0,0,0,0.18);
}

.settings-lang-note {
  margin: 0 0 12px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.button.lang-btn {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
  color: var(--text);
}
.button.lang-btn:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.14);
}
.button.lang-btn.active,
.button.lang-btn[data-currency].active {
  background: rgba(var(--primary-rgb), 0.18);
  border-color: rgba(var(--primary-rgb), 0.5);
  color: var(--text);
}

/* Email verified badge */
.settings-verified-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.settings-verified-badge.hidden { display: none; }
.settings-verified-badge--ok {
  background: rgba(74, 222, 128, 0.14);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.25);
}
.settings-verified-badge--warn {
  background: rgba(250, 176, 5, 0.12);
  color: #fab005;
  border: 1px solid rgba(250, 176, 5, 0.25);
}
.settings-resend-verify {
  margin-top: 6px;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--primary, #6f86ff);
  border: 1px solid rgba(111, 134, 255, 0.35);
  transition: background 0.2s, border-color 0.2s;
}
.settings-resend-verify:hover { background: rgba(111, 134, 255, 0.12); }
.settings-resend-verify:disabled { opacity: 0.5; cursor: default; }
.settings-resend-verify.hidden { display: none; }

/* Profile name editing row */
.settings-name-row {
  margin: 14px 0 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 14px;
}
.settings-name-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-name-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.settings-edit-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 0.82rem;
}

/* Plan billing actions */
.settings-billing-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.settings-billing-actions .button { flex: 1; min-width: 120px; }

/* Active sessions list */
.active-sessions-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}
.session-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.session-item--current {
  border-color: rgba(var(--primary-rgb), 0.2);
  background: rgba(var(--primary-rgb), 0.05);
}
.session-item-icon {
  flex-shrink: 0;
  color: var(--muted);
}
.session-item-info {
  flex: 1;
  display: grid;
  gap: 2px;
}
.session-item-info strong { font-size: 0.9rem; }
.session-item-info span { font-size: 0.78rem; color: var(--muted); }
.session-time { font-size: 0.74rem !important; }
.session-active-dot {
  flex-shrink: 0;
  font-size: 0.74rem;
  color: #4ade80;
  white-space: nowrap;
}
.settings-danger-btn { color: #ff8ca4 !important; border-color: rgba(255,140,164,0.3) !important; width: 100%; }
.settings-danger-btn:hover { border-color: rgba(255,140,164,0.6) !important; }

/* Small muted note under cards */
.settings-note {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 12px 0 0;
  line-height: 1.5;
}

/* Activity log — full-width card */
.settings-activity-card {
  grid-column: span 2;
}
.activity-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.activity-log-table th,
.activity-log-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.activity-log-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.activity-log-table tr:last-child td { border-bottom: 0; }
.activity-status-ok { color: #4ade80; font-size: 0.78rem; }
.activity-log-empty { color: var(--muted); font-size: 0.85rem; }

/* Light mode overrides */
body.light-mode .session-item {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
}
body.light-mode .session-item--current {
  background: rgba(var(--primary-rgb), 0.05);
  border-color: rgba(var(--primary-rgb), 0.18);
}
body.light-mode .activity-log-table th,
body.light-mode .activity-log-table td {
  border-color: rgba(0,0,0,0.06);
}
body.light-mode .settings-name-row {
  border-top-color: rgba(0,0,0,0.08);
}
body.light-mode .settings-overview-card,
body.light-mode .settings-security-center,
body.light-mode .settings-tabs,
body.light-mode .settings-overview-metric,
body.light-mode .security-check-item {
  border-color: rgba(15, 23, 42, 0.08);
  background-color: rgba(255,255,255,0.74);
}
body.light-mode .settings-tab:hover {
  background: rgba(15,23,42,0.04);
}
body.light-mode .settings-tab.active {
  background: rgba(var(--primary-rgb), 0.12);
}
body.light-mode .button.lang-btn {
  background: rgba(15,23,42,0.035);
  border-color: rgba(15,23,42,0.08);
}
body.light-mode .button.lang-btn:hover {
  background: rgba(15,23,42,0.06);
}

@media (max-width: 860px) {
  .settings-activity-card { grid-column: span 1; }
  .settings-overview-card,
  .settings-overview-grid {
    grid-template-columns: 1fr;
  }
  .settings-tabs {
    width: 100%;
  }
  .settings-tab {
    flex: 1;
  }
}

@media (max-width: 640px) {
  .settings-overview-grid {
    gap: 10px;
  }
  .settings-tabs {
    overflow-x: auto;
  }
  .settings-tab {
    min-width: 120px;
  }
  .security-score-row {
    align-items: start;
    flex-direction: column;
  }
}

/* ════════════════ Mejoras Tracker (L1 + L2) ════════════════ */

/* Toast genérico con acción (deshacer / validación) — L2.1, L1.6 */
.app-toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(12, 14, 28, 0.97);
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  color: var(--text);
  padding: 0.7rem 1.2rem;
  border-radius: 14px;
  font-size: 0.875rem;
  z-index: 10000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  animation: toastIn 0.25s ease;
  max-width: min(92vw, 460px);
}
.app-toast--error  { border-color: rgba(248, 113, 113, 0.55); }
.app-toast--success { border-color: rgba(74, 222, 128, 0.5); }
.app-toast--info   { border-color: rgba(var(--primary-rgb), 0.5); }
.app-toast--warn   { border-color: rgba(251, 191, 36, 0.55); }
.app-toast-action {
  background: rgba(var(--primary-rgb), 0.2);
  border: 1px solid rgba(var(--primary-rgb), 0.4);
  color: var(--accent, #6f86ff);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.32rem 0.8rem;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.app-toast-action:hover { background: rgba(var(--primary-rgb), 0.34); }
body.light-mode .app-toast { background: rgba(255,255,255,0.98); color: #1a1d2e; }

/* Botón gestionar efectivo + nota de alcance en KPIs — L1.10, L1.7 */
.kpi-cash-btn {
  margin-left: 8px;
  background: rgba(var(--primary-rgb), 0.16);
  border: 1px solid rgba(var(--primary-rgb), 0.32);
  color: var(--accent, #6f86ff);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 7px;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s ease;
}
.kpi-cash-btn:hover { background: rgba(var(--primary-rgb), 0.3); }

/* Toggle de operación de efectivo — L1.10 */
.cash-op-toggle { display: flex; gap: 0.5rem; }
.cash-op-btn {
  flex: 1;
  padding: 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--muted, #aeb6d6);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cash-op-btn.active {
  background: rgba(var(--primary-rgb), 0.2);
  border-color: rgba(var(--primary-rgb), 0.45);
  color: var(--text);
}

/* Badges de transacciones de efectivo — L1.10 */
.tx-deposit  { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.tx-withdraw { background: rgba(245, 184, 76, 0.15); color: #f5b84c; }
body.light-mode .tx-deposit  { background: rgba(22, 163, 74, 0.12); color: #16a34a; }
body.light-mode .tx-withdraw { background: rgba(202, 138, 4, 0.12); color: #ca8a04; }

/* Toggle base del donut — L2.3 */
.donut-base-toggle { display: inline-flex; gap: 2px; background: rgba(255,255,255,0.05); border-radius: 8px; padding: 2px; }
.donut-base-btn {
  border: none;
  background: transparent;
  color: var(--muted, #aeb6d6);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.donut-base-btn.active { background: rgba(var(--primary-rgb), 0.28); color: var(--text); }

/* ── Toggle de periodo del retorno por posición (P1.1) ─────────────────────── */
.pos-return-period-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: -4px 0 12px;
}
.pos-period-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
}
.pos-period-btn {
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted, #aeb6d6);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pos-period-btn.active { background: rgba(var(--primary-rgb), 0.28); color: var(--text); }
body.light-mode .pos-period-btn { background: rgba(0, 0, 0, 0.04); }

/* Búsqueda de posiciones — L2.2 */
.positions-header-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.positions-search {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 9px;
  color: var(--text);
  font-size: 0.82rem;
  padding: 0.4rem 0.7rem;
  width: 160px;
  outline: none;
  transition: border-color 0.15s ease;
}
.positions-search:focus { border-color: rgba(var(--primary-rgb), 0.5); }

/* Encabezados ordenables — L2.2 */
.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sortable:hover { color: var(--text); }
.th-sortable::after { content: "⇅"; opacity: 0.3; margin-left: 4px; font-size: 0.8em; }
.th-sortable.sort-asc::after  { content: "↑"; opacity: 0.9; }
.th-sortable.sort-desc::after { content: "↓"; opacity: 0.9; }

/* Indicador de frescura de precio — L2.10 */
.price-fresh-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.price-fresh-dot--fresh { background: #32d6a2; }
.price-fresh-dot--aging { background: #f5b84c; }
.price-fresh-dot--stale { background: #ff6b81; }

/* Spinner en línea para estados de carga — L2.5 */
.inline-spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(var(--primary-rgb), 0.25);
  border-top-color: var(--accent, #6f86ff);
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 6px;
  animation: inlineSpin 0.7s linear infinite;
}
@keyframes inlineSpin { to { transform: rotate(360deg); } }

/* Markets visual polish */
body:has(#section-markets.active) .dashboard-topbar {
  align-items: center;
  margin-bottom: 18px;
}
body:has(#section-markets.active) .dashboard-topbar h1 {
  font-size: 3rem;
  line-height: 0.98;
  letter-spacing: 0;
}
body:has(#section-markets.active) .profile-pill,
body:has(#section-markets.active) .plan-pill {
  min-height: 54px;
}

#section-markets {
  --mkt-panel: rgba(15, 17, 24, 0.9);
  --mkt-panel-strong: rgba(9, 10, 14, 0.96);
  --mkt-line: rgba(255, 255, 255, 0.08);
  --mkt-line-soft: rgba(255, 255, 255, 0.055);
  --mkt-hover: rgba(111, 134, 255, 0.13);
}

#section-markets .market-overview-row {
  align-items: stretch;
  gap: 12px;
  margin-bottom: 12px;
}
#section-markets .market-overview-bar {
  gap: 10px;
  margin: 0;
  padding: 2px 2px 8px;
  scroll-padding-inline: 2px;
}
#section-markets .mkt-index-tile {
  min-width: 150px;
  min-height: 58px;
  padding: 9px 54px 9px 12px;
  border-color: var(--mkt-line);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    var(--mkt-panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
#section-markets .mkt-index-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--primary-rgb), 0.32);
  background:
    linear-gradient(145deg, rgba(var(--primary-rgb), 0.13), rgba(255, 255, 255, 0.035)),
    var(--mkt-panel);
}
#section-markets .mkt-index-label,
#section-markets .mkt-index-chg {
  font-size: 0.72rem;
}
#section-markets .mkt-index-price {
  font-size: 0.9rem;
  line-height: 1.1;
}
#section-markets .mkt-index-spark {
  right: 10px;
  width: 42px;
  height: 24px;
  opacity: 0.92;
}
#section-markets .fng-gauge {
  width: 54px;
  min-height: 44px;
  border-radius: 14px;
  border-color: var(--mkt-line);
  background: var(--mkt-panel);
}
#section-markets .market-updated {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}

#section-markets .market-workspace {
  grid-template-columns: minmax(186px, 210px) minmax(0, 1fr) minmax(210px, 236px);
  gap: 12px;
  align-items: start;
}
#section-markets .market-main-col {
  min-width: 0;
  gap: 10px;
}

#section-markets .market-toolbar {
  gap: 10px;
  row-gap: 8px;
  padding: 12px 14px;
  border-color: var(--mkt-line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)),
    var(--mkt-panel-strong);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}
#section-markets .market-search-shell {
  flex: 1 1 320px;
  max-width: 420px;
  min-width: min(320px, 100%);
}
#section-markets .market-input-pill {
  min-height: 42px;
  padding: 0 9px 0 14px;
  border-color: var(--mkt-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}
#section-markets .market-input-pill:focus-within {
  border-color: rgba(var(--primary-rgb), 0.45);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}
#section-markets .range-segmented {
  min-height: 38px;
  padding: 3px;
  border-color: var(--mkt-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
}
#section-markets .range-btn {
  min-height: 30px;
  border-radius: 10px;
}
#section-markets .market-input-action,
#section-markets .market-circle-button,
#section-markets .market-menu-button,
#section-markets .chart-fullscreen-btn {
  min-height: 38px;
  border-radius: 12px;
}
#section-markets .market-circle-button,
#section-markets .market-input-action,
#section-markets .chart-fullscreen-btn {
  width: 38px;
  height: 38px;
}
#section-markets .market-menu-button {
  padding: 9px 12px;
}
#section-markets .market-menu-button.wide-button {
  min-width: 158px;
}
#section-markets .market-divider {
  height: 34px;
  opacity: 0.55;
}

#section-markets .market-chart-shell {
  border-color: rgba(255, 255, 255, 0.095);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.01)),
    #121722;
  box-shadow: 0 22px 62px rgba(0, 0, 0, 0.32);
}
#section-markets .market-chart-header {
  padding: 12px 18px;
  border-bottom-color: rgba(255, 255, 255, 0.07);
  background: linear-gradient(180deg, rgba(38, 44, 66, 0.96), rgba(29, 34, 49, 0.96));
}
#section-markets .market-chart-header strong {
  font-size: 1.05rem;
  letter-spacing: 0;
}
#section-markets .chart-price-label {
  font-size: 1rem;
}
#section-markets .chart-change-pct {
  border-radius: 8px;
}
#section-markets .chart-52w-track {
  background: rgba(255, 255, 255, 0.09);
}
#section-markets .market-chart-status {
  padding: 7px 18px 8px;
  border-bottom-color: rgba(255, 255, 255, 0.055);
  background: rgba(22, 26, 38, 0.95);
  color: var(--muted);
}
#section-markets .market-chart {
  height: min(68vh, 760px);
  min-height: 620px;
  background: #121722;
}

#section-markets .market-wl-sidebar,
#section-markets .market-stats-rail {
  top: 16px;
  border-color: var(--mkt-line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--mkt-panel-strong);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}
#section-markets .market-wl-head,
#section-markets .stats-rail-head {
  padding: 12px 14px 10px;
  border-bottom-color: var(--mkt-line-soft);
  background: rgba(255, 255, 255, 0.025);
  letter-spacing: 0.05em;
}
#section-markets .market-wl-items,
#section-markets .market-stats-rail {
  scrollbar-width: thin;
}
#section-markets .market-wl-item {
  min-height: 46px;
  gap: 8px;
  padding: 10px 14px;
  border-bottom-color: var(--mkt-line-soft);
}
#section-markets .market-wl-item:hover,
#section-markets .market-wl-item.active {
  background: var(--mkt-hover);
}
#section-markets .market-wl-sym {
  font-size: 0.82rem;
}
#section-markets .market-wl-price {
  font-size: 0.78rem;
}
#section-markets .market-wl-chg {
  min-width: 46px;
  text-align: right;
}

#section-markets .tech-rating-card {
  padding: 14px;
  border-bottom-color: var(--mkt-line-soft);
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.08), rgba(255, 255, 255, 0.015));
}
#section-markets .tr-badge {
  border-radius: 999px;
  padding: 5px 9px;
  box-shadow: 0 0 0 1px rgba(50, 214, 162, 0.14);
}
#section-markets .stats-rail-body {
  padding: 8px 6px 10px;
}
#section-markets .stats-rail-item {
  margin: 0;
  padding: 10px 8px;
  border-radius: 10px;
}
#section-markets .stats-rail-item:hover {
  background: rgba(255, 255, 255, 0.035);
}

#section-markets .ticker-news-section {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--mkt-line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012)),
    var(--mkt-panel-strong);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
}
#section-markets .ticker-news-title {
  margin: 0 0 14px;
  padding: 0;
  color: var(--text);
  letter-spacing: 0.05em;
}
#section-markets .news-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
#section-markets .news-card {
  min-height: 112px;
  border-color: var(--mkt-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}
#section-markets .news-card:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--primary-rgb), 0.28);
}
#section-markets .news-card-thumb {
  width: 82px;
  height: 58px;
  border-radius: 10px;
}

body.light-mode #section-markets {
  --mkt-panel: rgba(255, 255, 255, 0.92);
  --mkt-panel-strong: rgba(255, 255, 255, 0.96);
  --mkt-line: rgba(23, 31, 57, 0.11);
  --mkt-line-soft: rgba(23, 31, 57, 0.075);
  --mkt-hover: rgba(var(--primary-rgb), 0.11);
}
body.light-mode #section-markets .mkt-index-tile,
body.light-mode #section-markets .market-toolbar,
body.light-mode #section-markets .market-wl-sidebar,
body.light-mode #section-markets .market-stats-rail,
body.light-mode #section-markets .ticker-news-section {
  box-shadow: 0 18px 42px rgba(28, 36, 64, 0.08);
}
body.light-mode #section-markets .market-chart-shell {
  background: #f8faff;
  box-shadow: 0 18px 48px rgba(28, 36, 64, 0.1);
}
body.light-mode #section-markets .market-chart-header {
  background: linear-gradient(180deg, #ffffff, #f3f6ff);
}
body.light-mode #section-markets .market-chart-status,
body.light-mode #section-markets .market-chart {
  background: #f7f9ff;
}
body.light-mode #section-markets .chart-52w-track {
  background: rgba(23, 31, 57, 0.1);
}

@media (max-width: 1500px) {
  #section-markets .market-workspace {
    grid-template-columns: minmax(178px, 200px) minmax(0, 1fr) minmax(200px, 220px);
  }
  #section-markets .mkt-index-tile {
    min-width: 138px;
  }
  #section-markets .market-chart {
    height: min(65vh, 700px);
    min-height: 580px;
  }
}

@media (max-width: 1280px) {
  #section-markets .market-workspace {
    grid-template-columns: minmax(178px, 200px) minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  body:has(#section-markets.active) .dashboard-topbar {
    align-items: flex-start;
    gap: 12px;
  }
  #section-markets .market-overview-row {
    flex-direction: column;
  }
  #section-markets .market-workspace {
    grid-template-columns: 1fr;
  }
  #section-markets .market-wl-sidebar {
    position: relative;
    top: auto;
    max-height: 260px;
  }
  #section-markets .market-chart {
    height: 60vh;
    min-height: 500px;
  }
}

@media (max-width: 720px) {
  body:has(#section-markets.active) .dashboard-topbar h1 {
    font-size: 2.35rem;
  }
  #section-markets .market-toolbar {
    padding: 10px;
  }
  #section-markets .market-search-shell {
    flex-basis: 100%;
  }
  #section-markets .market-divider {
    display: none;
  }
  #section-markets .mkt-index-tile {
    min-width: 132px;
  }
  #section-markets .market-chart {
    height: 58vh;
    min-height: 420px;
  }
  #section-markets .ticker-news-section {
    padding: 14px;
  }
  #section-markets .news-list {
    grid-template-columns: 1fr;
  }
  #section-markets .news-card-thumb {
    width: 72px;
    height: 52px;
  }
}

/* Internal app UX polish */
.main-page {
  --app-surface: rgba(17, 18, 24, 0.86);
  --app-surface-strong: rgba(12, 13, 18, 0.94);
  --app-line: rgba(255, 255, 255, 0.09);
  --app-line-soft: rgba(255, 255, 255, 0.055);
  --app-hover: rgba(var(--primary-rgb), 0.12);
  --app-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  --app-radius: 18px;
}

.dashboard-content-shell {
  min-width: 0;
}

.dashboard-card,
.mini-status-card,
.summary-item,
.hero-kpi-card,
.tracker-kpi-hero,
.portfolio-card,
.anlz-card,
.mkw-method-block,
.hub-shell,
.hub-toolbar,
.hub-widget,
.settings-overview-card,
.settings-tabs {
  border-color: var(--app-line);
  box-shadow: var(--app-shadow);
}

.dashboard-card,
.mini-status-card,
.summary-item,
.hero-kpi-card,
.tracker-kpi-hero,
.anlz-card,
.mkw-method-block,
.hub-widget {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012)),
    var(--app-surface);
}

.dashboard-card {
  border-radius: var(--app-radius);
}

.dashboard-card:hover,
.tracker-kpi-hero:hover,
.anlz-card:hover,
.hub-widget:hover,
.mkw-method-block:hover {
  border-color: rgba(var(--primary-rgb), 0.22);
}

.card-header {
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--app-line-soft);
}

.card-header h2,
.card-header h3,
.tracker-dash-title,
.settings-overview-copy h2 {
  letter-spacing: 0;
  line-height: 1.08;
}

.card-header span,
.dashboard-copy,
.settings-overview-copy p,
.anlz-card-sub,
.mkw-info-text,
.topdown-heatmap-hint,
.td-regime-meta {
  color: rgba(226, 232, 255, 0.62);
}

.dashboard-topbar {
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}

.dashboard-topbar h1 {
  line-height: 0.98;
}

.dashboard-nav-item,
.button,
.tracker-export-btn,
.tracker-back-btn,
.hub-icon-btn,
.hub-widget-btn,
.market-menu-button,
.market-circle-button,
.td-period-btn,
.settings-tab,
.mkw-calc-tab,
.var-conf-btn {
  min-height: 40px;
}

.dashboard-nav-item,
.button,
.tracker-export-btn,
.tracker-back-btn,
.hub-icon-btn,
.market-menu-button,
.td-period-btn,
.settings-tab {
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.dashboard-nav-item:hover,
.button:hover,
.tracker-export-btn:hover,
.tracker-back-btn:hover,
.hub-icon-btn:hover,
.market-menu-button:hover,
.td-period-btn:hover,
.settings-tab:hover {
  transform: translateY(-1px);
}

.tracker-table-shell,
.mkw-weights-table-shell,
.td-ranking-table {
  border-color: var(--app-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.tracker-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(18, 21, 31, 0.96);
}

.tracker-table td,
.tracker-table th {
  vertical-align: middle;
}

.tracker-kpi-grid,
.summary-grid,
.topdown-macro-grid,
.settings-overview-grid,
.anlz-dcf-grid,
.anlz-mc-grid {
  gap: 12px;
}

.tracker-price-status-bar,
.market-chart-status,
.perf-chart-status,
.mkw-status {
  border-radius: 12px;
}

#section-topdown .topdown-layout {
  position: relative;
  max-width: none;
  padding: 0;
  gap: 16px;
  counter-reset: topdownStep;
}

#section-topdown .topdown-layout::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 20px;
  bottom: 20px;
  width: 1px;
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.55), rgba(50, 214, 162, 0.16), transparent);
  pointer-events: none;
}

#section-topdown .dashboard-card {
  position: relative;
  padding: 24px 24px 24px 58px;
}

#section-topdown .dashboard-card::before {
  counter-increment: topdownStep;
  content: "0" counter(topdownStep);
  position: absolute;
  left: 18px;
  top: 22px;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #dfe5ff;
  background: rgba(var(--primary-rgb), 0.22);
  border: 1px solid rgba(var(--primary-rgb), 0.36);
  box-shadow: 0 0 0 5px rgba(8, 9, 12, 0.9);
}

#section-topdown .topdown-macro-card::after,
#section-topdown .topdown-heatmap-card::after,
#section-topdown .topdown-scatter-card::after,
#section-topdown .topdown-flow-card::after,
#section-topdown .topdown-rotation-card::after {
  position: absolute;
  top: auto;
  bottom: 18px;
  right: 24px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(159, 176, 255, 0.55);
  pointer-events: none;
}

#section-topdown .topdown-macro-card::after { content: "Macro"; }
#section-topdown .topdown-heatmap-card::after { content: "Sectores"; }
#section-topdown .topdown-scatter-card::after { content: "Riesgo"; }
#section-topdown .topdown-flow-card::after { content: "Decision"; }
#section-topdown .topdown-rotation-card::after { content: "Ranking"; }

#section-topdown .td-macro-card,
#section-topdown .td-heatmap-cell,
#section-topdown .td-pick-card,
#section-topdown .td-flow-step {
  border-radius: 12px;
  border-color: var(--app-line);
  background: rgba(255, 255, 255, 0.035);
}

#section-topdown .topdown-flow {
  gap: 10px;
}

#section-topdown .td-flow-arrow {
  opacity: 0.75;
}

#section-topdown .topdown-heatmap-hint {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--app-line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

body.light-mode.main-page {
  --app-surface: rgba(255, 255, 255, 0.92);
  --app-surface-strong: rgba(255, 255, 255, 0.97);
  --app-line: rgba(18, 24, 42, 0.1);
  --app-line-soft: rgba(18, 24, 42, 0.07);
  --app-hover: rgba(var(--primary-rgb), 0.1);
  --app-shadow: 0 18px 48px rgba(23, 31, 57, 0.08);
}

body.light-mode .dashboard-card,
body.light-mode .mini-status-card,
body.light-mode .summary-item,
body.light-mode .hero-kpi-card,
body.light-mode .tracker-kpi-hero,
body.light-mode .anlz-card,
body.light-mode .mkw-method-block,
body.light-mode .hub-widget {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 255, 0.9)),
    var(--app-surface);
  border-color: var(--app-line);
  box-shadow: var(--app-shadow);
}

body.light-mode .dashboard-topbar {
  border-bottom-color: rgba(18, 24, 42, 0.07);
}

body.light-mode .card-header {
  border-bottom-color: var(--app-line-soft);
}

body.light-mode .card-header span,
body.light-mode .dashboard-copy,
body.light-mode .settings-overview-copy p,
body.light-mode .anlz-card-sub,
body.light-mode .mkw-info-text,
body.light-mode .topdown-heatmap-hint,
body.light-mode .td-regime-meta {
  color: rgba(30, 41, 59, 0.62);
}

body.light-mode .tracker-table th {
  background: rgba(246, 248, 255, 0.98);
}

body.light-mode #section-topdown .topdown-layout::before {
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.42), rgba(22, 163, 74, 0.16), transparent);
}

body.light-mode #section-topdown .dashboard-card::before {
  color: #344060;
  background: rgba(var(--primary-rgb), 0.12);
  border-color: rgba(var(--primary-rgb), 0.24);
  box-shadow: 0 0 0 5px rgba(246, 248, 255, 0.95);
}

body.light-mode #section-topdown .td-macro-card,
body.light-mode #section-topdown .td-heatmap-cell,
body.light-mode #section-topdown .td-pick-card,
body.light-mode #section-topdown .td-flow-step,
body.light-mode #section-topdown .topdown-heatmap-hint {
  background: rgba(15, 23, 42, 0.025);
  border-color: var(--app-line);
}

body.light-mode #section-topdown .td-macro-label,
body.light-mode #section-topdown .td-macro-sub,
body.light-mode #section-topdown .td-flow-body > span,
body.light-mode #section-topdown .td-flow-verdict,
body.light-mode #section-topdown .td-last-updated,
body.light-mode #section-topdown .td-scatter-legend {
  color: rgba(30, 41, 59, 0.55);
}

body.light-mode #section-topdown .td-macro-value,
body.light-mode #section-topdown .td-flow-body strong,
body.light-mode #section-topdown .td-pick-name {
  color: #172033;
}

:where(.main-page button, .main-page a, .main-page input, .main-page select, .main-page textarea, .main-page [tabindex]):focus-visible {
  outline: 2px solid rgba(var(--primary-rgb), 0.92);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(var(--primary-rgb), 0.16);
}

.main-page input,
.main-page select,
.main-page textarea {
  min-height: 40px;
}

@media (prefers-reduced-motion: reduce) {
  .main-page *,
  .main-page *::before,
  .main-page *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 1180px) {
  .dashboard-topbar {
    align-items: flex-start;
  }

  .dashboard-topbar-meta {
    grid-template-columns: 1fr;
    min-width: 210px;
  }

  .tracker-main-grid,
  .dashboard-grid,
  .topdown-layout,
  .anlz-dcf-grid,
  .anlz-mc-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .dashboard-content-shell {
    padding-inline: 18px;
  }

  .dashboard-topbar {
    gap: 14px;
    margin-bottom: 18px;
  }

  .dashboard-topbar h1 {
    font-size: 2.35rem;
  }

  .dashboard-topbar-meta {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-card,
  .dashboard-hero-card,
  .settings-overview-card,
  .hub-shell {
    padding: 18px;
  }

  #section-topdown .dashboard-card {
    padding: 22px 18px 18px 54px;
  }
}

@media (max-width: 640px) {
  .dashboard-content-shell {
    padding-inline: 12px;
  }

  .dashboard-topbar {
    padding-bottom: 12px;
  }

  .dashboard-topbar h1 {
    font-size: 2rem;
  }

  .dashboard-topbar-meta {
    grid-template-columns: 1fr;
  }

  .mini-status-card,
  .dashboard-card,
  .tracker-kpi-hero,
  .anlz-card {
    border-radius: 14px;
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .tracker-table th,
  .tracker-table td {
    padding: 11px 12px;
  }

  #section-topdown .topdown-layout::before {
    left: 14px;
  }

  #section-topdown .dashboard-card {
    padding-left: 48px;
  }

  #section-topdown .dashboard-card::before {
    left: 14px;
    width: 26px;
    height: 26px;
  }

  #section-topdown .topdown-macro-card::after,
  #section-topdown .topdown-heatmap-card::after,
  #section-topdown .topdown-scatter-card::after,
  #section-topdown .topdown-flow-card::after,
  #section-topdown .topdown-rotation-card::after {
    display: none;
  }
}

/* Investor profile */
.investor-profile-card {
  grid-column: 1 / -1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

.investor-profile-card .card-header {
  align-items: flex-start;
}

.investor-profile-card .card-header h3 {
  margin: 5px 0 0;
}

.investor-profile-status,
.investor-score-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(var(--primary-rgb), 0.28);
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.1);
  color: #9cabff;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}

.investor-profile-status.is-complete {
  border-color: rgba(39, 201, 156, 0.3);
  background: rgba(39, 201, 156, 0.1);
  color: #45ddb3;
}

.investor-profile-empty {
  padding: 28px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
  text-align: center;
}

.investor-profile-empty h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1.05rem;
}

.investor-profile-empty p {
  max-width: 620px;
  margin: 0 auto 20px;
  color: var(--muted);
  line-height: 1.6;
}

.investor-profile-heading,
.investor-profile-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.investor-profile-heading > div {
  display: grid;
  gap: 4px;
}

.investor-profile-heading span,
.investor-profile-meta > span {
  color: var(--muted);
  font-size: 0.78rem;
}

.investor-profile-heading strong {
  color: var(--text);
  font-size: 1.65rem;
}

.investor-profile-description {
  max-width: 760px;
  margin: 14px 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.investor-allocation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.investor-allocation-item {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.investor-allocation-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.investor-allocation-label strong {
  color: var(--text);
  font-size: 1rem;
}

.investor-allocation-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.investor-allocation-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.investor-allocation-item:nth-child(2) .investor-allocation-bar span { background: #38c7a2; }
.investor-allocation-item:nth-child(3) .investor-allocation-bar span { background: #d5a64b; }

.investor-profile-meta {
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.investor-profile-disclaimer {
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.72rem;
  line-height: 1.55;
}

.investor-profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 3, 7, 0.82);
  backdrop-filter: blur(10px);
}

.investor-profile-overlay.hidden { display: none; }

.investor-profile-modal {
  width: min(700px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  background: #0c0d12;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

.investor-modal-topbar,
.investor-modal-topbar > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.investor-progress-label {
  color: var(--muted);
  font-size: 0.75rem;
}

.investor-modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 1.35rem;
  cursor: pointer;
}

.investor-modal-close:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.2); }

.investor-progress-track {
  height: 3px;
  margin: 18px 0 30px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.investor-progress-track span {
  display: block;
  width: 16.66%;
  height: 100%;
  background: var(--primary);
  transition: width 180ms ease;
}

.investor-question-stage h2,
.investor-result-stage h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1.45rem;
  line-height: 1.25;
}

.investor-question-stage > p,
.investor-result-stage > p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.55;
}

.investor-option-list {
  display: grid;
  gap: 9px;
}

.investor-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 12px 15px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.022);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.investor-option:hover { border-color: rgba(var(--primary-rgb), 0.35); }
.investor-option:focus-visible, .investor-modal-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.investor-option.is-selected { border-color: var(--primary); background: rgba(var(--primary-rgb), 0.1); }

.investor-option-marker {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
}

.investor-option.is-selected .investor-option-marker {
  border: 5px solid var(--primary);
  background: #fff;
}

.investor-option strong { display: block; font-size: 0.9rem; }
.investor-option small { display: block; margin-top: 3px; color: var(--muted); font-size: 0.75rem; }

.investor-modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.investor-modal-footer #investorProfileNextBtn { margin-left: auto; min-width: 120px; }
.investor-result-stage .investor-allocation-grid { margin-top: 22px; }
.investor-result-stage .investor-profile-disclaimer { margin-top: 20px; }

body.light-mode .investor-profile-modal { background: #ffffff; border-color: rgba(15, 23, 42, 0.12); }
body.light-mode .investor-profile-overlay { background: rgba(15, 23, 42, 0.55); }
body.light-mode .investor-profile-empty,
body.light-mode .investor-allocation-item,
body.light-mode .investor-option { background: rgba(15, 23, 42, 0.025); border-color: rgba(15, 23, 42, 0.1); }
body.light-mode .investor-profile-meta,
body.light-mode .investor-modal-footer { border-color: rgba(15, 23, 42, 0.09); }
body.light-mode .investor-profile-disclaimer { color: rgba(15, 23, 42, 0.5); }
body.light-mode .investor-option-marker { border-color: rgba(15, 23, 42, 0.3); }
body.light-mode .investor-modal-close { color: #64748b; border-color: rgba(15, 23, 42, 0.1); background: rgba(15, 23, 42, 0.035); }

@media (max-width: 680px) {
  .investor-profile-overlay { padding: 0; align-items: flex-end; }
  .investor-profile-modal { max-height: 94vh; padding: 22px 18px; border-radius: 12px 12px 0 0; }
  .investor-allocation-grid { grid-template-columns: 1fr; }
  .investor-profile-heading, .investor-profile-meta { align-items: flex-start; flex-direction: column; }
  .investor-modal-topbar > div { align-items: flex-start; flex-direction: column; gap: 3px; }
  .investor-modal-footer { flex-wrap: wrap; }
  .investor-modal-footer #investorProfileLaterBtn { order: 3; width: 100%; }
  .investor-modal-footer #investorProfileNextBtn { flex: 1; }
}

/* Portfolio weighting chart */
.portfolio-weight-card {
  min-width: 0;
  overflow: visible;
}

.portfolio-weight-header {
  align-items: stretch;
  flex-direction: column;
  gap: 14px;
}

.portfolio-weight-heading {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.portfolio-weight-heading h3 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.portfolio-weight-heading span {
  color: rgba(226, 232, 255, 0.55);
  font-size: 0.72rem;
}

.portfolio-weight-card .donut-base-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  box-sizing: border-box;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.portfolio-weight-card .donut-base-btn {
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  line-height: 1.15;
  white-space: nowrap;
}

.portfolio-weight-card .donut-base-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.portfolio-weight-card .donut-base-btn.active {
  background: rgba(var(--primary-rgb), 0.3);
  box-shadow: 0 5px 14px rgba(var(--primary-rgb), 0.15);
}

.portfolio-weight-card .donut-wrap {
  align-items: stretch;
  flex-direction: column;
  gap: 18px;
}

.donut-chart-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  margin: 0 auto;
}

.donut-chart-stage canvas {
  display: block;
  width: 220px !important;
  height: 220px !important;
}

.donut-chart-tooltip {
  position: absolute;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  min-width: 118px;
  padding: 9px 11px;
  transform: translate(-50%, calc(-100% - 10px));
  border: 1px solid rgba(135, 151, 224, 0.28);
  border-radius: 8px;
  background: rgba(13, 15, 23, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.donut-chart-tooltip strong,
.donut-chart-tooltip span {
  color: #f3f5ff;
  font-size: 0.76rem;
}

.donut-chart-tooltip span {
  color: #8fa3ff;
  text-align: right;
}

.donut-chart-tooltip small {
  grid-column: 1 / -1;
  color: rgba(226, 232, 255, 0.58);
  font-size: 0.67rem;
}

.donut-legend-value {
  color: rgba(226, 232, 255, 0.5);
  font-size: 0.7rem;
  white-space: nowrap;
}

body.light-mode .portfolio-weight-heading span,
body.light-mode .donut-legend-value {
  /* 0.52 daba 3.4:1 sobre blanco; 0.68 sube a ~5.6:1 sin perder jerarquía */
  color: rgba(23, 32, 51, 0.68);
}

body.light-mode .donut-chart-tooltip {
  border-color: rgba(30, 41, 59, 0.14);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

body.light-mode .donut-chart-tooltip strong { color: #172033; }
body.light-mode .donut-chart-tooltip small { color: rgba(23, 32, 51, 0.58); }

@media (max-width: 480px) {
  .portfolio-weight-card .donut-base-btn {
    min-height: 40px;
    font-size: 0.78rem;
  }

  .donut-chart-stage,
  .donut-chart-stage canvas {
    width: 196px !important;
    height: 196px !important;
  }

  .donut-legend-item {
    grid-template-columns: 9px minmax(0, 1fr) auto;
    min-height: 38px;
  }

  .donut-legend-value {
    display: none;
  }
}

/* Invested capital vs market value */
.investment-value-card {
  margin-top: 24px;
}

.investment-value-header {
  gap: 16px;
}

.investment-value-header > div:first-child {
  display: grid;
  gap: 4px;
}

.investment-value-header > div:first-child > span {
  font-size: 0.74rem;
}

.investment-value-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.investment-value-legend span,
.investment-value-tooltip span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: rgba(226, 232, 255, 0.64);
  font-size: 0.72rem;
  white-space: nowrap;
}

.investment-value-legend i,
.investment-value-tooltip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.investment-value-legend i.is-invested,
.investment-value-tooltip i.is-invested {
  background: #f5b84c;
}

.investment-value-legend i.is-market,
.investment-value-tooltip i.is-market {
  background: #6f86ff;
}

.investment-value-chart-wrap {
  position: relative;
  width: 100%;
  min-height: 260px;
  margin-top: 14px;
  overflow: hidden;
}

#investmentValueChart {
  display: block;
  width: 100%;
  max-width: 100%;
}

.investment-value-tooltip {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: 7px;
  min-width: 184px;
  padding: 11px 12px;
  border: 1px solid rgba(135, 151, 224, 0.24);
  border-radius: 8px;
  background: rgba(12, 14, 22, 0.95);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.investment-value-tooltip strong {
  color: var(--text);
  font-size: 0.75rem;
}

.investment-value-tooltip span {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
}

.investment-value-tooltip b {
  color: var(--text);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.investment-value-tooltip small {
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.7rem;
  font-weight: 600;
}

body.light-mode .investment-value-legend span,
body.light-mode .investment-value-tooltip span {
  color: rgba(23, 32, 51, 0.62);
}

body.light-mode .investment-value-tooltip {
  border-color: rgba(30, 41, 59, 0.14);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

body.light-mode .investment-value-tooltip small {
  border-top-color: rgba(15, 23, 42, 0.09);
}

@media (max-width: 640px) {
  .investment-value-header {
    align-items: flex-start;
  }

  .investment-value-legend {
    gap: 12px;
  }

  .investment-value-chart-wrap {
    margin-top: 6px;
  }
}

/* ── iOS zoom fix: inputs/selects must be ≥16px on mobile or Safari auto-zooms ── */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: max(16px, 1em) !important;
  }
}

/* Mobile navigation and one-hand actions */
.mobile-bottom-nav,
.mobile-action-dock,
.mobile-data-status,
.mobile-disclosure-toggle,
.hub-mobile-order-btn {
  display: none;
}

.skip-to-content {
  position: fixed;
  z-index: 2000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  font-weight: 700;
  transform: translateY(-150%);
  transition: transform 0.16s ease;
}

.skip-to-content:focus {
  transform: translateY(0);
}

@media (max-width: 720px) {
  .main-page {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .dashboard-content-shell {
    padding-bottom: calc(138px + env(safe-area-inset-bottom));
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 190;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 64px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background: rgba(13, 15, 23, 0.94);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.46);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav-item {
    min-width: 0;
    min-height: 52px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    padding: 5px 3px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: rgba(226, 232, 255, 0.55);
    font-size: 0.66rem;
    font-weight: 650;
  }

  .mobile-bottom-nav-item svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-bottom-nav-item.active {
    color: #fff;
    background: rgba(var(--primary-rgb), 0.18);
  }

  .mobile-bottom-nav-item.is-locked {
    opacity: 0.42;
  }

  .mobile-action-dock {
    position: fixed;
    z-index: 180;
    right: 16px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    display: block;
  }

  .mobile-action-dock.hidden {
    display: none;
  }

  .mobile-primary-action {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 17px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: #6f86ff;
    color: #fff;
    box-shadow: 0 14px 34px rgba(54, 75, 196, 0.42);
    font-size: 0.84rem;
    font-weight: 750;
  }

  .mobile-primary-action svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
  }

  .mobile-primary-action:disabled {
    opacity: 0.46;
    box-shadow: none;
  }

  .mobile-data-status {
    position: fixed;
    z-index: 185;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(142px + env(safe-area-inset-bottom));
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(111, 134, 255, 0.28);
    border-radius: 13px;
    background: rgba(17, 19, 29, 0.96);
    color: rgba(238, 242, 255, 0.86);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(16px);
    font-size: 0.78rem;
  }

  .mobile-data-status.hidden {
    display: none;
  }

  .mobile-data-status svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: #8ea0ff;
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  .mobile-data-status span {
    flex: 1;
    line-height: 1.35;
  }

  .mobile-data-status button {
    min-height: 44px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    font-size: 0.74rem;
    font-weight: 700;
  }

  .mobile-data-status[data-state="offline"],
  .mobile-data-status[data-state="error"] {
    border-color: rgba(255, 184, 76, 0.38);
  }

  .mobile-data-status[data-state="offline"] svg,
  .mobile-data-status[data-state="error"] svg {
    stroke: #f5b84c;
  }

  .mobile-data-status[data-state="online"] {
    border-color: rgba(50, 214, 162, 0.36);
  }

  .mobile-data-status[data-state="online"] svg {
    stroke: #32d6a2;
  }

  .main-page button,
  .main-page input:not([type="checkbox"]):not([type="radio"]),
  .main-page select,
  .main-page textarea,
  .main-page [role="button"] {
    min-height: 44px;
  }

  .main-page button,
  .main-page [role="button"],
  .mobile-bottom-nav-item,
  .mobile-primary-action {
    touch-action: manipulation;
  }

  .sidebar-close-btn,
  .sidebar-toggle-btn,
  .hub-icon-btn,
  .hub-widget-btn,
  .tracker-modal-close,
  .market-circle-button,
  .chart-fullscreen-btn,
  .pos-delete-btn,
  .pos-expand-btn,
  .positions-density-btn,
  .mobile-data-status button {
    min-width: 44px;
    min-height: 44px;
  }

  /* Hint de descubrimiento del menú "Más" (una sola vez) */
  .mobile-bottom-nav-item.more-hint-pulse {
    color: #fff;
    animation: moreHintPulse 1.6s ease-in-out infinite;
  }

  @keyframes moreHintPulse {
    0%, 100% { background: rgba(var(--primary-rgb), 0.14); }
    50% { background: rgba(var(--primary-rgb), 0.42); }
  }

  .more-hint-bubble {
    position: fixed;
    z-index: 200;
    max-width: min(280px, calc(100vw - 24px));
    padding: 11px 14px;
    border: 1px solid rgba(var(--primary-rgb), 0.4);
    border-radius: 13px;
    background: rgba(17, 19, 29, 0.98);
    color: rgba(238, 242, 255, 0.92);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
    font-size: 0.8rem;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.28s ease, transform 0.28s ease;
    pointer-events: auto;
  }

  .more-hint-bubble.visible {
    opacity: 1;
    transform: translateY(0);
  }

  .more-hint-bubble::after {
    content: "";
    position: absolute;
    right: 22px;
    bottom: -7px;
    width: 12px;
    height: 12px;
    background: inherit;
    border-right: 1px solid rgba(var(--primary-rgb), 0.4);
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.4);
    transform: rotate(45deg);
  }

  #portfolioDonutChart,
  #investmentValueChart,
  .market-chart canvas {
    touch-action: pan-y;
  }

  /* Mobile investment center: stacked widgets with explicit order controls */
  #section-home {
    padding: 0 12px 20px;
  }

  .hub-shell {
    height: auto;
    min-height: calc(100svh - 180px);
    overflow: visible;
  }

  .hub-toolbar {
    position: sticky;
    top: 0;
    z-index: 30;
    align-items: center;
    background: rgba(10, 12, 20, 0.96);
    backdrop-filter: blur(14px);
  }

  .hub-tabs {
    flex: 1 1 180px;
  }

  .hub-toolbar-actions {
    margin-left: auto;
  }

  .hub-canvas {
    display: grid;
    gap: 12px;
    min-height: 420px;
    padding: 12px;
    overflow: visible;
  }

  .hub-empty {
    position: relative;
    min-height: 380px;
  }

  .hub-widget {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    min-width: 0;
    min-height: 230px;
    user-select: auto;
  }

  .hub-widget-chart,
  .hub-widget-calendar,
  .hub-widget-portfolio,
  .hub-widget-risk,
  .hub-widget-dividends,
  .hub-widget-sentiment,
  .hub-widget-macro {
    min-height: 300px;
  }

  .hub-widget-heatmap {
    min-height: 420px;
  }

  .hub-widget-header {
    min-height: 48px;
    cursor: default;
  }

  .hub-mobile-order-btn {
    display: inline-flex;
  }

  .hub-resize-handle {
    display: none;
  }

  .hub-add-widget-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(142px + env(safe-area-inset-bottom));
    max-height: min(62svh, 520px);
    overflow-y: auto;
  }

  /* Progressive disclosure keeps advanced mobile screens scannable */
  .mobile-disclosure-toggle {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-left: auto;
    padding: 0 11px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(226, 232, 255, 0.72);
    font-size: 0.72rem;
    font-weight: 700;
  }

  .mobile-disclosure-toggle svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.18s ease;
  }

  .mobile-disclosure-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  .mobile-collapsible.is-mobile-collapsed > :not(.card-header):not(.anlz-card-header):not(.market-wl-head):not(.stats-rail-head) {
    display: none !important;
  }

  .mobile-collapsible.is-mobile-collapsed {
    padding-bottom: 12px;
  }

  .mobile-collapsible > .card-header,
  .mobile-collapsible > .anlz-card-header,
  .mobile-collapsible > .market-wl-head,
  .mobile-collapsible > .stats-rail-head {
    margin-bottom: 0;
  }

  .mobile-collapsible:not(.is-mobile-collapsed) > .card-header,
  .mobile-collapsible:not(.is-mobile-collapsed) > .anlz-card-header,
  .mobile-collapsible:not(.is-mobile-collapsed) > .market-wl-head,
  .mobile-collapsible:not(.is-mobile-collapsed) > .stats-rail-head {
    margin-bottom: 16px;
  }

  /* Core tracker tables become readable cards instead of wide desktop grids */
  #positionsTableShell,
  #txTableShell,
  #summaryTableBody {
    overflow: visible;
  }

  #positionsTableShell .tracker-table,
  #txTableShell .tracker-table,
  .tracker-table:has(#summaryTableBody) {
    min-width: 0;
  }

  #positionsTableShell thead,
  #txTableShell thead,
  .tracker-table:has(#summaryTableBody) thead {
    display: none;
  }

  #positionsTableBody,
  #txTableBody,
  #summaryTableBody {
    display: grid;
    gap: 10px;
  }

  #positionsTableBody > .pos-row,
  #txTableBody > tr,
  #summaryTableBody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
  }

  #positionsTableBody > .pos-row > td,
  #txTableBody > tr > td,
  #summaryTableBody > tr > td {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 5px;
    padding: 10px;
    border: 0;
    text-align: left;
  }

  #positionsTableBody > .pos-row > td::before,
  #txTableBody > tr > td::before,
  #summaryTableBody > tr > td::before {
    content: attr(data-label);
    color: rgba(226, 232, 255, 0.48);
    font-size: 0.66rem;
    font-weight: 650;
    text-transform: uppercase;
  }

  #positionsTableBody > .pos-row > td:first-child,
  #positionsTableBody > .pos-row > .pos-actions-cell,
  #txTableBody > tr > td:first-child,
  #summaryTableBody > tr > td:first-child,
  #positionsTableBody > tr > td[colspan],
  #txTableBody > tr > td[colspan] {
    grid-column: 1 / -1;
  }

  #positionsTableBody .td-sparkline {
    width: auto;
  }

  #positionsTableBody .pos-actions-cell {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }

  #positionsTableBody > .pos-lots-row {
    grid-column: 1 / -1;
    display: block;
  }

  #positionsTableBody > .pos-lots-row[style*="display: none"] {
    display: none !important;
  }

  .pos-lots-inner {
    padding-left: 0;
    overflow-x: auto;
  }

  .tracker-price-status-msg,
  .market-chart-status,
  .perf-chart-status,
  .mkw-status {
    overflow-wrap: anywhere;
  }

  .main-page p,
  .main-page label,
  .main-page .form-message,
  .main-page .anlz-card-sub,
  .main-page .mkw-step-hint {
    overflow-wrap: break-word;
  }

  .main-page :focus-visible {
    outline: 3px solid #9aabff;
    outline-offset: 3px;
  }
}

body.light-mode .mobile-bottom-nav {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.16);
}

body.light-mode .mobile-bottom-nav-item {
  color: rgba(15, 23, 42, 0.55);
}

body.light-mode .mobile-bottom-nav-item.active {
  color: #3348b8;
}

body.light-mode .mobile-data-status {
  border-color: rgba(51, 72, 184, 0.2);
  background: rgba(255, 255, 255, 0.97);
  color: #27324a;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

body.light-mode .mobile-data-status button,
body.light-mode .mobile-disclosure-toggle {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.045);
  color: #26314a;
}

@media (max-width: 420px) {
  #positionsTableBody > .pos-row,
  #txTableBody > tr,
  #summaryTableBody > tr {
    grid-template-columns: 1fr;
  }

  #positionsTableBody > .pos-row > td:first-child,
  #positionsTableBody > .pos-row > .pos-actions-cell,
  #txTableBody > tr > td:first-child,
  #summaryTableBody > tr > td:first-child {
    grid-column: auto;
  }
}

/* Tracker mobile width guard: prevents intrinsic text sizing from collapsing the view */
@media (max-width: 720px) {
  .dashboard-main,
  .dashboard-content-shell,
  #section-tracker.active,
  #trackerListView,
  #trackerDashView,
  .tracker-dash-topbar,
  .tracker-kpi-grid,
  .tracker-price-status-bar,
  .tracker-tab-nav,
  .tracker-tab-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #section-tracker.active,
  #trackerDashView:not(.hidden),
  #trackerListView:not(.hidden) {
    display: block;
  }

  .tracker-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tracker-kpi-grid > *,
  .tracker-main-grid > *,
  .tracker-dash-title-group,
  .tracker-dash-title,
  .summary-item,
  .kpi-hero-label-row {
    min-width: 0;
    max-width: 100%;
  }

  .tracker-dash-title,
  .summary-item span,
  .summary-item strong,
  .tracker-tab-btn,
  .tracker-price-status-msg {
    overflow-wrap: normal;
    word-break: normal;
  }

  .tracker-dash-title {
    white-space: normal;
  }

  .tracker-tab-nav {
    display: flex;
  }

  .tracker-tab-btn {
    flex: 0 0 auto;
  }
}

@media (max-width: 720px) and (orientation: landscape) and (max-height: 500px) {
  .mobile-bottom-nav {
    top: max(8px, env(safe-area-inset-top));
    right: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: 70px;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }

  .mobile-bottom-nav-item {
    min-height: 0;
  }

  .dashboard-content-shell {
    margin-left: calc(78px + env(safe-area-inset-left));
    padding-bottom: 82px;
  }

  .mobile-action-dock {
    right: max(12px, env(safe-area-inset-right));
    bottom: 12px;
  }

  .mobile-data-status {
    left: calc(90px + env(safe-area-inset-left));
    bottom: 68px;
  }
}

@media (prefers-contrast: more) {
  .mobile-bottom-nav,
  .mobile-data-status,
  .mobile-disclosure-toggle,
  .mobile-primary-action {
    border-width: 2px;
  }

  .mobile-bottom-nav-item,
  .mobile-data-status,
  .mobile-disclosure-toggle {
    color: CanvasText;
  }
}

@media (forced-colors: active) {
  .mobile-bottom-nav-item.active,
  .mobile-primary-action,
  .mobile-disclosure-toggle {
    forced-color-adjust: auto;
    border: 1px solid ButtonText;
  }
}

/* ── Asistente IA conversacional (Portafolio Tracker · DeepSeek) ─────────────── */
.tracker-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  border: 1px solid rgba(var(--primary-rgb), 0.55);
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.95), rgba(167, 139, 250, 0.95));
  box-shadow: 0 6px 18px rgba(var(--primary-rgb), 0.28);
}
.tracker-ai-btn:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}
.tracker-ai-btn svg { opacity: 0.95; }

.ai-chat-panel {
  display: none;
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100dvh - 48px);
  flex-direction: column;
  background: linear-gradient(180deg, rgba(18, 18, 24, 0.99), rgba(10, 10, 14, 0.99));
  border: 1px solid rgba(var(--primary-rgb), 0.28);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  z-index: 1200;
  overflow: hidden;
  animation: aiChatIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ai-chat-panel.open { display: flex; }
@keyframes aiChatIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.18), rgba(167, 139, 250, 0.12));
}
.ai-chat-title { display: flex; align-items: center; gap: 10px; }
.ai-chat-spark {
  font-size: 20px;
  color: var(--primary, #6f86ff);
  filter: drop-shadow(0 0 6px rgba(var(--primary-rgb), 0.6));
}
.ai-chat-title-text { display: flex; flex-direction: column; line-height: 1.2; }
.ai-chat-title-text strong { color: #fff; font-size: 15px; }
.ai-chat-sub { color: rgba(255, 255, 255, 0.55); font-size: 11.5px; }
.ai-chat-header-actions { display: flex; align-items: center; gap: 2px; }
.ai-chat-close,
.ai-chat-min {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.18s ease, color 0.18s ease;
}
.ai-chat-close:hover,
.ai-chat-min:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* Estado minimizado: solo la barra de cabecera, anclada abajo a la derecha */
.ai-chat-panel.minimized {
  height: auto;
  animation: none;
}
.ai-chat-panel.minimized .ai-chat-messages,
.ai-chat-panel.minimized .ai-chat-suggestions,
.ai-chat-panel.minimized .ai-chat-input-row {
  display: none;
}
.ai-chat-panel.minimized .ai-chat-header {
  border-bottom: none;
  cursor: pointer;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-chat-msg { display: flex; }
.ai-chat-msg-user { justify-content: flex-end; }
.ai-chat-msg-bot { justify-content: flex-start; }
.ai-chat-bubble {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
}
.ai-chat-msg-user .ai-chat-bubble {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.95), rgba(140, 120, 245, 0.95));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-chat-bubble-bot {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  border-bottom-left-radius: 4px;
}
.ai-chat-bubble-bot .ai-h { font-weight: 700; color: #fff; margin: 8px 0 3px; font-size: 13px; }
.ai-chat-bubble-bot ul { margin: 4px 0 0; padding-left: 18px; }
.ai-chat-bubble-bot p { margin: 0 0 6px; }
.ai-chat-bubble-bot strong { color: #fff; }

.ai-chat-typing { display: inline-flex; gap: 4px; align-items: center; padding: 13px; }
.ai-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  animation: aiChatBlink 1.2s infinite ease-in-out both;
}
.ai-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes aiChatBlink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.ai-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
}
.ai-chat-chip {
  background: rgba(var(--primary-rgb), 0.14);
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease;
}
.ai-chat-chip:hover { background: rgba(var(--primary-rgb), 0.26); }

.ai-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.ai-chat-input {
  flex: 1;
  resize: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  padding: 10px 12px;
  max-height: 120px;
  outline: none;
  transition: border-color 0.18s ease;
}
.ai-chat-input:focus { border-color: rgba(var(--primary-rgb), 0.6); }
.ai-chat-input::placeholder { color: rgba(255, 255, 255, 0.4); }
.ai-chat-send {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary, #6f86ff), rgba(140, 120, 245, 1));
  color: #fff;
  cursor: pointer;
  transition: filter 0.16s ease, transform 0.16s ease;
}
.ai-chat-send:hover { filter: brightness(1.1); }
.ai-chat-send:disabled { opacity: 0.5; cursor: default; }

/* Light mode */
body.light-mode .ai-chat-panel {
  background: linear-gradient(180deg, #ffffff, #f6f8fc);
  border-color: rgba(var(--primary-rgb), 0.25);
  box-shadow: 0 24px 60px rgba(23, 31, 57, 0.18);
}
body.light-mode .ai-chat-header { border-bottom-color: rgba(0, 0, 0, 0.07); }
body.light-mode .ai-chat-title-text strong { color: #1a1a1e; }
body.light-mode .ai-chat-sub { color: #6b7280; }
body.light-mode .ai-chat-close,
body.light-mode .ai-chat-min { color: #6b7280; }
body.light-mode .ai-chat-close:hover,
body.light-mode .ai-chat-min:hover { background: rgba(0, 0, 0, 0.06); color: #1a1a1e; }
body.light-mode .ai-chat-bubble-bot {
  background: #eef1f8;
  border-color: rgba(0, 0, 0, 0.06);
  color: #24262e;
}
body.light-mode .ai-chat-bubble-bot .ai-h,
body.light-mode .ai-chat-bubble-bot strong { color: #14151a; }
body.light-mode .ai-chat-chip { color: #3a3f55; }
body.light-mode .ai-chat-input-row { border-top-color: rgba(0, 0, 0, 0.07); }
body.light-mode .ai-chat-input {
  background: #f1f3f9;
  border-color: rgba(0, 0, 0, 0.1);
  color: #1a1a1e;
}
body.light-mode .ai-chat-input::placeholder { color: #9aa1b2; }
body.light-mode .ai-chat-typing span { background: rgba(0, 0, 0, 0.35); }

@media (max-width: 560px) {
  .ai-chat-panel {
    right: 8px; left: 8px; bottom: 8px;
    width: auto;
    height: 72dvh;
  }
}

/* ── Códigos de respaldo 2FA ──────────────────────────────────────────────── */
.backup-codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.backup-code-chip {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 9px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text, #f4f4f6);
  user-select: all;
}
.backup-codes-actions {
  display: flex;
  gap: 8px;
}
.backup-codes-actions .button { flex: 1; }
.backup-codes-ack {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 12px;
  cursor: pointer;
}
@media (max-width: 480px) {
  .backup-codes-grid { grid-template-columns: 1fr; }
}

/* ── Botón flotante de feedback (beta) ────────────────────────────────────── */
.feedback-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #5b6bff, #8e5bff);
  box-shadow: 0 10px 28px rgba(91, 107, 255, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.feedback-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(91, 107, 255, 0.55);
}
.feedback-fab-icon { font-size: 1.05rem; line-height: 1; }
@media (max-width: 560px) {
  .feedback-fab { right: 14px; bottom: 14px; padding: 11px; }
  .feedback-fab-label { display: none; }
}

/* ── Modal de bienvenida a la beta ────────────────────────────────────────── */
.beta-welcome-modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
}
.beta-welcome-body { font-size: 0.9rem; color: var(--text, #ececf1); }
.beta-welcome-body h4 {
  margin: 16px 0 6px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--primary, #8ea0ff);
}
.beta-welcome-list { margin: 0; padding-left: 18px; line-height: 1.55; }
.beta-welcome-list li { margin-bottom: 4px; }
.beta-welcome-list--muted { color: var(--muted); }
.beta-welcome-cta-note {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(91, 107, 255, 0.1);
  border: 1px solid rgba(91, 107, 255, 0.25);
  font-size: 0.85rem;
}
.beta-welcome-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.beta-welcome-actions .button { flex: 1; }
@media (max-width: 480px) {
  .beta-welcome-actions { flex-direction: column-reverse; }
}

/* Mobile beta polish: tracker, markets, modals and data states */
@media (max-width: 720px) {
  .dashboard-topbar {
    padding: 0 16px;
    margin-bottom: 14px;
  }

  .dashboard-topbar-actions {
    display: none;
  }

  .dashboard-content-shell {
    gap: 0;
    overflow-x: hidden;
  }

  .dashboard-section.active {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .tracker-dash-topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    padding: 0 16px;
    row-gap: 10px;
  }

  .tracker-back-btn {
    justify-self: start;
  }

  .tracker-dash-title-group {
    grid-column: 1 / -1;
    order: 3;
  }

  .tracker-export-btns {
    justify-content: flex-end;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .tracker-export-btns::-webkit-scrollbar {
    display: none;
  }

  .tracker-export-btn {
    flex: 0 0 auto;
    min-width: 44px;
  }

  .tracker-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 16px;
  }

  .tracker-kpi-hero {
    grid-column: 1 / -1;
    min-height: 136px;
  }

  .summary-item {
    min-height: 112px;
  }

  .summary-item strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kpi-hero-label-row {
    align-items: flex-start;
    gap: 8px;
  }

  .kpi-alt-currency-select {
    /* 112px truncaba la opción "Sin equivalencia" (bug #7). */
    width: auto;
    min-width: 118px;
    max-width: 62%;
  }

  .tracker-price-status-bar {
    align-items: flex-start;
    gap: 10px;
  }

  .tracker-price-status-msg {
    min-width: 0;
    line-height: 1.35;
  }

  .tracker-refresh-btn {
    flex: 0 0 auto;
  }

  .tracker-tab-nav {
    position: sticky;
    top: 0;
    z-index: 35;
    margin: 0 0 16px;
    padding: 8px 16px;
    background: rgba(7, 8, 14, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(14px);
    scroll-padding-inline: 16px;
  }

  .tab-group-label,
  .tab-group-sep {
    display: none;
  }

  .tracker-tab-btn {
    border-radius: 12px;
    white-space: nowrap;
  }

  .tracker-tab-panel {
    padding-inline: 16px;
  }

  .portfolio-weight-header,
  .investment-value-header {
    align-items: stretch;
    flex-direction: column;
  }

  .donut-base-toggle,
  .investment-value-legend {
    width: 100%;
  }

  .donut-base-btn {
    flex: 1 1 0;
  }

  .donut-wrap canvas {
    width: min(210px, 62vw) !important;
    height: min(210px, 62vw) !important;
  }

  .positions-header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .positions-search {
    width: 100%;
  }

  #positionsTableBody > .pos-row,
  #txTableBody > tr,
  #summaryTableBody > tr {
    border-radius: 16px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
      rgba(15, 17, 25, 0.86);
  }

  #positionsTableBody > .pos-row > td:first-child,
  #summaryTableBody > tr > td:first-child {
    font-size: 1rem;
    font-weight: 800;
  }

  #positionsTableBody .pos-actions-cell {
    justify-content: space-between;
  }

  .perf-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .perf-period-nav {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .perf-period-nav::-webkit-scrollbar {
    display: none;
  }

  .perf-period-btn {
    flex: 0 0 auto;
    min-height: 40px;
  }

  .perf-chart-wrap,
  .investment-value-chart-wrap {
    height: clamp(260px, 58vh, 430px);
  }

  .tracker-modal-backdrop {
    z-index: 260;
    align-items: flex-end;
    padding: 12px;
    background: rgba(0, 0, 0, 0.72);
  }

  .tracker-modal {
    width: 100%;
    max-height: min(88dvh, 680px);
    overflow-y: auto;
    border-radius: 24px 24px 18px 18px;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }

  .tracker-modal .button,
  .tracker-modal button[type="submit"] {
    min-height: 48px;
  }

  #section-markets {
    padding-inline: 0;
  }

  body:has(#section-markets.active) .dashboard-topbar {
    padding-inline: 16px;
  }

  #section-markets .market-overview-row,
  #section-markets .market-workspace,
  #section-markets .ticker-news-section {
    margin-inline: 16px;
  }

  #section-markets .market-overview-row {
    gap: 8px;
  }

  #section-markets .market-overview-bar {
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  #section-markets .market-overview-bar::-webkit-scrollbar {
    display: none;
  }

  #section-markets .mkt-index-tile {
    min-width: 142px;
  }

  #section-markets .market-toolbar {
    position: sticky;
    top: 0;
    z-index: 38;
    margin: 0;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  }

  #section-markets .market-search-shell {
    max-width: none;
    min-width: 0;
  }

  #section-markets .market-input-pill {
    min-height: 48px;
  }

  #section-markets .market-range-seg {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  #section-markets .market-range-seg::-webkit-scrollbar {
    display: none;
  }

  #section-markets .market-range-btn {
    flex: 0 0 auto;
    min-width: 48px;
    min-height: 40px;
  }

  #section-markets .market-chart-shell {
    border-radius: 18px;
    overflow: hidden;
  }

  #section-markets .market-chart-header {
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
  }

  #section-markets .chart-header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  #section-markets .chart-52w-bar {
    flex: 1 1 150px;
    min-width: 150px;
  }

  #section-markets .market-chart {
    height: clamp(390px, 64vh, 540px);
    min-height: 390px;
  }

  #section-markets .chart-drawing-toolbar {
    max-height: calc(100% - 20px);
    transform: scale(0.92);
    transform-origin: left top;
  }

  #section-markets .market-wl-sidebar,
  #section-markets .market-stats-rail {
    margin: 0;
    max-height: none;
    border-radius: 16px;
  }

  #section-markets .market-wl-head,
  #section-markets .stats-rail-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
  }

  #section-markets .market-wl-items {
    padding: 10px;
  }

  #section-markets .market-stats-rail {
    overflow: hidden;
  }

  #section-markets .tech-rating-card {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  #section-markets .stats-rail-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }

  #section-markets .stats-rail-item {
    min-height: 70px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.065);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.028);
  }

  #section-markets .market-menu,
  #section-markets .indicator-panel,
  .ind-settings-panel {
    position: fixed;
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    bottom: calc(86px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: none;
    max-height: min(70dvh, 560px);
    overflow-y: auto;
    border-radius: 20px;
    z-index: 240;
  }

  .mobile-data-status {
    border-radius: 16px;
    font-weight: 650;
  }

  .feedback-fab {
    right: 16px;
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .tracker-kpi-grid,
  .perf-metrics-grid,
  #section-markets .stats-rail-body {
    grid-template-columns: 1fr;
  }

  .tracker-export-btn span,
  .tracker-export-btn:not(.tracker-ai-btn) {
    font-size: 0.78rem;
  }

  .summary-item {
    min-height: 104px;
  }

  #section-markets .market-chart {
    height: 58vh;
    min-height: 360px;
  }
}

body.light-mode .tracker-tab-nav {
  background: rgba(248, 250, 255, 0.94);
  border-bottom-color: rgba(15, 23, 42, 0.09);
}

body.light-mode #positionsTableBody > .pos-row,
body.light-mode #txTableBody > tr,
body.light-mode #summaryTableBody > tr,
body.light-mode #section-markets .stats-rail-item {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 248, 255, 0.9)),
    #fff;
  border-color: rgba(15, 23, 42, 0.08);
}
/* Mobile beta readiness pass */
.mobile-quick-start {
  display: none;
}

@media (max-width: 720px) {
  html,
  body {
    overflow-x: hidden;
  }

  .dashboard-main {
    padding: 10px;
  }

  .dashboard-content-shell {
    border-radius: 18px;
    padding: 14px;
  }

  .dashboard-topbar {
    position: sticky;
    top: 0;
    z-index: 80;
    margin: -14px -14px 12px;
    padding: 12px 14px;
    border-radius: 0 0 18px 18px;
    background: rgba(8, 10, 18, 0.94);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
  }

  .dashboard-topbar h1 {
    max-width: 70vw;
    font-size: clamp(1.55rem, 7vw, 2.35rem);
    line-height: 0.98;
  }

  .dashboard-topbar-meta {
    display: none;
  }

  .mobile-quick-start {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 14px;
  }

  .mobile-quick-start button {
    min-width: 0;
    min-height: 58px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 9px;
    border: 1px solid rgba(111, 134, 255, 0.22);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025));
    color: #fff;
    text-align: left;
  }

  .mobile-quick-start span {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(111, 134, 255, 0.24);
    color: #9fb0ff;
    font-size: 0.72rem;
    font-weight: 800;
  }

  .mobile-quick-start strong {
    min-width: 0;
    font-size: 0.74rem;
    line-height: 1.15;
    /* "anywhere" partía palabras a la mitad ("portafoli/o"); "break-word"
       prioriza el salto entre palabras y solo rompe si no cabe (bug #7). */
    overflow-wrap: break-word;
  }

  /* Una vez que ya existe al menos un portafolio, el chip "Crear portafolio"
     deja de ser relevante: se oculta la barra completa de inicio rápido
     (móvil/tablet #9), clase agregada por JS en updateMobileQuickStartVisibility. */
  .mobile-quick-start.is-dismissed {
    display: none !important;
  }

  .mobile-bottom-nav {
    min-height: 68px;
    border-radius: 20px;
  }

  .mobile-bottom-nav-item {
    min-height: 56px;
    touch-action: manipulation;
  }

  .mobile-bottom-nav-item.active {
    box-shadow: inset 0 0 0 1px rgba(111, 134, 255, 0.28);
  }

  .mobile-action-dock {
    right: 12px;
    bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .mobile-primary-action {
    max-width: calc(100vw - 24px);
    min-height: 50px;
    border-radius: 16px;
  }

  .tracker-dash-topbar,
  .tracker-list-header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .tracker-list-actions,
  .tracker-export-btns {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    /* Indicio de que la barra scrollea: difumina el borde derecho (móvil/tablet #5). */
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 22px), transparent 100%);
  }

  .tracker-list-actions::-webkit-scrollbar,
  .tracker-export-btns::-webkit-scrollbar {
    display: none;
  }

  .tracker-export-btn,
  .tracker-back-btn,
  .tracker-list-actions .button {
    flex: 0 0 auto;
    min-width: max-content;
  }

  .tracker-dash-title-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .tracker-kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tracker-kpi-hero,
  .summary-item {
    min-height: 104px;
    padding: 16px;
  }

  .tracker-kpi-hero strong {
    font-size: clamp(2rem, 10vw, 3.1rem);
    line-height: 0.95;
  }

  .summary-item strong {
    font-size: clamp(1.25rem, 6vw, 1.65rem);
  }

  .tracker-tab-nav {
    position: sticky;
    top: 78px;
    z-index: 70;
    margin: 0 -14px 14px;
    padding: 8px 14px;
    border-radius: 0;
    background: rgba(8, 10, 18, 0.94);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px);
  }

  .tracker-tab-btn,
  .perf-period-btn,
  .range-btn,
  .mkw-mode-tab,
  .mkw-calc-tab,
  .settings-tab {
    min-height: 44px;
    white-space: nowrap;
  }

  .tab-group-label,
  .tab-group-sep {
    display: none;
  }

  .tracker-main-grid,
  .performance-grid,
  .settings-grid,
  .mkw-workspace,
  .anlz-layout,
  .td-grid {
    grid-template-columns: 1fr !important;
  }

  .donut-card,
  .tracker-positions-section,
  .dashboard-card,
  .mkw-card,
  .anlz-card,
  .td-card {
    content-visibility: auto;
    contain-intrinsic-size: 420px;
  }

  .tracker-table-shell,
  .tracker-table-wrap,
  .mkw-weights-table-shell {
    overflow: visible;
  }

  #watchlistTableShell .tracker-table,
  #divByTickerTable,
  #divForecastTable,
  #rebalTable,
  .mkw-weights-table-shell .tracker-table {
    min-width: 0;
  }

  #watchlistTableShell thead,
  #divByTickerTable thead,
  #divForecastTable thead,
  #rebalTable thead,
  .mkw-weights-table-shell thead {
    display: none;
  }

  #watchlistTableBody,
  #divByTickerTable tbody,
  #divForecastTable tbody,
  #rebalTable tbody,
  .mkw-weights-table-shell tbody {
    display: grid;
    gap: 10px;
  }

  #watchlistTableBody > tr,
  #divByTickerTable tbody > tr,
  #divForecastTable tbody > tr,
  #rebalTable tbody > tr,
  .mkw-weights-table-shell tbody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
  }

  #watchlistTableBody > tr > td,
  #divByTickerTable tbody > tr > td,
  #divForecastTable tbody > tr > td,
  #rebalTable tbody > tr > td,
  .mkw-weights-table-shell tbody > tr > td {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 9px;
    border: 0;
    text-align: left;
    overflow-wrap: anywhere;
  }

  #watchlistTableBody > tr > td::before,
  #divByTickerTable tbody > tr > td::before,
  #divForecastTable tbody > tr > td::before,
  #rebalTable tbody > tr > td::before,
  .mkw-weights-table-shell tbody > tr > td::before {
    content: attr(data-label);
    color: rgba(226, 232, 255, 0.48);
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  #watchlistTableBody > tr > td:first-child,
  #divByTickerTable tbody > tr > td:first-child,
  #divForecastTable tbody > tr > td:first-child,
  #rebalTable tbody > tr > td:first-child,
  .mkw-weights-table-shell tbody > tr > td:first-child {
    grid-column: 1 / -1;
  }

  .market-overview-row,
  #section-markets .market-overview-row {
    margin: 0 -14px 10px;
    padding: 0 14px 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .market-overview-row::-webkit-scrollbar {
    display: none;
  }

  #section-markets .market-toolbar {
    position: sticky;
    top: 78px;
    z-index: 70;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin: 0 -14px 12px;
    padding: 10px 14px;
    border-radius: 0;
    background: rgba(8, 10, 18, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px);
  }

  #section-markets .market-search-shell {
    grid-column: 1 / -1;
  }

  #section-markets .range-segmented {
    grid-column: 1 / -1;
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
  }

  #section-markets .range-segmented::-webkit-scrollbar {
    display: none;
  }

  #section-markets .market-menu,
  #indSettingsPanel,
  .indicator-panel,
  .tracker-modal,
  .investor-profile-modal,
  .perf-info-popup {
    position: fixed !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    top: auto !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: none !important;
    max-height: min(82svh, 680px);
    border-radius: 22px 22px 16px 16px;
    overflow: auto;
  }

  .tracker-modal-backdrop,
  .investor-profile-overlay,
  .perf-info-overlay {
    align-items: flex-end;
    padding: 10px;
  }

  #section-markets .market-chart-shell {
    margin: 0 -8px;
    border-radius: 18px;
  }

  #section-markets .market-chart-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  #section-markets .chart-header-right {
    align-items: flex-end;
  }

  #section-markets .market-chart {
    min-height: 54svh;
    height: 54svh;
  }

  #section-markets .market-wl-sidebar,
  #section-markets .market-stats-rail {
    border-radius: 16px;
  }

  .beta-welcome-modal {
    max-height: min(86svh, 720px);
  }

  .beta-welcome-actions,
  .settings-billing-actions,
  .backup-codes-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (min-width: 721px) and (max-width: 1100px) {
  .dashboard-main {
    padding: 18px;
  }

  .dashboard-content-shell {
    padding: 24px;
  }

  .dashboard-topbar {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .tracker-kpi-grid,
  .settings-overview-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tracker-main-grid,
  .market-workspace,
  #section-markets .market-workspace,
  .mkw-workspace,
  .anlz-layout {
    grid-template-columns: 1fr !important;
  }

  #section-markets .market-chart {
    height: 62svh;
  }

  .tracker-tab-nav,
  .settings-tabs,
  .mkw-mode-tabs,
  .mkw-calc-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
}

body.light-mode .dashboard-topbar,
body.light-mode #section-markets .market-toolbar,
body.light-mode .tracker-tab-nav {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(15, 23, 42, 0.1);
}

body.light-mode .mobile-quick-start button {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(241, 244, 252, 0.92));
  border-color: rgba(51, 72, 184, 0.16);
  color: #172033;
}

/* ── Tipografía display (consistencia con la landing) ─────────────────────────
   La landing usa Space Grotesk para títulos; el dashboard usaba solo Inter.
   Se aplica a h1–h3 (títulos de sección, tarjetas y modales); h4+ siguen en
   Inter para no ruido en labels densos de datos. */
.main-page h1,
.main-page h2,
.main-page h3 {
  font-family: var(--font-display, "Space Grotesk", "Inter", sans-serif);
  letter-spacing: -0.01em;
}

/* ── Reduced motion: kill-switch global (mismo criterio que styles.css) ──── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Focus ring de teclado garantizado ────────────────────────────────────────
   main.css tiene ~30 resets `outline: none` sobre :focus que pisaban el anillo
   base de styles.css. Este bloque restaura el anillo SOLO para navegación por
   teclado (:focus-visible); el !important es deliberado: debe ganar a cualquier
   reset de foco por ratón. Mismo estilo que la landing (accent, offset 3px). */
:is(a, button, input, select, textarea, summary, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid var(--accent, #7892ff) !important;
  outline-offset: 3px;
}

/* ══════════════════════════════════════════════════════════════════════════
   Tracker · refinamientos móvil/tablet y rediseño (lote de mejoras 2026-07)
   Bloque final: gana por orden de cascada a reglas previas equivalentes.
   ══════════════════════════════════════════════════════════════════════════ */

/* Tablet intermedio: en 900–1100px hay espacio para 2 columnas en el grid
   principal del Resumen (antes se forzaba a 1 col en todo 721–1100). */
@media (min-width: 900px) and (max-width: 1100px) {
  .tracker-main-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) !important;
  }
  .tracker-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  /* Los heroes deben ocupar la fila completa en un grid de 3 columnas;
     el span-2 heredado del desktop (grid de 6 columnas) dejaba una
     columna muerta junto a cada hero (bug tablet 900-1100px). */
  .tracker-kpi-hero {
    grid-column: span 3 !important;
  }
  .perf-metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  /* Mobile 1 · Operaciones cerradas: convertir a tarjetas (sus <td> ya traen
     data-label) para que no desborde la página con su min-width de escritorio. */
  #closedTradesShell { overflow: visible; }
  #closedTradesShell .closed-trades-table { min-width: 0; }
  #closedTradesShell thead { display: none; }
  #closedTradesBody { display: grid; gap: 10px; }
  #closedTradesBody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
  }
  #closedTradesBody > tr > td {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px;
    border: 0;
    text-align: left;
    overflow-wrap: anywhere;
  }
  #closedTradesBody > tr > td::before {
    content: attr(data-label);
    color: rgba(226, 232, 255, 0.48);
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
  #closedTradesBody > tr > td:first-child { grid-column: 1 / -1; }

  /* Mobile 4 · Desempeño: 2 columnas en vez de 1 para no hacer scroll eterno. */
  .perf-metrics-grid,
  .corr-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }
  .perf-metric-card { padding: 12px; }
  .perf-metric-value { font-size: clamp(1.1rem, 5.5vw, 1.5rem); }

  /* Mobile 6 · Indicador de scroll horizontal en la barra de pestañas:
     máscara sutil en el borde derecho que insinúa que hay más contenido. */
  .tracker-tab-nav {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
  }

  /* Tooltips (?) accesibles al tacto: fijarlos dentro del viewport. */
  .tracker-kpi-grid .kpi-tooltip,
  .corr-metrics-grid .kpi-tooltip {
    left: 0;
    right: auto;
    max-width: min(86vw, 320px);
  }
}

/* ── Menú de acciones por posición (P0.1) ─────────────────────────────────── */
.pos-action-menu { position: relative; display: inline-block; }
.pos-action-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #f5f7fb);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.pos-action-trigger:hover,
.pos-action-trigger[aria-expanded="true"] {
  background: rgba(var(--primary-rgb), 0.14);
  border-color: rgba(var(--primary-rgb), 0.4);
}
.pos-action-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 120;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-strong, #12121a);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}
.pos-action-dropdown[hidden] { display: none; }
.pos-action-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text, #f5f7fb);
  font-size: 0.85rem;
  font-family: Inter, sans-serif;
  cursor: pointer;
  transition: background 0.12s;
}
.pos-action-dropdown button:hover {
  background: rgba(var(--primary-rgb), 0.14);
}
.pos-action-dropdown .pos-action-danger { color: var(--loss, #ff6b81); }
.pos-action-dropdown .pos-action-danger:hover { background: rgba(var(--loss-rgb), 0.14); }

body.light-mode .pos-action-dropdown {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.12);
}
body.light-mode .pos-action-trigger {
  color: #172033;
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.03);
}

/* ── Menú de acciones como bottom sheet en móvil (móvil/tablet #2) ─────────── */
@media (max-width: 720px) {
  #positionsTableBody .pos-actions-cell { justify-content: flex-start; }

  .pos-action-dropdown {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 500;
    min-width: 0;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.55);
    animation: posSheetSlideUp 0.18s ease-out;
  }

  .pos-action-dropdown button {
    padding: 13px 14px;
    font-size: 0.92rem;
    min-height: 44px;
  }

  /* Fondo atenuado detrás del sheet (sin backdrop dedicado en el DOM). */
  body:has(.pos-action-dropdown:not([hidden])) {
    overflow: hidden;
  }
  body:has(.pos-action-dropdown:not([hidden]))::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 490;
    animation: posSheetFade 0.15s ease-out;
  }
}

@keyframes posSheetSlideUp {
  from { transform: translateY(20px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes posSheetFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .pos-action-dropdown { animation: none; }
}

/* ── Watchlist: acciones de fila (P1.11 / P0.2) ───────────────────────────── */
.wl-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.wl-buy {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(var(--primary-rgb), 0.4);
  background: rgba(var(--primary-rgb), 0.14);
  color: var(--text, #f5f7fb);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.wl-buy:hover { background: rgba(var(--primary-rgb), 0.24); }
.wl-alert, .wl-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted, #9ca3b4);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.wl-alert:hover { background: rgba(var(--warm-rgb, 255,180,84), 0.16); color: var(--warm, #ffb454); }
.wl-remove:hover { background: rgba(var(--loss-rgb), 0.16); color: var(--loss, #ff6b81); }
.wl-sparkline { width: 80px; height: 28px; }
@media (max-width: 720px) {
  .wl-actions { justify-content: flex-start; }
}

/* ── Toggle de serie del gráfico hero del Resumen (P0.3) ───────────────────── */
.value-chart-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.value-series-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
}
.value-series-btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: Inter, sans-serif;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.value-series-btn:hover { color: rgba(255, 255, 255, 0.8); }
.value-series-btn.active {
  background: rgba(var(--primary-rgb), 0.2);
  color: #fff;
}
body.light-mode .value-series-toggle { background: rgba(15, 23, 42, 0.05); }
body.light-mode .value-series-btn { color: #5b6478; }
body.light-mode .value-series-btn.active { color: #172033; }

/* Gráfico de barras de dividendos mensuales (P1.6) */
.div-bars-wrap { position: relative; width: 100%; margin-top: 8px; }
.div-bars-wrap canvas { display: block; width: 100%; }

/* ── Tarjeta de composición unificada (Visual 1) ──────────────────────────── */
.composition-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.composition-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.composition-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
}
.comp-btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: Inter, sans-serif;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.comp-btn:hover { color: rgba(255, 255, 255, 0.8); }
.comp-btn.active { background: rgba(var(--primary-rgb), 0.2); color: #fff; }
.comp-panel { margin-top: 6px; }
.comp-panel.hidden { display: none; }
.comp-panel-sub { display: block; margin-bottom: 8px; font-size: 0.8rem; color: var(--muted, #9ca3b4); }
/* El toggle Invertido/Valor actual sólo aplica a la vista de ponderación. */
.composition-card:not([data-comp="donut"]) #donutBaseToggle { display: none; }
body.light-mode .composition-toggle { background: rgba(15, 23, 42, 0.05); }
body.light-mode .comp-btn { color: #5b6478; }
body.light-mode .comp-btn.active { color: #172033; }
@media (max-width: 560px) {
  .composition-controls { width: 100%; }
  .composition-toggle { width: 100%; }
  .comp-btn { flex: 1; padding: 7px 6px; font-size: 0.74rem; }
}

/* ── Rango de fechas personalizado del gráfico hero (P1.8) ─────────────────── */
.value-chart-controls { position: relative; }
.value-custom-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 130;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-strong, #12121a);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}
.value-custom-popover.hidden { display: none; }
.value-custom-popover label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted, #9ca3b4);
}
.value-custom-popover input[type="date"] {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #f5f7fb);
  font-size: 0.82rem;
}
.value-custom-popover .button { padding: 7px 14px; }
.value-custom-error { flex-basis: 100%; color: var(--loss, #ff6b81); font-size: 0.72rem; }
body.light-mode .value-custom-popover { background: #fff; border-color: rgba(15, 23, 42, 0.12); }
body.light-mode .value-custom-popover input[type="date"] { color: #172033; border-color: rgba(15, 23, 42, 0.14); background: rgba(15, 23, 42, 0.03); }
@media (max-width: 560px) {
  .value-custom-popover { left: 0; right: auto; }
}

/* ── Vista consolidada navegable "Todos" (P0.4) ───────────────────────────── */
.cbar-cta { margin-left: auto; white-space: nowrap; align-self: center; }
.consolidated-badge {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--warm, #ffb454);
  background: rgba(var(--warm-rgb, 255, 180, 84), 0.14);
  border: 1px solid rgba(var(--warm-rgb, 255, 180, 84), 0.3);
}
#trackerDashView.is-consolidated .consolidated-badge { display: inline-flex; }
/* Modo sólo lectura: ocultar toda acción que edite datos del portafolio. */
#trackerDashView.is-consolidated #addPositionBtn,
#trackerDashView.is-consolidated .pos-action-menu,
#trackerDashView.is-consolidated #manageCashBtn,
#trackerDashView.is-consolidated .portfolio-rename-btn,
#trackerDashView.is-consolidated #editPortfolioSettingsBtn,
#trackerDashView.is-consolidated #sharePortfolioBtn {
  display: none !important;
}

/* ── Gráficas táctiles en móvil (Mobile 8) ────────────────────────────────────
   Permite el scroll vertical de la página, pero captura el arrastre horizontal
   sobre el lienzo para mover el crosshair/tooltip (Pointer Events ya unifican
   ratón y tacto en las gráficas del tracker). */
#portfolioValueChart,
#investmentValueChart,
#perfLineChart,
#mcCanvas,
#whatifCanvas {
  touch-action: pan-y;
}

/* ── Correlación: lista de pares (visible solo en móvil) — Mobile 2 ────────── */
.corr-top-pairs { display: none; }
.corr-pairs-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #9ca3b4);
  margin: 4px 0 8px;
}
.corr-pair-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.02);
}
.corr-pair-names { font-weight: 600; font-size: 0.9rem; }
.corr-pair-val { font-weight: 700; display: flex; flex-direction: column; align-items: flex-end; }
.corr-pair-val small { font-weight: 500; font-size: 0.66rem; opacity: 0.7; color: var(--muted, #9ca3b4); }
@media (max-width: 720px) {
  #corrMatrixWrap { display: none; }
  .corr-top-pairs { display: block; }
}

/* ── Jerarquía de KPIs (Visual 2): atenúa métricas de detalle ──────────────── */
.summary-item.summary-item--muted { opacity: 0.9; }
.summary-item.summary-item--muted strong { font-size: 1.15rem; font-weight: 650; }
.summary-item.summary-item--muted > span:not(.kpi-hero-label-row) { color: var(--muted, #9ca3b4); }

/* ── Estados de carga uniformes (Visual 7): shimmer para lienzos ───────────── */
@keyframes bpChartShimmer {
  0% { background-position: -420px 0; }
  100% { background-position: 420px 0; }
}
.chart-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: linear-gradient(100deg,
    rgba(255, 255, 255, 0.02) 30%,
    rgba(255, 255, 255, 0.07) 50%,
    rgba(255, 255, 255, 0.02) 70%);
  background-size: 840px 100%;
  animation: bpChartShimmer 1.3s linear infinite;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .chart-loading::after { animation: none; }
}

/* ── Tabla de posiciones entre 721px y 1439px ──────────────────────────────
   Abajo de 720px la tabla ya se convierte en tarjetas. El tope era 1000px,
   pero ahí sólo se miraba el ancho de la ventana y no el de la lámina: pasado
   1100px reaparece la barra lateral de 290px y la lámina se ENCOGE (a 1280px
   de ventana la lámina mide 801px, menos que a 1100px, donde mide 954px). Con
   las 12 columnas el ancho mínimo de la tabla es 953px, así que la franja que
   necesita recorte llega hasta ~1432px de ventana; se redondea a 1439px.
   Se ocultan las tres columnas menos accionables — la minigráfica decorativa,
   la fecha (visible al desplegar los lotes) y el costo total (derivable de
   precio promedio × cantidad). */
@media (min-width: 721px) and (max-width: 1439px) {
  .tracker-table--positions > thead > tr > th.th-sparkline,
  .tracker-table--positions > thead > tr > th:nth-child(3),
  .tracker-table--positions > thead > tr > th:nth-child(8),
  #positionsTableBody > .pos-row > td[data-label="30 días"],
  #positionsTableBody > .pos-row > td[data-label="Fecha"],
  #positionsTableBody > .pos-row > td[data-label="Costo total"] {
    display: none;
  }
}

/* ── Jerarquía de tarjetas de posición en móvil (Mobile 3) ─────────────────── */
@media (max-width: 720px) {
  /* Destaca lo esencial (valor, retorno, cambio hoy) y atenúa el resto. */
  #positionsTableBody > .pos-row > td[data-label="Valor actual"] { font-weight: 700; }
  #positionsTableBody > .pos-row > td[data-label="Fecha"],
  #positionsTableBody > .pos-row > td[data-label="Precio promedio"],
  #positionsTableBody > .pos-row > td[data-label="Cantidad"],
  #positionsTableBody > .pos-row > td[data-label="Costo total"] {
    opacity: 0.72;
  }
  #positionsTableBody > .pos-row > td[data-label="Fecha"] > *,
  #positionsTableBody > .pos-row > td[data-label="Precio promedio"],
  #positionsTableBody > .pos-row > td[data-label="Cantidad"],
  #positionsTableBody > .pos-row > td[data-label="Costo total"] { font-size: 0.86rem; }
}
@media (max-width: 560px) {
  .value-chart-controls { justify-content: flex-start; }
  .value-series-btn { padding: 6px 9px; font-size: 0.74rem; }
}

/* ── Ajustes responsive de las mejoras del tracker (tablet + móvil) ────────── */
/* KPIs terciarios: 2 columnas en tablet estrecho (no aplica a móvil ≤720). */
@media (min-width: 721px) and (max-width: 900px) {
  .kpi-details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  /* Carrusel horizontal de KPIs hero en móvil (móvil/tablet #4): antes 3
     tarjetas apiladas de ancho completo (~600px de scroll); ahora un
     scroll-snap horizontal, sin JS, con solo el primero visible de entrada. */
  .tracker-kpi-grid {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 10px;
  }
  .tracker-kpi-grid::-webkit-scrollbar {
    display: none;
  }
  .tracker-kpi-hero {
    grid-column: auto;
    flex: 0 0 84%;
    scroll-snap-align: start;
  }

  /* KPIs terciarios colapsables: una columna en móvil. */
  .kpi-details-grid {
    grid-template-columns: 1fr;
  }

  /* En vista de tarjetas, el ticker no debe quedar "pegajoso" ni con fondo de
     columna: se restaura el flujo normal de la card. */
  .tracker-table--positions .th-ticker-sticky,
  .tracker-table--positions td:first-child,
  .tracker-table--positions th:last-child,
  .tracker-table--positions td:last-child {
    position: static;
    background: transparent;
    box-shadow: none;
  }

  /* El menú de exportación ocupa el ancho disponible dentro del scroll. */
  .tracker-export-menu { flex: 0 0 auto; }
  .tracker-export-dropdown {
    right: auto;
    left: 0;
    min-width: 220px;
  }

  /* ── Fila compacta expandible de posiciones (bug #2 / P0) ──────────────────
     Por defecto solo se ve Ticker, sparkline, Valor actual, Retorno y
     Acciones; el resto se revela al tocar el chevron (clase .is-row-expanded
     agregada por JS). Antes cada posición apilaba ~12 campos y ocupaba una
     pantalla completa; ahora caben varias posiciones sin expandir. */
  #positionsTableBody > .pos-row:not(.is-row-expanded) > td[data-label="Fecha"],
  #positionsTableBody > .pos-row:not(.is-row-expanded) > td[data-label="Precio promedio"],
  #positionsTableBody > .pos-row:not(.is-row-expanded) > td[data-label="Precio actual"],
  #positionsTableBody > .pos-row:not(.is-row-expanded) > td[data-label="Cambio hoy"],
  #positionsTableBody > .pos-row:not(.is-row-expanded) > td[data-label="Cantidad"],
  #positionsTableBody > .pos-row:not(.is-row-expanded) > td[data-label="Costo total"],
  #positionsTableBody > .pos-row:not(.is-row-expanded) > td.td-vs-bench {
    display: none;
  }

  /* El chevron siempre debe verse en móvil (incluso sin lotes): ahí es donde
     se revelan los campos secundarios de la fila. */
  .pos-expand-btn { display: inline-flex !important; align-items: center; }
}
