/* ==========================================================================
   Overlook — sistema de diseño
   Estilo: Dark (OLED) fintech · Tipografía: IBM Plex Sans · Densidad: dashboard
   ========================================================================== */
:root {
  /* superficies */
  --bg: #020617;
  --surface: #0b1120;
  --surface-2: #111a2e;
  --surface-3: #18233b;
  --border: #1e293b;
  --border-strong: #334155;
  /* texto */
  --text: #f8fafc;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  /* marca e interacción */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(59, 130, 246, .14);
  --link: #60a5fa;
  --ring: #93c5fd;
  /* semánticos (solo para datos) */
  --up: #22c55e;
  --up-soft: rgba(34, 197, 94, .12);
  --down: #f87171;
  --down-soft: rgba(248, 113, 113, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .1);
  --violet: #a78bfa;
  /* escala */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .5);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 160ms;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
  /* z-index */
  --z-sticky: 20;
  --z-drawer: 50;
  --z-modal: 100;
  --z-toast: 200;
  --topbar-bg: rgba(2, 6, 23, .82);
  --placeholder: #64748b;
  --warn-text: #fde68a;
  --info-text: #bfdbfe;
  --hero-border: #1e3a8a;
  --on-primary: #ffffff;
  --chart-ink: #3b82f6;
  --chart-grid: rgba(148, 163, 184, .08);
  --chart-muted: #64748b;
  --tooltip-bg: #111a2e;
  --scroll-thumb: rgba(148, 163, 184, .28);
  --scroll-thumb-hover: rgba(148, 163, 184, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'tnum' 0;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* foco visible para teclado */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* iconos SVG */
.ico { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ico.sm { width: 14px; height: 14px; }
.ico.lg { width: 22px; height: 22px; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: var(--z-toast); background: var(--primary); color: #fff; padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; }

/* ---------- acceso ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(900px 500px at 10% 0%, rgba(37, 99, 235, .28), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, rgba(34, 197, 94, .12), transparent 60%),
    var(--surface);
  border-right: 1px solid var(--border);
}
.auth-hero h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.02em; max-width: 460px; margin-top: 24px; }
.auth-hero .lead { color: var(--text-2); font-size: 16px; max-width: 440px; margin-top: 14px; }
.auth-feats { display: grid; gap: 14px; margin-top: 36px; max-width: 440px; }
.auth-feat { display: flex; gap: 12px; align-items: flex-start; color: var(--text-2); }
.auth-feat .ico-wrap { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--link); flex-shrink: 0; }
.auth-feat b { color: var(--text); display: block; font-weight: 600; }
.auth-chart { margin-top: 32px; opacity: .9; }
.auth-panel { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 24px; }
.auth-card form { display: grid; gap: 14px; margin-top: 22px; }
.auth-card .tabs { display: flex; margin-top: 20px; }
.auth-card .tab { flex: 1; }
.auth-foot { color: var(--muted); font-size: 12px; margin-top: 18px; display: flex; gap: 6px; align-items: center; }
.auth-analysis { display: flex; gap: 8px; align-items: center; margin-top: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); font-size: 13px; text-decoration: none; }
.auth-analysis:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-hero { display: none; } }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff; box-shadow: 0 4px 14px rgba(37, 99, 235, .35); }
.logo .ico { width: 17px; height: 17px; stroke-width: 2.25; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 0 8px; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; margin-top: 20px; flex: 1; }
.sidebar nav a {
  position: relative; color: var(--text-2); padding: 8px 10px; min-height: 36px; border-radius: 8px;
  display: flex; gap: 11px; align-items: center; font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar nav a .ico { color: var(--muted); transition: color var(--dur) var(--ease); }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--primary-soft); color: var(--text); }
.sidebar nav a.active .ico { color: var(--link); }
.sidebar nav a.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--link); }
.nav-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 10px 6px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 4px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.user-meta { min-width: 0; flex: 1; line-height: 1.3; }
.user-meta .n { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta .e { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; min-height: 64px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: var(--z-sticky);
  background: var(--topbar-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar h1 { flex: 1; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.market-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; }
.market-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.market-status.open .dot { background: var(--up); }
#menuBtn { display: none; }
.page { padding: 24px 28px 64px; display: grid; gap: 20px; width: 100%; animation: page-in 220ms var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.scrim { position: fixed; inset: 0; background: rgba(2, 6, 23, .6); z-index: calc(var(--z-drawer) - 1); }
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: var(--z-drawer); left: 0; transform: translateX(-100%); transition: transform 220ms var(--ease); box-shadow: var(--shadow-2); }
  .sidebar.open { transform: none; }
  #menuBtn { display: inline-flex; }
  .page { padding: 16px 16px 64px; gap: 16px; }
  .topbar { padding: 10px 16px; min-height: 56px; }
  .market-status { display: none; }
}

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 -4px; }
.grid { display: grid; gap: 16px; }
.grid.k { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.c2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.c2e { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 1100px) { .grid.c2, .grid.c2e { grid-template-columns: 1fr; } }

/* KPIs */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.kpi .sub { font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi.hero { grid-column: span 2; background: linear-gradient(135deg, rgba(37, 99, 235, .16), rgba(37, 99, 235, 0) 60%), var(--surface); border-color: var(--hero-border); }
.kpi.hero .value { font-size: 32px; }
@media (max-width: 600px) {
  .grid.k { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 17px; }
  .kpi.hero .value { font-size: 26px; }
  .calc-params { order: -1; }
}

/* variación con icono (no solo color) */
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta .ico { width: 13px; height: 13px; stroke-width: 2.5; }
.delta.pill { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.delta.pill.up { background: var(--up-soft); }
.delta.pill.down { background: var(--down-soft); }
.delta.pill.flat { background: var(--surface-3); color: var(--muted); }

/* botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 80ms var(--ease);
  touch-action: manipulation;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 1px 0 rgba(255, 255, 255, .1) inset; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--down); }
.btn.danger:hover { background: var(--down-soft); border-color: rgba(248, 113, 113, .4); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.btn.icon { padding: 6px; min-width: 36px; }
.btn.small.icon { min-width: 30px; padding: 4px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn .spin { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* pestañas segmentadas */
.tabs { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tab {
  border: 0; background: transparent; color: var(--muted); padding: 5px 11px; min-height: 28px; border-radius: 6px;
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }
.tab:hover:not(.active) { color: var(--text); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; min-height: 34px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer; color: var(--text-2); font: inherit; font-weight: 500;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.dashed { border-style: dashed; color: var(--muted); }

/* formularios */
.field { display: grid; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--text); border-radius: 8px;
  padding: 8px 11px; min-height: 38px; font: inherit; font-size: 14px; font-weight: 400; width: 100%; min-width: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input::placeholder { color: var(--placeholder); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--link); box-shadow: 0 0 0 3px rgba(96, 165, 250, .2); }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=color] { padding: 3px; height: 38px; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--primary); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.error { color: var(--down); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.error:empty { display: none; }
.hint { font-size: 12px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.input-icon { position: relative; }
.input-icon .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 36px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-wrap button { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); }
@media (max-width: 600px) { input, select, textarea { font-size: 16px; min-height: 44px; } .btn { min-height: 44px; } .btn.small { min-height: 36px; } }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 18px; }
.badge.buy { color: var(--up); background: var(--up-soft); }
.badge.sell { color: var(--down); background: var(--down-soft); }
.badge.transfer { color: var(--violet); background: rgba(167, 139, 250, .12); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }

/* tablas */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th[aria-sort] { color: var(--text); }
th .ico { width: 12px; height: 12px; margin-left: 2px; }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tbody tr { transition: background var(--dur) var(--ease); }
tr.clickable:hover td { background: var(--surface-2); }
tr.closed td { opacity: .5; }
th.num, td.num { text-align: right; }
.asset-cell { display: flex; align-items: center; gap: 11px; min-width: 180px; }
.asset-cell .txt { display: flex; flex-direction: column; min-width: 0; }
.asset-cell .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.asset-cell .sym { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.asset-av { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; letter-spacing: -.02em; }
.row-actions { display: inline-flex; gap: 2px; opacity: .7; transition: opacity var(--dur); }
tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }

/* gráficos */
.chart-box { position: relative; height: 320px; }
.chart-box.sm { height: 180px; }
.chart-box.xs { height: 60px; }
.chart-box.lg { height: 400px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; display: grid; justify-items: center; gap: 8px; }
.empty .ico-wrap { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); margin-bottom: 4px; }
.empty b { color: var(--text); font-weight: 600; }
.empty .btn { margin-top: 8px; }
.spark { width: 110px; height: 34px; display: block; }

/* skeleton de carga */
.skeleton, .loading {
  position: relative; overflow: hidden; border-radius: var(--radius); color: transparent !important;
  background: var(--surface-2); min-height: 18px; user-select: none;
}
.loading { min-height: 96px; border: 1px solid var(--border); }
.skeleton::after, .loading::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, .08), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.kpi.skeleton { height: 96px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(2, 6, 23, .72); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: var(--z-modal); padding: 16px; overflow-y: auto; animation: fade-in 140ms var(--ease); }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; width: 100%; max-width: 620px;
  max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: var(--shadow-2); animation: modal-in 200ms var(--ease);
}
.modal.wide { max-width: 920px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h2 { flex: 1; font-size: 16px; }
.modal-body { padding: 20px; display: grid; gap: 16px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }

/* búsqueda */
.search-box { position: relative; }
.search-results { position: absolute; left: 0; right: 0; top: 100%; margin-top: 6px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); max-height: 300px; overflow-y: auto; z-index: 10; box-shadow: var(--shadow-2); padding: 4px; }
.search-results div { padding: 9px 10px; cursor: pointer; display: flex; gap: 10px; align-items: center; border-radius: 7px; }
.search-results div:hover, .search-results div.sel { background: var(--primary-soft); }
.search-results .sym { font-weight: 600; min-width: 90px; font-variant-numeric: tabular-nums; }
.search-results .nm { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-asset { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius); }

/* brokers */
.broker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.broker {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; min-height: 44px; border: 1px solid var(--border);
  background: var(--bg); border-radius: var(--radius); cursor: pointer; color: var(--text-2); font: inherit; font-size: 13px; text-align: left;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.broker:hover { border-color: var(--border-strong); color: var(--text); }
.broker.active { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.bl { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08) inset; }

/* cartera */
.pf-card { cursor: pointer; transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease); display: grid; gap: 4px; }
.pf-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.pf-card .pf-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.pf-card .pf-val { font-size: 22px; font-weight: 600; margin-top: 8px; font-variant-numeric: tabular-nums; }
.pf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; }
.pf-stats span { color: var(--muted); display: block; margin-bottom: 2px; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 0 rgba(34, 197, 94, .5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .5); } 70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.legend-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 14px; font-size: 13px; }
.legend-list div { display: flex; align-items: center; gap: 9px; }
.legend-list .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.legend-list .bar { flex: 0 0 60px; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.legend-list .bar i { display: block; height: 100%; border-radius: 2px; }
.donut-wrap { position: relative; height: 210px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-center .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* mercado */
.mkt-card .mkt-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mkt-card .mkt-price { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mkt-card .mkt-sub { color: var(--muted); font-size: 12px; }

/* macro */
.ind { cursor: pointer; display: grid; gap: 4px; transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease); text-align: left; font: inherit; color: inherit; }
.ind:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.ind .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ind canvas { margin-top: 8px; }
.fg-gauge { display: grid; place-items: center; text-align: center; }

/* noticias */
.news-list { display: grid; }
.news-item { display: grid; gap: 4px; padding: 14px 12px; border-radius: var(--radius); color: var(--text); border-bottom: 1px solid var(--border); transition: background var(--dur) var(--ease); }
.news-item:last-child { border-bottom: 0; }
.news-item:hover { background: var(--surface-2); text-decoration: none; }
.news-item .t { font-weight: 500; line-height: 1.4; }
.news-item .m { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.news-item .src { color: var(--link); font-weight: 500; }
.news-item .d { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* calendario */
.day-list { display: grid; gap: 10px; }
.cal-day { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-day > .h { background: var(--surface-2); padding: 9px 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; text-transform: capitalize; }
.event-row { display: flex; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--border); align-items: center; }
.event-row .ico { color: var(--muted); }
.highlight { background: rgba(251, 191, 36, .06); box-shadow: inset 3px 0 0 var(--warn); }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: var(--z-toast); }
.toast { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border: 1px solid var(--border-strong); padding: 11px 14px; border-radius: var(--radius); box-shadow: var(--shadow-2); max-width: 380px; animation: toast-in 200ms var(--ease); }
.toast.err .ico { color: var(--down); }
.toast.ok .ico { color: var(--up); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.notice, .info { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius); font-size: 13px; line-height: 1.5; }
.notice { background: var(--warn-soft); border: 1px solid rgba(251, 191, 36, .3); color: var(--warn-text); }
.info { background: var(--primary-soft); border: 1px solid rgba(96, 165, 250, .3); color: var(--info-text); }
.notice > .ico, .info > .ico { margin-top: 1px; }

/* evita que los iframes de TradingView se pinten con fondo blanco */
.tradingview-widget-container, .tradingview-widget-container iframe { color-scheme: normal; }
#txForm { display: grid; gap: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.fg-gauge .loading { width: 100%; height: 160px; }
/* en indicadores macro la dirección no es "buena" ni "mala": color neutro */
.neutral-delta .delta { color: var(--text-2); }
.mkt-card .tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.mkt-card .tab { padding: 4px 8px; }

/* ==========================================================================
   Barras de desplazamiento finas y minimalistas
   ========================================================================== */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- logos de empresas y brokers ---------- */
.asset-av, .bl { position: relative; overflow: hidden; }
.asset-av img, .bl img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 3px; }
.bl img { padding: 2px; }
.asset-av.has-logo, .bl.has-logo { color: transparent; }
[data-theme="taste"] .asset-av.has-logo { background: #fff !important; }

/* ---------- estado del mercado (pre / abierto / post / cerrado) ---------- */
.market-status.pre .dot { background: var(--warn); }
.market-status.post .dot { background: #a78bfa; }
.market-status.open .dot { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); }
.market-status .when { color: var(--muted); }

/* ---------- arrastrar y soltar ---------- */
.sortable-item { touch-action: pan-y; }
.sortable-item.dragging { opacity: .9; box-shadow: var(--shadow-2); z-index: 5; position: relative; cursor: grabbing; transform: scale(1.03); }
.sortable-ghost { outline: 2px dashed var(--border-strong); outline-offset: -2px; opacity: .35; }
.chips.reorder-hint .chip.sortable-item { cursor: grab; }
.chip .gear { display: inline-grid; place-items: center; width: 22px; height: 22px; margin: -4px -6px -4px 0; border-radius: 6px; color: var(--muted); }
.chip .gear:hover { background: var(--surface-3); color: var(--text); }

/* ---------- tipos de cartera ("Otros") ---------- */
.kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kind { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius); cursor: pointer; color: var(--text-2); font: inherit; text-align: left; }
.kind .ico { color: var(--muted); }
.kind b { color: var(--text); font-weight: 600; font-size: 13px; }
.kind span { font-size: 12px; color: var(--muted); }
.kind.active { border-color: var(--primary); background: var(--primary-soft); }
.check-list { display: grid; gap: 4px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; }
.check-row:hover { background: var(--surface-2); }
.check-row .grow { flex: 1; min-width: 0; }

/* ---------- tarjeta "añadir" en Bolsa hoy ---------- */
.add-card { display: grid; place-items: center; gap: 6px; min-height: 160px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--muted); background: transparent; cursor: pointer; font: inherit; }
.add-card:hover { color: var(--text); border-color: var(--muted); }
.card-x { opacity: 0; transition: opacity var(--dur); }
.mkt-card:hover .card-x, .card-x:focus-visible { opacity: 1; }
@media (hover: none) { .card-x { opacity: 1; } }

/* ---------- mini calendario semanal de resultados ---------- */
.week-strip { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.week-day { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); display: grid; gap: 8px; align-content: start; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.week-day:hover { border-color: var(--border-strong); }
.week-day.today { border: 2px solid var(--text); padding: 11px; }
.week-day .wd { display: flex; align-items: baseline; gap: 6px; }
.week-day .wd b { font-size: 15px; text-transform: capitalize; }
.week-day .wd span { color: var(--muted); font-size: 12px; }
.week-day .co { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.week-day .co .asset-av { width: 22px; height: 22px; border-radius: 5px; font-size: 8px; }
.week-day .co .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-day .empty-day { color: var(--muted); font-size: 12px; }

/* ---------- herramientas ---------- */
.result-big { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* ---------- importación ---------- */
.dropzone { display: grid; place-items: center; gap: 8px; padding: 28px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over, .dropzone:hover { border-color: var(--muted); color: var(--text); background: var(--surface-2); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.preview-table td, .preview-table th { padding: 6px 8px; font-size: 12px; }
.row-bad td { color: var(--down); }

/* ==========================================================================
   Móvil: tablas convertidas en tarjetas (cada celda con su etiqueta)
   ========================================================================== */
@media (max-width: 640px) {
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive thead { display: none; }
  table.responsive tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
  table.responsive tbody tr:last-child { border-bottom: 0; }
  table.responsive td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex-shrink: 0; }
  table.responsive td[data-label=""]::before, table.responsive td.cell-main::before { display: none; }
  table.responsive td.cell-main { padding-bottom: 8px; justify-content: flex-start; text-align: left; }
  table.responsive td.cell-main .asset-cell { min-width: 0; }
  table.responsive tr.clickable:hover td { background: transparent; }
  table.responsive .row-actions { opacity: 1; }
  .table-wrap:has(table.responsive) { overflow-x: visible; }
  .topbar-actions .btn .label { display: none; }
  .topbar h1 { font-size: 18px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .modal-back { padding: 0; align-items: end; }
  .modal { max-height: 94dvh; border-radius: 16px 16px 0 0; }
  .card-head { gap: 8px; }
  .tabs { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }
  .week-strip { grid-template-columns: repeat(5, 72%); scroll-snap-type: x mandatory; }
  .week-day { scroll-snap-align: start; }
  .chart-box.lg { height: 260px; }
  .grid.c3 { grid-template-columns: 1fr; }
}

/* los hijos de la página nunca ensanchan la vista (p. ej. la tira semanal desplazable) */
.page > *, #calBody, #toolBody { min-width: 0; }
#calBody { display: grid; gap: 16px; }

/* ==========================================================================
   Análisis diario de mercado (página pública /analisis y sección de la app)
   ========================================================================== */
.an-public { min-height: 100vh; }
.an-top { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: 12px; padding: 12px max(16px, calc((100vw - 880px) / 2)); background: var(--topbar-bg); border-bottom: 1px solid var(--border); backdrop-filter: blur(10px); }
.an-top .brand { color: var(--text); text-decoration: none; }
.an-tag { font-size: 12px; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--border); }
.an-actions { display: flex; gap: 8px; }
.an-wrap { max-width: 880px; margin: 0 auto; padding: 32px 16px 56px; }
.an-article { min-width: 0; }
.an-date { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.an-title { font-size: clamp(24px, 4vw, 32px); line-height: 1.2; letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.an-lead { font-size: 17px; line-height: 1.6; color: var(--text-2); margin: 14px 0 0; max-width: 68ch; }
.an-figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin: 24px 0 8px; }
.an-fig { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.an-fig .n { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-fig .v { font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text); }
.an-fig .c { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.an-fig .c.up { color: var(--up); }
.an-fig .c.down { color: var(--down); }
.an-body { font-size: 16px; line-height: 1.7; color: var(--text-2); max-width: 72ch; }
.an-body h2 { font-size: 21px; color: var(--text); margin: 36px 0 10px; padding-top: 20px; border-top: 1px solid var(--border); }
.an-body h3 { font-size: 16px; color: var(--text); margin: 24px 0 6px; }
.an-body p { margin: 0 0 14px; }
.an-body ul, .an-body ol { margin: 0 0 14px; padding-left: 22px; }
.an-body li { margin: 4px 0; }
.an-body strong { color: var(--text); font-weight: 600; }
.an-body a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong); }
.an-body a:hover { text-decoration-color: currentColor; }
.an-body blockquote { margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.an-body blockquote p:last-child { margin: 0; }
.an-body hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.an-table { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.an-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.an-table th, .an-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.an-table th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--surface-2); }
.an-table tr:last-child td { border-bottom: 0; }
.an-table td { font-variant-numeric: tabular-nums; }
.an-cta { display: flex; align-items: center; gap: 16px; margin-top: 40px; flex-wrap: wrap; }
.an-cta-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); flex-shrink: 0; }
.an-cta-ico .ico.sm { width: 18px; height: 18px; }
.an-cta-txt { flex: 1; min-width: 220px; }
.an-cta-txt p { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.an-cta-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.an-disclaimer { margin: 24px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
@media (max-width: 600px) {
  .an-tag { display: none; }
  .an-wrap { padding-top: 24px; }
  .an-actions .btn { padding-left: 12px; padding-right: 12px; }
  .an-cta-btns { width: 100%; }
  .an-cta-btns .btn { flex: 1; }
}

/* Sección "Análisis diario" dentro de la app */
.an-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.an-layout .an-article { padding: 24px 28px; }
.an-history { position: sticky; top: 76px; padding: 12px; }
.an-history h2 { padding: 6px 8px 10px; }
.an-history-list { display: flex; flex-direction: column; gap: 2px; max-height: 70vh; overflow-y: auto; }
.an-history-list button { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); cursor: pointer; font: inherit; }
.an-history-list button:hover { background: var(--surface-2); color: var(--text); }
.an-history-list button[aria-current="true"] { background: var(--primary-soft); color: var(--text); }
.an-history-list .d { font-size: 13px; font-weight: 500; }
.an-history-list .t { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 1100px) {
  .an-layout { grid-template-columns: 1fr; }
  .an-history { position: static; order: -1; }
  .an-history-list { flex-direction: row; overflow-x: auto; max-height: none; }
  .an-history-list button { flex: 0 0 auto; }
  .an-history-list .t { display: none; }
  .an-layout .an-article { padding: 18px; }
}
