:root {
  --bg: #0D1117; --card: #161B22; --card2: #1C2330; --line: #2A3140; --text: #E6EDF3; --muted: #8B949E;
  --faint: #5E6773; --accent: #3B82F6; --accent2: #2563EB; --green: #3FB950; --red: #F85149; --amber: #D29922;
  --greenbg: #12261C; --redbg: #2D1417; --amberbg: #2B2111; --bluebg: #0F2342; --field: #0F141B; --even: #18202A;
  --purple: #BC8CFF; --purplebg: #271B3D;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.r { text-align: right; }
#app { display: flex; flex-direction: column; gap: 8px; padding: 12px; height: 100vh; max-width: 1400px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.top { display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 16px; flex-wrap: wrap; }
.brand { font-size: 20px; font-weight: 700; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 4px; background: var(--card2); color: var(--muted); }
.badge.paper { background: var(--bluebg); color: var(--accent); }
.badge.live { background: var(--redbg); color: var(--red); }
.state { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--faint); flex: none; }
.stateLbl { font-weight: 700; font-size: 15px; }
.subLbl { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 6px; align-items: center; }
.btn { border: 0; border-radius: 5px; padding: 8px 16px; cursor: pointer; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.start { background: var(--green); color: #07130B; } .btn.start:hover { background: #46C659; }
.btn.stop { background: var(--red); color: #1A0707; } .btn.stop:hover { background: #FF6A63; }
.btn.primary { background: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: var(--card2); color: var(--text); font-weight: 400; } .btn.ghost:hover { background: var(--line); }
.btn.xs { padding: 2px 10px; font-size: 12px; line-height: 18px; }
.xbtn { width: 22px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: transparent;
  color: var(--faint); font-size: 12px; line-height: 20px; cursor: pointer; }
.xbtn:hover { border-color: var(--red); color: var(--red); }
.menuWrap { position: relative; }
.menu { position: absolute; right: 0; top: 40px; z-index: 20; background: var(--card2); border: 1px solid var(--line);
  border-radius: 6px; min-width: 260px; padding: 4px 0; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.menu div { padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.menu div:hover { background: var(--accent2); color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .dis { color: var(--faint); cursor: default; } .menu .dis:hover { background: none; color: var(--faint); }
.banner { padding: 8px 14px; border-radius: 6px; font-weight: 700; background: var(--amberbg); color: var(--amber); }
.banner.red { background: var(--redbg); color: var(--red); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi { padding: 12px 16px; }
.kt { font-size: 11px; font-weight: 700; color: var(--faint); letter-spacing: .04em; }
.kv { font-size: 26px; font-weight: 700; margin: 2px 0; white-space: nowrap; }
.ks { font-size: 12px; color: var(--muted); min-height: 16px; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }
.now { display: grid; grid-template-columns: 3fr 2fr; gap: 8px; }
.ch { display: flex; align-items: center; gap: 10px; padding: 10px 14px 4px; }
.ct { font-weight: 700; font-size: 15px; }
.tw { padding: 0 10px 10px; overflow: auto; }
.now .tw { max-height: 190px; }
.hist { flex: 1; display: flex; flex-direction: column; min-height: 220px; }
.hist .grow { flex: 1; min-height: 0; }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); font-weight: 400; font-size: 12px; text-align: left; padding: 4px 8px; position: sticky; top: 0; background: var(--card); }
td { padding: 4px 8px; height: 26px; white-space: nowrap; }
tbody tr:nth-child(even) td { background: var(--even); }
td.wrap { white-space: normal; }
.tcol { width: 150px; }
.tabs { margin-left: auto; display: flex; gap: 4px; }
.tab { background: none; border: 0; border-radius: 4px; padding: 3px 10px; color: var(--muted); font-weight: 700; font-size: 12px; cursor: pointer; }
.tab.on { background: var(--bluebg); color: var(--accent); }
.tab.link { color: var(--accent); font-weight: 400; }
.tab.link:hover { background: var(--bluebg); }
/* модуль пампов: пометка «ПАМП» и полоска слева у строки (позиции, история) */
.pmb { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 3px;
  background: var(--purplebg); color: var(--purple); vertical-align: 1px; }
tr.pmrow td:first-child { box-shadow: inset 3px 0 0 var(--purple); }
/* ручной запрет монет в настройках */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
  padding: 2px 4px 2px 10px; font-size: 12px; font-weight: 700; }
.chipx { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 11px; padding: 0 4px; line-height: 16px; }
.chipx:hover { color: var(--red); }
.banin { display: flex; gap: 6px; align-items: center; }
.banin input.w { width: 220px; }
.diag { color: var(--faint); font-size: 11px; padding: 0 4px 4px; cursor: pointer; white-space: pre-wrap; }
.modalBg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modal { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; width: 720px; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; }
.modal.small { width: 440px; }
.mh { padding: 14px 18px 6px; font-weight: 700; font-size: 16px; }
.mb { padding: 6px 12px; overflow: auto; flex: 1; }
.mf { padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.mf .left { margin-right: auto; color: var(--faint); font-size: 11px; }
.mtabs { display: flex; gap: 2px; padding: 0 6px; }
.mtab { background: none; border: 0; padding: 8px 16px; color: var(--muted); cursor: pointer; border-radius: 6px 6px 0 0; }
.mtab.on { background: var(--card); color: var(--text); }
.pane { background: var(--card); border-radius: 0 6px 6px 6px; padding: 10px 6px; }
.row { display: grid; grid-template-columns: 200px auto 1fr; gap: 12px; align-items: center; padding: 6px 12px; }
.row .hint { color: var(--muted); font-size: 12px; }
.note { color: var(--muted); font-size: 12px; padding: 4px 12px 8px; }
.note.ok { color: var(--green); } .note.bad { color: var(--red); } .note.amber { color: var(--amber); }
input[type=text], input[type=password], input[type=number], select { background: var(--field); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; }
input[type=number] { width: 90px; } input.w { width: 300px; max-width: 100%; }
input:focus, select:focus { outline: 1px solid var(--accent); }
label.opt { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; cursor: pointer; }
.logbox { background: var(--field); border: 1px solid var(--line); border-radius: 4px; padding: 8px; font: 12px Consolas, "Courier New", monospace; white-space: pre-wrap; max-height: 65vh; overflow: auto; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 6px; z-index: 60; }
.now > .card, .hist { min-width: 0; }      /* широкая таблица прокручивается внутри карточки, а не тянет страницу */
@media (max-width: 1240px) { .now { grid-template-columns: 1fr; } }   /* позиции во всю ширину — кнопка «Закрыть» видна */
@media (max-width: 900px) {
  #posT td:nth-child(5) { white-space: normal; }  /* «вход → цель / стоп» в две строки — ✕ остаётся на экране */
  #app { height: auto; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .now { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; gap: 4px; }
  .hist { min-height: 360px; }
}
@media (max-width: 600px) {                /* телефон: позиция — монета, $, цена, время, ✕ (вход/цель/стоп — на широком экране) */
  #posT th:nth-child(5), #posT td:nth-child(5), #posT .rp { display: none; }
  #posT td, #posT th { padding: 4px 5px; }
}
/* страница «вся история сделок» (/history) */
.hp { display: flex; flex-direction: column; gap: 8px; padding: 12px; height: 100vh; max-width: 1600px; margin: 0 auto; }
.hp .top { gap: 12px; }
.hp .grow { flex: 1; min-height: 0; overflow: auto; padding: 0 10px 10px; }
.hp th { cursor: pointer; user-select: none; white-space: nowrap; }
.hp th:hover { color: var(--text); }
.hp th.sorted { color: var(--accent); }
.hp td.n { text-align: right; font-variant-numeric: tabular-nums; }
.hp .filters { display: flex; gap: 4px; }
/* страница входа */
.login { max-width: 400px; margin: 10vh auto; padding: 24px; }
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login .sub { color: var(--muted); margin-bottom: 18px; font-size: 13px; }
.login label { display: block; color: var(--muted); font-size: 12px; margin: 12px 0 4px; }
.login input, .login select { width: 100%; }
.login .btn { width: 100%; margin-top: 18px; padding: 10px; }
.login .err { color: var(--red); min-height: 20px; margin-top: 10px; font-size: 13px; }
.login .langrow { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.login .langrow select { width: auto; }
