/* Huginn — сайт данных.
   Принцип: цвет — только у данных. Интерфейс вокруг них монохромный, чтобы цвет на графике всегда что-то значил.
   Серифный шрифт — для имени монеты и цены, всё остальное — гротеск с моноширинными цифрами. */

@font-face { font-family: "Huginn Sans"; src: url("fonts/inter-regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Huginn Sans"; src: url("fonts/inter-medium.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Huginn Sans"; src: url("fonts/inter-semibold.woff") format("woff"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Huginn Serif"; src: url("fonts/lora.woff") format("woff"); font-weight: 400 700; font-display: swap; }

:root {
  color-scheme: dark;
  --page: #0b0d12;        /* чернила с синим отливом — «вороново крыло» */
  --surface: #12151d;
  --surface-2: #181c26;
  --raise: #1f2431;
  --line: rgba(150, 165, 205, 0.13);
  --line-strong: rgba(150, 165, 205, 0.24);
  --text: #e7e9ef;
  --text-2: #b0b6c4;
  --muted: #7b8295;
  --grid: #1d2230;
  --axis: #2a3040;
  --sheen: #aab4ff;       /* отлив пера: фокус, активный раздел, ссылки */
  --s1: #3987e5;          /* Bybit */
  --s2: #d95926;          /* Binance */
  --s3: #199e70;          /* спот, Coinbase, топ-трейдеры */
  --up: #3987e5;          /* покупки, рост, ликвидации шортов */
  --down: #e66767;        /* продажи, падение, ликвидации лонгов */
  --good: #0ca30c;
  --warn: #fab219;
  --bad: #d03b3b;
  --sans: "Huginn Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Huginn Serif", Georgia, "Times New Roman", serif;
  --r-outer: 14px;
  --r-ctl: 8px;
  font-family: var(--sans);
  font-feature-settings: "cv05", "cv11";
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f2f3f6; --surface: #ffffff; --surface-2: #f6f7f9; --raise: #eceef3;
  --line: rgba(20, 28, 50, 0.10); --line-strong: rgba(20, 28, 50, 0.18);
  --text: #12141b; --text-2: #474d5c; --muted: #737a8c; --grid: #e6e8ee; --axis: #c8ccd6; --sheen: #4b53c6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --up: #2a78d6; --down: #e34948;
}
@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="dark"])) {
    color-scheme: light;
    --page: #f2f3f6; --surface: #ffffff; --surface-2: #f6f7f9; --raise: #eceef3;
    --line: rgba(20, 28, 50, 0.10); --line-strong: rgba(20, 28, 50, 0.18);
    --text: #12141b; --text-2: #474d5c; --muted: #737a8c; --grid: #e6e8ee; --axis: #c8ccd6; --sheen: #4b53c6;
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --up: #2a78d6; --down: #e34948;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); color: var(--text); }
body { font-size: 14px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--sheen); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--sheen); outline-offset: 2px; border-radius: 4px; }
.num, table.t, .readouts dd, .hero-px { font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }

/* ── шапка ── */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: 54px; background: color-mix(in srgb, var(--page) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.mark { font-family: var(--serif); font-weight: 600; font-size: 21px; color: var(--text); letter-spacing: 0.005em; }
.mark:hover { text-decoration: none; }
.nav { display: flex; gap: 2px; align-self: stretch; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: flex; align-items: center; padding: 0 11px; color: var(--text-2); white-space: nowrap; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.on { color: var(--text); border-bottom-color: var(--sheen); font-weight: 500; }
.bar .spacer { flex: 1; }

/* выпадающие: переключатель монет и «Система» */
.drop { position: relative; }
.drop > summary { list-style: none; cursor: pointer; user-select: none; }
.drop > summary::-webkit-details-marker { display: none; }
.drop-panel {
  position: absolute; top: calc(100% + 8px); z-index: 30; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35); padding: 6px;
}
.picker > summary {
  display: flex; align-items: baseline; gap: 10px; padding: 6px 12px; border: 1px solid var(--line-strong);
  border-radius: 999px; background: var(--surface);
}
.picker > summary:hover, .picker[open] > summary { background: var(--raise); }
.picker .pk-base { font-weight: 600; }
.picker .pk-px { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 13px; }
.picker .pk-caret { color: var(--muted); font-size: 11px; }
.picker .drop-panel { left: 0; width: min(340px, calc(100vw - 24px)); }
.pk-q { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--page); margin-bottom: 4px; }
.pk-list { list-style: none; margin: 0; padding: 0; max-height: min(60vh, 460px); overflow-y: auto; }
.pk-list a {
  display: grid; grid-template-columns: 1fr auto 68px; gap: 10px; align-items: baseline; padding: 7px 8px;
  border-radius: 7px; color: var(--text); font-variant-numeric: tabular-nums;
}
.pk-list a:hover, .pk-list a.hl { background: var(--raise); text-decoration: none; }
.pk-list a.on b { color: var(--sheen); }
.pk-list .px { color: var(--text-2); font-size: 13px; }
.pk-list .ch { text-align: right; font-size: 13px; }
.sys > summary { padding: 7px 10px; border-radius: var(--r-ctl); color: var(--text-2); font-size: 14px; }
.sys > summary:hover, .sys[open] > summary, .sys.on > summary { color: var(--text); background: var(--surface-2); }
.sys .drop-panel { right: 0; min-width: 210px; }
.sys .drop-panel a, .sys .drop-panel button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 7px; color: var(--text);
  background: none; border: 0; cursor: pointer; font-size: 14px;
}
.sys .drop-panel a:hover, .sys .drop-panel button:hover { background: var(--raise); text-decoration: none; }
.sys .drop-panel a.on { color: var(--sheen); }
.sys hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.sys .who { padding: 6px 10px 2px; color: var(--muted); font-size: 12.5px; }
.in-tg .logout-row { display: none; }

/* ── раскладка ── */
.wrap { max-width: 1360px; margin: 0 auto; padding: 22px 20px 48px; }
h1, h2, h3 { margin: 0; }
.page-head { margin: 4px 0 18px; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.15; }
.lede { color: var(--text-2); margin: 6px 0 0; max-width: 72ch; }
.sub { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.empty { color: var(--muted); font-size: 13px; padding: 34px 12px; text-align: center; }
.empty b { color: var(--text-2); font-weight: 500; }

/* герой монеты: имя и цена — главное на странице */
.hero { display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 10px 36px; margin: 2px 0 18px; }
.hero .ticker { font-family: var(--serif); font-weight: 600; font-size: 48px; line-height: 1; letter-spacing: -0.01em; }
.hero .pair { color: var(--muted); margin: 8px 0 0; font-size: 13px; }
.hero-px { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.hero-px .px { font-family: var(--serif); font-size: 48px; line-height: 1; font-weight: 500; font-feature-settings: "tnum", "lnum"; }
.hero-px .chg { font-size: 17px; font-weight: 500; }
.hero-px .hl { color: var(--muted); font-size: 13px; }
.hero .when { color: var(--muted); font-size: 12.5px; text-align: right; margin-top: 6px; }
.flash-up { animation: flash-up 1.2s ease-out; }
.flash-down { animation: flash-down 1.2s ease-out; }
@keyframes flash-up { from { color: var(--up); } to { color: inherit; } }
@keyframes flash-down { from { color: var(--down); } to { color: inherit; } }
@media (prefers-reduced-motion: reduce) { .flash-up, .flash-down { animation: none; } }

/* показатели строкой: разделены тонкими линиями, без карточек */
.readouts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 18px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.readouts > div { padding: 12px 16px 12px 0; margin-right: 16px; border-right: 1px solid var(--line); min-width: 0; }
.readouts > div:last-child { border-right: 0; }
.readouts dt { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readouts dd { margin: 3px 0 0; font-size: 18px; font-weight: 600; white-space: nowrap; }
.readouts .d { display: block; font-size: 12.5px; font-weight: 400; color: var(--text-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* мозаика графиков: тонкие линии между плитками = у всех одна ось времени и общий курсор */
.mosaic {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-outer); overflow: hidden; margin-bottom: 18px;
}
.mosaic.lead { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); }
.mosaic.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mosaic > section { background: var(--surface); padding: 12px 14px 10px; min-width: 0; }
.mosaic > section.full { grid-column: 1 / -1; }
.tile-h { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; margin-bottom: 6px; }
.tile-h h2 { font-size: 13.5px; font-weight: 600; }
.tile-h p { margin: 0; color: var(--muted); font-size: 12.5px; }
.tile-h .r { margin-left: auto; }
.chart { width: 100%; height: 230px; }
.chart.tall { height: 420px; }
.chart.mid { height: 300px; }
.chart.short { height: 180px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-outer); padding: 12px 14px; margin-bottom: 18px; min-width: 0; }
.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.cols.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols > .panel { margin-bottom: 0; }
.stack { margin-bottom: 18px; }

/* ── элементы управления ── */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.controls select, .controls input[type=search], .controls input[type=text], .controls input:not([type]),
.controls input[type=password] {
  background: var(--page); border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: 7px 10px; min-width: 0;
}
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: 2px; background: var(--surface); }
.seg a { padding: 4px 10px; border-radius: 6px; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a.on { background: var(--raise); color: var(--text); font-weight: 600; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--text); color: var(--page); border: 1px solid var(--text);
  border-radius: var(--r-ctl); padding: 7px 14px; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.ghost, .mini {
  display: inline-flex; align-items: center; gap: 6px; background: transparent; color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: 6px 12px; cursor: pointer; font-size: 13.5px;
}
.mini { padding: 4px 10px; font-size: 12.5px; }
.ghost:hover, .mini:hover { background: var(--raise); }
.ghost:disabled, .mini:disabled { opacity: 0.45; cursor: default; }
.danger { color: var(--bad) !important; }
label.check { display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); font-size: 13px; cursor: pointer; }
label.check input { accent-color: var(--sheen); margin: 0; }

/* ── таблицы ── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { padding: 8px 9px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
table.t th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
table.t th.sort { cursor: pointer; user-select: none; }
table.t th.sort:hover, table.t th.sort.on { color: var(--text); }
table.t td:first-child, table.t th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.t th:first-child { z-index: 2; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tr.go { cursor: pointer; }
table.t td.l, table.t th.l { text-align: left; }
.coin-cell { display: flex; align-items: center; gap: 10px; }
.coin-cell b { font-weight: 600; color: var(--text); min-width: 54px; }
.spark { display: block; }
.pos { color: var(--up); }
.neg { color: var(--down); }
.mut { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* полоса «лонги/шорты» */
.split { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--grid); gap: 2px; margin-top: 7px; }
.split i { display: block; height: 100%; }

/* ── лента событий ── */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 13px; font-variant-numeric: tabular-nums; }
.feed li:last-child { border-bottom: 0; }
.feed .tm { color: var(--muted); font-size: 12px; }
.feed .amt { font-weight: 600; text-align: right; }
.news-item { padding: 9px 0; border-bottom: 1px solid var(--grid); }
.news-item:last-child { border-bottom: 0; }
.news-item .meta { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.news-item a, .news-item span.t { color: var(--text); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips a { border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 11px; color: var(--text-2); font-size: 12.5px; }
.chips a:hover { text-decoration: none; color: var(--text); }
.chips a.on { background: var(--raise); color: var(--text); border-color: var(--line-strong); }

/* ── состояние сбора ── */
.health { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; margin-top: 8px; }
.health .dot { margin-right: 2px; }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin-top: 10px; }
.src { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.src .ic { font-size: 13px; line-height: 20px; width: 18px; text-align: center; flex: none; }
.src .t { font-weight: 500; }
.src .m { color: var(--muted); font-size: 12.5px; }
.src details summary { cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.src details div { color: var(--muted); font-size: 12px; }
.st-ok .ic { color: var(--good); }
.st-late .ic { color: var(--warn); }
.st-down .ic { color: var(--bad); }
.st-never .ic { color: var(--muted); }
details.more > summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; background: var(--muted); vertical-align: 0; }
.dot.ok { background: var(--good); } .dot.late { background: var(--warn); } .dot.down { background: var(--bad); }

/* ── список монет ── */
.chip-edit { display: flex; flex-wrap: wrap; gap: 6px; min-height: 36px; }
.chip-edit span {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 11px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 13px; font-weight: 500;
}
.chip-edit span.new { border-color: var(--sheen); }
.chip-edit span.gone { opacity: 0.45; text-decoration: line-through; }
.chip-edit button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 6px; font-size: 15px; line-height: 1; border-radius: 999px; }
.chip-edit button:hover { color: var(--text); background: var(--raise); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-2); }
.toggle { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line-strong); background: transparent; cursor: pointer; color: var(--text-2); }
.toggle.on { background: var(--text); color: var(--page); border-color: var(--text); }

/* ── сборщики ── */
.node { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.node .hd { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.node .nm { font-weight: 600; font-size: 15px; }
.node .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.node .srcs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.node .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.node .acts button { background: transparent; color: var(--text); border: 1px solid var(--line-strong); border-radius: 7px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; }
.node .acts button:hover { background: var(--raise); }
.node .err { color: var(--bad); font-size: 12.5px; margin-top: 5px; white-space: pre-wrap; }
pre.log { background: var(--page); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 420px;
  overflow: auto; font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; margin: 0; }
.seg-r { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: 2px; }
.segopt { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.segopt:has(input:checked) { background: var(--raise); color: var(--text); font-weight: 600; }
.segopt input { accent-color: var(--sheen); margin: 0; }

/* ── плитки (хранилище) ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tile { padding: 12px 16px 12px 0; margin-right: 16px; border-right: 1px solid var(--line); }
.tile:last-child { border-right: 0; }
.tile .l { color: var(--muted); font-size: 12.5px; }
.tile .v { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 12.5px; color: var(--text-2); }

/* ── вход ── */
.login-box { max-width: 420px; margin: 14vh auto; text-align: center; padding: 30px 24px; }
body > .login-box { margin-left: max(12px, calc(50% - 210px)); margin-right: max(12px, calc(50% - 210px)); }
.login-box h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; margin-bottom: 10px; }
.login-box p { color: var(--text-2); }
.login-box .err { color: var(--bad); }
.login-box code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }
.stub { border: 1px dashed var(--axis); border-radius: 12px; padding: 14px; color: var(--muted); }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-2); }

/* ── узкие экраны и Telegram ── */
@media (max-width: 1100px) {
  .mosaic.lead { grid-template-columns: minmax(0, 1fr); }
  .cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .mosaic, .mosaic.three, .cols.two { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: 1fr; gap: 10px; }
  .hero .when { text-align: left; }
}
@media (max-width: 680px) {
  .bar { flex-wrap: wrap; height: auto; padding: 8px 12px 0; gap: 8px 12px; }
  .bar .nav { order: 5; flex-basis: 100%; height: 40px; margin: 0 -12px; padding: 0 6px; }
  .wrap { padding: 14px 12px 40px; }
  .hero .ticker, .hero-px .px { font-size: 38px; }
  .page-head h1 { font-size: 25px; }
  .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 0; }
  .readouts > div { border-right: 0; margin-right: 0; padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); }
  .readouts > div:nth-child(odd) { border-right: 1px solid var(--line); margin-right: 12px; }
  .chart { height: 210px; }
  .chart.tall { height: 340px; }
  .mosaic > section, .panel { padding: 10px 11px 8px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #add-form input, #add-form button { width: 100%; }
}
