:root {
  --bg: #0f1115; --card: #171a21; --card2: #1d212a; --line: #262a33; --text: #e8eaed; --muted: #8b919c;
  --buy: #2ebd85; --sell: #f6465d; --accent: #f0b90b; --info: #4ea1ff;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
header { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
h1 { font-size: 18px; margin: 0; margin-right: auto; }
nav { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
nav button { background: none; border: 0; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; }
nav button.on { background: var(--card2); color: var(--text); }
nav .badge { background: var(--sell); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.src { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { padding: 3px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.pill.ok::before, .pill.err::before, .pill.off::before { content: "● "; }
.pill.ok::before { color: var(--buy); } .pill.err::before { color: var(--sell); } .pill.off::before { color: var(--muted); }
.banner { margin: 12px 16px 0; padding: 10px 12px; border-radius: 8px; background: rgba(240,185,11,.12); color: var(--accent); font-size: 13px; }
.banner.err { background: rgba(246,70,93,.12); color: var(--sell); }
.bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; align-items: center; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.grid { padding: 0 16px 40px; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 7px; }
.order { cursor: pointer; transition: border-color .15s; }
.order:hover { border-color: #3a404c; }
.order.new { animation: flash 1.2s ease 4; }
@keyframes flash { 50% { border-color: var(--accent); } }
.row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tag { font-weight: 700; font-size: 11px; padding: 2px 8px; border-radius: 6px; letter-spacing: .3px; }
.BUY { background: rgba(46,189,133,.15); color: var(--buy); }
.SELL { background: rgba(246,70,93,.15); color: var(--sell); }
.ex { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-left: 6px; }
.big { font-size: 21px; font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.timer.low { color: var(--sell); }
.need { color: var(--accent); font-size: 12px; font-weight: 600; }
.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 60px 0; }
.btn { border: 0; border-radius: 8px; padding: 10px 14px; font-weight: 700; cursor: pointer; text-align: center; text-decoration: none; display: inline-block; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-pay { background: var(--buy); color: #04140d; }
.btn-release { background: var(--sell); color: #fff; }
.btn-gray { background: #2a2f3a; color: var(--text); }
.btn-accent { background: var(--accent); color: #1a1400; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Drawer */
#drawer { position: fixed; inset: 0; display: none; z-index: 20; }
#drawer.open { display: block; }
#drawer .shade { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
#drawer .panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.dhead { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.dbody { flex: 1; overflow-y: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.sec { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.sec h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.pm { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 8px; background: var(--card2); }
.pm.sel { border-color: var(--buy); }
.pm label.hd { display: flex; gap: 8px; align-items: center; font-weight: 700; cursor: pointer; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px dashed var(--line); }
.field:first-of-type { border-top: 0; }
.field .k { color: var(--muted); font-size: 12px; min-width: 90px; }
.field .v { flex: 1; font-weight: 600; word-break: break-all; }
.copy { background: #2a2f3a; border: 0; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.copy.done { background: var(--buy); color: #04140d; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card2); border-radius: 8px; padding: 8px; }
.stat b { display: block; font-size: 15px; }
.stat span { color: var(--muted); font-size: 11px; }
.actions { display: flex; gap: 8px; }
.actions > * { flex: 1; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 85%; padding: 7px 10px; border-radius: 10px; background: var(--card2); align-self: flex-start; word-break: break-word; }
.msg .txt { white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: #1e3a5f; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 12px; text-align: center; }
.msg .meta { font-size: 10px; color: var(--muted); margin-top: 3px; }
.msg img { max-width: 220px; max-height: 260px; border-radius: 6px; display: block; cursor: zoom-in; }
.detected { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.detected .copy { background: rgba(240,185,11,.15); color: var(--accent); }
.composer { display: flex; gap: 6px; margin-top: 8px; }
.composer textarea { flex: 1; resize: none; height: 40px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

/* Anuncios */
.ad .price { font-size: 26px; font-weight: 800; }
.pos { font-weight: 800; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--card2); }
.pos.top { background: rgba(46,189,133,.18); color: var(--buy); }
.inline { display: flex; gap: 6px; }
.inline input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.mine td { background: rgba(240,185,11,.1); color: var(--accent); font-weight: 700; }
tr.ref td { background: rgba(78,161,255,.08); }
.tablewrap { overflow-x: auto; }
.botline { font-size: 12px; padding: 6px 8px; border-radius: 8px; background: var(--card2); }
.botline.on { border-left: 3px solid var(--buy); }

/* Diálogos */
dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; max-width: 480px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin-top: 0; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form input[type=number], .form input[type=text], .form input[type=password], dialog input[type=password] { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--text); width: 100%; }
.form .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.preview { margin-top: 10px; padding: 10px; border-radius: 8px; background: var(--card2); font-size: 13px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #2a2f3a; padding: 10px 16px; border-radius: 8px; display: none; z-index: 50; max-width: calc(100% - 32px); }
.log td { white-space: normal; }
.hidden { display: none !important; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } .form { grid-template-columns: 1fr; } }

/* Conexiones */
.conn select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--text); width: 100%; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.ck { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; background: var(--card2); }
.ck.error { background: rgba(246,70,93,.1); }
.ck.warn { background: rgba(240,185,11,.08); }
.conn ol { padding-left: 18px; margin: 8px 0; }
.conn code, .bar code { background: var(--card2); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 560px) { nav { max-width: 100%; overflow-x: auto; } nav button { white-space: nowrap; } }

/* Historial y ganancias */
select.chip, input.chip { color: var(--text); }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); padding: 0 16px 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.tile span { color: var(--muted); font-size: 12px; }
.tile b { font-size: 18px; }
.tile small { color: var(--muted); font-size: 11px; }
table.hist td { vertical-align: top; }
.sect { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 16px 10px; }
.hero { margin: 0 16px; padding: 18px; }
.heronum { font-size: 40px; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.heronum small, .cnum small { font-size: 14px; color: var(--muted); font-weight: 600; }
.herosub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.counters { display: grid; gap: 10px; padding: 0 16px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.counter { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.counter .cnum { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.counter .csub { font-size: 13px; color: var(--muted); }
.counter .btn { margin-top: 6px; }
.counter.live { border-color: var(--accent); }
.counter.neg .cnum { color: #e66767; }
.livebadge { color: var(--accent); font-size: 11px; font-weight: 700; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.charts { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
@media (max-width: 560px) { .charts { grid-template-columns: 1fr; } .heronum { font-size: 32px; } }
.chart { position: relative; margin-top: 8px; }
.chart .legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chart .legend i, .tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: absolute; top: 6px; transform: translateX(-50%); background: #0f1115; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; pointer-events: none; display: none; white-space: nowrap; z-index: 3; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.tip b:first-child { display: block; margin-bottom: 3px; }
.negtxt { color: #e66767; }
tr.totalrow td { font-weight: 700; border-top: 2px solid var(--line); }

/* Anuncios fuera de línea (minimizados) */
.offads { grid-column: 1 / -1; background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; }
.offads > summary { cursor: pointer; list-style: revert; }
.offads .grid.inner { padding: 12px 0 0; }
.offads .card { opacity: .85; }

.copy.copyall { background: var(--buy); color: #04140d; font-weight: 700; padding: 6px 12px; }
.copy.copyall.done { background: var(--accent); }

/* Compras con tarjeta */
.tag.CARD { background: rgba(144,133,233,.18); color: #9085e9; }
tr.cardrow td { background: rgba(144,133,233,.04); }
.cardsum { margin: 10px 16px 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.card-tile b { color: #9085e9; }

/* Liquidez compartida */
.pools { margin-bottom: 6px; }
.pool .big small { font-size: 13px; }
.pool.off { opacity: .75; }
.bar-track { height: 8px; background: var(--card2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: #3987e5; border-radius: 999px; transition: width .4s; }
.poolbadge { font-size: 12px; color: #3987e5; background: rgba(57,135,229,.12); padding: 4px 8px; border-radius: 6px; }
.poolpick { max-height: 260px; overflow-y: auto; }
.poolpick .pm { display: block; cursor: pointer; }

/* Favoritos y número de anuncio */
.star { background: none; border: 0; cursor: pointer; font-size: 20px; line-height: 1; color: var(--muted); padding: 0 2px; vertical-align: -2px; }
.star.on { color: var(--accent); }
.adid { font-size: 13px; }

/* Mercado rápido */
.mstrip-host { padding: 0 16px 10px; }
.mstrip { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.mhead { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.mhead .chip { padding: 4px 10px; font-size: 13px; }
.mrow { display: flex; gap: 10px; align-items: stretch; border-top: 1px solid var(--line); padding-top: 6px; }
.mex { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.mex .chip { padding: 3px 6px; font-size: 12px; max-width: 170px; }
.mchips { display: flex; gap: 6px; overflow-x: auto; flex: 1; align-items: stretch; }
.mchip { background: var(--card2); border-radius: 8px; padding: 5px 9px; min-width: 128px; font-size: 12px; display: flex; flex-direction: column; gap: 1px; }
.mchip b { font-size: 15px; }
.mchip.mine { outline: 1px solid var(--accent); }
.mlim { font-variant-numeric: tabular-nums; }
.mnick { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
@media (max-width: 560px) { .mrow { flex-direction: column; } .mex { flex-direction: row; align-items: center; } }

/* Estrategias */
.strat { gap: 6px; }
.strat.hot { border-color: #0ca30c; box-shadow: 0 0 0 1px rgba(12,163,12,.35) inset; }
.snet { font-size: 26px; font-weight: 800; color: #0ca30c; }
.strat .leg { background: var(--card2); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.sgroup { margin-bottom: 14px; }
#sBooks td .muted { font-size: 10px; }
#sAlert.on { border-color: var(--accent); color: var(--accent); }
.pill.hotpill { background: rgba(12,163,12,.15); color: #0ca30c; border-color: rgba(12,163,12,.4); }

/* ---------- Escáner y aprendizaje ---------- */
.heat { border-collapse: separate; border-spacing: 2px; font-variant-numeric: tabular-nums; }
.heat th { font-weight: 600; color: var(--muted); font-size: 12px; padding: 4px 6px; white-space: nowrap; }
.heat th.rowh { text-align: left; color: var(--text); }
.heat td { border-radius: 4px; text-align: center; padding: 7px 6px; min-width: 64px; font-size: 12px; cursor: default; }
.heat td:focus-visible { outline: 2px solid var(--text); }
.heat.small td { min-width: 22px; padding: 6px 0; font-size: 10px; }
.heat.small th { font-size: 10px; padding: 2px; }
.heatlegend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 8px; flex-wrap: wrap; }
.heatlegend .ramp { width: 160px; height: 10px; border-radius: 3px; }
.vtip { position: fixed; z-index: 50; pointer-events: none; background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; max-width: 280px; box-shadow: 0 6px 20px rgba(0,0,0,.35); display: none; }
.insights { margin: 8px 0 0; padding-left: 0; list-style: none; }
.insights li { padding: 6px 0 6px 26px; position: relative; border-bottom: 1px solid var(--line); }
.insights li:last-child { border-bottom: 0; }
.insights li::before { position: absolute; left: 0; top: 6px; }
.insights li.good::before { content: '✓'; color: #0ca30c; font-weight: 800; }
.insights li.bad::before { content: '!'; color: #ec835a; font-weight: 800; }
.insights li.info::before { content: 'i'; color: var(--info); font-weight: 800; }
.opp td { vertical-align: top; }
.opp .net { font-size: 16px; font-weight: 800; }
.grade { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.grade.g-hi { color: #0ca30c; border-color: rgba(12,163,12,.45); }
.grade.g-mid { color: #fab219; border-color: rgba(250,178,25,.45); }
.grade.g-lo { color: var(--muted); }
.kind { font-size: 10px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; margin-right: 4px; }
tr.hotrow td { background: rgba(12,163,12,.07); }
.tag.PAY { background: rgba(240,185,11,.15); color: var(--accent); }

/* ---------- Anuncios en tabla (estilo "Mis anuncios" de Binance) ---------- */
.adswrap { padding: 0 16px 40px; }
.adcard { padding: 0; overflow: hidden; }
.adtable { width: 100%; border-collapse: collapse; }
.adtable > thead > tr > th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; padding: 10px 12px; line-height: 1.5; border-bottom: 1px solid var(--line); vertical-align: bottom; white-space: nowrap; }
.adtable > tbody > tr > td { padding: 14px 12px; vertical-align: top; border-bottom: 1px solid var(--line); line-height: 1.7; }
.adtable > tbody > tr.adrow:hover > td { background: rgba(255,255,255,.02); }
.adtable > tbody > tr.off > td:not(.act):not(:nth-child(6)) { opacity: .6; }
.adtable .act { text-align: right; white-space: nowrap; }
.adtable .paym div { white-space: nowrap; }
.adtable > tbody > tr.adexp > td { background: var(--card2); padding: 12px; }
.adno { display: flex; align-items: center; gap: 6px; }
.adno .uline { text-decoration: underline; text-underline-offset: 3px; font-variant-numeric: tabular-nums; }
.adno .copy { padding: 0 6px; }
.buytxt { color: var(--buy); font-weight: 600; } .selltxt { color: var(--sell); font-weight: 600; }
.nowrap { white-space: nowrap; }
.exb { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; margin-left: 4px; vertical-align: 1px; }
.exb.binance { background: rgba(240,185,11,.15); color: var(--accent); }
.exb.bybit { background: rgba(78,161,255,.15); color: var(--info); }
.balbar { display: inline-flex; gap: 1px; vertical-align: -1px; margin-left: 4px; }
.balbar i { width: 3px; height: 11px; background: var(--line); border-radius: 1px; }
.balbar i.on { background: var(--buy); }
.balbar.low i.on { background: var(--sell); }
.poolmini { font-size: 11px; color: #3987e5; }
.adstat { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.sw { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: .15s; }
.sw span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.sw input:checked + span { background: var(--accent); }
.sw input:checked + span::before { transform: translateX(14px); }
.sw.dis span { cursor: not-allowed; opacity: .55; }
.ib { background: none; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; cursor: pointer; font-size: 15px; line-height: 1; }
.ib:hover { border-color: var(--line); background: var(--card2); }
.ib.on { border-color: rgba(46,189,133,.5); }
.ib:disabled { opacity: .35; cursor: default; }

.vfoot { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 16px 24px; border-top: 1px solid var(--line); margin-top: 24px; }
.order.blk { border-color: var(--sell); box-shadow: 0 0 0 1px rgba(246,70,93,.4) inset; }
.ctags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.cnote { width: 100%; min-height: 54px; box-sizing: border-box; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 8px; margin-bottom: 6px; font: inherit; }
.hcheck { font-size: 12px; margin: 4px 0 6px; } .hcheck.ok { color: var(--buy); } .hcheck.bad { color: var(--sell); }
.pfbox { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.form div.full { grid-column: 1 / -1; }
tr.skipped td { opacity: .45; }
