/* Synthera Mine 2 - base: reset, type, the one container, breakpoints, view switching, the shell (header, dock, toast,
   sheet host), the reveal, skeleton bars (spec 2.5-2.6, 5.3-5.6, 6.2 #1-4 #36, 7.1). No colour literals: tokens only.
   Breakpoints everywhere: < 760 one column · 760-1199 two columns · >= 1200 the per-view desktop layout. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body) / var(--lh-body) var(--font);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
svg { flex: none; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--acc-line); outline-offset: 2px; border-radius: var(--r-s); }

.num, .tnum { font-variant-numeric: tabular-nums lining-nums; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); } .info { color: var(--info); }
.ink2 { color: var(--ink-2); } .ink3 { color: var(--ink-3); }
.desk-only { display: none !important; }
@media (min-width: 1200px) { .desk-only { display: block !important; } .phone-only { display: none !important; } }

/* ---------------------------------------------------------------- the one container (2.6) */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------------------------------------------------------------- views: one visible (the inline script sets data-view before paint) */
#app { padding-top: 4px; padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 16px); }
@media (min-width: 760px) { #app { padding-top: 16px; padding-bottom: 40px; } }
.view { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.view > * { min-width: 0; }
html:not([data-view="home"]) .view[data-view="home"],
html:not([data-view="trade"]) .view[data-view="trade"],
html:not([data-view="mining"]) .view[data-view="mining"],
html:not([data-view="money"]) .view[data-view="money"],
html:not([data-view="log"]) .view[data-view="log"],
html:not([data-view="bots"]) .view[data-view="bots"] { display: none !important; }

/* ---------------------------------------------------------------- header (AppHeader 52 / 56) */
#hdr {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--line);                                   /* a rule that takes no height */
  min-height: calc(var(--hdr-h) + env(safe-area-inset-top));          /* no shift when the script fills it */
}
.hdr-in { height: var(--hdr-h); display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; flex: none; color: var(--ink); }
.brand-g { width: 28px; height: 28px; }
.brand-bg { fill: var(--acc); }
.brand-m { stroke: var(--acc-ink); }
.brand-t { display: none; font-size: 15px; line-height: 20px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.hdr-title { flex: 1 1 auto; font-size: var(--fs-title); line-height: var(--lh-title); font-weight: 600; letter-spacing: -0.01em; }
.hdr-sp { display: none; flex: 1 1 auto; }
.hdr-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.tt { display: none; }
/* Width budget of the one-line header (Golos widths; Segoe is narrower):
   phone 390: glyph 28 + title (86 left; "Торговля" 78) + pill 92 + tools 128 + gaps 24 = 358 = 390 − 2 × 16;
   under 390 the decorative glyph steps aside so the longest title still fits (375: 107, 360: 92).
   760–1199: glyph 28 + tabs 387 (13 px, padding 12) + pill 92 + tools 128 + gaps 40 = 675 ≤ 712 (760 − 2 × 24): the
   wordmark would need 113 more, so it shows from 1200 (tabs 14 px, padding 14: 885 ≤ 1152). */
@media (max-width: 389.98px) { .brand { display: none; } }
@media (min-width: 760px) {
  .hdr-title { display: none; }
  .hdr-sp { display: block; }
  .tt { display: flex; align-items: center; gap: 2px; height: 40px; margin-left: 8px; }
}
@media (min-width: 1200px) {
  .brand-t { display: inline; }
  .tt { margin-left: 16px; }
}
/* TopTabs (>= 760) */
.tt-i {
  position: relative; height: 40px; padding: 0 12px; border-radius: var(--r-m);
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
@media (min-width: 1200px) { .tt-i { padding: 0 14px; } }
.tt-i:hover { background: var(--surface-2); }
.tt-i[aria-selected="true"] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.tt-i[aria-selected="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; border-radius: 2px; background: var(--acc-line); }

/* FreshPill 28 × 92: dot 8 + text 12/16 600 at every width (not --fs-micro, which is 13 from 1200); text room 92 − 10 − 8 − 4 = 70 */
.fp {
  flex: none; width: 92px; height: 28px; padding: 0 5px; border-radius: var(--r-s);
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2); color: var(--ink-2);
  font-size: 12px; line-height: 16px; font-weight: 600; font-variant-numeric: tabular-nums lining-nums;
}
.fp-dot { flex: none; width: 8px; height: 8px; border-radius: var(--r-dot); background: var(--ink-4); }
.fp-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fp[data-lv="live"] .fp-dot { background: var(--up); }
.fp[data-lv="ok"] .fp-dot { background: var(--info); }
.fp[data-lv="warn"] .fp-dot { background: var(--warn); }
.fp[data-lv="bad"] .fp-dot { background: var(--down); }

/* IconButton 40 × 40 (hit 44) */
.ib {
  position: relative; flex: none; width: 40px; height: 40px; border-radius: var(--r-m);
  display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2);
}
.ib::before { content: ""; position: absolute; inset: -2px; }
.ib:hover { color: var(--ink); }
.ib[aria-pressed="true"] { color: var(--ink); }
.ib[disabled] { opacity: .45; cursor: default; }
.ib-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: var(--r-dot); background: var(--warn); }
.ib.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- dock (TabDock, phone) */
#dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  min-height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 -1px 0 var(--line);
}
@media (min-width: 760px) { #dock { display: none; } }
.dock-in { height: var(--dock-h); display: grid; grid-template-columns: repeat(6, 1fr); max-width: 600px; margin: 0 auto; }
.dk { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-3); min-width: 0; }
.dk-ic { position: relative; width: 48px; height: 28px; display: grid; place-items: center; }
.dk-ic::before { content: ""; position: absolute; left: 8px; top: 2px; width: 32px; height: 24px; border-radius: 8px; background: transparent; }
.dk-ic svg { position: relative; }
.dk-l { font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.dk[aria-selected="true"] { color: var(--ink); }
.dk[aria-selected="true"] .dk-ic::before { background: var(--acc); }
.dk[aria-selected="true"] .dk-ic svg { color: var(--acc-ink); }
.dk-badge {
  position: absolute; top: 0; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-dot);
  font-size: 12px; line-height: 16px; font-weight: 600; text-align: center; color: var(--acc-ink); background: var(--warn);
  font-variant-numeric: tabular-nums lining-nums;
}
.dk-badge[data-lv="bad"] { background: var(--down); }
.dk-dot { position: absolute; top: 2px; right: 8px; width: 6px; height: 6px; border-radius: var(--r-dot); background: var(--acc-line); }
.tt-i .dk-badge { position: static; }
.tt-i .dk-dot { position: static; }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 12px); z-index: 50;
  max-width: min(358px, calc(100vw - 32px)); padding: 10px 14px; border-radius: var(--r-m);
  background: var(--surface-3); color: var(--ink); box-shadow: var(--shadow-pop);
  font-size: var(--fs-small); line-height: var(--lh-small);
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) { #toast { bottom: 24px; } }

/* ---------------------------------------------------------------- the reveal (5.5): once, at html.go; html.ready ends it for good */
html:not(.go) .rv { opacity: 0; animation: rv-safe 0s 3s forwards; }          /* no script: shown after 3 s anyway */
html.go:not(.ready) .rv { animation: rv .24s ease-out both; animation-delay: calc(var(--rv-i, 0) * 30ms); }
html.ready .rv, html.rm .rv { opacity: 1; animation: none; }
@keyframes rv { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes rv-safe { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  html .rv { opacity: 1 !important; animation: none !important; }
  .ib.busy svg { animation: none; }
  #toast { transition: none; }
}

/* ---------------------------------------------------------------- skeletons (5.6 loading: static bars, no shimmer) */
.sk { border-radius: var(--r-l); border: 1px solid var(--line); background: var(--surface); padding: var(--pad); overflow: hidden; }
.sk.flat { border: 0; background: transparent; padding: 0; }
.sk.strip { border: 0; background: var(--surface-2); border-radius: var(--r-m); padding: 0 12px; display: flex; align-items: center; }
.sk-bar { height: 12px; border-radius: 4px; background: var(--surface-2); margin: 6px 0; }
.sk.strip .sk-bar { background: var(--surface-3); margin: 0; }
.sk-t { color: var(--ink-3); font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 600; margin-bottom: 8px; }

/* ---------------------------------------------------------------- sheet host (the controller js/ui/sheet.js styles its panel) */
#sheet { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#sheet.on { pointer-events: auto; }
.sheet-back { position: absolute; inset: 0; background: var(--backdrop); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 85vh; display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-pop);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-panel:focus, .sheet-panel:focus-visible { outline: none; }   /* focused for the trap, not a control */
.sheet-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 8px auto 0; flex: none; }
.sheet-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px; flex: none; }
.sheet-title { flex: 1; margin: 0; font-size: var(--fs-title); line-height: var(--lh-title); font-weight: 600; letter-spacing: -0.01em; }
.sheet-x { width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink-2); border-radius: var(--r-m); }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 16px; }
@media (min-width: 760px) {
  .sheet-panel { left: auto; top: 0; width: 420px; max-height: none; border-radius: var(--r-sheet) 0 0 var(--r-sheet); }
  .sheet-grab { display: none; }
}
