
:root{ --green:#0f3a2e; --green-2:#135342; --green-3:#0b2a22; --green-text:#b6f2d7; 
  --bg:#0b1118; --card:#111a26; --muted:#a8b3c7; --text:#e7edf6;
  --line:#1b2433; --accent:#3a6ff8; --ok:#1fa47f; --bad:#9b2b2b;
  --pill:#0f3a2e; --pill-b:#135342;
 --lev-green:rgb(0,200,100); --lev-yellow:rgb(245,200,66); --lev-red:rgb(220,70,70); --lev-track:linear-gradient(to right,var(--lev-green) 0%,var(--lev-green) 28%,rgb(170,220,85) 31%,var(--lev-yellow) 33%,var(--lev-yellow) 72%,rgb(245,150,60) 74%,var(--lev-red) 77%,var(--lev-red) 100%);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--bg);color:var(--text);font:16px/1.4 Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial}
header.topbar{position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:12px;padding:10px 14px;background:var(--bg);border-bottom:1px solid var(--line)}
h1{font-size:18px;margin:0}
.toolbar{margin-left:auto;display:flex;gap:10px}
.toolbar button{width:44px;height:44px;border-radius:12px;border:1px solid var(--pill-b);background:var(--card);position:relative}
#btnRefresh::before{content:"↻";font-size:20px}
#btnKeys::before{content:"🔑";font-size:18px}
#btnDiag::before{content:"⚙️";font-size:18px}

.tabs{display:flex;gap:8px;padding:8px 14px;border-bottom:1px solid var(--line);position:sticky;top:60px;background:var(--bg);z-index:4}
.tab{background:var(--card);border:1px solid var(--pill-b);border-bottom-color:var(--card);border-radius:10px 10px 0 0;padding:8px 12px;color:var(--text);opacity:.85}
.tab.active{opacity:1;background:#0f1623}
.pane{display:none}
.pane.active{display:block}

.kpis{display:grid;gap:12px;padding:14px 14px 6px;grid-template-columns:repeat(3,minmax(0,1fr))}
@media (max-width:520px){ .kpis{grid-template-columns:repeat(2,minmax(0,1fr))} }
.kpi{background:#0f1623;border:1px solid var(--line);border-radius:16px;padding:12px 14px}
.kpi-title{color:var(--muted);font-size:13px}
.kpi-value{font-size:28px;font-weight:800}

.actions{display:flex;flex-wrap:wrap;gap:10px;padding:10px 14px}
.pill{background:var(--pill);border:1px solid var(--pill-b);color:var(--text);border-radius:12px;padding:10px 12px}
.pill.primary{background:var(--accent);border-color:var(--accent)}
.pill.danger{background:#561a1a;border-color:#6c2222}

.list{display:flex;flex-direction:column;gap:10px;padding:10px 14px 40px}
.item{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:10px 12px;display:flex;gap:10px;align-items:center}
.item .symbol{font-weight:700;letter-spacing:.3px}
.badge{padding:2px 8px;border-radius:999px;border:1px solid var(--pill-b);background:#0e1521;color:#9dd6c9}
.badge.err{background:#2a1313;color:#f5bcbc}
.item .pid{margin-left:auto;color:var(--muted);font-size:13px}

.pairs-bar{position:sticky;top:112px;z-index:3;display:flex;gap:10px;align-items:center;padding:8px 14px;background:var(--bg);border-bottom:1px solid var(--line)}
.pairs-bar input{flex:1;padding:10px;border-radius:10px;border:1px solid var(--pill-b);background:#0e1521;color:var(--text)}
.pairs-grid{display:grid;gap:10px;padding:10px 14px;grid-template-columns:1fr}
.more-wrap{display:flex;justify-content:center;padding:10px}

.empty{padding:20px 14px;color:var(--muted);text-align:center}

.modal{border:none;padding:0;background:transparent}
.modal::backdrop{background:rgba(0,0,0,.5)}
.card{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:16px;min-width:280px}
.card h2{margin:0 0 10px 0}
.card label{display:flex;flex-direction:column;gap:6px;margin:8px 0}
.card input, .card select{padding:10px;border-radius:10px;border:1px solid var(--pill-b);background:#0e1521;color:var(--text)}
.card .row{display:flex;gap:8px;justify-content:flex-end;margin-top:10px}

.toasts{position:fixed;bottom:12px;left:12px;right:12px;display:flex;flex-direction:column;gap:8px;pointer-events:none}
.toast{pointer-events:auto;background:#0f1623;border:1px solid var(--line);color:var(--text);padding:10px 12px;border-radius:12px;display:flex;gap:8px;justify-content:space-between;align-items:center}

/* visibility & feedback for header icons */
.toolbar button{ color: var(--text); }
.toolbar button:hover{ outline:2px solid var(--pill-b); }
/* tabs z-index cascade */
.tabs{ z-index: 6; top: 60px; }
/* pairs bar: wrap nicely on phones */
.pairs-bar{ flex-wrap: wrap; gap:10px; }
@media (max-width:520px){
  .pairs-bar input{ flex: 1 0 100%; }
  .pairs-bar .pill{ flex: 1 0 48%; }
}
/* truncate long pair names */
.pairs-grid label{ min-width: 0; }
.pairs-grid label span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; }
/* toasts, inputs readability */
::placeholder{ color: #7f8aa6; }
/* disabled/err badge */
.badge.err, .badge.disabled{ background:#2a1313; border-color:#6c2222; color:#f5bcbc; }

/* refresh spin feedback */
#btnRefresh.spin::before{ animation: rot 0.8s linear; display:inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ===== Bots list readability ===== */
.item{ align-items:center; }
.item .symbol{ flex:1 1 auto; min-width:0; font-size:17px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.item .badge{ margin-left:8px; }
.item .pid{ flex:0 0 auto; margin-left:auto; color:var(--muted); font-size:12px; white-space:nowrap; }
@media (max-width:460px){
  .item .symbol{ font-size:15px; }
  .item .pid{ font-size:11px; }
}

/* ===== Pairs pane: ensure full list + better layout on phones ===== */
.more-wrap{ position:relative; }
#btnMorePairs{ min-width:200px; }
@media (max-width:520px){
  .pairs-grid{display:grid;gap:10px;padding:10px 14px;grid-template-columns:1fr}
}

/* ===== Modal readability ===== */
.modal .card{ color: #e9eef9; }
.modal .card h2{ color:#e9eef9; }
.modal .card label{ color:#d6dfef; }
.card input, .card select{ background:#122034; color:#e9eef9; border-color:#33425d; }
.card input:focus, .card select:focus{ outline:2px solid #d4a94d; }


/* ===== Status tables ===== */
.table-card{ background:#0f1623; border:1px solid var(--line); border-radius:16px; padding:10px 12px; margin:10px 14px; }
.table-head{ display:flex; justify-content:space-between; align-items:center; margin:6px 2px 8px; }
.table-head h3{ margin:0; font-size:16px; font-weight:700; }
.table-wrap{ overflow-x:auto; }
table{ width:100%; border-collapse:collapse; }
th, td{ padding:8px 10px; border-bottom:1px solid var(--line); font-size:14px; }
td.num, th.num{ text-align:right; }
td.pnl-pos{ color: var(--ok); font-weight:700; }
td.pnl-neg{ color: var(--bad); font-weight:700; }
td.muted{ color: var(--muted); }
@media (max-width:520px){
  th, td{ font-size:13px; padding:7px 8px; }
}

.pairs-grid label:hover{ border-color:var(--green); box-shadow:0 0 0 1px var(--green-2) inset; }


/* grid layout for bot row */
.item.bot-row{display:grid;grid-template-columns:auto 1fr auto auto auto;gap:10px;align-items:center}
.item.bot-row .symbol{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* nice range slider */
#levSlider{width:100%;height:8px;border-radius:999px;appearance:none;background:var(--lev-track);outline:none}
#levSlider::-webkit-slider-thumb{appearance:none;width:22px;height:22px;border-radius:50%;background:#e7edf6;border:2px solid var(--pill-b)}
#levSlider::-moz-range-thumb{width:22px;height:22px;border-radius:50%;background:#e7edf6;border:2px solid var(--pill-b)}
#levSlider::-webkit-slider-runnable-track{height:8px;border-radius:999px}
#levSlider::-moz-range-track{height:8px;border-radius:999px}

/* refresh spinner */
#btnRefresh.spin{animation:spin .9s linear infinite}
@keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}

/* stabilize range rendering across browsers */
#levSlider{padding:0;height:8px;border:0;background:var(--lev-track);background-repeat:no-repeat;background-size:100% 100%}
#levSlider::-webkit-slider-runnable-track{height:8px;background:transparent;border:0}
#levSlider::-moz-range-track{height:8px;background:transparent;border:0}
#levSlider::-webkit-slider-thumb{margin-top:-7px;box-shadow:none}
#levSlider::-moz-range-thumb{box-shadow:none}

/* override: always single column */
@media (min-width:1px){ .pairs-grid{display:grid;gap:10px;padding:10px 14px;grid-template-columns:1fr} }


/* pair row 3-part layout */
.pair{display:block;background:#0f1623;border:1px solid #1e2a3d;border-radius:12px;padding:10px 12px;position:relative}
.pair input[type="checkbox"]{position:absolute;left:12px;top:12px;transform:scale(1.2)}
.pair .row{display:grid;grid-template-columns:1fr auto auto;gap:10px;align-items:center;padding-left:28px}
.pair .sym{font-weight:600;letter-spacing:0.3px}
.pair .minbal{font-size:12px;opacity:.8}
.pair .maxlev{font-size:12px;opacity:.8}
.pair.disabled{opacity:.5}
/* slider bar width to match grid container */
.pairs-bar .range{width:100%}

#levSlider{width:100%}
.pairs-bar{padding:10px 14px}


/* minor ui patch: keys help link + refresh spin support */
.keys-help{ display:block; margin-top:8px; font-size:12px; opacity:.95; text-decoration:underline; color: var(--text); }
#btnRefresh.spin::before{ animation: rot 0.8s linear infinite; display:inline-block; }


/* ===== Modal readability (dark) ===== */
.modal .card p,
.modal .card .muted { color: var(--text); opacity: .92; }
.modal .card .code.small { color: var(--text); background:#0e1521; border-color: var(--pill-b); }


/* === Pairs: make slider full-width to match tiles === */
#pane-pairs .pairs-bar{padding:10px 14px;}
#pane-pairs .lev-ctrl{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:10px;width:100%;}
#pane-pairs #levSlider{width:100%;display:block;}

.modal .card a{ color: var(--accent); }


/* calc stripe inside pairs bar */
.pairs-bar .calc{ flex:1 0 100%; font-size:13px; line-height:1.35; color:var(--muted); margin-top:4px; }
/* smaller ticker text */
/* center show more */
.more-wrap{ display:flex; justify-content:center; padding:14px 14px 22px; } .more-wrap #btnMorePairs{ margin:0 auto; }
/* sticky bars stack */
#pane-pairs .pairs-bar{ position:sticky; z-index:3; background:var(--bg); border-bottom:1px solid var(--line); top:0; }


/* === Abublik patches (2025-09-11) === */
/* Explicit sticky offsets for pairs bars */
#pane-pairs .pairs-bar{ position: sticky; z-index: 3; background: var(--bg); border-bottom: 1px solid var(--line); }
#pane-pairs .pairs-bar:first-of-type{ top:112px; }      /* slider (leverage) bar */
#pane-pairs .pairs-bar:nth-of-type(2){ top:164px; }     /* search + buttons + calc bar */

/* Ensure 'Показать ещё' is truly centered */
.more-wrap{ display:flex; justify-content:center; padding:14px 14px 22px; }
.more-wrap #btnMorePairs{ margin:0 auto; }


/* Force smaller ticker text (override) */
.pair .sym{ font-size:14px; }
@media (max-width:520px){
  .pair .sym{ font-size:13px; }
}

/* status additions */

.hidden{display:none}
.fuel-warn{margin:6px 14px 0;color:#ffd9a0;background:#3a2a00;border:1px solid #5a4100;border-radius:12px;padding:8px 12px;font-size:13px}


/* === Closed trades preview (5 columns) — moved to unified section below ===


/* Preview: two-line time cell */
#tblClosed td.time2{ white-space:normal; line-height:1.1; text-align:center; }
#tblClosed td.time2 br{ content:""; }


/* Closed trades modal adjustments */
#closedModal{ width:100vw; max-width:100vw; margin:0; padding:0; }
#closedModal .card{ width:100%; margin:0; border-radius:16px 16px 0 0; }
#closedModal .table-wrap{ margin:0 12px 12px; max-height:70vh; overflow:auto; }
#closedModal table{ table-layout:auto; width:100%; font-size:0.90rem; }
#closedModal thead th{ position:sticky; top:0; background:#0f1623; }
@media (max-width:420px){
  #closedModal table{ font-size:0.86rem; }
}


/* === Closed modal: full-screen and legible === */
#closedModal[open]{ inset:0; margin:0; padding:0; width:auto; max-width:none; height:auto; }
#closedModal::backdrop{ background: rgba(0,0,0,.55); }
#closedModal .card{ width:100%; height:100%; margin:0; border-radius:0; background:#0f1623; color:var(--text); padding:14px 16px; }
#closedModal .card h2{ color:var(--text); font-size:22px; margin:0 0 10px; }
#closedModal .table-wrap{ margin:8px 0 12px; max-height: calc(100vh - 180px); overflow:auto; }
#closedModal table{ width:100%; table-layout:fixed; font-size:0.92rem; }
#closedModal th, #closedModal td{ color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#closedModal thead th{ position:sticky; top:0; background:#121a27; color:#d6e2f3; }
#closedModal td.num, #closedModal th.num{ text-align:right; font-variant-numeric:tabular-nums; }
#closedModal .pnl-pos{ color:#3dd598; }
#closedModal .pnl-neg{ color:#f25f5c; }
#closedModal menu.row{ padding:0; display:flex; justify-content:flex-end; }
#closedModal menu.row .pill{ margin-left:auto; }

#tblOpen th, #tblOpen td,
#tblClosed th, #tblClosed td{ text-align:center; }
#tblOpen td.num, #tblOpen th.num,
#tblClosed td.num, #tblClosed th.num{ text-align:right; }

.ton-wallet{min-width:44px;height:44px;padding:0 10px;display:inline-flex;align-items:center;justify-content:center;border:1px solid #22c55e;border-radius:10px;color:#22c55e;background:transparent;font-weight:600;letter-spacing:.3px;} .ton-wallet[data-connected="1"]{outline:2px solid #22c55e;}

/* TON wallet visuals */
#btnTonWallet.ton-wallet{ min-width:44px; height:44px; padding:0 12px; display:inline-flex;
  align-items:center; justify-content:center; border:1px solid #22c55e; border-radius:10px;
  background: var(--card); color:#c8facc; font-weight:700; letter-spacing:.3px; }
#btnTonWallet.ton-wallet::before{ content:""; margin-right:0; }
#btnTonWallet.ton-wallet.connected{ background:#0d2a1f; border-color:#16a34a; color:#b6f2d7; box-shadow:0 0 0 2px rgba(34,197,94,.15) inset; }
#btnTonWallet.ton-wallet.connected::before{ content:""; }

#uidModal input[readonly]{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing:.3px; }

/* === Both tables: unified grid (5 columns) ===

#tblClosed td.time2{
  white-space:normal; line-height:1.1; text-align:center; font-size:12px;
}
@media (max-width:420px){
  #tblClosed td.time2{ font-size:11px; }
}


/* === Both tables: unified grid styling ===

/* === Side arrows (normal size) === */
td .side{ display:inline-block; min-width:1.2em; text-align:center; font-weight:800; font-size:14px; }
td .side.long{ color: var(--ok); }
td .side.short{ color: var(--bad); }


.pair .row{ display:grid; grid-template-columns: 1fr auto; align-items:center; gap:10px; }
.pair .meta{ display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
.pair .tag{ font-size:11.5px; opacity:.95; padding:3px 6px; border-radius:999px; border:1px solid var(--pill-b); background:#0e1521; color:var(--text); white-space:nowrap; }
#pairVolFilter{ flex:1; padding:10px; border-radius:10px; border:1px solid var(--pill-b); background:#0e1521; color:var(--text); }
@media (max-width:560px){
  .pair .row{ grid-template-columns: 1fr; }
  .pair .meta{ justify-content:flex-start; }
}


/* leverage value color by zone */
.lev-val{min-width:2ch;text-align:right;font-weight:700;}
.lev-val[data-zone="low"]{color:var(--lev-green);} 
.lev-val[data-zone="mid"]{color:var(--lev-yellow);} 
.lev-val[data-zone="high"]{color:var(--lev-red);} 

/* === Recommended pairs block === */
.card-lite{background:#0f1623;border:1px solid var(--line);border-radius:16px;padding:12px}
.pairs-reco{flex:1 0 100%;margin-top:4px}
.pairs-reco-head{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.pairs-reco-head h3{margin:0;font-size:15px}
.pairs-reco-list{display:grid;grid-template-columns:1fr;gap:10px}
.reco-card{background:#101b2a;border:1px solid #20324d;border-radius:14px;padding:10px 12px}
.reco-head{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:8px}
.reco-symbol{font-weight:700;letter-spacing:.3px}
.reco-text{font-size:12px;color:var(--muted);margin-top:8px}
.reco-tags{display:flex;flex-wrap:wrap;gap:6px}
.reco-add{padding:8px 10px}
@media (min-width:760px){
  .pairs-reco-list{grid-template-columns:1fr 1fr}
}


/* === compact recommendations / no sticky overlap === */
#pane-pairs .pairs-reco{
  position: relative;
  z-index: 1;
  margin: 10px 14px 0;
  padding: 12px;
  background:#0f1623;
  border:1px solid var(--line);
  border-radius:16px;
}
#pane-pairs .pairs-reco-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
#pane-pairs .pairs-reco-head h3{ margin:0; font-size:18px; }
#pane-pairs .pairs-reco-list{ display:grid; gap:8px; }
#pane-pairs .reco-card{
  border:1px solid #1e2a3d;
  border-radius:14px;
  padding:10px 12px;
  background:#101927;
}
#pane-pairs .reco-head{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  align-items:center;
}
#pane-pairs .reco-symbol{ font-size:16px; font-weight:700; }
#pane-pairs .reco-check{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid var(--pill-b);
  border-radius:12px;
  background:#0f3a2e;
  color:var(--text);
  cursor:pointer;
  user-select:none;
}
#pane-pairs .reco-check input{
  width:16px;
  height:16px;
  margin:0;
  accent-color:#22c55e;
}
#pane-pairs .reco-check span{ font-size:14px; }
#pane-pairs .reco-tags{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:8px;
}
#pane-pairs .reco-text{
  margin-top:8px;
  color:var(--muted);
  font-size:13px;
  line-height:1.25;
}
#pane-pairs .reco-note{ color:var(--muted); }
#pane-pairs .calc-compact div{ margin:1px 0; }
@media (max-width:520px){
  #pane-pairs .pairs-reco-head{ align-items:flex-start; flex-direction:column; }
  #pane-pairs .reco-head{ grid-template-columns:1fr; }
  #pane-pairs .reco-check{ width:100%; justify-content:center; }
  #pane-pairs .reco-symbol{ font-size:15px; }
  #pane-pairs .reco-text{ font-size:12px; }
}

/* === shimmering green border for recommended pair tiles === */
#pane-pairs .reco-card{
  position: relative;
  border: 1px solid rgba(31,164,127,.42);
  box-shadow: inset 0 0 0 1px rgba(31,164,127,.10), 0 0 0 1px rgba(10,20,34,.65);
  overflow: hidden;
}
#pane-pairs .reco-card::before{
  content:"";
  position:absolute;
  inset:-1px;
  border-radius: inherit;
  padding:1px;
  background: linear-gradient(
    120deg,
    rgba(31,164,127,.18) 0%,
    rgba(31,164,127,.42) 18%,
    rgba(182,242,215,.95) 30%,
    rgba(31,164,127,.50) 42%,
    rgba(31,164,127,.18) 58%,
    rgba(31,164,127,.40) 76%,
    rgba(182,242,215,.90) 88%,
    rgba(31,164,127,.18) 100%
  );
  background-size: 220% 220%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events:none;
  animation: recoBorderShimmer 3.8s linear infinite;
}
#pane-pairs .reco-card::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  pointer-events:none;
  box-shadow: 0 0 18px rgba(31,164,127,.10);
}
@keyframes recoBorderShimmer{
  0%{ background-position: 0% 50%; }
  100%{ background-position: 220% 50%; }
}
@media (prefers-reduced-motion: reduce){
  #pane-pairs .reco-card::before{ animation: none; }
}


/* === Referral button/modal === */
#btnReferral::before{content:"🎁";font-size:18px}
.referral-card{min-width:0; width:min(92vw,420px); max-width:92vw; box-sizing:border-box; overflow-x:hidden;}
#referralModal{max-width:100vw; overflow-x:hidden;}
#referralModal .card{box-sizing:border-box; overflow-x:hidden;}
.ref-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(0,1fr));gap:10px;margin:10px 0 12px}
.ref-stats>div{background:#0f1623;border:1px solid var(--line);border-radius:14px;padding:10px 12px;display:flex;flex-direction:column;gap:4px;min-width:0;}
.ref-stats b{font-size:22px}
#refLinkInput{font-size:13px; width:100%; min-width:0;}
.copy-line{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
.copy-line input{flex:1 1 auto;min-width:0;}
@media (max-width:420px){.ref-stats{grid-template-columns:1fr}.referral-card .row{flex-wrap:wrap}.referral-card .row .pill{flex:1 0 45%}}

/* === Fix iteration: mobile toolbar width + referral modal readability === */
html, body { max-width: 100%; overflow-x: hidden; }
main, .pane, .kpis, .actions, .list, .pairs-grid, .table-card { max-width: 100%; }
header.topbar{
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
}
header.topbar h1{
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toolbar{
  margin-left: 0;
  display: flex;
  justify-content: flex-end;
  min-width: 0;
  gap: 8px;
}
.toolbar button{
  flex: 0 0 auto;
}
#btnTonWallet.ton-wallet{
  width: auto;
  min-width: 50px;
  padding: 0 10px;
}
.referral-card{
  width: min(92vw, 420px);
  max-width: 92vw;
}
.ref-stats b,
#refJoined,
#refEarned{
  color: var(--text) !important;
  opacity: 1;
}
#refLinkInput{
  width: 100%;
  color: var(--text);
}
@media (max-width: 430px){
  header.topbar{ padding: 10px 8px; gap: 6px; }
  header.topbar h1{ font-size: 17px; }
  .toolbar{ gap: 6px; }
  .toolbar button{ width: 40px; height: 40px; border-radius: 11px; }
  #btnTonWallet.ton-wallet{ min-width: 52px; height: 40px; padding: 0 8px; font-size: 14px; }
  .kpis{ grid-template-columns: repeat(2, minmax(0, 1fr)); padding-left: 12px; padding-right: 12px; }
  .kpi{ min-width: 0; }
  .actions{ padding-left: 12px; padding-right: 12px; }
  .actions .pill{ max-width: 100%; }
  .item{ width: 100%; }
}
@media (max-width: 370px){
  header.topbar h1{ font-size: 15px; }
  .toolbar{ gap: 5px; }
  .toolbar button{ width: 36px; height: 36px; border-radius: 10px; }
  #btnTonWallet.ton-wallet{ min-width: 46px; height: 36px; padding: 0 6px; font-size: 13px; }
}


/* === Referral/balance UI fix v2 === */
html, body { max-width: 100%; overflow-x: hidden; }
header.topbar { width: 100%; max-width: 100vw; overflow: hidden; gap: 8px; }
header.topbar h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { min-width: 0; flex: 1 1 auto; justify-content: flex-end; gap: 8px; flex-wrap: nowrap; }
.toolbar button { flex: 0 0 auto; }
main, .pane, .kpis, .actions, .list, .pairs-bar, .pairs-grid, .pairs-reco, .table-card { max-width: 100vw; }
.kpis, .actions, .list, .pairs-bar, .pairs-grid, .table-card { width: 100%; }
.pair, .item, .kpi, .card-lite, .pairs-reco { max-width: calc(100vw - 28px); }
#referralModal .card { width: min(92vw, 680px); max-width: 92vw; }
#refJoined, #refEarned, .ref-stat-value, .ref-value { color: var(--text) !important; }
.ref-stat, .ref-card, #referralModal .card input { color: var(--text); }
@media (max-width: 420px){
  header.topbar { padding-left: 10px; padding-right: 10px; }
  .toolbar { gap: 6px; }
  .toolbar button { width: 38px; height: 38px; border-radius: 11px; }
  #btnTonWallet { width: 54px; min-width: 54px; font-size: 13px; }
  #btnRefresh::before, #btnReferral::before, #btnKeys::before, #btnDiag::before { font-size: 16px; }
}
@media (max-width: 360px){
  .toolbar button { width: 34px; height: 34px; }
  #btnTonWallet { width: 48px; min-width: 48px; font-size: 12px; }
  header.topbar h1 { font-size: 16px; }
}

/* === User-facing pairs cleanup (2026-04-28) === */
#pane-pairs .pairs-reco{
  position: relative;
  border: 2px solid rgba(34,197,94,.82);
  box-shadow: 0 0 0 1px rgba(182,242,215,.18) inset, 0 0 24px rgba(34,197,94,.18);
  overflow: hidden;
}
#pane-pairs .pairs-reco::before{
  content:"";
  position:absolute;
  inset:-2px;
  border-radius:18px;
  padding:2px;
  background: linear-gradient(120deg,
    rgba(20,83,45,.85),
    rgba(34,197,94,.95),
    rgba(187,247,208,1),
    rgba(45,212,191,.75),
    rgba(34,197,94,.95),
    rgba(20,83,45,.85));
  background-size:240% 240%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events:none;
  animation: recoBorderShimmer 4s linear infinite;
}
#pane-pairs .pairs-reco > *{ position:relative; z-index:1; }
#pane-pairs .reco-check{
  width:30px;
  height:30px;
  padding:0;
  border:0;
  background:transparent;
  border-radius:8px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
#pane-pairs .reco-check:hover{ background:rgba(34,197,94,.10); }
#pane-pairs .reco-check input{
  width:22px;
  height:22px;
  cursor:pointer;
}
#pane-pairs .reco-check span{ display:none; }
@media (max-width:520px){
  #pane-pairs .reco-head{ grid-template-columns:1fr auto; }
  #pane-pairs .reco-check{ width:30px; justify-self:end; }
}
@media (prefers-reduced-motion: reduce){
  #pane-pairs .pairs-reco::before{ animation:none; }
}


/* === Status viewport fix + sane table columns (2026-04-28) === */
#pane-status{
  width:100%;
  max-width:100vw;
  overflow-x:hidden;
  padding:0 14px 28px;
}
#pane-status .kpis,
#pane-status .actions{
  width:100%;
  max-width:100%;
  padding-left:0;
  padding-right:0;
}
#pane-status .table-card{
  width:100%;
  max-width:100%;
  min-width:0;
  margin:10px 0;
  overflow:hidden;
}
#pane-status .table-wrap{
  width:100%;
  max-width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
#tblOpen,
#tblClosed{
  width:100%;
  min-width:0;
  table-layout:fixed;
  border-collapse:collapse;
}
#tblOpen th,
#tblOpen td,
#tblClosed th,
#tblClosed td{
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-variant-numeric:tabular-nums;
}
#tblOpen th:nth-child(1), #tblOpen td:nth-child(1){width:20%; text-align:left;}
#tblOpen th:nth-child(2), #tblOpen td:nth-child(2){width:12%; text-align:center;}
#tblOpen th:nth-child(3), #tblOpen td:nth-child(3){width:20%; text-align:center;}
#tblOpen th:nth-child(4), #tblOpen td:nth-child(4){width:24%; text-align:center;}
#tblOpen th:nth-child(5), #tblOpen td:nth-child(5){width:20%; text-align:center;}
#tblClosed th:nth-child(1), #tblClosed td:nth-child(1){width:20%; text-align:left;}
#tblClosed th:nth-child(2), #tblClosed td:nth-child(2){width:12%; text-align:center;}
#tblClosed th:nth-child(3), #tblClosed td:nth-child(3){width:24%; text-align:center;}
#tblClosed th:nth-child(4), #tblClosed td:nth-child(4){width:24%; text-align:center;}
#tblClosed th:nth-child(5), #tblClosed td:nth-child(5){width:20%; text-align:center;}
#tblClosed td.time2{white-space:normal; line-height:1.08; text-align:center;}
@media (max-width:520px){
  #pane-status{padding-left:10px; padding-right:10px;}
  #pane-status .table-card{padding:8px 6px; border-radius:14px;}
  #tblOpen th, #tblOpen td, #tblClosed th, #tblClosed td{font-size:10.5px; padding:5px 4px;}
}
@media (max-width:380px){
  #pane-status{padding-left:8px; padding-right:8px;}
  #tblOpen th, #tblOpen td, #tblClosed th, #tblClosed td{font-size:10.5px; padding:5px 4px;}
}


/* === Invite-only referral onboarding === */
.invite-code-label small{
  display:block;
  margin-top:6px;
  font-size:12px;
  line-height:1.35;
}
.copy-line{
  display:flex;
  gap:8px;
  align-items:center;
}
.copy-line input{
  flex:1 1 auto;
  min-width:0;
}
.copy-line .pill{
  flex:0 0 auto;
  white-space:nowrap;
}
#refCodeInput,
#refAppLinkInput{
  width:100%;
  font-size:13px;
}
@media (max-width:430px){
  .copy-line{flex-direction:column;align-items:stretch;}
  .copy-line .pill{width:100%;}
}
