/* Мини-апп Telegram (s143). Цвета — из темы Telegram (--tg-theme-*), запасные — тёмная тема Telegram.
   Без внешних шрифтов и картинок: всё — системный шрифт и inline SVG. */
:root {
  --bg: var(--tg-theme-bg-color, #0e1621);
  --bg2: var(--tg-theme-secondary-bg-color, #17212b);
  --panel: var(--tg-theme-section-bg-color, #17212b);
  --text: var(--tg-theme-text-color, #f5f7fa);
  --hint: var(--tg-theme-hint-color, #7d8b99);
  --link: var(--tg-theme-link-color, #6ab3f3);
  --btn: var(--tg-theme-button-color, #3d7fc4);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #ec5f59);
  --line: rgba(127, 140, 153, 0.22);
  --line-soft: rgba(127, 140, 153, 0.12);
  --deal: #45b97c;
  --wait: #5aa9e6;
  --pause: #8793a0;
  --warn: #e2a64a;
  --bad: #ec5f59;
  --author: #e2a64a;
  --ours: #5aa9e6;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:disabled { cursor: default; opacity: 0.6; }
input, select { font: inherit; color: var(--text); }
small { font-size: 12px; color: var(--hint); display: block; font-weight: 400; }
code { font-family: var(--mono); font-size: 12px; }
h2 { font-size: 19px; margin: 0 0 8px; letter-spacing: -0.2px; }
h3 { font-size: 15px; margin: 16px 0 8px; color: var(--text); }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }

/* ── шапка ── */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
}
.back { font-size: 28px; line-height: 1; width: 30px; height: 30px; color: var(--link); margin-left: -4px; }
.brand { display: flex; flex-direction: column; line-height: 1.15; flex: 1; min-width: 0; }
.brand b { font-size: 17px; letter-spacing: 0.2px; }
.brand span { font-size: 11px; color: var(--hint); }
.chip-paper {
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px; color: var(--deal); white-space: nowrap;
  border: 1px solid rgba(69, 185, 124, 0.45); border-radius: 999px; padding: 3px 9px;
}
.devbar {
  margin: 8px 14px 0; padding: 6px 10px; border-radius: 10px; font-size: 11px; line-height: 1.35;
  color: #1b1405; background: var(--warn); font-weight: 600;
}

.view { padding: 12px 14px 8px; }
.loading { color: var(--hint); padding: 30px 0; text-align: center; }
.loading.small { padding: 12px 0; font-size: 13px; }
.empty { color: var(--hint); text-align: center; padding: 18px 0; font-size: 14px; }

/* ── нижние вкладки ── */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--bg2);
  border-top: 1px solid var(--line-soft); padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabs button { padding: 10px 4px; border-radius: 10px; font-size: 13px; color: var(--hint); font-weight: 500; }
.tabs button.on { color: var(--text); background: rgba(127, 140, 153, 0.14); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 28px); max-width: 452px; z-index: 9; background: #26323f; color: #f5f7fa;
  padding: 11px 14px; border-radius: 12px; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ── главный экран ── */
.hero { background: var(--panel); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.hero-label { color: var(--hint); font-size: 13px; }
.hero-value { font-size: 34px; font-weight: 700; letter-spacing: -0.6px; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.hero-value span { font-size: 15px; color: var(--hint); font-weight: 600; letter-spacing: 0; }
.hero-note { font-size: 12px; color: var(--hint); }
.noincome {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.45;
  background: rgba(226, 166, 74, 0.1); border: 1px solid rgba(226, 166, 74, 0.28);
}
.link { color: var(--link); font-size: 13px; font-weight: 500; padding: 6px 0; text-align: left; }

.filters { display: flex; gap: 6px; margin: 4px 0 10px; }
.filters button { flex: 1; padding: 8px 6px; border-radius: 10px; background: var(--panel); font-size: 13px; color: var(--hint); }
.filters button.on { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--btn); }
.filters i { font-style: normal; opacity: 0.8; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 14px; border-radius: 12px;
  background: rgba(127, 140, 153, 0.16); font-weight: 600; font-size: 14px;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.danger { color: var(--danger); background: rgba(236, 95, 89, 0.12); }
.btn.wide { width: 100%; margin: 8px 0; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ── карточка бота ── */
.card { background: var(--panel); border-radius: var(--radius); padding: 12px 14px 8px; margin: 10px 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; width: 100%; text-align: left; }
.card-title { display: flex; flex-direction: column; min-width: 0; }
.name { font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font-size: 12px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.deal { color: var(--deal); background: rgba(69, 185, 124, 0.14); }
.pill.wait { color: var(--wait); background: rgba(90, 169, 230, 0.14); }
.pill.pause { color: var(--pause); background: rgba(135, 147, 160, 0.16); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(127, 140, 153, 0.15); color: var(--text); }
.tag.long { color: var(--deal); background: rgba(69, 185, 124, 0.12); font-weight: 600; }
.tag.paper { color: var(--hint); }
.tag.fwd { color: var(--warn); background: rgba(226, 166, 74, 0.12); }
.tag.ok { color: var(--deal); background: rgba(69, 185, 124, 0.12); }
.kv2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kv2 div { display: flex; flex-direction: column; }
.kv2 span { font-size: 11px; color: var(--hint); }
.kv2 b { font-size: 15px; font-variant-numeric: tabular-nums; font-weight: 600; }
.why { font-size: 12px; color: var(--hint); margin: 8px 0 2px; line-height: 1.4; }
.card-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; border-top: 1px solid var(--line-soft); padding-top: 6px; }
.ic { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; color: var(--link); font-size: 11px; }
.ic svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic:active { background: rgba(127, 140, 153, 0.14); }
.ic.is-disabled { color: var(--hint); opacity: 0.55; }
.drawer { margin: 8px -4px 4px; padding-top: 8px; border-top: 1px dashed var(--line); }
.fwd-note { margin-top: 14px; }

/* ── панели и строки ── */
.panel { background: var(--panel); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.panel h3:first-child { margin-top: 0; }
.bot-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.bot-name { font-size: 20px; font-weight: 700; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--hint); flex: 1 1 45%; }
.kv b { font-weight: 550; text-align: right; flex: 1 1 55%; font-variant-numeric: tabular-nums; word-break: break-word; }
.m-title { font-weight: 650; margin: 12px 0 4px; font-size: 14px; }
.small { font-size: 12px; color: var(--hint); line-height: 1.45; margin: 4px 0; }
.src { font-size: 10.5px; color: var(--hint); opacity: 0.8; margin: 6px 0 2px; line-height: 1.35; word-break: break-word; }
.note { font-size: 13px; line-height: 1.45; padding: 10px 12px; border-radius: 10px; background: rgba(127, 140, 153, 0.1); margin: 8px 0; }
.note.warn { background: rgba(226, 166, 74, 0.1); border: 1px solid rgba(226, 166, 74, 0.25); }
.note.bad { background: rgba(236, 95, 89, 0.1); border: 1px solid rgba(236, 95, 89, 0.28); }
.blocked { padding: 12px; border-radius: 10px; background: rgba(236, 95, 89, 0.12); border: 1px solid rgba(236, 95, 89, 0.35); margin: 8px 0; font-size: 13px; }
.blocked b { display: block; color: var(--bad); margin-bottom: 4px; }
.blocked.soft { background: rgba(236, 95, 89, 0.08); }
.bad { color: var(--bad); }
.journal div { font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.journal span { color: var(--hint); font-family: var(--mono); font-size: 11px; }

/* ── пять честных показателей ── */
.honest { margin: 10px 0; padding: 12px; border-radius: 12px; border: 1px solid rgba(90, 169, 230, 0.35); background: rgba(90, 169, 230, 0.06); }
.honest-cap { font-size: 10.5px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--ours); font-weight: 700; margin-bottom: 8px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { background: var(--bg); border-radius: 10px; padding: 9px 10px; min-width: 0; }
.tile:last-child { grid-column: 1 / -1; }
.tile .t { font-size: 10px; letter-spacing: 0.3px; color: var(--hint); text-transform: uppercase; line-height: 1.25; }
.tile .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .v small { display: inline; font-size: 12px; font-weight: 500; }
.tile .l { font-size: 11px; color: var(--hint); }
.more { margin-top: 8px; font-size: 13px; }
.more summary { color: var(--link); cursor: pointer; padding: 4px 0; font-size: 12.5px; }
.more-h { font-weight: 650; font-size: 12px; margin: 10px 0 2px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--hint); }
.profit { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.profit .honest-cap { color: var(--hint); }
.wr { font-size: 11.5px; color: var(--warn); margin: 6px 0; line-height: 1.4; }
.warnbox { margin: 8px 0; }

/* ── график ── */
.tf { display: flex; gap: 4px; align-items: center; margin-bottom: 6px; }
.tf button { padding: 5px 10px; border-radius: 8px; font-size: 12px; color: var(--hint); background: rgba(127, 140, 153, 0.12); }
.tf button.on { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--btn); }
.tf-coin { margin-left: auto; font-size: 12px; color: var(--hint); font-weight: 600; }
.chart { width: 100%; height: auto; display: block; background: var(--bg); border-radius: 10px; }
.chart .plot { fill: none; }
.chart .wick { stroke-width: 1; }
.chart .up { stroke: var(--deal); fill: var(--deal); }
.chart .dn { stroke: var(--bad); fill: var(--bad); }
.chart .lv { stroke: var(--deal); stroke-width: 1; }
.chart .lv-w { stroke-dasharray: 4 3; opacity: 0.75; }
.chart .lv-f { stroke-width: 1.6; }
.chart .be { stroke: var(--warn); stroke-width: 1.4; }
.chart .tp { stroke: var(--ours); stroke-width: 1.4; }
.chart .last { stroke: var(--text); stroke-width: 0.8; stroke-dasharray: 2 3; opacity: 0.6; }
.chart .lt { fill: var(--hint); font-size: 9px; font-family: var(--mono); }
.chart .be-t { fill: var(--warn); }
.chart .tp-t { fill: var(--ours); }
.chart .last-t { fill: var(--text); }
.chart-empty { padding: 26px 12px; text-align: center; color: var(--hint); font-size: 13px; background: var(--bg); border-radius: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 2px; font-size: 11.5px; color: var(--hint); }
.lg::before { content: ""; display: inline-block; width: 14px; height: 0; border-top: 2px solid; margin-right: 5px; vertical-align: middle; }
.lg-grid::before { border-color: var(--deal); border-top-style: dashed; }
.lg-be::before { border-color: var(--warn); }
.lg-tp::before { border-color: var(--ours); }
.lg-last::before { border-color: var(--text); border-top-style: dotted; }
.levels { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 8px 0; font-variant-numeric: tabular-nums; }
.levels th { text-align: left; color: var(--hint); font-weight: 500; font-size: 11px; padding: 4px 4px; border-bottom: 1px solid var(--line); }
.levels td { padding: 4px 4px; border-bottom: 1px solid var(--line-soft); }
.levels tr.is-filled td { color: var(--deal); font-weight: 600; }

/* ── формы ── */
.field { margin: 14px 0; }
.field-l { font-size: 12px; color: var(--hint); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; font-weight: 600; }
.field input[type="text"], .field input[type="password"], .field input[type="date"] {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: none;
}
.field input:focus { border-color: var(--btn); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: flex; background: var(--bg); border-radius: 11px; padding: 3px; gap: 3px; margin: 4px 0; }
.seg button { flex: 1; padding: 8px 6px; border-radius: 9px; font-size: 13.5px; color: var(--hint); font-weight: 550; }
.seg button.on { background: var(--btn); color: var(--btn-text); }
.seg.small button { font-size: 12px; padding: 6px 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 11px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.chip.on { border-color: var(--btn); background: rgba(61, 127, 196, 0.2); color: var(--text); font-weight: 600; }
.chip.is-disabled { opacity: 0.45; text-decoration: line-through; }
.radio { display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left; padding: 11px 12px; margin: 6px 0; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.radio.on { border-color: var(--btn); box-shadow: inset 0 0 0 1px var(--btn); }
.radio-t { font-weight: 650; font-size: 14px; }
.radio-t em { font-style: normal; font-size: 11px; color: var(--deal); font-weight: 600; margin-left: 6px; }
.radio-x { font-size: 12.5px; color: var(--hint); line-height: 1.4; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.toggle-t { font-size: 14px; }
.toggle-t small { margin-top: 1px; }
.knob { flex: none; width: 44px; height: 26px; border-radius: 999px; background: rgba(127, 140, 153, 0.35); position: relative; transition: background 0.15s; }
.knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle.on .knob { background: var(--deal); }
.toggle.on .knob::after { transform: translateX(18px); }
.range { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.range input { flex: 1; accent-color: var(--btn); }
.range b { font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 6px 0; line-height: 1.35; }
.check input { margin-top: 2px; accent-color: var(--btn); width: 17px; height: 17px; flex: none; }
.fixed { margin: 10px 0; padding: 4px 12px; border-radius: 10px; background: var(--bg); }
.rule { margin: 10px 0 6px; padding: 12px; border-radius: 12px; background: rgba(69, 185, 124, 0.08); border: 1.5px solid rgba(69, 185, 124, 0.5); }
.rule-t { font-size: 12px; font-weight: 800; letter-spacing: 0.6px; color: var(--deal); }
.rule-x { font-size: 15px; font-weight: 650; margin: 4px 0; line-height: 1.35; }
.sub-item { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.sub-item.is-off { opacity: 0.6; }
.sub-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }

/* ── пресеты ── */
.preset-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.preset-head h2 { margin: 0 6px 0 0; }
.cols2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 400px) { .cols2 { grid-template-columns: 1fr 1fr; } }
.col { border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.col .kv { font-size: 12.5px; }
.col-cap { font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; margin-bottom: 4px; line-height: 1.3; }
.col.author { border-top: 3px solid var(--author); }
.col.author .col-cap { color: var(--author); }
.col.ours { border-top: 3px solid var(--ours); }
.col.ours .col-cap { color: var(--ours); }
.tablewrap { overflow-x: auto; margin: 8px 0; }
.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cmp th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.2px; font-weight: 700; padding: 6px 5px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: bottom; }
.cmp th.author { color: var(--author); }
.cmp th.ours { color: var(--ours); }
.cmp td { padding: 7px 5px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.cmp td:first-child { color: var(--hint); }
.cmp td small { font-size: 10.5px; margin-top: 2px; }
.legendline { display: flex; flex-direction: column; gap: 2px; font-size: 11px; margin: 4px 0; }
.legendline .author { color: var(--author); }
.legendline .ours { color: var(--ours); }
.mode-head { display: flex; align-items: center; gap: 8px; }
.mode-head h2 { margin: 0; }

/* ── бэктест-заглушка ── */
.stub-badge {
  display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: 1.2px; color: #1b1405; background: var(--warn);
  padding: 3px 10px; border-radius: 6px; margin-bottom: 8px;
}
.stub { border: 2px dashed var(--warn); }
.stub-big { font-size: 30px; font-weight: 900; letter-spacing: 2px; color: var(--warn); text-align: center; margin: 4px 0 8px; }
.fmt { font-family: var(--mono); font-size: 10.5px; line-height: 1.4; background: var(--bg); padding: 10px; border-radius: 10px; overflow-x: auto; white-space: pre; max-height: 360px; }
.laws { font-size: 12.5px; padding-left: 18px; line-height: 1.45; }

/* ── о продукте ── */
.diff-row { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.diff-k { font-weight: 650; font-size: 14px; margin-bottom: 4px; }
.diff-a, .diff-o { font-size: 12.5px; line-height: 1.4; padding-left: 10px; margin: 3px 0; }
.diff-a { border-left: 3px solid var(--author); }
.diff-o { border-left: 3px solid var(--ours); }
.diff-a span, .diff-o span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.diff-a span { color: var(--author); }
.diff-o span { color: var(--ours); }
.disc { font-size: 13px; padding-left: 18px; line-height: 1.5; }
