/* JEV dashboard — diseño móvil primero. Los estilos base son para ~360px; los @media (min-width) amplían. */
/* Tema oscuro empresarial (navy) — por defecto para todos, como la referencia. */
:root {
  --bg: #0a0f1d; --surface: #111a2e; --surface2: #1a2740; --text: #e6ecf5; --muted: #8a98b5;
  --line: #1f2b45; --brand: #3b82f6; --brand-ink: #ffffff;
  --for: #22c55e; --against: #ef4444; --warn: #f59e0b; --info: #38bdf8;
  --for-bg: #0f2e1d; --against-bg: #3a1620; --warn-bg: #3a2c0b; --info-bg: #10263f;
  --radius: 14px; --gutter: 16px; --nav-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {    /* tema oscuro (por defecto en Sof-i); se reafirma para quien prefiera oscuro en su sistema */
  :root {
    --bg: #0a0f1d; --surface: #111a2e; --surface2: #1a2740; --text: #e6ecf5; --muted: #8a98b5;
    --line: #1f2b45; --brand: #3b82f6; --brand-ink: #ffffff;
    --for: #22c55e; --against: #ef4444; --warn: #f59e0b; --info: #38bdf8;
    --for-bg: #0f2e1d; --against-bg: #3a1620; --warn-bg: #3a2c0b; --info-bg: #10263f;
  }
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #0a0f1d; --surface: #111a2e; --surface2: #1a2740; --text: #e6ecf5; --muted: #8a98b5;
    --line: #1f2b45; --brand: #3b82f6; --brand-ink: #ffffff;
    --for: #22c55e; --against: #ef4444; --warn: #f59e0b; --info: #38bdf8;
    --for-bg: #0f2e1d; --against-bg: #3a1620; --warn-bg: #3a2c0b; --info-bg: #10263f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font);
  overflow-x: hidden; overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* --- estructura --- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) 8px calc(var(--gutter) + env(safe-area-inset-left));
  background: var(--surface); color: var(--text); border-bottom: 1px solid var(--line);
}
.topbar .logo { font-weight: 800; font-size: 18px; letter-spacing: .3px; color: var(--brand); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.topbar .logo .logo-img { height: 26px; width: auto; display: block; }
.login .login-logo-img { display: block; width: 180px; max-width: 70%; height: auto; margin: 0 auto 4px; }
.topbar .mode { font-size: 12px; opacity: .85; display: none; }
@media (min-width: 481px) { .topbar .mode { display: inline; } }

/* --- FASE 8: barra de empresa activa (visible en toda la app) --- */
.company-bar { display: flex; align-items: center; gap: 6px; flex: 1 1 100%; min-width: 0; max-width: 100%; order: 5; }
.company-bar .ico { font-size: 16px; flex: none; }
.company-select { flex: 1 1 auto; min-width: 0; max-width: 100%; min-height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface2); color: inherit; padding: 0 8px; font-size: 13px; }
.company-select option { color: var(--text); background: var(--surface); }
.company-name, .company-link { color: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 auto; }
@media (min-width: 481px) { .company-bar { flex: 1 1 auto; max-width: 260px; order: 0; } .company-select { max-width: 180px; } }

/* --- FASE 8: layout de dos columnas (barra lateral en escritorio) --- */
.shell-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar { display: none; }
.iconbtn {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,.16);
  color: inherit; padding: 0 12px;
}
a.iconbtn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #9ca3af; display: inline-block; }
.dot.live { background: #4ade80; }
main {
  flex: 1; width: 100%; max-width: 1100px; margin: 0 auto;
  padding: 16px calc(var(--gutter) + env(safe-area-inset-right)) calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 16px;
}
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 12px; position: relative; text-decoration: none; min-width: 0; padding: 0 2px; overflow: hidden; white-space: nowrap;
}
.nav a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.nav .ico { font-size: 20px; line-height: 1; }
.badge-count {
  position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--against); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center;
}

/* --- tarjetas --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h2 { font-size: 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { display: block; color: inherit; text-decoration: none; min-height: 88px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 28px; font-weight: 800; line-height: 1.15; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stat.wide { grid-column: 1 / -1; }
.stat.kpi.no-data { opacity: .6; border-style: dashed; }
.stat.kpi.no-data .value { color: var(--muted); font-size: 20px; }
.list { display: flex; flex-direction: column; gap: 12px; }

/* --- tarjeta de mercado --- */
.mkt { display: block; color: inherit; text-decoration: none; }
.mkt:hover { text-decoration: none; border-color: var(--brand); }
.mkt .title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.metrics.six { grid-template-columns: repeat(2, 1fr); }
.m .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.m .v { font-size: 18px; font-weight: 700; }
.pos { color: var(--for); } .neg { color: var(--against); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.tag.supports, .tag.confirmed { background: var(--for-bg); color: var(--for); }
.tag.opposes, .tag.contradictory, .tag.conflicted_evidence, .tag.conflicted_fact { background: var(--against-bg); color: var(--against); }
.tag.probable, .tag.unverified { background: var(--warn-bg); color: var(--warn); }
.tag.info { background: var(--info-bg); color: var(--info); }

/* --- controles --- */
.search { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.btn { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--brand); color: var(--brand-ink); font-weight: 700; width: 100%; }
.btn.ghost { background: var(--surface2); color: var(--text); }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
select.search { width: auto; max-width: 100%; }
.row > * { min-width: 0; }
.row > select.search, .row > label { flex: 1 1 0; width: 100%; }
.list > label { display: flex; flex-direction: column; gap: 4px; }

/* --- detalle --- */
.back { align-self: flex-start; min-height: 44px; border: 0; background: none; color: var(--brand); padding: 0; font-weight: 700; }
.question { font-size: 20px; font-weight: 700; line-height: 1.3; }
.meta { font-size: 13px; color: var(--muted); }
.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item .claim { font-weight: 600; }
.item .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface2); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.ver { font-size: 12px; color: var(--muted); margin-top: 6px; }
details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.rules { white-space: pre-wrap; font-size: 14px; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.k-kalshi { background: #64748b; } .k-jev { background: #0f766e; } .k-brier { background: #b91c1c; }
.mt { margin-top: 8px; }
.legend b { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.empty, .skeleton { color: var(--muted); font-size: 14px; padding: 8px 0; }
.skeleton { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.disclaimer { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0 8px; }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.3);
}

/* --- login --- */
.login { max-width: 420px; margin: 0 auto; padding: 48px var(--gutter); display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 32px; color: var(--brand); }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.err { color: var(--against); font-size: 14px; min-height: 20px; }

/* --- señales en vivo --- */
.card.sig { display: block; color: inherit; text-decoration: none; }
.card.sig .title { overflow-wrap: anywhere; }
.card.sig .sub { margin-top: 8px; overflow-wrap: anywhere; }
.nav a { font-size: 10px; }
.nav .ico { font-size: 18px; }

/* --- entrenamiento --- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 2px; margin-bottom: 4px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 1 auto; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; font-size: 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: inherit; text-decoration: none; font-size: 14px; }
.tab[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
pre.json { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.35; background: var(--surface2); border-radius: 10px; padding: 10px; margin: 6px 0 0; max-height: 260px; overflow: auto; }
progress.bar { width: 100%; height: 8px; margin-top: 6px; accent-color: var(--brand); }
button.card.left { text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer; }

/* --- pantallas más grandes --- */
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat.wide { grid-column: span 2; }
  .metrics.six { grid-template-columns: repeat(3, 1fr); }
  .list.cols { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (min-width: 1024px) {
  :root { --gutter: 28px; }
  .stats { grid-template-columns: repeat(5, 1fr); }
  .stat.wide { grid-column: auto; }
  .metrics.six { grid-template-columns: repeat(6, 1fr); }
  .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .detail-grid > .full { grid-column: 1 / -1; }
  .nav { display: none; }                                                 /* la barra inferior de móvil se reemplaza por la barra lateral */
  .badge-count { position: static; }
  main { padding-bottom: 32px; }
  .toast { left: auto; right: 24px; bottom: 24px; max-width: 420px; }
  /* --- FASE 8: barra lateral (Executive Shell) --- */
  .shell-body { flex-direction: row; align-items: stretch; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px; width: 232px; flex: none; padding: 16px 10px; overflow-y: auto;
    position: sticky; top: 0; align-self: flex-start; height: 100dvh; border-right: 1px solid var(--line); background: var(--surface);
  }
  .sidebar-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 14px 10px 4px; }
  .sidebar-title:first-child { padding-top: 4px; }
  .sidebar-link {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; position: relative;
  }
  .sidebar-link:hover { background: var(--surface2); text-decoration: none; }
  .sidebar-link[aria-current="page"] { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
  .sidebar-link .ico { font-size: 17px; width: 20px; text-align: center; }
  .sidebar-link .badge-count.abadge { position: static; margin-left: auto; }
  main { flex: 1; min-width: 0; margin: 0 auto; max-width: 1100px; }
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* --- conectar teléfono / menú Más --- */
.qrbox { display: flex; justify-content: center; padding: 8px 0; }
.qr { width: min(100%, 320px); height: auto; background: #ffffff; border-radius: 8px; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.ico { font-size: 22px; line-height: 1; }
.list.cols .mkt .row { gap: 12px; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }

/* --- barra superior estrecha (320-480 px) --- */
.topbar { flex-wrap: wrap; }
.topbar .logo { flex: 1 0 auto; }
.iconbtn { white-space: nowrap; font-size: 14px; padding: 0 10px; }
.topbar select.search { flex: 1 1 140px; min-height: 44px; width: auto; max-width: 60%; }
.hide-sm { display: none !important; }
@media (min-width: 641px) { .hide-sm { display: inline-flex !important; } }

/* ===== FASE 8: portada ejecutiva de la empresa (tema oscuro empresarial) ===== */
.exec-sub { color: var(--muted); font-size: 13px; margin-top: -6px; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 760px) { .kpi-grid { grid-template-columns: repeat(5, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; min-height: 118px; }
.kpi.no-data { opacity: .7; border-style: dashed; }
.kpi-link { cursor: pointer; text-decoration: none; color: inherit; transition: transform .1s ease, border-color .1s ease, box-shadow .1s ease; }
.kpi-link:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 4px; }
.kpi-ico { width: 40px; height: 40px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.kpi-blue .kpi-ico { background: rgba(59,130,246,.18); }
.kpi-teal .kpi-ico { background: rgba(20,184,166,.18); }
.kpi-green .kpi-ico { background: rgba(34,197,94,.18); }
.kpi-purple .kpi-ico { background: rgba(168,85,247,.18); }
.kpi-red .kpi-ico { background: rgba(239,68,68,.18); }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kpi.no-data .kpi-value { font-size: 17px; color: var(--muted); }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-delta { font-size: 12px; font-weight: 700; }
.kpi-delta.up { color: var(--for); }
.kpi-delta.down { color: var(--against); }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-head h3 { font-size: 15px; margin: 0; }
.exec-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1024px) { .exec-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }
.exec-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.exec-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.exec-2up { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .exec-2up { grid-template-columns: 1fr 1fr; } }
.exec-range { max-width: 160px; min-height: 36px; }
.chart { width: 100%; height: auto; }
.k-sales { background: #3b82f6; }
.k-forecast { background: #a855f7; }

.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut-c { position: relative; width: 150px; height: 150px; flex: none; }
.donut { width: 150px; height: 150px; display: block; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.dc-num { font-size: 20px; font-weight: 800; }
.dc-lbl { font-size: 11px; color: var(--muted); }
.donut-legend { flex: 1 1 150px; min-width: 150px; display: flex; flex-direction: column; gap: 7px; }
.leg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.leg-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.leg-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-pct { color: var(--muted); font-variant-numeric: tabular-nums; }

.hub { width: 100%; height: auto; color: var(--muted); display: block; }
.hub-center { fill: var(--brand); }
.hub-ctext { fill: var(--brand-ink); }
.hub-node { fill: var(--surface2); stroke: var(--line); }

.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flow-col { background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 160px; }
.flow-h { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 6px; }
.flow-src { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 3px 0; }
.flow-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.flow-on { background: var(--for); }
.flow-off { background: var(--muted); opacity: .5; }
.flow-src .sub { margin-left: auto; font-size: 11px; white-space: nowrap; }
.flow-name { font-weight: 600; }
.flow-arrow { color: var(--muted); font-size: 18px; flex: none; }
.flow-node { background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-align: center; min-width: 120px; }
.flow-nt { font-weight: 700; font-size: 13px; }

.op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.op-cell { display: flex; align-items: center; gap: 10px; background: var(--surface2); border-radius: 12px; padding: 12px; }
.op-ico { font-size: 22px; }
.op-n { font-size: 20px; font-weight: 800; }

.activity { display: flex; flex-direction: column; }
.act-item { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.act-item:first-child { border-top: 0; padding-top: 0; }
.act-ico { font-size: 15px; flex: none; margin-top: 1px; }
.act-body .claim { font-weight: 600; font-size: 14px; }
.act-body .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.jev-panel { border: 1px solid var(--line); }
@media (min-width: 1024px) { .jev-panel { position: sticky; top: 76px; } }
.jev-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.jev-star { color: var(--brand); font-size: 18px; }
.jev-sec { margin-top: 14px; }
.jev-h { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.jev-h.op { color: var(--warn); }
.jev-h.rk { color: var(--against); }
.jev-h.rc { color: var(--info); }
.jev-li { font-size: 13px; color: var(--text); padding: 3px 0 3px 14px; position: relative; }
.jev-li::before { content: '•'; position: absolute; left: 2px; color: var(--muted); }
.jev-conf { margin-top: 16px; }
.jev-bar { height: 7px; border-radius: 4px; background: var(--surface2); overflow: hidden; margin-top: 5px; }
.jev-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #22d3ee); }
.jev-ask { display: flex; gap: 6px; margin-top: 16px; }
.jev-ask .search { flex: 1; min-height: 42px; }
.jev-send { min-width: 44px; min-height: 42px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 700; flex: none; }
