/* One Trade AI MiniApp — терминальный стиль: графит + янтарь, весь текст моноширинный */

:root {
  --bg: #0D0F10;
  --bg-deep: #0A0C0D;
  --panel: #15181A;
  --line: #2A2F33;
  --seg-off: #22272A;
  --text: #E6E3D8;
  --muted: #8C9196;
  --dim: #5D6267;
  --accent: #FFB000;
  --accent-bg: #1E1A10;
  --up: #3DDC97;
  --up-bg: #0E1A14;
  --down: #FF6B5B;
  --down-bg: #1C100E;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--mono);
  min-height: 100vh;
  overscroll-behavior-y: none;
}

button { font-family: var(--mono); color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.acc { color: var(--accent); }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
}

/* ---------------- Шапка ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin: 0 -16px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 16px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap;
}
.logo-text { overflow: hidden; text-overflow: ellipsis; }

.cursor {
  width: 9px; height: 17px; flex: none;
  background: var(--accent);
}
@media (prefers-reduced-motion: no-preference) {
  .cursor { animation: blink 1.1s steps(1) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }

.top-actions { display: flex; gap: 6px; flex: none; }

.tbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 2px;
  background: var(--panel);
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
  transition-property: border-color, background-color;
  transition-duration: 150ms;
}
.tbtn .mut { color: var(--muted); }
@media (hover: hover) { .tbtn:hover { border-color: var(--accent); } }

/* ---------------- Поиск ---------------- */

.search-wrap {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 12px;
  height: 46px; padding: 0 4px 0 12px;
  border: 1px solid var(--line); background: var(--panel);
}
.search-wrap:focus-within { border-color: var(--accent); }
.prompt { color: var(--accent); font-weight: 700; }
#search {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  color: var(--text); font: 14px var(--mono);
  caret-color: var(--accent);
}
#search::placeholder { color: var(--muted); }
.search-clear {
  width: 44px; height: 40px; border: 0; background: transparent;
  color: var(--muted); font-size: 12px;
}

/* ---------------- Категории ---------------- */

.cats {
  display: flex; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px 10px;
}
.cats::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 2px;
  background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  white-space: nowrap;
  transition-property: background-color, color, border-color;
  transition-duration: 150ms;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.chip-count { font-weight: 800; }

/* ---------------- Список ---------------- */

.list-head {
  display: flex; gap: 10px;
  padding: 8px 0 4px;
  font-size: 10px; letter-spacing: .1em; color: var(--dim);
}
.lh-idx { width: 22px; }
.lh-name { flex: 1; }
.lh-pay { margin-right: 54px; }

.row {
  display: flex; align-items: center; gap: 10px;
  min-height: 58px; padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
  transition-property: background-color;
  transition-duration: 150ms;
}
@media (hover: hover) { .row:not(.closed):hover { background: var(--panel); } }
.row:not(.closed):active { background: var(--panel); }
.row.closed { cursor: default; color: var(--muted); }

.row-idx { width: 22px; flex: none; color: var(--dim); font-size: 11px; }

.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.row-name {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: 15px; font-weight: 700;
}
.row-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge-otc {
  flex: none;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  color: var(--bg); background: var(--muted);
  padding: 1px 4px;
}

.pbar { display: flex; gap: 2px; }
.pbar i { width: 7px; height: 8px; background: var(--seg-off); }
.pbar i.on { background: var(--accent); }
.row.closed .pbar i.on { background: var(--seg-off); }

.row-payout { flex: none; font-size: 16px; font-weight: 700; color: var(--accent); }
.row.closed .row-payout { color: var(--muted); }

.star-btn {
  flex: none;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; padding: 0;
  color: var(--muted);
}
.star-btn svg path { fill: transparent; transition-property: fill; transition-duration: 150ms; }
.star-btn.active { color: var(--accent); }
.star-btn.active svg path { fill: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .star-btn.pop svg { animation: pop 300ms ease-out; }
}
@keyframes pop { 40% { transform: scale(1.3); } }

.empty { padding: 56px 12px; text-align: center; }
.empty-code { color: var(--accent); font-size: 12px; margin-bottom: 10px; }
.empty-text { color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ---------------- Модалки ---------------- */

.modal { position: fixed; inset: 0; z-index: 50; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 6, 6, .74);
  opacity: 0; transition: opacity 220ms ease-out;
}
.modal.open .modal-backdrop { opacity: 1; }

.modal-sheet {
  position: absolute; left: 12px; right: 12px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  max-width: 536px; margin: 0 auto;
  max-height: calc(100% - 28px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--accent);
  padding: 14px 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
  opacity: 0;
  transition-property: opacity, transform;
  transition-duration: 220ms;
  transition-timing-function: ease-out;
}
@media (prefers-reduced-motion: no-preference) {
  .modal-sheet { transform: translateY(16px); }
}
.modal.open .modal-sheet { opacity: 1; transform: none; }

/* окно сигнала — почти во весь экран */
.modal-full .modal-sheet {
  top: calc(12px + env(safe-area-inset-top));
  border-color: var(--line);
  background: var(--bg);
}

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-title { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.sheet-close {
  width: 44px; height: 44px; flex: none;
  border: 0; background: transparent; color: var(--text); font-size: 13px;
}

.sheet-pair {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line);
}
.sheet-pair-label { color: var(--muted); }
.sheet-pair-main { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; font-weight: 700; }
.sheet-pair-main > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-pair-payout { margin-left: auto; flex: none; color: var(--accent); font-weight: 700; }

.exp-auto {
  height: 52px; border: 2px solid var(--accent); border-radius: 2px;
  background: var(--accent); color: var(--bg);
  font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.exp-auto:not(.active) { background: transparent; color: var(--accent); }

.exp-or { color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }

.exp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.exp-btn {
  height: 52px; border: 1px solid var(--line); border-radius: 2px;
  background: var(--bg); font-size: 15px; font-weight: 600;
  transition-property: border-color, color, background-color;
  transition-duration: 150ms;
}
.exp-btn.active { border: 2px solid var(--accent); color: var(--accent); background: var(--accent-bg); }
.exp-btn:active, .exp-auto:active, .sig-btn:active, .tbtn:active { transform: scale(.96); }
.exp-btn, .exp-auto, .sig-btn, .tbtn { transition-property: border-color, color, background-color, transform; transition-duration: 150ms; transition-timing-function: ease-out; }

/* ---------------- Сигнал: анализ ---------------- */

#sig-body { display: flex; flex-direction: column; }

.sig-loading { display: flex; flex-direction: column; gap: 18px; padding-top: 8px; }

.sig-log { font-size: 14px; line-height: 2; }
.sig-log .ok { color: var(--up); white-space: nowrap; }
.sig-log .mut { color: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .sig-log > div { opacity: 0; animation: logIn 200ms ease-out forwards; }
  .sig-log > div:nth-child(2) { animation-delay: 400ms; }
  .sig-log > div:nth-child(3) { animation-delay: 800ms; }
  .sig-log > div:nth-child(4) { animation-delay: 1200ms; }
  .sig-log > div:nth-child(5) { animation-delay: 1600ms; }
  .sig-log > div:nth-child(6) { animation-delay: 2000ms; }
  .sig-log > div:nth-child(7) { animation-delay: 2400ms; }
}
@keyframes logIn { to { opacity: 1; } }

/* ---------------- Сигнал: результат ---------------- */

.sig-result { display: flex; flex-direction: column; gap: 16px; padding-top: 4px; }

.sig-top { display: flex; align-items: center; gap: 8px; }
.sig-top .sheet-pair-main { flex: 1; }
.sig-chip {
  flex: none;
  border: 1px solid var(--line); padding: 4px 8px; font-size: 12px; color: var(--muted);
}
.sig-chip b { color: var(--accent); }

.sig-dir {
  position: relative;
  display: flex; align-items: center; gap: 16px;
  padding: 28px 18px;
  background: var(--up-bg); color: var(--up);
}
.sig-dir.down { background: var(--down-bg); color: var(--down); }
.sig-dir .c { position: absolute; width: 14px; height: 14px; border: 0 solid currentColor; }
.sig-dir .c1 { top: 0; left: 0; border-width: 2px 0 0 2px; }
.sig-dir .c2 { top: 0; right: 0; border-width: 2px 2px 0 0; }
.sig-dir .c3 { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.sig-dir .c4 { bottom: 0; right: 0; border-width: 0 2px 2px 0; }
.sig-dir svg { flex: none; }
.sig-dir-text { display: flex; flex-direction: column; gap: 2px; }
.sig-dir-label { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.sig-dir-sub { font-size: 12px; letter-spacing: .1em; color: var(--muted); }

.sig-enter {
  height: 52px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px dashed var(--accent);
  font-size: 15px; font-weight: 700; text-transform: uppercase;
  color: var(--muted);
}
.sig-enter b { color: var(--accent); font-size: 24px; }
.sig-enter.now { background: var(--accent); color: var(--bg); border-style: solid; font-size: 20px; letter-spacing: .1em; }
.sig-enter.gone { display: none; }

.sig-conf { display: flex; flex-direction: column; gap: 8px; }
.sig-conf-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.sig-conf-top .pct { font-size: 16px; font-weight: 700; color: var(--up); }
.sig-conf.down .pct { color: var(--down); }
.segs { display: flex; gap: 3px; }
.segs i { flex: 1; height: 10px; background: var(--seg-off); }
.segs i.on { background: var(--up); }
.sig-conf.down .segs i.on { background: var(--down); }

.sig-count {
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--line); padding-top: 18px;
}
.sig-count-label { font-size: 12px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.sig-count-time { font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.sig-count-bar { height: 8px; background: var(--seg-off); }
.sig-count-fill { height: 8px; background: var(--accent); }
.sig-count.low .sig-count-time { color: var(--down); }
.sig-count.low .sig-count-fill { background: var(--down); }

.sig-result.expired .sig-dir,
.sig-result.expired .sig-conf { opacity: .45; }

.sig-expired { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.sig-expired-text { color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .06em; }

.sig-btn {
  height: 52px; border: 0; border-radius: 2px;
  background: var(--accent); color: var(--bg);
  font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}

/* ---------------- Сигнал: ошибка ---------------- */

.sig-error { display: flex; flex-direction: column; gap: 12px; padding-top: 24px; }
.sig-error-code { color: var(--down); font-size: 13px; font-weight: 700; }
.sig-error-text { font-size: 16px; font-weight: 700; }
.sig-error-hint { color: var(--muted); line-height: 1.6; }
