:root{
  --bg:#0e1117; --card:#161b22; --card2:#1c232d; --line:#2a313c;
  --txt:#e6edf3; --muted:#8b949e; --accent:#2f81f7;
  --up:#3fb950; --down:#f85149; --gold:#d4a72c;
  --r:14px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none !important}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--txt);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  padding-bottom:calc(72px + env(safe-area-inset-bottom));
  font-size:15px; line-height:1.4;
}
.muted{color:var(--muted)}
.small{font-size:12px}
.chg.up,.up{color:var(--up)} .chg.down,.down{color:var(--down)}

/* Topbar */
.topbar{
  position:sticky; top:0; z-index:20; background:var(--bg);
  display:flex; align-items:center; justify-content:space-between;
  padding:calc(10px + env(safe-area-inset-top)) 14px 10px; border-bottom:1px solid var(--line);
}
.brand{font-weight:700; font-size:16px}
.indicators{display:flex; gap:6px}
.pill{background:var(--card2); border:1px solid var(--line); border-radius:999px; padding:3px 9px; font-size:11px; color:var(--muted)}

/* Views */
.view{padding:12px 14px; max-width:980px; margin:0 auto}
.status{margin:10px 2px}

.card{background:var(--card); border:1px solid var(--line); border-radius:var(--r); padding:14px; margin-bottom:12px}
.total-card .big{font-size:26px; font-weight:700; margin:2px 0}
.big{font-variant-numeric:tabular-nums}
.sec{font-size:13px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); margin:18px 2px 8px}

/* Inputs */
input,select,button{font-family:inherit; font-size:15px}
input,select{
  background:var(--card2); border:1px solid var(--line); color:var(--txt);
  border-radius:10px; padding:11px 12px; outline:none; min-width:0;
}
input:focus,select:focus{border-color:var(--accent)}
.add-row{display:flex; gap:8px; margin-bottom:12px}
.add-row input{flex:1}
.add-row button, #addBtn{
  background:var(--accent); border:none; color:#fff; border-radius:10px;
  padding:0 16px; font-size:20px; font-weight:600; cursor:pointer;
}
.addline{
  width:100%; background:transparent; border:1px dashed var(--line); color:var(--muted);
  border-radius:10px; padding:11px; cursor:pointer; margin-bottom:6px;
}
.addline:active{background:var(--card2)}
button.ghost{background:var(--card2); border:1px solid var(--line); color:var(--txt); border-radius:10px; padding:9px 12px; cursor:pointer}
button.ghost.full{width:100%; margin-top:8px}

/* Segmented (Lista / Mapa) */
.seg{display:flex; gap:4px; background:var(--card2); border:1px solid var(--line); border-radius:10px; padding:3px; margin-bottom:12px}
.seg button{flex:1; background:none; border:none; color:var(--muted); border-radius:8px; padding:8px 0; cursor:pointer; font-size:13px}
.seg button.active{background:var(--accent); color:#fff}

/* ===== Tabla watchlist ===== */
.table-scroll{overflow-x:auto; border:1px solid var(--line); border-radius:var(--r); background:var(--card)}
.wl-table{width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums}
.wl-table th,.wl-table td{padding:10px 8px; text-align:right; white-space:nowrap; border-bottom:1px solid var(--line)}
.wl-table th{position:sticky; top:0; background:var(--card2); color:var(--muted); font-size:11px; font-weight:600; cursor:pointer; user-select:none; text-transform:uppercase; letter-spacing:.03em}
.wl-table th.left,.wl-table td.left{text-align:left}
.wl-table th.active{color:var(--txt)}
.wl-table th .car{font-size:9px; margin-left:2px}
.wl-table tbody tr{cursor:pointer}
.wl-table tbody tr:last-child td{border-bottom:none}
.wl-table tbody tr:active{background:var(--card2)}
.wl-table td.del{text-align:center; width:30px}
.wl-table td.del button{background:none; border:none; color:var(--muted); cursor:pointer; font-size:14px; padding:2px 4px}
.tick{display:flex; align-items:center; gap:9px}
.tick .ic{width:28px; height:28px; border-radius:7px; display:grid; place-items:center; font-size:12px; font-weight:700; color:#0e1117; flex:none}
.tick .sym{font-weight:700; font-size:14px}
.tick .nm{color:var(--muted); font-size:11px; max-width:140px; overflow:hidden; text-overflow:ellipsis}
.td-price{font-weight:600}

/* ===== Mapa de calor ===== */
.heatmap{display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:6px}
.heat-tile{border-radius:10px; padding:12px 10px; cursor:pointer; color:#fff; min-height:74px; display:flex; flex-direction:column; justify-content:space-between; border:1px solid rgba(255,255,255,.06)}
.heat-tile .hs{font-weight:700; font-size:15px}
.heat-tile .hp{font-size:13px; font-variant-numeric:tabular-nums; opacity:.95}
.heat-tile .hq{font-size:11px; opacity:.8; font-variant-numeric:tabular-nums}

/* Listas (posiciones / alertas) */
.list{display:flex; flex-direction:column; gap:8px}
.row{
  background:var(--card); border:1px solid var(--line); border-radius:var(--r);
  padding:12px 14px; display:flex; align-items:center; gap:10px;
}
.row .sym{font-weight:700}
.row .name{color:var(--muted); font-size:12px}
.row .spacer{flex:1}
.row .x{color:var(--muted); padding:4px 6px; border:none; background:none; cursor:pointer; font-size:16px}
.row.sub{flex-wrap:wrap}
.row .grow{flex:1; min-width:90px}
.row.dim{opacity:.5}
.note{margin:8px 2px 0}

/* ===== Gráfico flotante ===== */
.chart-card.floating{
  position:fixed; z-index:40; left:50%; top:74px; transform:translateX(-50%);
  width:min(620px,94vw); height:460px;
  background:var(--card); border:1px solid var(--line); border-radius:14px;
  box-shadow:0 14px 44px rgba(0,0,0,.55);
  display:flex; flex-direction:column; overflow:hidden;
  min-width:260px; min-height:300px; max-width:98vw; max-height:90vh;
}
.chart-head{display:flex; justify-content:space-between; align-items:flex-start; padding:10px 12px 6px; cursor:move; touch-action:none}
.chart-head .ghost{cursor:pointer}
.chart-sym{font-weight:700; font-size:18px}
.chart-price{font-size:14px; font-variant-numeric:tabular-nums}
.ranges{display:flex; gap:4px; padding:0 12px 6px; flex-wrap:wrap}
.ranges button{flex:1; background:var(--card2); border:1px solid var(--line); color:var(--muted); border-radius:8px; padding:6px 0; cursor:pointer; font-size:13px}
.ranges button.active{background:var(--accent); color:#fff; border-color:var(--accent)}
.chart{flex:1; width:100%; min-height:120px}
.chart-foot{padding:2px 12px 4px}
.chart-news{flex:none; max-height:150px; overflow-y:auto; padding:0 12px 8px; border-top:1px solid var(--line)}
.news-h{font-size:10px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; padding:7px 0 3px; position:sticky; top:0; background:var(--card)}
.news-item{display:block; padding:7px 0; border-bottom:1px solid var(--line); text-decoration:none; color:var(--txt)}
.news-item:last-child{border-bottom:none}
.news-item .nh{font-size:13px; line-height:1.32}
.news-item .nm{font-size:11px; color:var(--muted); margin-top:2px}
.news-item:active{opacity:.7}
.resize-handle{
  position:absolute; right:0; bottom:0; width:22px; height:22px; cursor:nwse-resize;
  display:grid; place-items:center; color:var(--muted); font-size:13px; touch-action:none; user-select:none;
}

/* Nav inferior */
.bottomnav{
  position:fixed; bottom:0; left:0; right:0; z-index:30;
  display:flex; background:var(--card); border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom);
}
.bottomnav button{
  flex:1; background:none; border:none; color:var(--muted); cursor:pointer;
  padding:10px 0 8px; font-size:20px; display:flex; flex-direction:column; align-items:center; gap:2px;
}
.bottomnav button span{font-size:10px}
.bottomnav button.active{color:var(--accent)}

/* Toast */
.toast{
  position:fixed; left:50%; bottom:88px; transform:translateX(-50%);
  background:var(--card2); border:1px solid var(--line); color:var(--txt);
  padding:10px 16px; border-radius:10px; z-index:50; max-width:90%; text-align:center; font-size:13px;
  box-shadow:0 6px 24px rgba(0,0,0,.4);
}
