@font-face {
  font-family: "Golos Text";
  src: url("/fonts/golos-text.woff") format("woff");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

/* Ночное табло: тёмный сине-чёрный фон, мятная прибыль, коралловый убыток.
   Янтарный — голос самого робота: состояние, указатель «сейчас», активная вкладка. */
:root {
  --ground: #0c1117;
  --panel: #131a23;
  --raise: #1a2330;
  --line: #222c39;
  --text: #e9eef5;
  --muted: #8794a6;
  --faint: #566478;
  --gain: #3ad29f;
  --loss: #ff6b78;
  --signal: #f2b84b;
  --gain-soft: rgba(58, 210, 159, .13);
  --loss-soft: rgba(255, 107, 120, .13);
  --signal-soft: rgba(242, 184, 75, .15);
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bar: 46px;
  --tabs: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --ground: #eef1f5;
    --panel: #ffffff;
    --raise: #f6f8fb;
    --line: #d9e0e8;
    --text: #101a27;
    --muted: #596a7e;
    --faint: #8b99aa;
    --gain: #0b8f63;
    --loss: #d3364d;
    --signal: #a86a00;
    --gain-soft: rgba(11, 143, 99, .11);
    --loss-soft: rgba(211, 54, 77, .10);
    --signal-soft: rgba(168, 106, 0, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--ground); color: var(--text); font: 15px/1.42 var(--font); -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; min-height: 100dvh;
  padding: calc(var(--bar) + var(--safe-top) + 14px) 0 calc(var(--tabs) + var(--safe-bottom) + 24px);
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: inherit; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 8px; }
h1, h2 { font-weight: 600; }
.num { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum", "lnum"; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.flat, .muted { color: var(--muted); }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; transition: opacity .3s; }
.wrap.stale { opacity: .5; }

/* --- верхняя полоса: жив ли сервер --- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 30; height: calc(var(--bar) + var(--safe-top));
  padding: var(--safe-top) max(16px, calc((100vw - 528px) / 2)) 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--ground);
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.pulse.ok { background: var(--gain); }
.pulse.warn { background: var(--signal); }
.pulse.bad { background: var(--loss); }
.pulse.beat { animation: beat .9s ease-out; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(58, 210, 159, .55); } 100% { box-shadow: 0 0 0 9px rgba(58, 210, 159, 0); } }
.bar-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.bar-text b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-text span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar time { font-size: 13px; color: var(--muted); }

/* --- разделы --- */
.sec { margin-top: 26px; }
.sec:first-child { margin-top: 0; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sec-head h2 { font-size: 13.5px; color: var(--muted); }
.sec-head span { font-size: 12.5px; color: var(--faint); }
.empty { color: var(--muted); font-size: 14px; padding: 14px 0; }
.hint { color: var(--faint); font-size: 12.5px; margin-top: 8px; }

/* --- главная цифра дня --- */
.hero { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px 16px 10px; }
.hero-label { font-size: 13.5px; color: var(--muted); }
.hero-value { font-size: clamp(40px, 12.5vw, 58px); font-weight: 680; letter-spacing: -.03em; line-height: 1.04; margin: 2px 0 10px; white-space: nowrap; }
.hero-value .sg, .big .sg { font-weight: 500; font-size: .66em; letter-spacing: 0; margin-right: .04em; opacity: .85; }
.hero-value .cur, .big .cur { font-size: .46em; font-weight: 560; color: var(--muted); margin-left: .18em; letter-spacing: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--line); }
.split > div { padding: 10px 0 8px; display: flex; flex-direction: column; gap: 1px; }
.split > div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.split span { font-size: 12.5px; color: var(--muted); }
.split b { font-size: 17px; font-weight: 620; }
.strip-wrap { margin: 6px -4px 0; }
canvas.strip { width: 100%; height: 132px; display: block; }
.strip-note { font-size: 12px; color: var(--faint); padding: 0 4px 4px; }

/* --- строки «название и значение» --- */
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line); }
.kv > div:first-child { border-top: 0; }
.kv .k { color: var(--muted); font-size: 14px; }
.kv .v { font-weight: 560; text-align: right; }
.state { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line); }
.state:first-child { border-top: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--faint); }
.dot.ok { background: var(--gain); }
.dot.warn { background: var(--signal); }
.dot.bad { background: var(--loss); }
.state b { font-weight: 580; }
.state small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; overflow-wrap: anywhere; }

/* --- позиции --- */
.tiles { display: flex; flex-direction: column; gap: 10px; }
.pos { display: block; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 12px; }
.pos:active { background: var(--raise); }
.pos-head { display: flex; align-items: baseline; gap: 8px; }
.tk { font-size: 17px; font-weight: 680; letter-spacing: -.01em; }
.side { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--gain-soft); color: var(--gain); }
.side.short { background: var(--loss-soft); color: var(--loss); }
.qty { color: var(--muted); font-size: 13.5px; }
.pnl { margin-left: auto; font-weight: 650; font-size: 17px; }
.pos-sub { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.gauge { position: relative; height: 22px; margin-top: 10px; }
.gauge .track { position: absolute; left: 0; right: 0; top: 8px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--loss-soft) var(--entry), var(--gain-soft) var(--entry)); }
.gauge .fill { position: absolute; top: 8px; height: 6px; border-radius: 3px; }
.gauge .fill.gain { background: var(--gain); }
.gauge .fill.loss { background: var(--loss); }
.gauge .mark { position: absolute; top: 3px; width: 3px; height: 16px; margin-left: -1.5px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 2px var(--panel); }
.gauge .tick { position: absolute; top: 5px; width: 1px; height: 12px; background: var(--faint); }
.gauge-ends { display: flex; justify-content: space-between; font-size: 12px; margin-top: 2px; }
.gauge-ends .loss, .gauge-ends .gain { opacity: .9; }
.pos-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 12.5px; }

/* --- фильтры и переключатели --- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; }
.chip[aria-pressed="true"] { border-color: var(--signal); color: var(--signal); background: var(--signal-soft); font-weight: 580; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { min-height: 36px; text-align: center; border-radius: 9px; color: var(--muted); font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }

/* --- итоги --- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 12px; }
.stat { padding: 11px 0; border-top: 1px solid var(--line); }
.stat:nth-child(even) { padding-left: 14px; border-left: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: 12.5px; }
.stat b { font-size: 18px; font-weight: 620; }
.big { font-size: clamp(30px, 9vw, 40px); font-weight: 680; letter-spacing: -.025em; line-height: 1.1; margin-top: 12px; }
canvas.chart, canvas.curve { width: 100%; display: block; touch-action: pan-y; }
canvas.curve { height: 170px; }

/* --- списки --- */
.rows > .r { display: grid; grid-template-columns: 52px 1fr auto; gap: 4px 10px; padding: 11px 0; border-top: 1px solid var(--line); align-items: baseline; }
.rows > .r:first-child { border-top: 0; }
.r-time { color: var(--faint); font-size: 12.5px; }
.r-main { min-width: 0; overflow-wrap: anywhere; }
.r-main b { font-weight: 620; }
.r-sub { grid-column: 2 / 4; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.r-end { text-align: right; font-weight: 600; white-space: nowrap; }
button.r { width: 100%; text-align: left; }
.ev { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 9px 0 9px 10px; border-top: 1px solid var(--line); border-left: 3px solid transparent; font-size: 13.5px; }
.ev:first-child { border-top: 0; }
.ev .t { color: var(--faint); font-size: 12.5px; padding-top: 1px; }
.ev span:last-child { overflow-wrap: anywhere; }
.ev.TRADE { border-left-color: var(--gain); }
.ev.TRADE.sell { border-left-color: var(--loss); }
.ev.WARN { border-left-color: var(--signal); }
.ev.ERROR { border-left-color: var(--loss); }
.ev.INFO { color: var(--muted); }
.day-bar { grid-column: 2 / 4; height: 4px; border-radius: 2px; background: var(--line); position: relative; overflow: hidden; }
.day-bar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }

/* --- бюджет фьючерсов --- */
.meter { padding: 11px 0; border-top: 1px solid var(--line); }
.meter:first-child { border-top: 0; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.meter-top span { color: var(--muted); font-size: 14px; }
.meter-top b { font-weight: 580; font-size: 14.5px; text-align: right; }
.meter .track { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter .track i { display: block; height: 100%; border-radius: 3px; background: var(--signal); }
.meter .track i.gain { background: var(--gain); }
.meter .track i.loss { background: var(--loss); }

/* --- нижние вкладки --- */
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs) + var(--safe-bottom)); padding: 0 max(0px, calc((100vw - 560px) / 2)) var(--safe-bottom);
  background: var(--ground);
  background: color-mix(in srgb, var(--ground) 90%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--faint); font-size: 11.5px; position: relative; text-align: center; }
.tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--signal); font-weight: 600; }
.tabs button[aria-current="page"]::before { content: ""; position: absolute; top: -1px; width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--signal); }

/* --- график в отдельном окне --- */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--ground); display: flex; flex-direction: column; transform: translateY(0); animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-top) + 10px) 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 19px; letter-spacing: -.01em; }
.sheet-head small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.sheet-head .close { margin-left: auto; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); }
.sheet-head .close svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; }
.sheet-body { overflow-y: auto; padding: 14px 16px calc(var(--safe-bottom) + 28px); flex: 1; max-width: 560px; width: 100%; margin: 0 auto; }
.price-line { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.price-line b { font-size: 30px; font-weight: 680; letter-spacing: -.02em; }
canvas.chart { height: 300px; margin: 10px 0 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); margin: 6px 0 22px; }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px dashed currentColor; vertical-align: middle; margin-right: 6px; }

/* --- экран без ключа --- */
.lock { position: fixed; inset: 0; z-index: 60; background: var(--ground); display: grid; place-items: center; padding: 24px; }
.lock[hidden] { display: none; }
.lock-card { max-width: 340px; text-align: center; }
.lock-card img { border-radius: 18px; margin-bottom: 18px; }
.lock-card h1 { font-size: 22px; margin-bottom: 8px; letter-spacing: -.01em; }
.lock-card p { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .sheet, .pulse.beat { animation: none; }
}
