/* 177 Trading Mini App.
   Dark navy, two-column card grid, large touch targets - built to the owner's design.
   Works in both directions: Arabic is RTL, English is LTR, same layout either way. */

:root {
  /* Telegram's safe areas, written by app.js (safeAreaInset + contentSafeAreaInset). In
     fullscreen the client's own controls sit over the page, so the layout has to move out
     from under them; outside Telegram these stay 0 and env() alone applies. */
  --tg-safe-top: 0px;
  --tg-safe-bottom: 0px;
  --tg-safe-left: 0px;
  --tg-safe-right: 0px;

  /* Near-black, not grey-blue. The surfaces are only a few points apart so the cards read as
     depth rather than as boxes; the separation comes from a hairline border, not from a heavy
     fill. Shadows stay almost invisible on black - they lift, they do not frame. */
  --bg: #050506;
  --bg-2: #0b0b0d;
  --card: #0f0f12;
  --card-2: #141418;
  --stroke: #27272d;
  --stroke-soft: #1b1b20;
  --text: #f3f4f6;
  --muted: #9b9ba6;
  --muted-2: #6f6f7a;

  /* One accent family: blood red. --accent is the interactive colour (icons, the live toggle,
     the selected language), --accent-deep anchors the gradients. */
  --accent: #d11626;
  --accent-bright: #f2283a;
  --accent-deep: #8c0d18;
  --accent-ink: #ff6b76;          /* on near-black, for small bright marks */

  /* Signal colours stay semantic and are deliberately NOT the accent: a SELL badge must not be
     mistaken for a piece of interface chrome, so it is a lighter, cooler red than the accent. */
  --green: #19cf67;
  --red: #ff4d5e;
  --radius: 18px;
  --gap: 10px;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
               "Helvetica Neue", "Noto Naskh Arabic", Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  background:
    radial-gradient(130% 55% at 50% 0%, #131316 0%, rgba(19, 19, 22, 0) 62%),
    var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding-top: calc(14px + max(env(safe-area-inset-top), var(--tg-safe-top)));
  padding-bottom: calc(18px + max(env(safe-area-inset-bottom), var(--tg-safe-bottom)));
  padding-inline-start: calc(12px + var(--tg-safe-left));
  padding-inline-end: calc(12px + var(--tg-safe-right));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.app[aria-busy="true"] .grid { opacity: .35; }
/* Fullscreen floor: if the client reports no inset, Telegram's floating close / menu buttons
   would land on the header. 46px clears them; where the real insets are larger (any notched
   iPhone reports far more) the max() below keeps the real value and this never applies. */
:root.tg-fullscreen .app {
  padding-top: calc(10px + max(env(safe-area-inset-top), var(--tg-safe-top), 46px));
}
.grid { transition: opacity .18s ease; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ header */
.profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 2px 10px;
}
.avatar {
  flex: 0 0 auto;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1c1c22, #101014);
  border: 2px solid #33333c;
  background-size: cover;
  background-position: center;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 700; color: var(--muted);
  overflow: hidden;
}
.who { flex: 1 1 auto; min-width: 0; }
.name {
  margin: 0;
  /* Smaller than the mock and responsive: a Telegram username can be 32 characters, and the
     whole handle has to stay readable. The starting size below suits ordinary names; longer
     ones are measured and stepped down by fitName() in app.js, which also lets the text wrap
     once it reaches the floor. The handle is never abbreviated - no ellipsis anywhere. */
  font-size: clamp(15px, 5.4vw, 24px);
  font-weight: 800;
  letter-spacing: -.4px;
  line-height: 1.15;
  white-space: nowrap;
  overflow-wrap: anywhere;
  direction: ltr;                 /* a @username is always read left to right */
  text-align: start;
}
/* Set by fitName() when even the smallest size will not fit on one line. */
.name.wrapping { white-space: normal; }
html[dir="rtl"] .name { text-align: right; }
.uid {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 17px;
  direction: ltr;
  text-align: start;
}
html[dir="rtl"] .uid { text-align: right; }

/* The balance sits under the id: one line, no new row in the layout. */
.wallet {
  margin: 3px 0 0;
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(242, 40, 58, .10);
  border: 1px solid rgba(242, 40, 58, .32);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .1px;
}

/* ------------------------------------------------------------ locked signal */
.card.locked { border-color: rgba(242, 40, 58, .22); }
.badge.locked { background: #2a1116; color: var(--accent-ink); font-size: 12px; padding: 3px 8px; }
.lock-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.lock-title {
  margin: 0;
  font-size: clamp(12.5px, 3.7vw, 15px);
  font-weight: 700;
  color: var(--text);
}
.unlock {
  border: 1px solid rgba(242, 40, 58, .45);
  background: linear-gradient(180deg, rgba(242, 40, 58, .16), rgba(140, 13, 24, .20));
  color: #ffd9dd;
  border-radius: 11px;
  padding: 8px 10px;
  font-size: clamp(11px, 3.2vw, 13px);
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  transition: filter .15s ease;
}
.unlock:hover { filter: brightness(1.15); }
.unlock:active { filter: brightness(.92); }
.unlock:disabled { opacity: .6; cursor: default; }

/* ----------------------------------------------------------------- plans */
.plan {
  position: relative;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
}
/* The most-chosen plan is lifted, never at the cost of the others: they keep full contrast,
   full size and a working button. */
.plan.popular {
  border-color: rgba(242, 40, 58, .55);
  box-shadow: 0 0 0 1px rgba(242, 40, 58, .18), 0 10px 26px rgba(170, 16, 28, .22);
  background: linear-gradient(180deg, rgba(242, 40, 58, .07), var(--card));
}
.plan-tag {
  position: absolute;
  top: -9px; inset-inline-start: 14px;
  background: linear-gradient(100deg, var(--accent-deep), #db1226);
  color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: .4px;
  padding: 3px 9px;
  border-radius: 999px;
}
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.plan-name { font-size: 17px; font-weight: 800; }
.plan-price { color: var(--muted); font-size: 13px; }
.plan-price b { color: var(--text); font-size: 19px; }
.plan-credits { margin: 8px 0 2px; font-size: 14px; font-weight: 700; color: var(--accent-ink); }
.plan-stars { margin: 0 0 4px; color: var(--text); font-size: 13px; font-weight: 700; }
.plan-pairs { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; }
.plan.current { border-color: rgba(255, 255, 255, .22); }
.plan.current .plan-choose { opacity: .55; cursor: default; }
.plan-choose {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px;
  background: #1a1a20;
  color: var(--text);
  font-size: 15px; font-weight: 800;
  cursor: pointer;
}
.plan.popular .plan-choose {
  background: linear-gradient(100deg, var(--accent-deep), #db1226);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.plan-choose:disabled { opacity: .6; }
.sheet-notice {
  background: rgba(242, 40, 58, .10);
  border: 1px solid rgba(242, 40, 58, .3);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text) !important;
  font-size: 13.5px;
}

.icon-button {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--accent-bright);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .15s ease;
}
.icon-button:hover { background: rgba(242, 40, 58, .10); }
.icon-button:active { background: rgba(242, 40, 58, .18); }
.icon { width: 24px; height: 24px; display: block; }

/* -------------------------------------------------------------- alerts bar */
.alerts-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #141418, #0d0d10);
  border: 1px solid var(--stroke);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .025) inset;
  border-radius: var(--radius);
  padding: 12px 13px;
}
/* The two halves of the bar share the width instead of the label taking whatever it wants:
   "Оповещения вкл." is twice the length of "Alerts On", and when the left block refused to
   shrink it left the message an 85px column that broke words mid-syllable. */
.alerts-left { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
/* The alert icons carry the warning colour; the labels stay near-white so nothing that has to
   be READ is tinted. */
.bell { color: var(--accent-bright); width: 23px; height: 23px; flex: 0 0 auto; }
/* No nowrap: "Сповіщення увімк." and "Notifikasi aktif" are far wider than "Alerts On", and a
   non-wrapping label would push the rest of the bar off the screen. */
.alerts-label { font-weight: 700; font-size: 14.5px; }
.alerts-divider { width: 1px; align-self: stretch; background: var(--stroke); flex: 0 0 auto; }
.alerts-right { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 54%; }
/* Long single words - "Мгновенное", "Сповіщення", "Natychmiastowa" - have no break opportunity,
   so without these the paragraph box pushes past the screen edge and the whole page scrolls
   sideways. The intermediate div needs min-width too, or the flex child refuses to shrink. */
.alerts-right > div { min-width: 0; }
.alerts-title, .alerts-sub { overflow-wrap: anywhere; }
.plane { color: var(--accent); width: 24px; height: 24px; flex: 0 0 auto; }
.alerts-title { margin: 0; font-weight: 700; font-size: 13.5px; line-height: 1.25; }
.alerts-sub { margin: 2px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.3; }

.switch {
  width: 48px; height: 28px;
  border-radius: 999px;
  border: 0;
  background: #2a2a31;
  position: relative;
  cursor: pointer;
  transition: background .18s ease;
  flex: 0 0 auto;
}
.switch[aria-checked="true"] {
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  box-shadow: 0 0 0 1px rgba(242, 40, 58, .35), 0 2px 10px rgba(209, 22, 38, .35);
}
.switch .knob {
  position: absolute;
  top: 3px; inset-inline-start: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
}
.switch[aria-checked="true"] .knob { transform: translateX(20px); }
html[dir="rtl"] .switch[aria-checked="true"] .knob { transform: translateX(-20px); }

/* -------------------------------------------------------------- card grid */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}
.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--stroke-soft);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset, 0 6px 18px rgba(0, 0, 0, .45);
  padding: 12px;
  min-height: 146px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;            /* last resort on a very narrow screen: the badge drops below,
                                 rather than the symbol being cut */
  gap: 4px;
}
.pair-icon { width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%; }
.pair {
  font-weight: 800;
  /* Sized so the longest symbol (BTCUSDT) still fits whole next to the badge on a 375px
     phone; it grows with the screen. It never shrinks and is never abbreviated - a trader
     reading "XAU…" cannot tell XAUUSD from XAGUSD. */
  font-size: clamp(10.8px, 3.05vw, 16px);
  letter-spacing: -.3px;
  direction: ltr;
  flex: 1 0 auto;
  white-space: nowrap;
}
.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3.5px 6.5px;
  font-size: clamp(8.4px, 2.4vw, 12px);
  font-weight: 800;
  letter-spacing: .2px;
  color: #fff;
  background: #2a3550;
  white-space: nowrap;
}
/* Dark ink on the same green: white measured 2.07:1 here, which fails WCAG AA even for large
   text. #04230f on the unchanged #19cf67 measures 8.11:1. The background is untouched. */
.badge.buy  { background: var(--green); color: #04230f; }
.badge.sell { background: var(--red); }
.badge.none { background: #22222a; color: #a9a9b6; font-weight: 700; }

.card-body {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}
.levels {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 8px;
  font-size: clamp(12.5px, 3.7vw, 15px);
  direction: ltr;
  text-align: left;
  flex: 1 1 auto;
  min-width: 0;
}
.levels dt { color: var(--muted); }
.levels dd { margin: 0; font-weight: 700; }

.empty {
  color: var(--muted);
  font-size: clamp(12.5px, 3.7vw, 15px);
  flex: 1 1 auto;
  align-self: center;
}

/* The trend glyph. It is NOT a price chart: this project has no market-price feed, so drawing
   a fake price series would be a lie. It is a direction mark derived from the signal itself.
   It sits BESIDE the numbers, never behind them. */
.trend {
  flex: 0 0 auto;
  width: 58px; height: 42px;
  pointer-events: none;
  opacity: .9;
  direction: ltr;
}
.trend.flat { opacity: .22; }

.note {
  margin: 2px 2px 0;
  color: var(--muted-2);
  font-size: 12.5px;
  line-height: 1.45;
}

/* ----------------------------------------------------------- credits button */
.credits {
  margin-top: 4px;
  width: 100%;
  border: 0;
  border-radius: 20px;
  padding: 18px 20px;
  /* The bright end is #db1226 rather than --accent-bright: white on it measures 5.09:1, so the
     label stays well clear of AA along the whole sweep instead of only over the dark half. */
  background: linear-gradient(100deg, var(--accent-deep), #db1226);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  cursor: pointer;
  /* White on this gradient sits around 5.5:1 at its lightest point, so the label stays legible
     end to end rather than only over the dark half. */
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  box-shadow: 0 10px 26px rgba(170, 16, 28, .38);
  transition: filter .15s ease, box-shadow .15s ease, transform .08s ease;
}
.credits:hover { filter: brightness(1.08); box-shadow: 0 12px 30px rgba(190, 18, 32, .48); }
.credits:active {
  transform: translateY(1px);
  filter: brightness(.94);
  box-shadow: 0 6px 16px rgba(140, 13, 24, .45);
}
.credits .coins { width: 30px; height: 30px; }
.credits-divider { width: 1px; height: 26px; background: rgba(255, 255, 255, .5); }
.credits-label { flex: 1 1 auto; text-align: center; }
.credits .chevron { width: 24px; height: 24px; }
html[dir="rtl"] .credits .chevron { transform: scaleX(-1); }

/* ----------------------------------------------------------------- sheet */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .72); }
.sheet-panel {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  background: linear-gradient(180deg, #121216, var(--bg-2));
  border-top: 1px solid var(--stroke);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(22px + max(env(safe-area-inset-bottom), var(--tg-safe-bottom)));
  animation: rise .2s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } }
.sheet-grip {
  width: 42px; height: 4px; border-radius: 99px;
  background: #32323a; margin: 2px auto 14px;
}
.sheet-panel h2 { margin: 0 0 12px; font-size: 20px; font-weight: 800; }
.sheet-panel p { margin: 0 0 10px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.sheet-panel b { color: var(--text); }
.lang-option {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 15px 16px;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 17px; font-weight: 700;
  cursor: pointer;
}
/* Twenty rows will not fit on a phone, so the list scrolls inside the sheet while the title
   and the Close button stay put. Nothing else about the sheet changes. */
.sheet-list {
  max-height: min(58vh, 420px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin: 0 -4px 2px;
  padding: 0 4px;
}
.lang-option {
  transition: border-color .15s ease, color .15s ease;
}
.lang-option[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-ink); }
.lang-option:active { border-color: var(--accent-deep); }
.lang-option .tick { font-size: 18px; }
.sheet-close {
  width: 100%;
  margin-top: 6px;
  border: 0;
  border-radius: 14px;
  padding: 15px;
  background: #1a1a20;
  color: var(--text);
  font-size: 16px; font-weight: 700;
  cursor: pointer;
}

@media (max-width: 360px) {
  .alerts-bar { flex-wrap: wrap; }
  .alerts-divider { display: none; }
  .card { min-height: 138px; padding: 10px; }
  .trend { width: 48px; height: 36px; }
}
