/* «Тест-драйв 500», TG-UI-003: «Ночной стенд» (idea and tokens: research/tgapp/ui3/DESIGN.md). Every colour and size comes from the tokens below; the dark theme is the main one.
   Phone first; the computer gets a grid that really uses the screen. Nothing here loops: no animation runs after a screen has appeared. */
@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(fonts/onest-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(fonts/onest-latin-wght-normal.woff2) format("woff2"); 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"; font-style: normal; font-weight: 100 800; font-display: swap; src: url(fonts/jetbrains-mono-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215; }

:root {
  /* type and sizes: the same in both themes */
  --sans: "Onest", -apple-system, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-s: 13px; --fs-m: 15px; --fs-l: 18px; --fs-xl: 26px; --fs-val: 46px;
  --r-s: 10px; --r-m: 14px; --r-l: 20px; --r-full: 999px;
  --gap: 12px; --pad: 16px; --tap: 44px;
  --dur: .18s; --ease: cubic-bezier(.2, .7, .2, 1);

  /* light theme */
  --bg: #eef1f6; --bg-2: #e3e8f0;
  --surface: #ffffff; --surface-2: #f3f5f9; --surface-3: #e7ebf2;
  --glass: rgba(255, 255, 255, .86);
  --stroke: rgba(16, 24, 40, .1); --stroke-2: rgba(16, 24, 40, .2);
  --text: #0f1620; --text-2: #3f4a5a; --text-3: #566172;
  --accent: #2453d6; --accent-ink: #ffffff; --accent-soft: rgba(36, 83, 214, .1);
  --up: #03694c; --up-soft: rgba(3, 105, 76, .1);
  --down: #b42c1a; --down-soft: rgba(180, 44, 26, .09);
  --warn: #805300; --warn-soft: rgba(180, 120, 0, .14);
  --real: #2453d6; --hold: #5b6573;
  --s1: #2453d6; --s2: #c2550d; --s3: #0b8a78; --s4: #8f6d00; --s5: #c0397f; --s6: #6d46cf;   /* lines: at least 3:1 on the surface */
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 28px -18px rgba(16, 24, 40, .28);
  --shadow-pop: 0 16px 44px -12px rgba(16, 24, 40, .35);
  --hl: rgba(36, 83, 214, .05);        /* light under the pointer */
  --glow-a: rgba(36, 83, 214, .09); --glow-b: rgba(11, 138, 120, .07);
  --grid-dot: rgba(16, 24, 40, .055);
  /* names the chart section reads */
  --page: var(--bg); --card: var(--surface); --line: var(--stroke); --muted: var(--text-2);
}
:root[data-theme="dark"] {
  --bg: #080b10; --bg-2: #0e1219;
  --surface: #131922; --surface-2: #1a212c; --surface-3: #232c39;
  --glass: rgba(19, 25, 34, .84);
  --stroke: rgba(255, 255, 255, .09); --stroke-2: rgba(255, 255, 255, .18);
  --text: #f1f4f8; --text-2: #b4bdca; --text-3: #98a3b2;
  --accent: #86aeff; --accent-ink: #0a1020; --accent-soft: rgba(134, 174, 255, .15);
  --up: #3ddc9f; --up-soft: rgba(61, 220, 159, .13);
  --down: #ff8a80; --down-soft: rgba(255, 138, 128, .14);
  --warn: #f5c565; --warn-soft: rgba(245, 197, 101, .14);
  --real: #86aeff; --hold: #b4bdc9;
  --s1: #86aeff; --s2: #ffa767; --s3: #4fd6c0; --s4: #e3c14d; --s5: #f08cc0; --s6: #b79bff;
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 14px 34px -22px rgba(0, 0, 0, .9);
  --shadow-pop: 0 18px 54px -12px rgba(0, 0, 0, .75);
  --hl: rgba(134, 174, 255, .07);
  --glow-a: rgba(92, 132, 255, .16); --glow-b: rgba(61, 220, 159, .07);
  --grid-dot: rgba(255, 255, 255, .05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { --sa-t: 0px; --sa-b: 0px; --sa-l: 0px; --sa-r: 0px; --top: max(env(safe-area-inset-top), var(--sa-t)); --bot: max(env(safe-area-inset-bottom), var(--sa-b)); background: var(--bg); }   /* set by safe.js */
html, body { margin: 0; color: var(--text); font: var(--fs-m)/1.45 var(--sans); }
body { overscroll-behavior-y: none; padding-top: var(--top); min-height: 100vh; background: var(--bg); position: relative; isolation: isolate; }
/* the room: two fixed soft lights and a faint measuring grid. Painted once, never moves */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(900px 520px at 12% -8%, var(--glow-a), transparent 70%), radial-gradient(760px 480px at 96% 4%, var(--glow-b), transparent 70%); }
@media (hover: hover) and (pointer: fine) {
  body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(circle at 1px 1px, var(--grid-dot) 1px, transparent 1.5px) 0 0/28px 28px; }
}
a { color: var(--accent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--text-2); }
.mt { margin-top: 12px; } .mt8 { margin-top: 8px; } .mb8 { margin-bottom: 8px; }
.smalltext { font-size: 14px; }
main { padding: 12px max(12px, env(safe-area-inset-right), var(--sa-r)) calc(96px + var(--bot)) max(12px, env(safe-area-inset-left), var(--sa-l)); max-width: 640px; margin: 0 auto; }
html.no-nav main { padding-bottom: 24px; }

.anim .card, .anim > h1, .anim > h2 { animation: rise .42s var(--ease) both; }
.anim .bento > :nth-child(2) { animation-delay: 40ms; } .anim .bento > :nth-child(3) { animation-delay: 80ms; } .anim .bento > :nth-child(4) { animation-delay: 110ms; }
.anim .bento > :nth-child(5) { animation-delay: 140ms; } .anim .bento > :nth-child(n+6) { animation-delay: 170ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: var(--fs-xl); line-height: 1.15; font-weight: 700; letter-spacing: -.02em; margin: 8px 4px 14px; }
h2 { font-size: var(--fs-m); font-weight: 650; margin: 22px 4px 10px; color: var(--text-2); }
h3 { font-size: 14px; font-weight: 650; margin: 0 0 10px; letter-spacing: -.005em; }
.card { position: relative; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-l); padding: var(--pad); margin: 0 0 var(--gap); box-shadow: var(--shadow); min-width: 0; }
.card > * { position: relative; }
@media (hover: hover) and (pointer: fine) {
  .card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .25s; background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 0), var(--hl), transparent 70%); }
  .card:hover::before { opacity: 1; }
}
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cardhead h3 { margin: 0; }
.cardhead .seg { margin: 0; flex: 0 1 240px; }
.sub { color: var(--text-2); font-size: var(--fs-s); }
.tiny { color: var(--text-2); font-size: var(--fs-xs); }
.foot { margin-top: 10px; }
.note { margin: 0 4px 12px; }

/* banner */
#banner { position: sticky; top: var(--top); z-index: 4; }
#banner:empty { display: none; }
.demo { color: var(--warn); font-weight: 650; font-size: var(--fs-s); padding: 8px 16px; text-align: center; border-bottom: 1px solid var(--stroke); background: linear-gradient(var(--warn-soft), var(--warn-soft)), var(--bg); }

/* hero: the main instrument */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-full); padding: 3px 10px; font-size: var(--fs-xs); font-weight: 600; background: var(--accent-soft); color: var(--text); border: 1px solid var(--stroke); }
.badge.hist { background: var(--warn-soft); color: var(--warn); }
.hero { overflow: hidden; display: flex; flex-direction: column; }
.hero > .limit:last-child { margin-top: auto; padding-top: 12px; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .6; }
.hero-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-t { font-size: var(--fs-m); font-weight: 600; margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-t.big { font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.acct { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); }
.acct-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.hero .val { font-weight: 300; font-size: var(--fs-val); line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.035em; margin: 6px 0 4px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.hero .val small { font-size: .5em; font-weight: 400; color: var(--text-2); }
.ex { font: 700 var(--fs-xs)/1.3 var(--sans); letter-spacing: .02em; background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 3px 7px; align-self: center; }
.term { border-bottom: 1px dotted currentColor; cursor: help; }
.limit { font-size: 14px; line-height: 1.45; margin-top: 10px; color: var(--text); }
.limit.first { margin-top: 0; }
.warnline { font-size: 14px; line-height: 1.4; font-weight: 600; color: var(--down); margin: 0 0 10px; }
.intro { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; font-size: var(--fs-s); }
.x { flex: none; width: var(--tap); height: var(--tap); margin-left: auto; border: 0; background: none; color: var(--text-2); font: 16px var(--sans); cursor: pointer; }
.caveat { padding: 10px 0; border-top: 1px solid var(--stroke); font-size: 14px; line-height: 1.45; }
.caveat:last-child { padding-bottom: 0; }
.cavgrid { margin-top: 10px; }
.back { display: block; min-height: var(--tap); border: 0; background: none; color: var(--text-2); font: var(--fs-m) var(--sans); padding: 0 4px; cursor: pointer; }
.linkbtn { border: 0; background: none; color: inherit; font: inherit; padding: 0; cursor: pointer; text-align: left; }
.journal { display: flex; justify-content: center; gap: 8px; min-height: var(--tap); align-items: center; }
.about .block:first-child { margin-top: 0; }
.nw { white-space: nowrap; }
.strong { color: var(--text) !important; }
#tipbox { position: fixed; left: 12px; right: 12px; bottom: calc(92px + var(--bot)); z-index: 30; background: var(--glass); border: 1px solid var(--stroke-2); border-radius: var(--r-m); padding: 12px 14px; box-shadow: var(--shadow-pop); font-size: 14px; max-width: 616px; margin: 0 auto; animation: rise .2s var(--ease) both; }
.deltas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.delta { background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--r-m); padding: 10px 12px; min-width: 0; }
.delta.up { background: linear-gradient(var(--up-soft), var(--up-soft)), var(--surface-2); }
.delta.down { background: linear-gradient(var(--down-soft), var(--down-soft)), var(--surface-2); }
.delta .l { color: var(--text-2); font-size: var(--fs-xs); }
.delta .v { font: 600 17px/1.3 var(--mono); letter-spacing: -.03em; white-space: nowrap; }
.delta .p { font: 500 var(--fs-xs)/1.35 var(--mono); }
.delta .p.plain { color: var(--text-2); font-family: var(--sans); }
.vs { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--stroke); font-size: var(--fs-s); display: grid; gap: 8px; }
.vsrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 5px 8px; }
.vsn { min-width: 0; }
.vsv { text-align: right; font-weight: 600; }
.vsb { grid-column: 1 / -1; grid-row: 2; position: relative; height: 8px; background: var(--surface-3); border-radius: 4px; }
.vsb .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--text-3); }
.vsb i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: currentColor; }
.vsb i.hold { opacity: .7; }

/* controls */
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--r-s); padding: 2px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; color: var(--text-2); font: 600 var(--fs-s) var(--sans); padding: 6px 8px; border-radius: 8px; cursor: pointer; min-height: 36px; white-space: nowrap; transition: background var(--dur), color var(--dur); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--stroke); }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 calc(var(--pad) * -1) 10px; padding: 0 var(--pad) 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.free { margin: 0 -12px 10px; padding: 0 12px 2px; }
.chip { flex: none; border: 1px solid var(--stroke); background: transparent; color: var(--text); border-radius: var(--r-full); padding: 5px 12px; font: 500 var(--fs-s) var(--sans); cursor: pointer; min-height: 38px; transition: background var(--dur), border-color var(--dur); }
.chip:hover { border-color: var(--stroke-2); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chip.tgl.on { background: var(--surface-3); color: var(--text); border-color: var(--stroke-2); }
.chip.tgl:not(.on) { color: var(--text-2); }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.chip.tgl:not(.on) .dot { opacity: .4; }

/* line charts */
.chart { position: relative; }
.plot { position: relative; height: var(--h, 200px); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.plot svg { display: block; position: absolute; left: 0; top: 0; }
.chart .grid { stroke: var(--stroke); stroke-width: 1; }
.chart .base { stroke: var(--stroke-2); stroke-width: 1; }
.chart .tick { fill: var(--text-2); font: 11px var(--mono); }
.chart .endv { fill: var(--text); font: 600 12px var(--mono); letter-spacing: -.03em; }
.chart .endl { fill: var(--text-2); font: 11px var(--sans); }
.chart .stamp { fill: var(--warn); font: 700 12px var(--sans); }
.chart .cur { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot, .chart .head { stroke: var(--surface); stroke-width: 2; }
.chart .ln.muted { opacity: .4; }
.chart .halo { opacity: .16; }
.anim .chart .ln.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .7s .1s var(--ease) forwards; }
.anim .chart .ln.fade, .anim .chart .area, .anim .chart .head { animation: fadein .7s .1s var(--ease) both; }
.anim .chart .halo.fade { animation: fadehalo .7s .1s var(--ease) both; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { from { opacity: 0; } }
@keyframes fadehalo { from { opacity: 0; } to { opacity: .16; } }
.tip { position: absolute; top: 2px; z-index: 3; display: none; pointer-events: none; background: var(--glass); border: 1px solid var(--stroke-2); border-radius: var(--r-s); padding: 7px 10px; font-size: var(--fs-xs); box-shadow: var(--shadow-pop); white-space: nowrap; }
.tip-d { color: var(--text-2); margin-bottom: 2px; }
.tip-r { display: flex; align-items: center; gap: 6px; }
.tip-r i { width: 10px; height: 2px; flex: none; }
.tip-r span { color: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-xs); color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 2px; margin-right: 5px; vertical-align: 3px; }
.legend i.dash { height: 0; border-top: 2px dashed; }
.chart-empty { color: var(--text-2); font-size: var(--fs-s); text-align: center; padding: 30px 10px; border: 1px dashed var(--stroke-2); border-radius: var(--r-m); }
.chartnote { margin-top: 8px; }

/* day strip: bar above the line = plus, below = minus */
.dstrip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; height: 72px; background: linear-gradient(var(--stroke-2), var(--stroke-2)) 0 50%/100% 1px no-repeat; }
.dcell { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 3px; min-width: 0; max-width: 26px; width: 100%; }
.dcell:hover { background: var(--surface-3); }
.dcell i { position: absolute; left: 0; right: 0; background: currentColor; }
.dcell.up i { bottom: 50%; border-radius: 2px 2px 0 0; } .dcell.down i { top: 50%; border-radius: 0 0 2px 2px; }
.dcell.flat i { top: calc(50% - 1px); height: 2px !important; }
.dends { display: flex; justify-content: space-between; margin-top: 6px; }
.dayline { margin-top: 6px; min-height: 18px; }

/* gauge */
.gauge { position: relative; max-width: 220px; margin: 0 auto; }
.gauge svg { display: block; width: 100%; }
.g-track, .g-now { fill: none; stroke-width: 10; stroke-linecap: round; }
.g-track { stroke: var(--surface-3); }
.g-now { stroke: var(--down); }
.g-worst { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; }
.g-val { position: absolute; left: 0; right: 0; bottom: 2px; text-align: center; font-weight: 600; font-size: 20px; letter-spacing: -.03em; }
.g-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.g-legend b { display: block; font-size: var(--fs-m); font-weight: 600; }
.g-mark { display: inline-block; width: 2.5px; height: 10px; background: var(--text); margin-right: 5px; vertical-align: -1px; border-radius: 1px; }
.g-scale { margin-top: 6px; }

/* lists */
.status .top { min-height: 22px; }
.row { display: block; width: 100%; min-height: var(--tap); text-align: left; background: none; border: 0; color: inherit; font: inherit; padding: 11px 0; border-top: 1px solid var(--stroke); cursor: pointer; }
button.row:hover .coin, button.row:hover b { color: var(--accent); }
.row > .why { display: block; }
.status { margin-top: 12px; }
.part + .part { margin-top: 6px; }
.rule-row { margin-top: 10px; }
.card > .row:first-of-type, h3 + .row, .expo + .row { border-top: 0; padding-top: 2px; }
.card > .status:first-of-type { border-top: 1px solid var(--stroke); padding-top: 11px; }
.row .top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .coin { font-weight: 700; }
.mono-av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--stroke); font: 700 10px var(--mono); letter-spacing: -.02em; color: var(--text); }
.pos-main { min-width: 0; flex: 1 1 auto; line-height: 1.25; }
.pos-size { display: block; }
.spark { flex: none; display: block; width: 72px; height: 24px; }   /* the place is kept while the picture is on its way: rows do not jump */
.sparkline { display: block; }
.sparkline.up { color: var(--up); } .sparkline.down { color: var(--down); }
.side { font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.right { margin-left: auto; text-align: right; }
.row .res { font: 600 var(--fs-m) var(--mono); letter-spacing: -.03em; white-space: nowrap; }
.why { color: var(--text-2); font-size: var(--fs-s); margin-top: 3px; }
.more { display: none; font-size: var(--fs-s); margin-top: 8px; color: var(--text-2); }
.row.open > .more { display: block; }
.empty-line { color: var(--text-2); font-size: 14px; padding: 4px 0; }
.expo { margin-bottom: 10px; }
.expo-h { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* before the first data */
.count { font: 600 38px/1.15 var(--mono); letter-spacing: -.04em; font-variant-numeric: tabular-nums; margin: 2px 0; color: var(--text); }
.check { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; border-top: 1px solid var(--stroke); font-size: var(--fs-s); }
.check .ic { flex: none; width: 18px; text-align: center; }
.stepper { list-style: none; margin: 0; padding: 0; position: relative; }
.step { display: flex; gap: 10px; padding: 7px 0; font-size: 14px; position: relative; }
.step b { display: block; }
.stepper .step:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 33px; bottom: -5px; width: 1px; background: var(--stroke-2); }
.step .n { flex: none; width: 23px; height: 23px; border-radius: 50%; background: var(--accent-soft); border: 1px solid var(--stroke-2); text-align: center; font: 600 var(--fs-xs)/21px var(--mono); }
.ghosts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ghost { border: 1px dashed var(--stroke-2); border-radius: var(--r-m); padding: 12px; min-height: 76px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; font-size: var(--fs-s); }
.ghost b { font-weight: 600; }

/* tables */
.tw { overflow-x: auto; margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-s); }
th, td { text-align: left; padding: 9px 6px; border-top: 1px solid var(--stroke); white-space: nowrap; }
th { border-top: 0; color: var(--text-2); font-weight: 500; font-size: var(--fs-xs); padding-top: 2px; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td.n, th.n { text-align: right; }
td.n { font-family: var(--mono); letter-spacing: -.03em; }
td.sp, th.sp { display: none; padding: 4px 6px; }
tr.sel td { font-weight: 650; background: var(--accent-soft); }
tr[data-ver] { cursor: pointer; }
tr[data-ver]:hover td { background: var(--surface-2); }
tr.grp td { color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; padding-top: 14px; }
tr.subr td { white-space: normal; border-top: 0; padding-top: 0; font-size: var(--fs-xs); color: var(--text-2); }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* contribution bars */
.bar-row { padding: 9px 0; }
.bar-h { display: flex; justify-content: space-between; font-size: var(--fs-s); gap: 8px; }
.bar { position: relative; height: 8px; margin: 7px 0 4px; background: var(--surface-3); border-radius: 4px; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: currentColor; }
.bar .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--text-3); }

/* feed */
.day-h { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin: 16px 4px 6px; font-size: var(--fs-s); font-weight: 650; flex-wrap: wrap; }
.day-h .tiny { font-weight: 400; font-family: var(--mono); letter-spacing: -.02em; }
.daygrp:first-child .day-h { margin-top: 2px; }
.tr { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--stroke); align-items: flex-start; }
.tr:first-child { border-top: 0; padding-top: 0; }
.tr:last-child { padding-bottom: 0; }
.trade { padding: 9px 0; }
.trade .tr { border: 0; padding: 0; }
.tr .pill { flex: none; font-size: 11.5px; font-weight: 700; border-radius: 7px; padding: 3px 7px; margin-top: 1px; text-align: center; white-space: nowrap; background: var(--surface-3); }
.tr .pill.up { background: var(--up-soft); } .tr .pill.down { background: var(--down-soft); }
.btn { display: block; width: 100%; border: 1px solid var(--stroke); border-radius: var(--r-m); background: var(--accent-soft); color: var(--text); font: 600 14px var(--sans); padding: 11px; cursor: pointer; min-height: var(--tap); transition: border-color var(--dur), background var(--dur); }
.btn:hover { border-color: var(--stroke-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chartgo { margin-top: 8px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.tile { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-m); padding: 10px 12px; min-width: 0; box-shadow: var(--shadow); }
.tile .l { color: var(--text-2); font-size: var(--fs-xs); }
.tile .v { font: 600 14.5px/1.4 var(--mono); letter-spacing: -.03em; white-space: nowrap; }
.tiles.two { grid-template-columns: 1fr 1fr; }
.tiles .card-in { background: var(--surface-2); box-shadow: none; }
#pcmsg { min-height: 18px; margin-top: 6px; }

/* strategies + project */
.sgrid { display: grid; gap: var(--gap); }
.scard { display: flex; flex-direction: column; text-align: left; color: inherit; font: inherit; cursor: pointer; margin: 0; width: 100%; transition: border-color var(--dur); }
.scard:hover { border-color: var(--stroke-2); }
.scard .top { display: flex; align-items: baseline; gap: 8px; }
.sc-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 12px; flex-wrap: wrap; }
.sc-foot .sparkline { margin-left: auto; }
.sc-foot .num { font-weight: 600; font-size: var(--fs-s); }
.chev { flex: none; display: inline-block; width: 8px; height: 8px; margin: 0 3px 3px auto; font-size: 0; border: solid var(--text-2); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .15s; }
button .chev { transform: rotate(-45deg); margin-bottom: 1px; }
.row.open .chev { transform: rotate(225deg); margin-bottom: 0; }
.block { margin-top: 12px; font-size: 14px; }
.block b { display: block; font-size: var(--fs-s); color: var(--text-2); font-weight: 600; margin-bottom: 2px; }
.block.plus b { color: var(--up); } .block.minus b { color: var(--down); }
.rule { font: 12px/1.45 var(--mono); color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.pastctl .seg { margin-bottom: 10px; }
.feed { position: relative; }
.ev { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--stroke); }
.ev:first-child { border-top: 0; padding-top: 0; }
.ev:last-child { padding-bottom: 0; }
.ev .date { flex: none; width: 42px; color: var(--text-2); font: 12px/1.6 var(--mono); }
.ev .t { font-weight: 600; font-size: 14px; }
.ev .d { color: var(--text-2); font-size: var(--fs-s); overflow-wrap: anywhere; }
.ev .tag { font-size: var(--fs-s); margin-right: 4px; }
code { font: 12px var(--mono); }

/* login */
.login { max-width: 460px; margin: 8vh auto 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { font-weight: 700; letter-spacing: -.02em; font-size: var(--fs-m); white-space: nowrap; }
.brand em { font-style: normal; color: var(--accent); font-family: var(--mono); font-weight: 600; }
.brand img { border-radius: 9px; display: block; }
.brand.big { margin: 0 4px 16px; }
.brand.big b { font-size: 24px; }
.login .card { padding: 20px; }

/* navigation: a floating dock on a phone */
#tabs { position: fixed; left: 10px; right: 10px; bottom: calc(8px + var(--bot)); z-index: 15; display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--stroke-2); border-radius: 22px; padding: 5px; box-shadow: var(--shadow-pop); max-width: 620px; margin: 0 auto; }
#tabs .brand, #tabs .navfoot { display: none; }
#tabs button { flex: 1; min-width: 0; border: 0; background: none; color: var(--text-2); padding: 7px 0 5px; font: 500 var(--fs-xs) var(--sans); white-space: nowrap; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 17px; transition: background var(--dur), color var(--dur); }
#tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--stroke); }
#tabs button.on svg { color: var(--accent); }

/* skeleton: only while the first answer is on its way; plain still shapes, not a shimmer that looks like live data */
.sk { height: 12px; border-radius: 6px; margin: 10px 0; background: var(--surface-3); }
.sk.big { height: 42px; } .sk.chartsk { height: 180px; }
.w40 { width: 40%; } .w60 { width: 60%; } .w70 { width: 70%; } .w80 { width: 80%; } .w90 { width: 90%; }
.stop { text-align: center; color: var(--text-2); padding: 60px 20px; }

/* ---- one-page app (TG-UX-002): sections, three layouts ---- */
.d-only { display: none !important; }                        /* Сравнение and Проект have their own place only in the desktop menu; on a phone they sit under «Ещё» */
html.on-chart, html.on-chart body { overflow: hidden; height: 100%; }
html.on-chart #tabs { display: none; }                       /* phone: the chart uses the whole screen; Back (Telegram's or the ‹ in the toolbar) returns */
.row > .top .chev { margin-left: auto; }

/* phone turned sideways: a narrow column of icons on the left instead of the bottom bar (low height is too expensive); hidden on the chart */
@media (max-height: 520px) and (orientation: landscape) {
  #tabs { top: 0; left: 0; right: auto; bottom: 0; width: calc(64px + max(env(safe-area-inset-left), var(--sa-l))); flex-direction: column; justify-content: center; gap: 2px; margin: 0; border-radius: 0; box-shadow: none;
    padding: 4px 4px 4px max(4px, env(safe-area-inset-left), var(--sa-l)); border-width: 0 1px 0 0; padding-top: max(4px, var(--top)); background: var(--surface); }
  #tabs button { flex: none; padding: 6px 0 4px; font-size: 10.5px; border-radius: 12px; }
  #tabs svg { width: 21px; height: 21px; }
  main { margin: 0 0 0 calc(64px + max(env(safe-area-inset-left), var(--sa-l))); max-width: none; padding: 10px 16px 16px 12px; }
  main > div { max-width: 780px; margin: 0 auto; }
  #banner { margin-left: calc(64px + max(env(safe-area-inset-left), var(--sa-l))); }
  #tipbox { left: 84px; bottom: 12px; }
  html.no-nav main { margin-left: 0; }
}

/* computer: sections on the left with captions, content on a grid over the whole screen, the chart takes the rest */
@media (min-width: 1100px) and (min-height: 521px) {
  :root { --gap: 16px; --pad: 20px; --fs-val: 54px; --tap: 40px; }
  html { --navw: 216px; }
  html.no-nav { --navw: 0px; }
  .d-only { display: flex !important; }
  .m-only { display: none !important; }
  html.on-chart #tabs { display: flex; }
  #tabs { top: 0; left: 0; right: auto; bottom: 0; width: 216px; max-width: none; margin: 0; border-radius: 0; flex-direction: column; justify-content: flex-start; gap: 3px; padding: 18px 12px; border-width: 0 1px 0 0; box-shadow: none; background: var(--surface); }
  #tabs .brand { display: flex; padding: 2px 8px 16px; }
  #tabs .navfoot { display: block; margin-top: auto; padding: 12px 8px 2px; font-size: var(--fs-xs); color: var(--text-2); line-height: 1.4; }
  #tabs button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600; border-radius: 12px; }
  #tabs button:hover { background: var(--surface-2); color: var(--text); }
  #tabs button.on:hover { background: var(--accent-soft); }
  #tabs svg { width: 21px; height: 21px; }
  main { margin: 0 0 0 var(--navw); max-width: none; padding: 20px 24px 40px; }
  html.no-nav main { margin-left: 0; }
  main > div { margin: 0 auto; max-width: 1400px; }
  #banner { margin-left: var(--navw); }
  #tipbox { left: 236px; right: auto; width: 460px; bottom: 20px; margin: 0; }
  h1 { font-size: 30px; margin-top: 2px; }
  .card { margin: 0; }
  .card.intro { margin-bottom: var(--gap); }
  .bento { display: grid; gap: var(--gap); grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: stretch; }
  .chart.fill { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  .chart.fill .plot { flex: 1 1 auto; height: auto; min-height: clamp(220px, 34vh, 620px); }
  .a-curve, .a-past, .a-cmp { display: flex; flex-direction: column; }
  .a-curve > .chart-empty, .a-cmp > .chart-empty { flex: 1 1 auto; display: grid; place-items: center; min-height: clamp(220px, 34vh, 620px); }

  /* Счёт */
  .home .a-hero { grid-column: span 5; } .home .a-curve { grid-column: span 7; }
  .home .a-days { grid-column: span 8; } .home .a-gauge { grid-column: span 4; }
  .home .a-pos { grid-column: span 7; } .home .a-trades { grid-column: span 5; }
  /* before the first data */
  .empty .a-hero { grid-column: span 7; } .empty .a-next { grid-column: span 5; }
  .empty .a-past { grid-column: span 8; } .empty .a-ghost { grid-column: span 4; }
  .empty .ghosts { grid-template-columns: 1fr; }
  /* Сравнение */
  .compare .a-cmp { grid-column: span 7; } .compare .a-tbl { grid-column: span 5; } .compare .a-bars { grid-column: 1 / -1; }
  /* Сделки */
  .split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--gap); align-items: start; }
  .split-side { position: sticky; top: calc(var(--top) + 16px); }
  .split-side .chips { flex-wrap: wrap; overflow: visible; margin: 0 0 10px; padding: 0; }
  .split-side .tiles { grid-template-columns: 1fr 1fr; }
  .split-side .tile:last-child { grid-column: 1 / -1; }
  .daygrp .card { margin: 0; }
  /* Как работает */
  .sgrid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .cavgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
  .caveat:last-child { padding-bottom: 10px; }
  .pastwide .chart.fill .plot { min-height: clamp(260px, 38vh, 620px); }
  .pastctl { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
  .pastctl .seg { flex: 0 1 auto; }
  .pastctl .warnline { margin: 8px 0; flex: 1 1 300px; }
  .view > .seg { max-width: 380px; }
  .narrow { max-width: 620px; }
  .about { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 40px; }
  .about .block { margin-top: 12px; }
  .about .block:nth-child(-n+2) { margin-top: 0; }
  .card.tiny, .about + .card, .about ~ .card, .about ~ .journal { margin-top: var(--gap); }
  .detail .a-text { grid-column: span 5; } .detail .a-past { grid-column: span 7; }
  td.sp, th.sp { display: table-cell; }
}
/* big monitor: more columns, not bigger empty margins */
@media (min-width: 1700px) and (min-height: 521px) {
  :root { --fs-val: 62px; }
  main > div { max-width: none; }
  main { padding: 24px 32px 48px; }
  /* three columns: the instrument and the fall from the peak | the curve and the days | what is on the account */
  .home .a-hero { grid-column: 1 / span 3; grid-row: 1; } .home .a-gauge { grid-column: 1 / span 3; grid-row: 2; }
  .home .a-curve { grid-column: 4 / span 6; grid-row: 1; } .home .a-days { grid-column: 4 / span 6; grid-row: 2; }
  .home .a-pos { grid-column: 10 / span 3; grid-row: 1 / span 2; } .home .a-trades { grid-column: 1 / -1; grid-row: 3; }
  .home .a-trades { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 28px; }
  .home .a-trades > h3 { grid-column: 1 / -1; }
  .home .a-trades > .row:nth-of-type(-n+3) { border-top: 0; padding-top: 2px; }
  .empty .a-hero { grid-column: span 4; } .empty .a-next { grid-column: span 3; } .empty .a-ghost { grid-column: span 5; }
  .empty .a-past { grid-column: 1 / -1; order: 3; }
  .empty .ghosts { grid-template-columns: 1fr 1fr; }
  .compare .a-cmp { grid-column: span 8; } .compare .a-tbl { grid-column: span 4; }
  .split { grid-template-columns: 360px minmax(0, 1fr); }
  .feedgrid { column-count: 2; column-gap: var(--gap); }
  .daygrp { break-inside: avoid; }
  .daygrp .day-h { margin-top: 2px; padding-top: 10px; }
  .chart.fill .plot { min-height: clamp(240px, 40vh, 760px); }
  .cavgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .about { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .about .block { margin-top: 0; }
}
@media (min-width: 2300px) and (min-height: 521px) {
  :root { --fs-m: 16px; --fs-s: 14px; --fs-val: 72px; }
  html { --navw: 248px; }
  #tabs { width: 248px; }
  .feedgrid { column-count: 3; }
  .sgrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* a sharp, thin screen keeps every number readable */
@media (max-width: 360px) { :root { --fs-val: 40px; --pad: 14px; } .delta .v { font-size: 15px; } }

/* Все счета (accts.js): one overview, two groups, each account its own 500 $ */
.hero-top { justify-content: space-between; }
.acc-jump { border: 1px solid var(--stroke-2); background: transparent; color: var(--text); border-radius: var(--r-full); padding: 5px 12px; min-height: 32px; font: 600 var(--fs-xs)/1.3 var(--sans); cursor: pointer; }
.acc-jump:hover { background: var(--surface-3); }
.acc-group { margin: 18px 0 6px; font: 700 var(--fs-xs)/1.3 var(--sans); letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); }
.acc { border-top: 1px solid var(--stroke); padding: 6px 0; }
.acc-head { display: block; width: 100%; background: none; border: 0; color: inherit; text-align: left; padding: 6px 4px; font: inherit; cursor: pointer; border-radius: 8px; }
.acc-head:hover { background: var(--surface-2); }
.acc-title { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding-right: 22px; }
.acc-name { font-weight: 650; font-size: 15px; line-height: 1.3; }
.acc-title .chev { position: absolute; right: 4px; top: 6px; margin: 0; }
.acc-left { display: block; min-width: 0; }
.acc-meta { display: block; margin-top: 2px; }
.st { flex: none; font: 600 var(--fs-xs)/1.4 var(--sans); padding: 1px 8px; border-radius: var(--r-full); border: 1px solid var(--stroke-2); color: var(--text-2); white-space: nowrap; }
.st.run { color: var(--text); }
.st.bad { color: var(--down); border-color: currentColor; background: var(--down-soft); }
.st.off { color: var(--text-2); border-style: dashed; }
.acc-style { display: block; margin-top: 8px; min-width: 0; }
.acc-style:empty { display: none; }
.sty { display: inline-block; font-weight: 650; font-size: var(--fs-s); line-height: 1.4; }
.sty.none { font-weight: 500; color: var(--text-2); }
.sty-l { display: block; color: var(--text-2); font-size: var(--fs-xs); line-height: 1.5; }
.tag { display: inline-block; font: 700 11px/1.45 var(--sans); padding: 0 6px; border-radius: 5px; }
.tag.hist { background: var(--warn-soft); color: var(--warn); }
.tag.fact { background: var(--surface-3); color: var(--text); }
.acc-nums { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 8px; margin-top: 8px; }
.acc-nums.none { display: block; color: var(--text-2); font-size: var(--fs-s); }
.acc-nums.old .cell b, .acc-nums.old .cell .p { color: var(--text-2) !important; }
.acc-nums .cell { min-width: 0; display: block; }
.acc-nums .l, .fact .l { display: block; color: var(--text-2); font-size: var(--fs-xs); line-height: 1.3; }
.acc-nums b { display: block; font-weight: 600; font-size: 14px; line-height: 1.4; letter-spacing: -.03em; }
.acc-nums .cell.up b, .acc-nums .cell.up .p { color: var(--up); } .acc-nums .cell.down b, .acc-nums .cell.down .p { color: var(--down); }
.acc-nums .p { display: block; font-size: var(--fs-xs); }
.acc-warn, .acc-label, .acc-stale { display: block; }
.acc-warn { margin-top: 8px; padding: 8px 10px; border-radius: 8px; border-left: 4px solid var(--down); background: var(--down-soft); color: var(--text); font-weight: 650; font-size: 14.5px; line-height: 1.4; }
.acc-label { margin-top: 8px; padding: 6px 10px; border-radius: 8px; border-left: 4px solid var(--warn); background: var(--warn-soft); font-size: 14px; line-height: 1.4; }
.acc-stale { margin-top: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--down); color: var(--down); font-weight: 600; font-size: 14px; line-height: 1.4; }
.acc-why { display: block; margin-top: 6px; color: var(--text-2); font-size: var(--fs-s); line-height: 1.4; }
.acc-why::first-letter { text-transform: uppercase; }
.acc-off { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.acc.off { padding: 12px 4px; }
.acc.off .acc-name { font-weight: 500; color: var(--text-2); }
.acc-pane { padding: 12px; }
.acc-sub { margin: 16px 0 4px; font-weight: 650; font-size: var(--fs-s); }
.acc-trade { border-top: 1px solid var(--stroke); padding: 8px 0; font-size: var(--fs-s); }
.acc-trade .top { display: flex; align-items: center; gap: 6px; }
.acc-trade .right { margin-left: auto; font-family: var(--mono); font-weight: 600; }
.acc-trade .btn.chartgo { margin: 6px 6px 0 0; display: inline-flex; width: auto; }
.acc-trade .part { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.fact { min-width: 0; }
.fact b { display: block; font-weight: 600; font-size: 13.5px; line-height: 1.4; letter-spacing: -.02em; overflow-wrap: anywhere; }
.fact b.up { color: var(--up); } .fact b.down { color: var(--down); }
.skip { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--stroke); font-size: var(--fs-s); }
.skip:first-of-type { border-top: 0; }

/* a row across on a computer: name and marks, style, numbers */
@media (min-width: 1100px) and (min-height: 521px) {
  .home .a-accs, .empty .a-accs { grid-column: 1 / -1; }
  .a-accs .acc-head { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 3fr) minmax(0, 4fr); gap: 20px; align-items: start; }
  .a-accs .acc-style:empty { display: block; }
  .a-accs .acc-style, .a-accs .acc-nums { margin-top: 0; }
}
@media (min-width: 1800px) and (min-height: 521px) {
  .home .a-accs { grid-row: 3; } .home .a-trades { grid-row: 4; }
  .empty .a-accs { grid-row: auto; }
}
