/* Сигналы · Bybit — календарь сигналов pump / asset search и график цены после алерта. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #0b0b0c;
  --text-2: #3c3c43;
  --hint: #6e6e73;
  --sep: rgba(60, 60, 67, 0.14);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.22);
  --seg-on: #ffffff;
  --accent: #2481cc;
  --accent-text: #ffffff;
  /* цена: рост / падение — метки ≥3:1, текст ≥4.5:1 */
  --pos: #089981;
  --neg: #f23645;
  --pos-text: #04786a;
  --neg-text: #c92a39;
  /* стратегии — категориальные цвета (идентичность, не «хорошо/плохо») */
  --pump: #eb6834;
  --asset: #2a78d6;
  --grid: rgba(60, 60, 67, 0.1);
  --axis: rgba(60, 60, 67, 0.34);
  --after: rgba(118, 118, 128, 0.07);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 18px rgba(0, 0, 0, 0.05);
  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111113;
  --surface: #1c1c1e;
  --text: #f5f5f7;
  --text-2: #d1d1d6;
  --hint: #98989f;
  --sep: rgba(255, 255, 255, 0.1);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.36);
  --seg-on: rgba(255, 255, 255, 0.18);
  --accent: #3e88f7;
  --pos: #26a69a;
  --neg: #ef5350;
  --pos-text: #4cc9bb;
  --neg-text: #ff7a74;
  --pump: #d95926;
  --asset: #3987e5;
  --grid: rgba(255, 255, 255, 0.08);
  --axis: rgba(255, 255, 255, 0.3);
  --after: rgba(118, 118, 128, 0.12);
  --shadow: none;
  color-scheme: dark;
}

/* Внутри Telegram в авто-режиме — фон, карточки, текст и акцент из темы клиента */
:root[data-tg="1"] {
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #0b0b0c);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --sep: var(--tg-theme-section-separator-color, rgba(60, 60, 67, 0.14));
}
:root[data-tg="1"][data-theme="dark"] {
  --bg: var(--tg-theme-secondary-bg-color, #111113);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1c1c1e));
  --text: var(--tg-theme-text-color, #f5f5f7);
  --accent: var(--tg-theme-button-color, #3e88f7);
  --sep: var(--tg-theme-section-separator-color, rgba(255, 255, 255, 0.1));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.layer-open { overflow: hidden; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.hint { color: var(--hint); }
.t-pos { color: var(--pos-text); }
.t-neg { color: var(--neg-text); }
.t-flat { color: var(--text); }

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 8px) 16px calc(var(--safe-bottom) + 24px);
}

/* ── Шапка ─────────────────────────────────────────── */
.top-row { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.eyebrow {
  margin-right: auto;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hint);
  white-space: nowrap;
}
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.title-row h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; white-space: nowrap; }
.month-nav { display: flex; gap: 8px; }

.icon-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: var(--fill);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.ghost { background: transparent; color: var(--hint); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:disabled { opacity: 0.3; cursor: default; transform: none; }

.chip {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--fill);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--fill); }
.seg button {
  min-width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg button[aria-checked="true"] { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg button:disabled { opacity: 0.35; cursor: default; }
.seg .count { font-weight: 500; opacity: 0.6; font-variant-numeric: tabular-nums; }
.seg .count:empty { display: none; }
.seg-sm button { padding: 5px 10px; font-size: 12.5px; }
.filter { display: flex; width: 100%; margin-bottom: 12px; }
.filter button { flex: 1 1 auto; min-width: 0; padding-left: 6px; padding-right: 6px; }

.sdot { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.sdot.pump { background: var(--pump); }
.sdot.asset_search { background: var(--asset); }

/* ── Карточки ──────────────────────────────────────── */
.main.is-refreshing > .card { opacity: 0.55; transition: opacity 0.2s ease; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h3 { font-size: 15px; font-weight: 650; }
.label { font-size: 13px; font-weight: 600; color: var(--hint); }
.foot { margin: 4px 0 0; text-align: center; font-size: 12px; }

.summary .sum-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sum-meta { font-size: 13px; text-align: right; }
.hero { font-size: 46px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.08; margin: 4px 0 12px; }
.split { display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--fill); }
.split span { min-width: 3px; transition: opacity 0.2s ease; }
.split .pump { background: var(--pump); }
.split .asset_search { background: var(--asset); }
.split .is-dim { opacity: 0.25; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { font-weight: 650; font-variant-numeric: tabular-nums; }
.legend .is-dim { opacity: 0.45; }

/* ── Календарь ─────────────────────────────────────── */
.cal { padding: 10px 8px 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-grid.enter-next { animation: enter-next 0.24s ease; }
.cal-grid.enter-prev { animation: enter-prev 0.24s ease; }
@keyframes enter-next { from { opacity: 0; transform: translateX(18px); } }
@keyframes enter-prev { from { opacity: 0; transform: translateX(-18px); } }
.cal-h { padding: 2px 0 4px; text-align: center; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--hint); }
.cell {
  position: relative;
  min-width: 0;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 3px 7px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
button.cell { background: var(--fill); cursor: pointer; transition: transform 0.12s ease, background 0.15s ease; }
button.cell:active { transform: scale(0.95); }
.cell-d { min-width: 20px; height: 18px; padding: 0 4px; border-radius: 9px; font-size: 11.5px; font-weight: 600; line-height: 18px; color: var(--hint); }
.cell-n { font-size: 16px; font-weight: 700; line-height: 1.1; color: var(--text); }
.cell-bar { display: flex; gap: 2px; height: 4px; margin-top: auto; }
.cell-bar span { min-width: 3px; border-radius: 2px; }
.cell-bar .pump { background: var(--pump); }
.cell-bar .asset_search { background: var(--asset); }
.cell.is-empty .cell-d { opacity: 0.8; }
.cell.is-future .cell-d { opacity: 0.4; }
.cell.is-today .cell-d { background: var(--accent); color: var(--accent-text); opacity: 1; }
.cell.is-selected { box-shadow: inset 0 0 0 2px var(--accent); }

/* ── Состояния ─────────────────────────────────────── */
.main[data-state] > .card:not(.state), .main[data-state] > .foot { display: none; }
.state { padding: 32px 20px; text-align: center; }
.state-icon { width: 52px; height: 52px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 16px; background: var(--fill); color: var(--hint); }
.state-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.state h2 { margin-bottom: 6px; font-size: 18px; font-weight: 650; }
.state p { margin-bottom: 16px; font-size: 14px; }
.btn { border: 0; border-radius: 12px; padding: 11px 18px; background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 650; cursor: pointer; }
.btn-secondary { background: var(--fill); color: var(--accent); }
.btn-block { display: block; width: 100%; margin-bottom: 12px; }
.sk {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--fill) 25%, var(--fill-2) 37%, var(--fill) 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease infinite;
}
@keyframes sk { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.notice { padding: 18px 16px; border-radius: var(--radius); background: var(--surface); text-align: center; }
.notice p { margin-bottom: 12px; color: var(--text-2); font-size: 14px; }
.list-empty { padding: 20px; text-align: center; font-size: 14px; }

/* ── Шторка дня ────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.38); opacity: 0; transition: opacity 0.24s ease; }
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  max-width: 720px;
  max-height: calc(min(100dvh, var(--tg-viewport-stable-height, 100dvh)) - var(--safe-top) - 28px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: 18px 18px 0 0;
  background: var(--bg);
  box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.2);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.is-open { transform: translateY(0); }
.sheet.is-dragging { transition: none; }
.sheet-grip { display: flex; justify-content: center; padding: 7px 0 3px; touch-action: none; }
.sheet-grip span { width: 38px; height: 5px; border-radius: 3px; background: var(--fill-2); }
.sheet-head { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px 36px; align-items: center; gap: 6px; padding: 2px 12px 10px; touch-action: none; }
.sheet-title, .view-title { min-width: 0; text-align: center; }
.sheet-title h2, .view-title h2 { overflow: hidden; font-size: 17px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.sheet-title .hint, .view-title .hint { overflow: hidden; font-size: 12.5px; white-space: nowrap; text-overflow: ellipsis; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 16px calc(var(--safe-bottom) + 20px); }
.is-refreshing > * { opacity: 0.55; transition: opacity 0.2s ease; }
.sheet-body > .filter { margin: 2px 0 10px; }

.sig-list { margin: 0; padding: 0; list-style: none; overflow: hidden; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.sig-list li + li { border-top: 1px solid var(--sep); }
.sig {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.sig:active { background: var(--fill); }
.sig-main { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: baseline; gap: 10px; }
.sig-time { font-size: 14px; font-weight: 600; color: var(--text-2); }
.sig-sym { overflow: hidden; font-size: 16px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.sig-sym small, .view-title small { margin-left: 1px; font-size: 0.68em; font-weight: 600; color: var(--hint); }
.view-title .hint .sdot { margin-right: 6px; vertical-align: 1px; }
.sig-since { font-size: 15px; font-weight: 700; white-space: nowrap; }
.sig-sub { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-top: 3px; font-size: 12.5px; color: var(--hint); }
.stag { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.sig-detail { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sig-now { white-space: nowrap; }

/* ── Экран сигнала ─────────────────────────────────── */
.view {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.view.is-open { transform: none; }
.view-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 8px) 12px 10px;
}
.view-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px calc(var(--safe-bottom) + 24px);
}
.sig-hero { margin: 2px 0 12px; }
.sig-hero .hero { margin: 2px 0 2px; }
.sig-hero-meta { font-size: 13px; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile { min-width: 0; padding: 9px 12px 10px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.tile-label { overflow: hidden; font-size: 12px; color: var(--hint); white-space: nowrap; text-overflow: ellipsis; }
.tile b { display: block; margin: 1px 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.tile-sub { overflow: hidden; font-size: 12px; color: var(--hint); white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.chart-card .card-head { flex-wrap: wrap; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 12px; color: var(--hint); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-line { display: inline-block; width: 14px; height: 2px; border-radius: 1px; background: var(--sig); }
.key-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sig); box-shadow: 0 0 0 2px var(--surface); }
.alert-text { margin-bottom: 12px; }
.alert-text summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-2); }
.alert-text pre { margin: 10px 0 0; font: 13.5px/1.45 var(--font); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }

/* ── График свечей ─────────────────────────────────── */
.chart { position: relative; }
[data-strategy="pump"] { --sig: var(--pump); }
[data-strategy="asset_search"] { --sig: var(--asset); }
.chart-svg { display: block; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart-svg:focus { outline: none; }
.chart-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.c-grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.c-tick { fill: var(--hint); font-size: 10px; font-variant-numeric: tabular-nums; }
.c-after { fill: var(--after); }
.k-wick { fill: none; stroke-width: 1; shape-rendering: crispEdges; }
.k-up { fill: var(--pos); stroke: var(--pos); }
.k-down { fill: var(--neg); stroke: var(--neg); }
.k-body { stroke: none; }
.c-sig-line { stroke: var(--sig); stroke-width: 1.5; }
.c-sig-level { stroke: var(--sig); stroke-width: 1; opacity: 0.75; shape-rendering: crispEdges; }
.c-sig-dot { fill: var(--sig); stroke: var(--surface); stroke-width: 2; }
.c-chip { fill: var(--surface); stroke: var(--sep); stroke-width: 1; }
.c-chip-key { stroke-width: 3; stroke-linecap: round; }
.c-chip-key.sig { stroke: var(--sig); }
.c-chip-key.up { stroke: var(--pos); }
.c-chip-key.down { stroke: var(--neg); }
.c-chip-text { fill: var(--text); font-size: 10.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.c-label {
  fill: var(--text-2);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.c-cross { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.c-focus { stroke: var(--surface); stroke-width: 2; fill: var(--text); }
.chart-tip {
  position: absolute;
  z-index: 3;
  min-width: 150px;
  max-width: 240px;
  padding: 7px 10px 8px;
  border-radius: 10px;
  background: #1c1c1e;
  color: #ffffff;
  font-size: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
:root[data-theme="dark"] .chart-tip { background: #2c2c2e; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 6px 20px rgba(0, 0, 0, 0.5); }
.chart-tip .t-pos { color: #4cc9bb; }
.chart-tip .t-neg { color: #ff7a74; }
.chart-tip-title { margin-bottom: 3px; font-size: 11.5px; font-weight: 600; color: rgba(255, 255, 255, 0.7); }
.chart-tip-row { display: flex; justify-content: space-between; gap: 14px; line-height: 1.5; }
.chart-tip-row span { color: rgba(255, 255, 255, 0.72); }
.chart-tip-row b { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-tip-ohlc { margin-top: 2px; color: rgba(255, 255, 255, 0.6); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-empty { height: 180px; display: grid; place-items: center; color: var(--hint); font-size: 14px; }

@media (hover: hover) {
  button.cell:hover { background: var(--fill-2); }
  .icon-btn:hover { background: var(--fill-2); }
  .icon-btn.ghost:hover { color: var(--text); }
  .sig:hover { background: var(--fill); }
}

@media (min-width: 820px) {
  .app { padding-left: 24px; padding-right: 24px; }
  .cell { min-height: 72px; }
  .cell-n { font-size: 19px; }
  .sheet { bottom: 16px; border-radius: 18px; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
