/* MT Replay — MT5 mobile (iOS, dark) clone. Units are CSS px = iOS pt.
   Colours and metrics sampled from REF/mt5_history.webp (iPhone 393 pt wide). */
:root {
  --bg: #000;
  --text: #fff;
  --grey: #d3d3d3;            /* secondary row text (open → close, dates, comments) */
  --grey2: #8e8e93;           /* labels in sheets/settings */
  --grey3: #636366;
  --blue: #2287f4;            /* buy / profit */
  --red: #e7524c;             /* sell / loss */
  --accent: #1eabfa;          /* selected tab + header tint */
  --amber: #f5b301;
  --glass: rgba(31, 31, 31, 0.78);
  --glass-border: rgba(255, 255, 255, 0.11);
  --glass-sel: rgba(255, 255, 255, 0.145);
  --sheet: rgba(28, 28, 30, 0.97);
  --cell: #1c1c1e;
  --sep: rgba(84, 84, 88, 0.55);
  --f: -apple-system, system-ui, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --hdr-top: max(calc(var(--sat) - 4.5px), 6px);
  --hdr-h: 48px;
  --tb-h: 61px;
  --tb-bottom: max(calc(var(--sab) - 12.4px), 8px);
  --list-top: calc(var(--hdr-top) + var(--hdr-h) + 8px);
  --list-bottom: calc(var(--tb-bottom) + var(--tb-h) + 5.75px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--f); font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
  position: fixed; inset: 0;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
input { font: inherit; color: inherit; background: none; border: 0; outline: none; -webkit-user-select: text; user-select: text; min-width: 0; }
svg { display: block; }
[hidden] { display: none !important; }

#app { position: absolute; inset: 0; overflow: hidden; }
#app.booting .screen, #app.booting .tabbar { visibility: hidden; }

/* ---------- glass (iOS 26 style) ---------- */
.glass, .circ, .capsule {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.6); backdrop-filter: blur(14px) saturate(1.6);
  border: 1px solid var(--glass-border);
}

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: none; }
.screen.on { display: block; }
.scroll {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  padding-top: var(--list-top); padding-bottom: var(--list-bottom);
}
.scroll::-webkit-scrollbar { display: none; }

/* scroll-edge dimming under the status bar / header and above the tab bar */
.edge-top {
  position: absolute; left: 0; right: 0; top: 0; height: calc(var(--hdr-top) + 76px); pointer-events: none; z-index: 4;
  background: linear-gradient(to bottom, rgba(0,0,0,.8) 0, rgba(0,0,0,.74) var(--sat), rgba(0,0,0,.25) calc(var(--hdr-top) + 50px), rgba(0,0,0,0) 100%);
}
.edge-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--tb-bottom) + 40px); pointer-events: none; z-index: 4;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0, rgba(0,0,0,.45) 50%, rgba(0,0,0,0) 100%);
}
body.tab-chart .edge-top, body.tab-chart .edge-bottom { display: none; }

/* ---------- header ---------- */
.hdr {
  position: absolute; left: 0; right: 0; top: var(--hdr-top); height: var(--hdr-h); z-index: 6;
  display: flex; align-items: center; gap: 0; padding: 0 16px; pointer-events: none;
}
.hdr > * { pointer-events: auto; }
.flex1 { flex: 1; }
.circ { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.circ svg { width: 26px; height: 26px; }
.circ.accent { color: var(--accent); }
.circ:active, .capsule:active { background: rgba(70,70,70,.85); }
.circ-spacer { flex: 0 0 44px; }
.hdr-title {
  position: absolute; left: 76px; right: 76px; top: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 600; font-size: 17px; letter-spacing: -0.4px; pointer-events: none; white-space: nowrap; overflow: hidden;
}
.hdr-title.big { font-size: 20px; letter-spacing: -0.45px; font-feature-settings: "tnum" 1; }
.hdr-title small { font-size: 12px; font-weight: 400; color: var(--grey2); letter-spacing: 0; margin-top: 1px; }
.capsule { height: 44px; border-radius: 22px; padding: 0 16px; display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: 16px; letter-spacing: -0.3px; color: #fff; }
#c-sym { margin-left: 12px; }
.capsule .chev { width: 16px; height: 16px; color: var(--grey2); }

/* segmented control (History: Positions · Orders · Deals) */
.seg { position: relative; display: flex; height: 48px; border-radius: 24px; flex: 0 0 auto; margin-left: 12px; }
.seg button { position: relative; z-index: 1; width: 80.3px; height: 100%; font-weight: 500; font-size: 15px; letter-spacing: -0.2px; color: #fff; }
.seg-ind {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: 73px; border-radius: 21px; background: var(--glass-sel);
  transition: transform .38s cubic-bezier(.25, 1.25, .45, 1), width .3s;
}

/* ---------- tab bar ---------- */
.tabbar {
  position: absolute; left: 21px; right: 21px; bottom: var(--tb-bottom); height: var(--tb-h); border-radius: 31px; z-index: 8;
  display: flex; padding: 0 6.5px;
}
.tabbar button { position: relative; z-index: 1; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; color: #fff; }
.tabbar svg { width: 24px; height: 24px; margin-top: 10.8px; }
.tabbar span { font-weight: 500; font-size: 10px; line-height: 12px; margin-top: 3.2px; letter-spacing: 0; }
.tabbar button.on { color: var(--accent); }
.tb-pill {
  position: absolute; top: 3px; height: 53px; width: 73.5px; border-radius: 26.5px; background: var(--glass-sel); left: 0;
  transition: transform .42s cubic-bezier(.25, 1.2, .4, 1);
}

/* ---------- list rows (History / Trade positions) ---------- */
.list { position: relative; }
.hrow { height: 57px; padding: 4.3px 7px 0 6.5px; white-space: nowrap; }
.hrow.tap:active { background: rgba(255,255,255,.06); }
.l1, .l2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.l1 {
  height: 26px; line-height: 26px; font-size: 17.2px; font-weight: 560; letter-spacing: -0.25px;
  font-variation-settings: "wdth" 59; font-stretch: 59%; font-feature-settings: "tnum" 1; word-spacing: 1.5px;
}
.l2 { height: 20px; line-height: 20px; font-size: 14px; color: var(--grey); }
.l1 > span, .l2 > span { overflow: hidden; text-overflow: ellipsis; }
.l1 > .r, .l2 > .r { flex: 0 0 auto; }
.l1 > .r { font-variation-settings: "wdth" 62; font-stretch: 62%; }
.n2 { font-variation-settings: "wdth" 85; font-stretch: 85%; font-feature-settings: "tnum" 1; }
.l2 > .n2:first-child { margin-left: -1.5px; }
.l2 > span:not(.n2) { letter-spacing: -0.15px; }
.arr { display: inline-block; width: 12.3px; height: 5.4px; margin: 0 4.4px 0 4.6px; vertical-align: 0.26em; color: var(--grey); overflow: visible; }
.buy, .pos { color: var(--blue); }
.sell, .neg { color: var(--red); }
.hrow .more { display: none; }
.hrow.open { height: auto; padding-bottom: 8px; }
.hrow.open .more { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 2px 10px; font-size: 13px; color: var(--grey2); padding: 4px 0 0; }
.more b { font-weight: 400; color: var(--grey); text-align: right; font-feature-settings: "tnum" 1; }
.empty { padding: 26px 0; text-align: center; color: var(--grey2); font-size: 15px; }

/* summary block (bottom of History) + account block (Trade) */
.sumblock { padding: 4.7px 7px 0 6.5px; }
.sumrow { display: flex; justify-content: space-between; font-size: 16px; line-height: 23.4px; height: 23.4px; white-space: nowrap; }
.sumrow > span:last-child { font-weight: 500; }
.acct { padding-top: 2px; padding-bottom: 6px; }
.sechdr { padding: 16px 6.5px 4px; font-size: 13px; font-weight: 600; color: var(--grey2); letter-spacing: 0.1px; text-transform: uppercase; }

/* ---------- quotes ---------- */
.qrow { position: relative; height: 66px; padding: 0 7px 0 6.5px; display: flex; align-items: center; white-space: nowrap; }
.qrow:active { background: rgba(255,255,255,.06); }
.qrow .ql { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.qrow .qsym { font-size: 17.2px; line-height: 24px; font-weight: 560; letter-spacing: -0.25px; font-variation-settings: "wdth" 61; font-stretch: 61%; }
.qrow .qsub { font-size: 13px; line-height: 17px; color: var(--grey); font-variation-settings: "wdth" 85; font-stretch: 85%; font-feature-settings: "tnum" 1; }
.qrow .qsub .chg { margin-left: 6px; }
.qp { position: relative; width: 100px; flex: 0 0 100px; text-align: right; font-feature-settings: "tnum" 1; }
.qp .px { display: inline-flex; align-items: flex-start; line-height: 1; }
.qp .a { font-size: 15px; margin-top: 7px; letter-spacing: -0.2px; }
.qp .b { font-size: 27px; font-weight: 500; letter-spacing: -0.6px; }
.qp .c { font-size: 13px; margin-top: 1px; margin-left: 1px; min-width: 7px; text-align: left; }
.qp.up { color: var(--blue); }
.qp.dn { color: var(--red); }
.qsp { flex: 0 0 30px; align-self: flex-start; margin-top: 13px; text-align: center; font-size: 11px; line-height: 15px; color: var(--grey2); font-feature-settings: "tnum" 1; }

/* ---------- chart ---------- */
#c-wrap { position: absolute; left: 0; right: 0; top: calc(var(--hdr-top) + var(--hdr-h) + 58px); bottom: calc(var(--tb-bottom) + var(--tb-h) + 6px); }
#c-host { position: absolute; inset: 0; }
#c-legend { position: absolute; left: 8px; top: 6px; z-index: 2; pointer-events: none; display: flex; flex-direction: column; font-size: 13px; line-height: 17px; }
#c-legend b { font-weight: 600; }
#c-legend span { color: var(--grey2); font-size: 12px; }
#c-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--grey2); font-size: 15px; }
.tfrow {
  position: absolute; left: 16px; right: 16px; top: calc(var(--hdr-top) + var(--hdr-h) + 8px); height: 42px; border-radius: 21px; z-index: 6;
  display: flex; padding: 0 3px;
}
.tfrow button { position: relative; z-index: 1; flex: 1; font-size: 14px; font-weight: 600; color: #fff; letter-spacing: -0.2px; }
.tfrow button.on { color: var(--accent); }
.tfrow .seg-ind { top: 3px; bottom: 3px; left: 0; border-radius: 18px; }

/* ---------- sheets, menus, toast ---------- */
#layer { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .28s; pointer-events: auto; }
.backdrop.clear { background: transparent; }
.backdrop.in { opacity: 1; }
.sheet {
  position: absolute; left: 8px; right: 8px; bottom: 8px; max-height: calc(100% - var(--sat) - 16px); z-index: 1; pointer-events: auto;
  background: var(--sheet); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); border-radius: 34px;
  border: 1px solid rgba(255,255,255,.07); box-shadow: 0 -8px 40px rgba(0,0,0,.45);
  transform: translateY(calc(100% + 20px)); transition: transform .42s cubic-bezier(.2, 1, .3, 1);
  display: flex; flex-direction: column; overflow: hidden; padding-bottom: max(calc(var(--sab) - 18px), 10px);
}
.sheet.in { transform: translateY(0); }
.sheet.drag { transition: none; }
.grab { flex: 0 0 auto; height: 16px; display: grid; place-items: center; touch-action: none; }
.grab::before { content: ""; width: 36px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.28); }
.sh-head { flex: 0 0 auto; position: relative; height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; touch-action: none; }
.sh-head .circ { width: 40px; height: 40px; flex-basis: 40px; background: rgba(255,255,255,.1); border: 0; }
.sh-head .circ svg { width: 22px; height: 22px; }
.sh-title { position: absolute; left: 60px; right: 60px; text-align: center; font-size: 17px; font-weight: 600; letter-spacing: -0.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 16px 8px; -webkit-overflow-scrolling: touch; }
.sh-sub { text-align: center; color: var(--grey2); font-size: 13px; margin: -6px 0 10px; }

.group { background: var(--cell); border-radius: 20px; overflow: hidden; margin: 0 0 14px; }
.cell { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 16px; position: relative; font-size: 17px; letter-spacing: -0.4px; width: 100%; text-align: left; }
.cell + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--sep); }
button.cell:active { background: rgba(255,255,255,.08); }
.cell .cl { flex: 0 0 auto; }
.cell .cv { color: var(--grey2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-feature-settings: "tnum" 1; }
.cell input { flex: 1; text-align: right; font-size: 17px; }
.cell input::placeholder { color: var(--grey3); }
.cell .ck { width: 22px; height: 22px; color: var(--accent); flex: 0 0 22px; }
.cell .chev { width: 16px; height: 16px; color: var(--grey3); flex: 0 0 16px; }
.cell.danger { color: var(--red); justify-content: center; }
.cell.center { justify-content: center; }
.cell.blue { color: var(--accent); }
.cell .ico { width: 24px; height: 24px; color: var(--accent); flex: 0 0 24px; }

.actions .cell { justify-content: center; font-size: 18px; min-height: 56px; color: var(--accent); }
.actions .cell.cancel { font-weight: 600; }

.menu {
  position: absolute; min-width: 238px; padding: 7px 0; border-radius: 26px; pointer-events: auto; z-index: 2;
  background: rgba(38,38,40,.93); -webkit-backdrop-filter: blur(30px) saturate(1.4); backdrop-filter: blur(30px) saturate(1.4);
  border: 1px solid rgba(255,255,255,.08); box-shadow: 0 12px 44px rgba(0,0,0,.55);
  opacity: 0; transform: scale(.6); transition: opacity .18s, transform .32s cubic-bezier(.2, 1.25, .35, 1);
}
.menu.in { opacity: 1; transform: scale(1); }
.menu .mtitle { padding: 6px 18px 6px 46px; font-size: 13px; color: var(--grey2); }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; padding: 0 18px 0 14px; font-size: 17px; letter-spacing: -0.4px; text-align: left; }
.menu button:active { background: rgba(255,255,255,.1); }
.menu button svg { width: 22px; height: 22px; flex: 0 0 22px; visibility: hidden; }
.menu button.on svg.ck { visibility: visible; }
.menu button .dir { margin-left: auto; color: var(--grey2); font-size: 15px; }
.menu hr { border: 0; height: 0.5px; background: var(--sep); margin: 5px 0; }

#toast {
  position: absolute; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100% - 16px); top: calc(var(--sat) + 6px); z-index: 30;
  transform: translateY(-160%); transition: transform .45s cubic-bezier(.2, 1.1, .3, 1);
  padding: 11px 16px; border-radius: 22px; font-size: 15px; line-height: 20px; letter-spacing: -0.35px; text-align: center;
  background: rgba(44,44,46,.94); pointer-events: none; font-feature-settings: "tnum" 1; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
#toast.in { transform: translateY(0); }
#toast.err { color: #ff8a84; }

/* ---------- order / close / modify sheets ---------- */
.o-sym { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 0 0 2px; }
.o-sym b { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.o-sym span { color: var(--grey2); font-size: 14px; }
.o-exec { text-align: center; color: var(--grey2); font-size: 13px; margin-bottom: 12px; }
.stepper { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stepper .sbtn { width: 44px; height: 38px; border-radius: 19px; display: grid; place-items: center; background: rgba(255,255,255,.1); color: #fff; flex: 0 0 44px; }
.stepper .sbtn svg { width: 20px; height: 20px; }
.stepper .sbtn.small { font-size: 13px; font-weight: 600; width: 52px; flex-basis: 52px; }
.stepper .sbtn:active { background: rgba(255,255,255,.2); }
.stepper input { flex: 1 1 0; width: 0; min-width: 0; text-align: center; font-size: 20px; font-weight: 600; height: 38px; font-feature-settings: "tnum" 1; letter-spacing: -0.3px; }
.stepper input::placeholder { color: var(--grey3); font-weight: 400; font-size: 16px; }
.frow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 0 12px 0 16px; position: relative; }
.frow + .frow::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--sep); }
.frow > label { font-size: 16px; flex: 0 0 96px; letter-spacing: -0.3px; }
.frow .stepper { flex: 1 1 0; }
.o-prices { display: flex; justify-content: space-around; margin: 6px 0 10px; }
.o-prices .qp { width: auto; text-align: center; }
.o-prices .qp .a { font-size: 17px; margin-top: 8px; }
.o-prices .qp .b { font-size: 34px; }
.o-prices .qp .c { font-size: 15px; }
.o-btns { display: flex; gap: 10px; }
.o-btns button { flex: 1; height: 58px; border-radius: 29px; font-size: 16px; font-weight: 600; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; letter-spacing: -0.2px; }
.o-btns button small { font-size: 13px; font-weight: 500; opacity: .9; font-feature-settings: "tnum" 1; }
.o-btns .bsell { background: var(--red); }
.o-btns .bbuy { background: var(--blue); }
.o-btns button:active { filter: brightness(1.15); }
.o-btns button[disabled] { opacity: .45; }
.btn-primary { display: block; width: 100%; height: 54px; border-radius: 27px; background: var(--blue); color: #fff; font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
.btn-primary[disabled] { opacity: .5; }
.btn-amber { background: var(--amber); color: #000; }
.o-err { color: #ff8a84; text-align: center; font-size: 14px; min-height: 20px; margin: 4px 0 6px; }
.c-head { text-align: center; margin: 0 0 12px; }
.c-head .l1 { justify-content: center; }
.c-head .l2 { justify-content: center; }
.kv { display: flex; justify-content: space-between; font-size: 16px; line-height: 30px; padding: 0 16px; font-feature-settings: "tnum" 1; }
.kv span:first-child { color: var(--grey2); }

/* ---------- settings ---------- */
#s-body { padding: 4px 16px 0; }
.acard { background: var(--cell); border-radius: 22px; padding: 16px; margin-bottom: 14px; display: flex; gap: 14px; align-items: center; }
.acard .av { width: 52px; height: 52px; border-radius: 50%; background: #2c2c2e; display: grid; place-items: center; font-weight: 700; font-size: 20px; color: var(--grey); flex: 0 0 52px; }
.acard .ai { min-width: 0; flex: 1; }
.acard .an { font-size: 19px; font-weight: 600; letter-spacing: -0.4px; }
.acard .as { font-size: 14px; color: var(--grey2); margin-top: 2px; line-height: 19px; font-feature-settings: "tnum" 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acard .ab { font-size: 15px; margin-top: 4px; font-feature-settings: "tnum" 1; }
.about-logo { width: 84px; height: 84px; border-radius: 20px; margin: 8px auto 12px; display: block; }
.about-name { text-align: center; font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.about-ver { text-align: center; color: var(--grey2); font-size: 14px; margin: 4px 0 18px; }

/* switch */
.switch { width: 51px; height: 31px; border-radius: 16px; background: #39393d; position: relative; transition: background .25s; flex: 0 0 51px; }
.switch i { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform .25s cubic-bezier(.3, 1.3, .5, 1); }
.switch.on { background: #34c759; }
.switch.on i { transform: translateX(20px); }

/* ---------- login ---------- */
#login { position: fixed; inset: 0; z-index: 40; background: #000; overflow-y: auto; }
.login-inner { padding: calc(var(--sat) + 36px) 16px calc(var(--sab) + 24px); max-width: 480px; margin: 0 auto; }
.login-title { font-size: 34px; font-weight: 700; letter-spacing: 0.3px; padding: 0 4px; }
.login-sub { color: var(--grey2); font-size: 15px; margin: 4px 4px 22px; }
.login-err { color: #ff6961; font-size: 15px; margin: -4px 4px 14px; }
#login .cell .cl { width: 110px; }
#login .cell input { text-align: left; }
