/* ==========================================================================
   SpreadScope — «Midnight Atelier»
   Общие стили всех страниц (futures / dex / chart / status).
   Тёмная тема — по умолчанию (:root), светлая — :root[data-theme="light"].
   Токены, которые читает JS графика (--muted --line --line-strong --green
   --red --yellow --gold --chart-grid --watermark --panel-solid), — только
   литералы hex/rgba.
   ========================================================================== */

/* ---------- 1. Токены ---------------------------------------------------- */
:root {
  --bg: #070d1c;
  --bg-top: #0c1630;
  --bg-bottom: #050914;
  --glow-slate: rgba(92, 118, 180, .32);
  --glow-amber: rgba(222, 166, 96, .20);
  --glow-deep: rgba(40, 58, 120, .45);

  --panel: rgba(16, 25, 50, .62);
  --panel-solid: #0f1830;
  --th-bg: rgba(15, 24, 48, .975);
  --panel2: rgba(255, 255, 255, .035);
  --hover: rgba(255, 255, 255, .05);
  --line: rgba(200, 212, 255, .10);
  --line-strong: rgba(200, 212, 255, .20);
  --chart-grid: rgba(200, 212, 255, .055);

  --text: #eef1f8;
  --text-2: #c3cbe0;
  --muted: #8e9ab6;
  --gold: #d9b47c;
  --gold-2: #f0d3a1;
  --accent: var(--gold);
  --link: #bccaf2;
  --green: #45d49b;
  --red: #ff6f7d;
  --yellow: #f2c46b;
  --green-bg: rgba(69, 212, 155, .12);
  --red-bg: rgba(255, 111, 125, .12);
  --pill-bg: #f5f1ea;
  --pill-fg: #0b1224;
  --focus: rgba(217, 180, 124, .6);
  --watermark: rgba(255, 255, 255, .045);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .65);

  /* дополнительные (не читаются графиком) */
  --hi: rgba(255, 255, 255, .06);               /* внутренний блик стекла */
  --gold-tint: rgba(217, 180, 124, .10);
  --gold-line: rgba(217, 180, 124, .45);
  --hdr-bg: rgba(7, 13, 28, .58);
  --modal-bg: rgba(13, 21, 42, .88);
  --scrim: rgba(3, 6, 15, .55);
  --pill-bg-hover: #ffffff;
  --pill-glow: 0 10px 28px -12px rgba(240, 211, 161, .55);
  --selection: rgba(217, 180, 124, .32);
  --grain-o: .035;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%238e9ab6' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* не цветовые */
  --r-xs: 8px; --r-sm: 12px; --r-md: 16px; --r-lg: 20px; --r-xl: 24px; --r-pill: 999px;
  --top-h: 60px;
  --gap: 12px;
  --blur: 18px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 160ms;

  --font-display: "Playfair Display", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-ui: "Manrope", "Inter", system-ui, "Segoe UI", sans-serif;
  --font-num: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f3f1ec;
  --bg-top: #eef0f7;
  --bg-bottom: #f6f2ea;
  --glow-slate: rgba(120, 146, 210, .22);
  --glow-amber: rgba(226, 178, 110, .22);
  --glow-deep: rgba(170, 184, 225, .25);

  --panel: rgba(255, 255, 255, .72);
  --panel-solid: #ffffff;
  --th-bg: rgba(255, 255, 255, .975);
  --panel2: rgba(16, 28, 60, .035);
  --hover: rgba(16, 28, 60, .05);
  --line: rgba(16, 28, 60, .10);
  --line-strong: rgba(16, 28, 60, .20);
  --chart-grid: rgba(16, 28, 60, .06);

  --text: #0e1630;
  --text-2: #39435e;
  --muted: #5a6480;
  --gold: #8f6224;
  --gold-2: #b07a2e;
  --accent: var(--gold);
  --link: #2a3d8f;
  --green: #08794d;
  --red: #c8323f;
  --yellow: #9a5f00;
  --green-bg: rgba(8, 121, 77, .10);
  --red-bg: rgba(200, 50, 63, .09);
  --pill-bg: #0e1630;
  --pill-fg: #f5f1ea;
  --focus: rgba(143, 98, 36, .55);
  --watermark: rgba(14, 22, 48, .05);
  --shadow: 0 18px 40px -22px rgba(14, 22, 48, .25);

  --hi: rgba(255, 255, 255, .85);
  --gold-tint: rgba(143, 98, 36, .08);
  --gold-line: rgba(143, 98, 36, .42);
  --hdr-bg: rgba(246, 244, 239, .70);
  --modal-bg: rgba(255, 255, 255, .92);
  --scrim: rgba(14, 22, 48, .30);
  --pill-bg-hover: #1c2a55;
  --pill-glow: 0 10px 24px -14px rgba(14, 22, 48, .55);
  --selection: rgba(143, 98, 36, .20);
  --grain-o: .02;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%235a6480' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  color-scheme: light;
}

/* ---------- 2. База ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  accent-color: var(--gold);
}
body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
  color: var(--text);
  font: 500 13px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* атмосферный фон: свечения поверх вертикального градиента */
body::before {
  content: "";
  position: fixed;
  inset: -10vmax;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(58vmax 42vmax at 88% -5%, var(--glow-amber), transparent 62%),
    radial-gradient(70vmax 52vmax at 0% 0%, var(--glow-slate), transparent 64%),
    radial-gradient(80vmax 48vmax at 50% 110%, var(--glow-deep), transparent 66%),
    linear-gradient(180deg, var(--bg-top), var(--bg) 45%, var(--bg-bottom));
}
/* зерно */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-o);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

a { color: var(--link); text-decoration: none; }
a:hover {
  color: var(--gold-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: var(--gold-line);
}
:root[data-theme="light"] a:hover { color: var(--gold); }

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { -webkit-tap-highlight-color: transparent; }
b, strong { font-weight: 700; }
h1, h2, h3, h4 { font-weight: 600; }
img, svg { vertical-align: middle; }

::selection { background: var(--selection); color: var(--text); }

/* скроллбары */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  border-radius: var(--r-pill);
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--gold-line); }
::-webkit-scrollbar-corner { background: transparent; }

/* фокус */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* плавность */
a, .btn, .icon-btn, .input, .chip, .x, .pin, .more, .checks label, nav.tabs a,
.chart-link, .switch input, th.sortable, table.grid td, .stat, .logo {
  transition:
    color var(--dur) var(--ease),
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
/* мягкая смена темы (класс ставит app.js на ~250 мс) */
html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition:
    color 250ms var(--ease), background-color 250ms var(--ease), border-color 250ms var(--ease),
    box-shadow 250ms var(--ease), fill 250ms var(--ease), stroke 250ms var(--ease) !important;
}

/* ---------- 3. Утилиты --------------------------------------------------- */
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums slashed-zero; }
.num a, .num .coin, .num .chip, .num h3, .num .k, .num .h, .num th, .num .more { font-family: var(--font-ui); }
.mono { font-family: var(--font-num); font-variant-numeric: tabular-nums slashed-zero; }
.serif { font-family: var(--font-display); font-variant-numeric: lining-nums; }
.eyebrow {
  font: 600 10.5px/1.2 var(--font-ui);
  text-transform: uppercase;
  letter-spacing: .28em;
  color: var(--muted);
}
.muted { color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--yellow); }
.small { font-size: 11.5px; }
.spacer { flex: 1; }
.w-full { width: 100%; }
.mt-2 { margin-top: 10px; }
.wrap { white-space: normal !important; }
.sep { color: var(--line-strong); padding: 0 3px; }

/* иконки */
.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 14px;
  height: 14px;
  line-height: 0;
}
.ico svg, .x svg, .arrow svg, .pin svg, .chart-link svg, .icon-btn svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 4. Стекло ---------------------------------------------------- */
.glass, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), inset 0 1px 0 var(--hi);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  backdrop-filter: blur(var(--blur)) saturate(140%);
}

/* ---------- 5. Шапка ----------------------------------------------------- */
header.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  height: var(--top-h);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  backdrop-filter: blur(var(--blur)) saturate(140%);
}
/* тонкая золотая нить по нижнему краю */
header.top::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 8%, var(--gold-line) 50%, transparent 92%);
  opacity: .45;
}

.brand-wrap {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}
.brand-wrap:hover { color: var(--text); text-decoration: none; }
.brand-wrap:hover .logo { transform: rotate(-12deg); }
.logo { width: 30px; height: 30px; flex: none; color: var(--text); overflow: visible; }

.brand {
  font: 600 19px/1 var(--font-display);
  letter-spacing: .01em;
  white-space: nowrap;
  font-variant-numeric: lining-nums;
}
.brand span { color: var(--gold); font-style: italic; font-weight: 500; }

nav.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--hi), 0 10px 30px -18px rgba(0, 0, 0, .6);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  backdrop-filter: blur(var(--blur)) saturate(140%);
}
nav.tabs a {
  padding: 7px 14px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 18px;
  letter-spacing: .02em;
  white-space: nowrap;
}
nav.tabs a:hover { color: var(--text); background: var(--hover); text-decoration: none; }
nav.tabs a.active, nav.tabs a[aria-current="page"] {
  background: var(--pill-bg);
  color: var(--pill-fg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 6px 16px -8px rgba(0, 0, 0, .55);
}
nav.tabs a.active:hover { background: var(--pill-bg-hover); color: var(--pill-fg); }

.top-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
#hdr-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hdr-info:empty { display: none; }

/* переключатель темы: в тёмной — луна, в светлой — солнце */
#theme-btn .ico { width: 16px; height: 16px; }
#theme-btn .ico-sun { display: none; }
:root[data-theme="light"] #theme-btn .ico-sun { display: inline-flex; }
:root[data-theme="light"] #theme-btn .ico-moon { display: none; }
#theme-btn:hover .ico { transform: rotate(-18deg); }
#theme-btn .ico { transition: transform 300ms var(--ease); }

/* ---------- 6. Заголовок страницы и линия-разделитель -------------------- */
section.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 24px;
  padding: 22px 24px 6px;
}
section.page-head > div:first-child { min-width: 0; }
.page-head .eyebrow { display: flex; align-items: center; margin-bottom: 10px; }
.page-head .eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  margin-right: 10px;
  background: var(--gold);
  opacity: .85;
  flex: none;
}
h1.display {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 2.6vw, 38px);
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--text);
  font-variant-numeric: lining-nums;
}
h1.display em { font-style: italic; font-weight: 400; color: var(--gold); }
p.lede {
  margin: 8px 0 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}
.page-head-aside {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
  min-width: 0;
  max-width: 100%;
}
/* длинная сводка в шапке страницы переносится аккуратно */
.page-head-aside .chip {
  white-space: normal;
  overflow-wrap: anywhere;
  border-radius: 13px;
  padding: 4px 11px;
  line-height: 16px;
  max-width: min(100%, 720px);
}
.page-head-aside .chip.live { padding-left: 10px; }

.rule {
  position: relative;
  height: 1px;
  margin: 14px 24px 4px;
  background: linear-gradient(90deg, var(--gold-line), var(--line) 14%, var(--line) 86%, var(--gold-line));
}
.rule::before, .rule::after, .rule .dot {
  content: "";
  position: absolute;
  top: -2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}
.rule::before { left: -2px; }
.rule::after { right: -2px; }
.rule .dot { left: var(--dot-x, 50%); margin-left: -2.5px; animation: dot-pulse 2.4s var(--ease) infinite; }

@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 6px var(--gold), 0 0 0 0 var(--gold-line); }
  50% { box-shadow: 0 0 12px var(--gold), 0 0 0 5px transparent; }
}

/* ---------- 7. Панель инструментов -------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
}

/* ---------- 8. Кнопки ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text);
  font: 600 12.5px/18px var(--font-ui);
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}
.btn:hover { background: var(--hover); border-color: var(--line-strong); color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn .ico { margin-left: -2px; }

.btn.small { padding: 4px 10px; gap: 5px; font-size: 11.5px; line-height: 16px; }
.btn.small .ico { width: 12px; height: 12px; }

.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }

.btn.on {
  color: var(--gold);
  border-color: var(--gold-line);
  background: var(--gold-tint);
}
.btn.on:hover { color: var(--gold-2); border-color: var(--gold); }
:root[data-theme="light"] .btn.on:hover { color: var(--gold); }

.btn.primary {
  background: var(--pill-bg);
  border-color: var(--pill-bg);
  color: var(--pill-fg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), var(--pill-glow);
}
.btn.primary { gap: 8px; }
.btn.primary:hover { background: var(--pill-bg-hover); border-color: var(--pill-bg-hover); color: var(--pill-fg); }

/* круглый значок ↗ внутри основной кнопки */
.btn .arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin: -2px -10px -2px 3px;
  padding: 5px;
  border-radius: 50%;
  background: var(--pill-fg);
  color: var(--pill-bg);
  line-height: 0;
  transition: transform 220ms var(--ease);
}
.btn .arrow svg { stroke-width: 1.8; }
.btn:hover .arrow { transform: rotate(45deg); }
.btn:not(.primary) .arrow { background: var(--pill-bg); color: var(--pill-fg); }
.btn.small .arrow { width: 18px; height: 18px; padding: 4px; margin: -1px -7px -1px 2px; }

/* круглая кнопка-иконка */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel2);
  color: var(--text-2);
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--hi);
}
.icon-btn:hover { color: var(--gold); border-color: var(--gold-line); background: var(--hover); }
.icon-btn .ico { width: 16px; height: 16px; }
.icon-btn > svg { width: 16px; height: 16px; }

/* сегментированный переключатель */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--hi);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  backdrop-filter: blur(var(--blur)) saturate(140%);
}
.seg .btn { border-color: transparent; background: transparent; color: var(--muted); }
.seg .btn:hover { color: var(--text); background: var(--hover); }
.seg .btn.on {
  background: var(--pill-bg);
  color: var(--pill-fg);
  border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 12px -6px rgba(0, 0, 0, .5);
}
.seg .btn.on:hover { background: var(--pill-bg-hover); color: var(--pill-fg); }

/* ---------- 9. Поля ввода ------------------------------------------------ */
.input {
  min-width: 0;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background-color: var(--panel2);
  color: var(--text);
  font-size: 12.5px;
  line-height: 18px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12);
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:hover { border-color: var(--line-strong); }
.input:focus, .input:focus-visible {
  outline: none;
  border-color: var(--gold-line);
  box-shadow: 0 0 0 3px var(--gold-tint), 0 0 0 1px var(--focus);
}
.input[type="number"] { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

select.input {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px;
  background-image: var(--chev);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
  cursor: pointer;
}
select.input::-ms-expand { display: none; }
select.input option, select.input optgroup { background: var(--panel-solid); color: var(--text); }

textarea.input {
  display: block;
  width: 100%;
  min-height: 64px;
  resize: vertical;
  line-height: 1.5;
  font-family: var(--font-num);
  font-size: 12px;
}

/* поиск с иконкой */
.search { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.search > .ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
}
.search .input { width: 210px; padding-left: 32px; }
.search:focus-within > .ico { color: var(--gold); }

/* переключатель-тумблер: <label class="switch"><input type="checkbox"> текст</label> */
label.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
label.switch input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 28px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  cursor: pointer;
  background-color: var(--panel2);
  background-image: radial-gradient(circle, var(--muted) 0 4.4px, transparent 5px);
  background-repeat: no-repeat;
  background-size: 14px 14px;
  background-position: 0 0;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    background-position 200ms var(--ease), box-shadow var(--dur) var(--ease);
}
label.switch input:checked {
  background-color: var(--gold);
  border-color: var(--gold);
  background-image: radial-gradient(circle, var(--pill-fg) 0 4.4px, transparent 5px);
  background-position: 12px 0;
  box-shadow: 0 0 12px -2px var(--gold-line);
}
label.switch:hover input { border-color: var(--gold-line); }
label.switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- 10. Чипы ----------------------------------------------------- */
.chip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel2);
  color: var(--text-2);
  font: 500 11px/16px var(--font-ui);
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.chip.live { padding-left: 8px; }
.chip.live::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  vertical-align: 1px;
  animation: live-pulse 2s ease-out infinite;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 var(--green-bg), 0 0 6px var(--green); }
  70% { box-shadow: 0 0 0 6px transparent, 0 0 6px var(--green); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 6px var(--green); }
}
/* чип в строке таблицы: выровнять по центру соседнего текста (overflow:hidden сдвигает baseline) */
table.grid .chip { position: relative; top: -2px; }
.chip.long { color: var(--green); background: var(--green-bg); border-color: transparent; }
.chip.short { color: var(--red); background: var(--red-bg); border-color: transparent; }
.chip.gold { color: var(--gold); background: var(--gold-tint); border-color: var(--gold-line); }

/* ---------- 11. Таблицы -------------------------------------------------- */
.table-wrap { overflow-x: auto; padding: 0 24px 28px; }

table.grid {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
table.grid th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 10px 9px;
  background: var(--th-bg);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font: 600 10.5px/1.3 var(--font-ui);
  text-transform: uppercase;
  letter-spacing: .14em;
  text-align: left;
  white-space: nowrap;
  vertical-align: bottom;
}
table.grid th .muted {
  text-transform: none;
  letter-spacing: .02em;
  font-weight: 500;
  opacity: .75;
}
table.grid td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.35;
  vertical-align: top;
  white-space: nowrap;
}
table.grid tbody tr:last-child td { border-bottom: 0; }

/* скруглённые углы — через угловые ячейки (без overflow:hidden, чтобы работал sticky) */
table.grid thead tr:first-child th:first-child { border-top-left-radius: calc(var(--r-lg) - 1px); }
table.grid thead tr:first-child th:last-child { border-top-right-radius: calc(var(--r-lg) - 1px); }
table.grid tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--r-lg) - 1px); }
table.grid tbody tr:last-child td:last-child { border-bottom-right-radius: calc(var(--r-lg) - 1px); }

/* шапка липнет под header только на широких экранах */
/* 1180–1560px: плотнее, чтобы таблица помещалась; страница не скроллится вбок,
   таблица прокручивается внутри .table-wrap (th top:0) */
@media (min-width: 1180px) and (max-width: 1559.98px) {
  table.grid th, table.grid td { padding-left: 7px; padding-right: 7px; }
  table.grid th { letter-spacing: .08em; }
}
/* ≥1560px: таблица помещается целиком — шапка липнет под header */
@media (min-width: 1560px) {
  .table-wrap { overflow: visible; }
  table.grid th { top: var(--top-h); }
}

table.grid tbody tr:hover td { background-color: var(--hover); }
table.grid tbody tr:hover td.empty { background-color: transparent; }

/* сортировка */
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable::after {
  content: "↓";
  display: inline-block;
  margin-left: 5px;
  opacity: .3;
  font-family: var(--font-ui);
  letter-spacing: 0;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease);
}
table.grid th.sortable:hover { color: var(--text-2); }
table.grid th.sortable:hover::after { opacity: .6; }
table.grid th.sorted { color: var(--text); }
table.grid th.sorted::after { opacity: 1; color: var(--gold); }

/* вложенные строки */
table.grid tr.sub td { background-color: var(--panel2); }
table.grid tr.sub td:first-child { padding-left: 22px; position: relative; }
table.grid tr.sub td:first-child::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 0;
  height: 14px;
  width: 6px;
  border-left: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  border-bottom-left-radius: 4px;
}
table.grid tbody tr.sub:hover td { background-color: var(--hover); }

/* закреплённые */
table.grid tr.pinned td:first-child {
  box-shadow: inset 2px 0 0 var(--gold);
  background-image: linear-gradient(90deg, var(--gold-tint), transparent 85%);
}

/* содержимое ячеек */
.coin {
  font: 700 14px/1.2 var(--font-ui);
  letter-spacing: .02em;
  color: var(--text);
}
.big {
  font-family: var(--font-num);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  opacity: .3;
  cursor: pointer;
  user-select: none;
}
.pin:hover { opacity: .7; color: var(--text-2); }
.pin.on { opacity: 1; color: var(--gold); }
.pin.on svg { fill: var(--gold-tint); }
.more {
  display: inline-block;
  margin-top: 2px;
  color: var(--link);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  user-select: none;
}
.more:hover { color: var(--gold); }
.more[data-copy] {
  margin: 0 0 0 2px;
  font-family: "Segoe UI Symbol", "Segoe UI", sans-serif;
  font-size: 12px;
  font-variant-emoji: text;
  color: var(--link);
}
.empty {
  padding: 28px !important;
  text-align: center;
  color: var(--muted);
  white-space: normal !important;
  font-family: var(--font-ui);
}
.flag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--red-bg);
  color: var(--red);
  font: 600 10px/15px var(--font-ui);
  letter-spacing: .02em;
  vertical-align: 1px;
}
.mark { font-family: var(--font-ui); font-weight: 700; }
.mark.ok { color: var(--green); }
.mark.bad { color: var(--red); }
.mark.ok:empty::before { content: "✓"; }
.mark.bad:empty::before { content: "✕"; }

a.chart-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: -5px 0 -5px 4px;     /* не раздувает высоту строки */
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  vertical-align: middle;
  line-height: 0;
  text-decoration: none;
}
a.chart-link:hover {
  color: var(--gold);
  border-color: var(--gold-line);
  background: var(--gold-tint);
  text-decoration: none;
}

/* ---------- 12. Модальное окно ------------------------------------------ */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal-back.open { display: flex; animation: fade-in 180ms var(--ease); }
.modal-back.open .modal { animation: modal-in 260ms var(--ease); }

.modal {
  display: flex;
  flex-direction: column;
  width: calc(100% - 32px);
  max-width: 820px;
  max-height: 90vh;
  overflow: hidden;
  background: var(--modal-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .7), inset 0 1px 0 var(--hi);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
}
.modal .head, .modal > h2 {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 18px 20px 14px 24px;
  border-bottom: 1px solid var(--line);
}
.modal h2 {
  margin: 0;
  font: 500 22px/1.15 var(--font-display);
  letter-spacing: -.005em;
  color: var(--text);
  font-variant-numeric: lining-nums;
}
.modal .head h2 { flex: 1; min-width: 0; }
.modal .body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 24px 8px;
  overscroll-behavior: contain;
}
.modal .body > :last-child { margin-bottom: 10px; }
.modal .foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel2);
}

/* кнопка закрытия */
.x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin-left: auto;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: 500 13px/1 var(--font-ui);
  cursor: pointer;
  line-height: 1;
}
.x:hover { color: var(--text); border-color: var(--line-strong); background: var(--hover); transform: rotate(90deg); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* поля формы */
.field { margin-bottom: 14px; min-width: 0; }
.field label.title {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font: 600 10.5px/1.3 var(--font-ui);
  text-transform: uppercase;
  letter-spacing: .14em;
}
.field .input { width: 100%; }
.row2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0 12px;
  margin-bottom: 0;
}
.hint { margin-top: 5px; color: var(--muted); font-size: 11.5px; line-height: 1.4; }

/* чекбоксы-таблетки */
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.checks label::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.checks label:hover { border-color: var(--line-strong); color: var(--text); }
.checks label.on {
  color: var(--text);
  border-color: var(--gold-line);
  background: var(--gold-tint);
}
.checks label.on::before { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.checks label.all {
  padding: 5px 12px;
  border-style: dashed;
  border-color: var(--line-strong);
  background: transparent;
  color: var(--muted);
}
.checks label.all::before { display: none; }
.checks label.all:hover { color: var(--gold); border-color: var(--gold-line); }
.checks input { display: none; }

/* ---------- 13. Плитки-показатели --------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 0 24px 14px;
}
.stat {
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow), inset 0 1px 0 var(--hi);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  backdrop-filter: blur(var(--blur)) saturate(140%);
}
.stat::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-amber), transparent 70%);
  opacity: .55;
  pointer-events: none;
}
.rule + .stats { padding-top: 14px; }
.stat:hover { border-color: var(--line-strong); }
.stat .label {
  color: var(--muted);
  font: 600 10.5px/1.2 var(--font-ui);
  text-transform: uppercase;
  letter-spacing: .28em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .value {
  margin-top: 8px;
  font: 500 28px/1.05 var(--font-display);
  font-variant-numeric: lining-nums;
  letter-spacing: -.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .value small, .stat .value .unit {
  font: 500 12px/1 var(--font-ui);
  color: var(--muted);
  letter-spacing: .02em;
  margin-left: 3px;
}
.stat .value.pos { color: var(--green); }
.stat .value.neg { color: var(--red); }
.stat .sub { margin-top: 5px; color: var(--muted); font-size: 11.5px; line-height: 1.35; }

/* ---------- 14. Индикаторы состояния ------------------------------------ */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: 1px;
}
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg), 0 0 10px var(--green); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg), 0 0 10px var(--red); }

/* ---------- 15. Запасные варианты --------------------------------------- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .panel, .stat, .seg, nav.tabs { background: var(--panel-solid); }
  header.top { background: var(--panel-solid); }
  .modal { background: var(--panel-solid); }
  .modal-back { background: rgba(3, 6, 15, .72); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .panel, .stat, .seg, nav.tabs, header.top, .modal { background: var(--panel-solid); }
  table.grid { background: var(--panel-solid); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 16. Мобильные ≤700px ---------------------------------------- */
@media (max-width: 700px) {
  header.top {
    position: static;
    height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand right" "nav nav";
    gap: 10px 12px;
    padding: 10px 12px;
  }
  .brand-wrap { grid-area: brand; }
  .top-right { grid-area: right; }
  #hdr-info { display: none; }
  nav.tabs {
    grid-area: nav;
    justify-self: stretch;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  nav.tabs::-webkit-scrollbar { display: none; }
  nav.tabs a { flex: none; padding: 6px 12px; font-size: 12px; }

  section.page-head { padding: 16px 12px 4px; gap: 10px; }
  h1.display { font-size: 26px; }
  p.lede { display: none; }
  .rule { margin: 10px 12px 4px; }

  .toolbar { padding: 10px 12px; gap: 8px; }
  .toolbar .search { flex: 1 1 100%; order: 5; }
  .search .input { width: 100%; }

  .stats { padding: 0 12px 12px; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat .value { font-size: 24px; }

  /* без боковых полей у контейнера: закреплённая колонка не пропускает контент в «зазор» */
  .table-wrap { padding: 0 0 16px; }
  table.grid { margin: 0 12px; width: calc(100% - 24px); }
  /* первая колонка закреплена при горизонтальной прокрутке */
  table.grid th:first-child,
  table.grid td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: var(--panel-solid);
    box-shadow: 1px 0 0 var(--line);
  }
  table.grid th:first-child { z-index: 3; }
  table.grid tbody tr:hover td:first-child { background-image: linear-gradient(var(--hover), var(--hover)); }
  table.grid tr.sub td:first-child { background-image: linear-gradient(var(--panel2), var(--panel2)); }
  table.grid tr.pinned td:first-child {
    box-shadow: inset 2px 0 0 var(--gold), 1px 0 0 var(--line);
    background-image: linear-gradient(90deg, var(--gold-tint), transparent 85%);
  }
  table.grid td.empty:first-child { position: static; box-shadow: none; background-color: transparent; }

  /* модалка — нижний лист */
  .modal-back { align-items: flex-end; padding: 0; }
  .modal {
    width: 100%;
    max-width: none !important;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
  }
  .modal::before {
    content: "";
    flex: none;
    width: 36px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: var(--r-pill);
    background: var(--line-strong);
  }
  .modal-back.open .modal { animation: sheet-in 280ms var(--ease); }
  .modal .head, .modal > h2 { padding: 10px 14px 12px 18px; }
  .modal .body { padding: 16px 18px 6px; }
  .modal .foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }

  .hide-sm { display: none !important; }
}

@media (max-width: 379px) {
  .brand { display: none; }
}

/* ---------------- меню пользователя в шапке ---------------- */
.user-menu { position: relative; display: flex; align-items: center; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  font: 600 13px var(--font-ui); color: var(--gold); background: var(--gold-tint); border: 1px solid var(--gold-line);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.avatar:hover { background: var(--hover); border-color: var(--gold); }
.user-menu .menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; z-index: 60; padding: 6px;
  background: var(--modal-bg); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
}
.user-menu .menu[hidden] { display: none; }
.user-menu .menu-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-menu .menu a, .user-menu .menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--r-xs); border: 0; background: none;
  color: var(--text-2); font: 500 13px var(--font-ui); cursor: pointer; text-decoration: none;
}
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--hover); color: var(--text); }

.lang-btn { font-size: 11px; font-weight: 700; letter-spacing: .04em; margin-right: 6px; }
