/* SweepSignals — терминал робота в Telegram. Паспорт дизайна: ../../DESIGN_webapp.md.
   Строгий интерфейс брокера: плоские секции с тонкими линиями, цифры колонками (tabular), зелёный — лонг и плюс,
   красный — шорт и минус, янтарный — внимание и ТЕСТ, бирюзовый — только действие и выбор. Токены — только здесь. */

@font-face { font-family: 'Golos Text'; src: url(fonts/golos-cyrillic.woff2) format('woff2'); font-weight: 400 700; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; src: url(fonts/golos-latin.woff2) format('woff2'); font-weight: 400 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; src: url(fonts/jbmono-latin.woff2) format('woff2'); font-weight: 400 600; font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: 'JetBrains Mono'; src: url(fonts/jbmono-cyrillic.woff2) format('woff2'); font-weight: 400 600; font-display: swap;
  unicode-range: U+0400-045F; }

:root {
  --font: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --fs-2xs: 11px; --fs-xs: 12px; --fs-s: 13px; --fs-m: 15px; --fs-l: 17px; --fs-xl: 22px; --fs-2xl: 28px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --r-xs: 4px; --r-s: 8px; --r-m: 10px; --r-l: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1); --dur: 160ms;
  --strip-h: 40px; --tab-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  /* тёмная тема — по умолчанию (так смотрят рынок вечером) */
  --bg: oklch(0.165 0.008 245);
  --surface: oklch(0.2 0.009 245);
  --surface-2: oklch(0.24 0.01 245);
  --surface-3: oklch(0.28 0.011 245);
  --line: oklch(0.3 0.01 245);
  --line-soft: oklch(0.245 0.009 245);
  --ink: oklch(0.955 0.004 245);
  --ink-2: oklch(0.82 0.008 245);
  --muted: oklch(0.66 0.012 245);
  --faint: oklch(0.52 0.012 245);
  --bar: oklch(0.6 0.012 245);
  --up: oklch(0.77 0.15 152);
  --down: oklch(0.7 0.17 25);
  --warn: oklch(0.83 0.13 82);
  --accent: oklch(0.82 0.095 200);
  --accent-ink: oklch(0.2 0.035 205);
  --up-tint: oklch(0.77 0.15 152 / 0.13);
  --down-tint: oklch(0.7 0.17 25 / 0.14);
  --warn-tint: oklch(0.83 0.13 82 / 0.12);
  --accent-tint: oklch(0.82 0.095 200 / 0.13);
  --scrim: oklch(0.08 0.01 245 / 0.62);
  --focus: oklch(0.82 0.095 200 / 0.55);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: oklch(0.972 0.003 245);
  --surface: oklch(0.993 0.002 245);
  --surface-2: oklch(0.955 0.004 245);
  --surface-3: oklch(0.92 0.005 245);
  --line: oklch(0.87 0.006 245);
  --line-soft: oklch(0.92 0.005 245);
  --ink: oklch(0.22 0.012 245);
  --ink-2: oklch(0.37 0.012 245);
  --muted: oklch(0.5 0.014 245);
  --faint: oklch(0.62 0.012 245);
  --bar: oklch(0.62 0.012 245);
  --up: oklch(0.52 0.14 152);
  --down: oklch(0.54 0.19 25);
  --warn: oklch(0.58 0.13 70);
  --accent: oklch(0.5 0.1 212);
  --accent-ink: oklch(0.985 0.004 212);
  --up-tint: oklch(0.52 0.14 152 / 0.1);
  --down-tint: oklch(0.54 0.19 25 / 0.09);
  --warn-tint: oklch(0.7 0.13 75 / 0.16);
  --accent-tint: oklch(0.5 0.1 212 / 0.09);
  --scrim: oklch(0.2 0.01 245 / 0.42);
  --focus: oklch(0.5 0.1 212 / 0.45);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 400 var(--fs-m)/1.4 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: clip;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; touch-action: manipulation; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.s { width: 16px; height: 16px; }
.mono { font-family: var(--mono); font-size: 0.9em; letter-spacing: -0.01em; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); } .muted { color: var(--muted); } .faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- полоса состояния сверху (видна на всех разделах) ---------- */
.strip {
  position: sticky; top: 0; z-index: 20; height: var(--strip-h); display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-4); background: var(--bg); border-bottom: 1px solid var(--line-soft); font-size: var(--fs-s); color: var(--ink-2);
}
.strip .state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.strip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.strip .dot.ok { background: var(--up); } .strip .dot.warn { background: var(--warn); } .strip .dot.bad { background: var(--down); }
.strip .sp { flex: 1; }
.strip .refresh { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); min-height: 40px; padding-left: var(--sp-2); }
.strip .refresh.busy .ic { animation: spin 0.9s linear infinite; }

.view { padding-bottom: calc(var(--tab-h) + var(--safe-b) + var(--sp-6)); }
.view.has-bar { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 76px); }

/* ---------- секции ---------- */
.sec { padding: var(--sp-4); border-bottom: 1px solid var(--line-soft); }
.sec:last-child { border-bottom: 0; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin: 0 0 var(--sp-3); }
.sec-h h2 { margin: 0; font-size: var(--fs-m); font-weight: 600; color: var(--ink); }
.sec-h .aside { font-size: var(--fs-s); color: var(--muted); }
.sec-h .link { font-size: var(--fs-s); color: var(--accent); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }

/* ---------- главный статус ---------- */
.hero { padding: var(--sp-5) var(--sp-4) var(--sp-4); }
.hero h1 { margin: 0; font-size: var(--fs-xl); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.hero h1.bad { color: var(--down); } .hero h1.warn { color: var(--warn); }
.hero .meta { margin-top: var(--sp-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--ink-2); font-size: var(--fs-s); }
.hero .sub { margin-top: 6px; color: var(--faint); font-size: var(--fs-xs); }
.note { display: flex; gap: var(--sp-2); align-items: flex-start; margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-s);
  background: var(--warn-tint); color: var(--ink); font-size: var(--fs-s); }
.note .ic { color: var(--warn); margin-top: 1px; }
.note.bad { background: var(--down-tint); } .note.bad .ic { color: var(--down); }
.note.good { background: var(--up-tint); } .note.good .ic { color: var(--up); }
.note.plain { background: var(--surface-2); } .note.plain .ic { color: var(--muted); }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: var(--r-xs); font-size: var(--fs-2xs);
  font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.badge.long { color: var(--up); background: var(--up-tint); }
.badge.short { color: var(--down); background: var(--down-tint); }
.badge.test { color: var(--warn); background: var(--warn-tint); }
.badge.live { color: var(--accent); background: var(--accent-tint); }

/* ---------- переключатель ---------- */
.toggle-row { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 56px; }
.toggle-row .txt { flex: 1; min-width: 0; }
.toggle-row .txt b { display: block; font-weight: 600; }
.toggle-row .txt small { display: block; color: var(--muted); font-size: var(--fs-s); }
.switch { position: relative; width: 46px; height: 28px; flex: none; border-radius: 14px; background: var(--surface-3);
  transition: background-color var(--dur) var(--ease); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink);
  transition: transform var(--dur) var(--ease); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); background: var(--accent-ink); }

/* ---------- воронка дня (фирменный элемент) ---------- */
.funnel { display: grid; grid-template-columns: minmax(0, 1fr) 30% auto; align-items: center; gap: 10px var(--sp-3); }
.funnel .lbl { color: var(--ink-2); font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel .trk { height: 4px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.funnel .trk i { display: block; height: 100%; border-radius: 2px; background: var(--bar); }
.funnel .val { text-align: right; font-weight: 600; min-width: 3.5ch; }
.funnel .last .lbl { color: var(--ink); font-weight: 600; }
.funnel .last .trk i { background: var(--accent); }
.funnel .last .val { color: var(--accent); font-size: var(--fs-l); }

/* ---------- строки списков ---------- */
.list { margin: 0 calc(-1 * var(--sp-4)); }
.row { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 56px; padding: 10px var(--sp-4);
  border-top: 1px solid var(--line-soft); }
.row:first-child { border-top: 0; }
button.row:active, .tap:active { background: var(--surface); }
@media (hover: hover) and (pointer: fine) { button.row:hover { background: var(--surface); } }
.row .t { width: 3.4em; flex: none; color: var(--muted); font-family: var(--mono); font-size: var(--fs-s); }
.sigrow { display: block; }
.sigrow .l1 { display: flex; align-items: center; gap: 6px; }
.sigrow .l1 b { font-weight: 600; font-size: var(--fs-m); }
.sigrow .res { margin-left: auto; display: inline-flex; align-items: baseline; gap: 6px; font-weight: 600; }
.sigrow .res small { color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.sigrow .l2 { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; color: var(--muted); font-size: var(--fs-s); }
.sigrow .l2 > span { white-space: nowrap; }
.sigrow .l2 .tm { font-family: var(--mono); font-size: 0.92em; color: var(--faint); }
.row .main { flex: 1; min-width: 0; }
.row .main .l1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row .main b { font-weight: 600; font-size: var(--fs-m); }
.row .main small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nums span + span { margin-left: 10px; }
.row .end { text-align: right; flex: none; font-weight: 600; }
.row .end small { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.row .chev { color: var(--faint); }
.day { padding: var(--sp-4) var(--sp-4) var(--sp-2); color: var(--muted); font-size: var(--fs-s); font-weight: 600; border-top: 1px solid var(--line-soft); }
.day:first-child { border-top: 0; }

.reasons { display: grid; gap: 10px; }
.reason { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--sp-3); font-size: var(--fs-s); }
.reason .lbl { color: var(--ink-2); }
.reason .val { text-align: right; font-weight: 600; }
.reason .trk { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: var(--line-soft); }
.reason .trk i { display: block; height: 100%; border-radius: 2px; background: var(--bar); }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3) var(--sp-4); }
.kv div { min-width: 0; }
.kv .k { display: block; font-size: var(--fs-xs); color: var(--muted); }
.kv .v { display: block; font-size: var(--fs-l); font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.kv .v small { font-size: var(--fs-s); font-weight: 400; color: var(--ink-2); }
.kv .wide { grid-column: 1 / -1; }

.checks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: var(--fs-s); }
.checks li { display: flex; gap: var(--sp-2); align-items: flex-start; }
.checks li .ic { margin-top: 1px; }
.checks .pass .ic { color: var(--up); } .checks .fail .ic { color: var(--down); } .checks .nodata .ic { color: var(--faint); }
.checks small { color: var(--muted); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; border-radius: var(--r-m); background: var(--surface-2); }
.seg button { min-height: 36px; border-radius: 8px; font-size: var(--fs-s); font-weight: 600; color: var(--muted); text-align: center; padding: 0 var(--sp-2); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); }

.empty { padding: var(--sp-8) var(--sp-4); color: var(--muted); font-size: var(--fs-s); text-align: left; }
.empty b { display: block; color: var(--ink-2); font-size: var(--fs-m); margin-bottom: 4px; }

.sk { display: block; height: 14px; border-radius: 4px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
.sk.h1 { height: 26px; width: 60%; } .sk.w40 { width: 40%; } .sk.w70 { width: 70%; }

/* ---------- настройки ---------- */
.set-row { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 52px; padding: 8px var(--sp-4); border-top: 1px solid var(--line-soft); }
.set-row:first-child { border-top: 0; }
.set-row .lbl { flex: 1; min-width: 0; }
.set-row .val { color: var(--ink-2); text-align: right; max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-row.edited .val { color: var(--accent); font-weight: 600; }
.set-row .mark { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.ver { color: var(--muted); font-size: var(--fs-s); }

.changebar { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 25; display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px var(--sp-4); background: var(--surface); border-top: 1px solid var(--line); }
.changebar .cnt { flex: 1; min-width: 0; font-size: var(--fs-s); color: var(--ink-2); }
.changebar .cnt b { color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 var(--sp-4); border-radius: var(--r-m);
  font-weight: 600; font-size: var(--fs-m); white-space: nowrap; transition: transform 120ms var(--ease), background-color var(--dur) var(--ease); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.quiet { color: var(--accent); padding: 0 var(--sp-2); }
.btn.small { min-height: 36px; font-size: var(--fs-s); padding: 0 var(--sp-3); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.block { width: 100%; }
.btns { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); }
.btns .btn { flex: 1; }

/* ---------- нижняя панель разделов ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line-soft); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: var(--fs-2xs); font-weight: 600; }
.tab .ic { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab:active .ic { transform: scale(0.94); }

/* ---------- лист снизу ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); animation: fade var(--dur) var(--ease); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88svh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-l) var(--r-l) 0 0; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); animation: rise 220ms var(--ease); overscroll-behavior: contain; }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet-body { overflow-y: auto; padding: var(--sp-3) var(--sp-4) var(--sp-5); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet h3 { margin: 0 0 4px; font-size: var(--fs-l); font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet .lead { margin: 0 0 var(--sp-4); color: var(--muted); font-size: var(--fs-s); }
.sheet .blk { padding: var(--sp-4) 0; border-top: 1px solid var(--line-soft); }
.sheet .blk:first-of-type { border-top: 0; }
.sheet .blk h4 { margin: 0 0 var(--sp-2); font-size: var(--fs-s); color: var(--muted); font-weight: 600; }
.sheet ul.diff { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: var(--fs-s); }
.sheet ul.diff li { padding: 8px 10px; border-radius: var(--r-s); background: var(--surface-2); }

.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: var(--sp-2); align-items: center; }
.stepper button { height: 52px; border-radius: var(--r-m); background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.stepper button:active { transform: scale(0.97); }
.stepper .cur { text-align: center; font-size: var(--fs-2xl); font-weight: 700; }
.field-input { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.field-input input { flex: 1; min-width: 0; height: 44px; padding: 0 var(--sp-3); border-radius: var(--r-m); border: 1px solid var(--line);
  background: var(--bg); font-size: max(16px, 1rem); }
.field-input input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--accent); }
.err { margin-top: var(--sp-2); color: var(--down); font-size: var(--fs-s); }
.opts { display: grid; gap: 2px; margin: 0 calc(-1 * var(--sp-4)); }
.opt { display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; padding: 0 var(--sp-4); }
.opt .box { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center; flex: none; }
.opt .box.round { border-radius: 50%; }
.opt[aria-checked="true"] .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt .box .ic { width: 14px; height: 14px; stroke-width: 2.6; }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip { min-height: 36px; padding: 0 var(--sp-3); border-radius: var(--r-s); background: var(--surface-2); font-weight: 600; font-size: var(--fs-s); color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent); }

.progress { height: 4px; border-radius: 2px; background: var(--line-soft); overflow: hidden; margin: var(--sp-3) 0 var(--sp-2); }
.progress i { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left center; transform: scaleX(var(--p, 0)); transition: transform 400ms var(--ease); }
.progress.ind i { width: 30%; transform: none; animation: slide 1.2s var(--ease) infinite; }

table.cmp { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
table.cmp th { text-align: right; color: var(--muted); font-weight: 600; padding: 6px 0 6px var(--sp-3); }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; padding-left: 0; }
table.cmp td { text-align: right; padding: 8px 0 8px var(--sp-3); border-top: 1px solid var(--line-soft); font-weight: 600; white-space: nowrap; }
table.cmp td:first-child { font-weight: 400; color: var(--ink-2); white-space: normal; }

.toast { position: fixed; left: var(--sp-4); right: var(--sp-4); bottom: calc(var(--tab-h) + var(--safe-b) + var(--sp-3)); z-index: 50;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-m); background: var(--surface-3); color: var(--ink); font-size: var(--fs-s);
  display: flex; align-items: center; gap: var(--sp-3); animation: rise 200ms var(--ease); }
.toast .btn { margin-left: auto; }

.gate { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; padding: var(--sp-6); gap: var(--sp-3); }
.gate h1 { margin: 0; font-size: var(--fs-xl); }
.gate p { margin: 0; color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.55; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media (min-width: 640px) {
  .view, .strip, .changebar { max-width: 640px; margin-left: auto; margin-right: auto; }
  .changebar { left: 50%; transform: translateX(-50%); width: 100%; }
  .sheet { max-width: 640px; margin: 0 auto; }
  .tabs { max-width: 640px; margin: 0 auto; }
}
