:root {
  --bg: #0e1420;        /* фон экрана */
  --card: #1b2433;      /* поверхность */
  --card2: #26314a;     /* поверхность-2: инпуты, вложенные блоки */
  --line: #33405c;      /* видимые границы */
  --text: #f4f7fb;
  --mut: #a7b4ca;       /* вторичный текст */
  --faint: #7b89a1;     /* третичный, только крупным кеглем */
  --accent: #3ee49c;
  --accent-ink: #043621;
  --neg: #ff8b8b;
  --r: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  background-image: radial-gradient(130% 46% at 50% -6%, #17223c 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;              /* документ не скроллится — только внутренности экранов */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; touch-action: manipulation; }

/* ---------- экраны и переходы ----------
   Высота: SDK Telegram поддерживает --tg-viewport-stable-height; в браузере — 100dvh. */

.screens {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100dvh;
  height: var(--tg-viewport-stable-height, 100dvh);
}

.screen {
  position: absolute;
  inset: 0;
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform .38s cubic-bezier(.3, .8, .3, 1), opacity .3s;
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }
.screen.past { transform: translateX(-24%); }
.screen.active { transform: none; opacity: 1; pointer-events: auto; }

/* ---------- общие элементы ---------- */

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border-radius: 15px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 10px 28px -10px rgba(62, 228, 156, .45);
  transition: .15s;
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(.98); }

h2 { font-size: 24px; letter-spacing: -.01em; }

.back-link {
  color: var(--mut);
  font-size: 15px;
  font-weight: 600;
  padding: 0 0 14px;
  display: none;               /* видна только вне Telegram (там нет BackButton) */
}
body.no-tg .back-link { display: inline-block; }

.logo-badge {
  width: 40px; height: 40px;
  border-radius: 13px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feed-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.feed-date { font-size: 14px; color: var(--mut); margin-top: 2px; }

.pos { color: var(--accent); }
.neg { color: var(--neg); }

/* ---------- лента ---------- */

.free-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--mut);
  font-size: 15px;
  margin-bottom: 16px;
  cursor: pointer;
}
.free-input-icon { color: var(--accent); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 17px;
  margin-bottom: 12px;
}
.card-meta { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.card h3 { font-size: 17px; line-height: 1.32; margin-bottom: 7px; }
.card p { font-size: 14.5px; color: var(--mut); margin-bottom: 13px; }

.card-q > span { display: block; font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.card-btns { display: flex; flex-wrap: wrap; gap: 8px; }

.mini {
  flex: 1;
  padding: 10px 8px;
  border-radius: 11px;
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 14.5px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  transition: .15s;
  -webkit-user-select: none; user-select: none;
}
.mini:active { transform: scale(.96); }

/* ---------- ваш прогноз (цитата на плане) ---------- */

.statement {
  background: var(--card2);
  border: 1px solid #3d4c6e;
  border-radius: 15px;
  padding: 13px 17px 15px;
  font-size: 16.5px;
  line-height: 1.4;
  margin-bottom: 16px;
}
.statement-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  color: var(--mut);
  margin-bottom: 9px;
}
.field-label b { color: var(--text); font-size: 14.5px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill, 57%), #3a4a6c var(--fill, 57%));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
  cursor: pointer;
}

/* ---------- торговый план ---------- */

.plan-body h2 { margin-bottom: 14px; }

.risk-field {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px 16px 18px;
  margin-bottom: 10px;
}
.risk-field .field-label { margin-bottom: 14px; }
.risk-field .field-label span { font-size: 15px; color: var(--text); font-weight: 600; }
.risk-field .field-label b { font-size: 21px; }

.thesis {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 13px;
  padding: 14px 16px;
  font-size: 15.5px;
  margin-bottom: 16px;
}

.positions { margin-bottom: 14px; }
.pos-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 16px;
  margin-bottom: 8px;
}
.pos-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pos-top b { font-size: 15px; }
.pos-top span { font-size: 14px; color: var(--text); font-weight: 700; white-space: nowrap; }

.risk-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.risk-grid.two { grid-template-columns: 1fr 1fr; }
.risk-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 8px;
  text-align: center;
}
.risk-label { font-size: 12px; color: var(--mut); margin-bottom: 4px; }
.risk-value { font-size: 17px; font-weight: 700; }

/* ---------- подтверждение ---------- */

.exec-body { display: flex; flex-direction: column; min-height: 100%; }
.confirm-view { display: flex; flex-direction: column; flex: 1; }
.confirm-view .exec-total { margin-top: auto; }
.confirm-view .btn { margin-top: 18px; }
.exec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.exec-head h2 { font-size: 22px; }

.orders-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 2px 8px;
}
.orders + .orders-label { margin-top: 14px; }

.order {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px 16px;
  margin-bottom: 8px;
}
.order b { font-size: 15px; display: block; }
.order p { font-size: 13px; color: var(--mut); margin-top: 3px; }
.order > span { font-weight: 700; white-space: nowrap; }

.exec-total, .exec-fee {
  display: flex;
  justify-content: space-between;
  font-size: 14.5px;
  padding: 10px 4px 0;
}
.exec-total b { font-size: 16.5px; }
.exec-fee { color: var(--mut); padding-top: 4px; }
.exec-fee b { font-weight: 600; color: var(--mut); }

/* ---------- выбор брокера ---------- */

.broker-body h2 { margin-top: 2px; }
.broker-sub { color: var(--mut); font-size: 15px; margin: 6px 0 18px; }

.broker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.broker-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 20px 10px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  transition: .15s;
  -webkit-user-select: none; user-select: none;
}
.broker-tile:active { transform: scale(.96); }
.broker-tile.sel { border-color: var(--accent); }
.broker-grid.locked .broker-tile { opacity: .45; pointer-events: none; }

#broker-custom input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  font: inherit;
  font-size: 16px;   /* ≥16px — iOS не зумит при фокусе */
}
#broker-custom input::placeholder { color: var(--faint); }

/* ---------- спасибо ---------- */

.thanks-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  text-align: center;
  padding: 20px 10px;
}
.done-check {
  width: 78px; height: 78px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 40px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 40px -10px rgba(62, 228, 156, .5);
}
.thanks-body p { color: var(--mut); margin-top: 12px; }
.thanks-body .btn { margin-top: 28px; }
