/* Economista IA — app v2. Blanco y negro, una cifra protagonista por pantalla; el índigo solo para MAX y lo que pasa en directo. */
:root {
  --bg: #ffffff; --ink: #000000; --mute: #737a82; --faint: #a3a9af; --line: #eceef0; --fill: #f4f5f6;
  --up: #12a06d; --down: #e0453a; --max: #4b44e5; --max-soft: #ecebfd; --warn: #b26b00;
  --font: "Geist", "Helvetica Neue", Arial, sans-serif;
  --tab-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000000; --ink: #ffffff; --mute: #8d949b; --faint: #5d646b; --line: #1d2023; --fill: #121416;
    --up: #2fca8c; --down: #ff6a5e; --max: #8a85ff; --max-soft: #1b1a3a; --warn: #f0b04a; color-scheme: dark; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 400 16px/1.45 var(--font); font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
:focus-visible { outline: 2px solid var(--max); outline-offset: 2px; border-radius: 6px; }
a { color: inherit; }

.screen { max-width: 560px; margin: 0 auto; padding: calc(16px + var(--safe-t)) 20px calc(var(--tab-h) + var(--safe-b) + 32px); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 8px; }
.top h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0; }

/* Segmento */
.seg { display: inline-flex; background: var(--fill); border-radius: 999px; padding: 3px; }
.seg button { padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 550; color: var(--mute); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Cifra protagonista */
.hero { margin: 18px 0 6px; }
.hero .label { color: var(--mute); font-size: 14px; }
.hero .value { font-size: clamp(40px, 11vw, 52px); font-weight: 600; letter-spacing: -.035em; line-height: 1.05; margin: 4px 0 6px; }
.hero .delta { font-size: 15px; font-weight: 550; }
.up { color: var(--up); } .down { color: var(--down); } .mute { color: var(--mute); }
.flash-up { animation: fu 1.2s ease-out; } .flash-down { animation: fd 1.2s ease-out; }
@keyframes fu { 0% { color: var(--up); } 100% { color: inherit; } }
@keyframes fd { 0% { color: var(--down); } 100% { color: inherit; } }

/* Gráfico */
.chart { width: 100%; height: 190px; display: block; margin: 14px 0 6px; touch-action: pan-y; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .base { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .dot { stroke: var(--bg); stroke-width: 2; }
.chart text { fill: var(--mute); font: 12px var(--font); }
.ranges { display: flex; gap: 4px; justify-content: space-between; margin-bottom: 22px; }
.ranges button { flex: 1; padding: 7px 0; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--mute); }
.ranges button[aria-pressed="true"] { background: var(--fill); color: var(--ink); }

/* Secciones y filas */
.sec { margin-top: 26px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.sec-h h2 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.sec-h button { font-size: 14px; font-weight: 550; color: var(--mute); }
.row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 0; text-align: left; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.av { flex: 0 0 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; letter-spacing: -.02em; color: #fff; }
.row .main { flex: 1; min-width: 0; }
.row .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { font-size: 14px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex: 0 0 auto; }
.row .end .t1 { font-weight: 600; }
.row .end .t2 { font-weight: 550; }
.row svg.spark { flex: 0 0 64px; height: 28px; }
.empty { color: var(--mute); padding: 18px 0; }
.note { color: var(--mute); font-size: 13px; line-height: 1.5; margin: 12px 0 0; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 22px; border-radius: 999px; font-weight: 650; font-size: 16px; background: var(--ink); color: var(--bg); }
.btn.sec2 { background: var(--fill); color: var(--ink); }
.btn.max { background: var(--max); color: #fff; }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btns { display: flex; gap: 10px; }
.btns .btn { flex: 1; }
.link { color: var(--max); font-weight: 600; font-size: 15px; }

/* Barra inferior */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: var(--safe-b); }
.tabbar nav { display: flex; width: 100%; max-width: 560px; }
.tabbar button { flex: 1; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--faint); position: relative; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-selected="true"] { color: var(--ink); }
.tabbar .livedot { position: absolute; top: 12px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 2px var(--bg); }

/* En directo */
.live-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--fill); color: var(--mute); }
.live-chip.on { background: var(--fill); background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; position: relative; }
.live-chip.on .pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid currentColor; opacity: 0; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(1.4); opacity: 0; } }
.pilot { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; background: var(--max-soft); margin: 18px 0 4px; }
.pilot .main { flex: 1; min-width: 0; }
.pilot .t1 { font-weight: 650; }
.pilot .t2 { font-size: 14px; color: var(--mute); }
.pilot .clock { font-weight: 650; color: var(--max); }
.switch { flex: 0 0 auto; width: 52px; height: 32px; border-radius: 999px; background: var(--faint); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch[aria-checked="true"] { background: var(--max); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .when { font-size: 13px; color: var(--mute); padding-top: 2px; }
.feed .what { font-weight: 600; }
.feed .why { font-size: 14px; color: var(--mute); margin-top: 2px; }
.feed .tag { display: inline-block; font-size: 12px; font-weight: 650; padding: 1px 8px; border-radius: 999px; margin-right: 6px; vertical-align: 1px; }
.tag.buy { background: var(--fill); background: color-mix(in srgb, var(--up) 15%, transparent); color: var(--up); }
.tag.sell { background: var(--fill); background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--down); }
.tag.info { background: var(--max-soft); color: var(--max); }
.tag.rej { background: var(--fill); color: var(--mute); }

/* Hojas (detalle de valor, orden, ajustes) */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .2s; }
.sheet-bg.open { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 94vh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); padding: 8px 20px calc(24px + var(--safe-b)); overscroll-behavior: contain; }
.sheet.open { transform: none; }
.sheet .inner { max-width: 560px; margin: 0 auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet .sh-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sheet .sh-top h2 { font-size: 20px; margin: 0; font-weight: 650; }
.x { width: 36px; height: 36px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; font-size: 20px; line-height: 1; color: var(--mute); }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-bg, .switch, .switch::after { transition: none; } .live-chip.on .pulse::after { animation: none; } }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; width: 560px; transform: translate(-50%, 100%); } .sheet.open { transform: translate(-50%, 0); } }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 8px 0 20px; }
.stats div { display: flex; flex-direction: column; }
.stats span:first-child { font-size: 13px; color: var(--mute); }
.stats span:last-child { font-weight: 600; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 4px; display: flex; flex-direction: column; gap: 10px; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field label, .field .lbl { font-size: 14px; color: var(--mute); font-weight: 500; }
.field input, .field select { height: 50px; border-radius: 14px; border: 0; background: var(--fill); padding: 0 16px; font-size: 17px; width: 100%; }
.amount { font-size: 44px !important; font-weight: 600; letter-spacing: -.03em; height: 64px !important; background: transparent !important; padding: 0 !important; }
.sum { list-style: none; padding: 0; margin: 10px 0 16px; }
.sum li { display: flex; justify-content: space-between; padding: 7px 0; font-size: 15px; }
.sum li span:first-child { color: var(--mute); }
.msg { padding: 12px 14px; border-radius: 14px; background: var(--fill); font-size: 14px; margin: 10px 0; }
.msg.bad { background: var(--fill); background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); }
.msg.ok { background: var(--fill); background: color-mix(in srgb, var(--up) 12%, transparent); color: var(--up); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { padding: 8px 12px; border-radius: 999px; background: var(--fill); font-size: 14px; font-weight: 550; }

/* IA */
.insight { padding: 16px; border-radius: 18px; background: var(--fill); margin-top: 10px; }
.insight h3 { margin: 0 0 6px; font-size: 16px; }
.insight .body { font-size: 15px; }
.insight .body p { margin: 0 0 8px; } .insight .body ul { margin: 0 0 8px; padding-left: 18px; }
.chat { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 20px; font-size: 15px; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.bubble.ai { align-self: flex-start; background: var(--fill); border-bottom-left-radius: 6px; max-width: 100%; }
.bubble.ai p { margin: 0 0 8px; } .bubble.ai p:last-child { margin: 0; }
.bubble.ai ul, .bubble.ai ol { margin: 0 0 8px; padding-left: 20px; }
.bubble.ai h1, .bubble.ai h2, .bubble.ai h3 { font-size: 16px; margin: 4px 0 6px; }
.bubble.ai table { border-collapse: collapse; font-size: 13px; }
.bubble.ai .tw { overflow-x: auto; margin: 0 0 8px; }
.bubble.ai th, .bubble.ai td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.bubble.err { background: var(--fill); background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); }
.thinking { display: inline-flex; gap: 8px; align-items: center; color: var(--mute); font-size: 14px; }
.thinking::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--max); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 15; padding: 8px 16px; background: var(--bg); }
.composer form { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; background: var(--fill); border-radius: 24px; padding: 6px 6px 6px 16px; }
.composer textarea { flex: 1; border: 0; background: transparent; resize: none; outline: none; font-size: 16px; line-height: 1.4; padding: 8px 0; max-height: 140px; }
.composer button { width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; flex: 0 0 auto; }
.composer button:disabled { opacity: .35; }
.ia-screen { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 90px); }

/* Cuenta */
.list-nav { border-radius: 18px; background: var(--fill); overflow: hidden; margin-top: 10px; }
.list-nav > * { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 15px 16px; text-align: left; border-bottom: 1px solid var(--line); gap: 12px; }
.list-nav > *:last-child { border-bottom: 0; }
.list-nav .v { color: var(--mute); font-size: 15px; text-align: right; }
.danger { color: var(--down); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 380px; }
.login h1 { font-size: 30px; letter-spacing: -.02em; margin: 18px 0 6px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 50; max-width: 528px; margin: 0 auto; padding: 14px 16px; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 550; box-shadow: 0 8px 28px rgba(0,0,0,.2); }
.top h1 { white-space: nowrap; }
.live-chip { white-space: nowrap; }

/* Gráfico profesional (Lightweight Charts) */
.pro-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 6px; flex-wrap: wrap; }
.seg.small button { padding: 5px 11px; font-size: 13px; }
.chips.ind { gap: 6px; }
.chips.ind button { padding: 5px 10px; font-size: 13px; color: var(--mute); }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.pro { width: 100%; margin: 4px 0 8px; touch-action: pan-y; }
.pro-main, .pro-rsi { width: 100%; }
.pro-lbl { font-size: 11px; color: var(--mute); margin: 6px 0 0; }
.attr { margin-top: 6px; }
.attr a { color: var(--mute); }

/* Broker */
.mode-badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 999px; vertical-align: 2px; margin-left: 6px; }
.mode-badge.paper { background: var(--max-soft); color: var(--max); }
.mode-badge.live { background: var(--down); color: #fff; }
.btn .mode-badge.paper { background: rgba(255,255,255,.2); color: inherit; }
.btn.danger { background: var(--down); color: #fff; }
.btn.sec2.danger { background: var(--fill); color: var(--down); }
.steps { padding-left: 20px; margin: 0 0 10px; }
.steps li { margin: 6px 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; margin: 12px 0 0; }
.check input { width: 20px; height: 20px; accent-color: var(--max); flex: 0 0 auto; }
.tabbar .acctdot { background: var(--down); }
