/* DezhEx -- dark, rounded, one-column. Built for a phone, fine on desktop.
   The customer app is Persian and right-to-left; the back office is not,
   and has its own stylesheet. */

/* Vazirmatn, served from our own domain: Google Fonts and most CDNs are
   unreliable or blocked from Iran, and a missing font would leave Persian
   text in whatever the device falls back to. SIL OFL, see fonts/LICENSE. */
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500 650; font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700 900; font-display: swap;
}

:root {
  --bg: #0b0b0f;
  --surface: #16161d;
  --surface-2: #1f1f28;
  --line: #2a2a35;
  --text: #f4f4f6;
  --muted: #8b8b99;
  --accent: #7c5cff;
  --up: #2bd67b;
  --down: #ff5c5c;
  --radius: 18px;
}

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

/* Money, tickers and references are Latin and must not be reordered by the
   bidi algorithm -- "$755.72" would otherwise render with the sign adrift.
   `isolate` keeps each one its own little left-to-right island. */
.phone .balance, .phone .big-price, .phone .change, .phone .px,
.phone .pill, .phone .reference, .phone .kv b, .phone .row-side,
.phone .amount, .phone .qty input, .phone .t-when,
.phone .trade-row > span:last-child, .phone .nm, .phone #stock-symbol {
  direction: ltr;
  unicode-bidi: isolate;
}
/* …but they still sit at the far (left) edge of their row in RTL. */
.phone .row-side, .phone .kv b,
.phone .trade-row > span:last-child { text-align: left; }

/* Email and password are Latin input; the name field is not. */
#auth-email, #auth-password { direction: ltr; text-align: left; }

/* `display` rules below would otherwise beat the UA style for [hidden]. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: #000;
  color: var(--text);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

/* Persian, and only here -- the back office shares this stylesheet and
   stays in English, left to right. */
.phone {
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  line-height: 1.75;
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  padding: 20px 16px 96px;
  background: var(--bg);
  overflow-x: hidden;
}

@media (min-width: 480px) {
  .phone { margin: 24px 0; min-height: calc(100vh - 48px); border-radius: 28px; }
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
strong, b { font-weight: 650; }

/* ---------- headers ---------- */

.app-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.avatar {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), #4a2fd6);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; letter-spacing: .5px;
}

.app-head-text { display: flex; flex-direction: column; }
.balance { font-size: 28px; letter-spacing: -.5px; }

.sub-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.sub-head-text { display: flex; flex-direction: column; line-height: 1.2; }
.sub-head-text strong { font-size: 17px; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--text);
  font-size: 22px; line-height: 1;
  cursor: pointer;
}
.icon-btn:active { background: var(--line); }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.summary-row { display: flex; gap: 8px; }
.summary-row > div { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.summary-row strong { font-size: 15px; white-space: nowrap; }

.card-actions {
  display: flex;
  width: calc(100% + 32px);
  margin: 14px -16px -16px;
  border-top: 1px solid var(--line);
}

.link-btn {
  flex: 1;
  padding: 13px 16px;
  border: 0;
  background: transparent; color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.link-btn:active { background: var(--surface-2); }
.link-btn.primary { color: var(--accent); }
a.link-btn { text-align: center; text-decoration: none; }
.link-btn.danger { color: var(--down); }
.chev { color: var(--muted); font-size: 20px; }

/* ---------- auth ---------- */

.auth { padding-top: 36px; }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo {
  display: block;
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 20px;
  /* The mark is drawn on white, so it sits on a white tile -- the same
     treatment the stock logos get, rather than a box on the dark page. */
  background: #fff;
  object-fit: contain;
  padding: 6px;
  box-sizing: border-box;
}
.auth-brand h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.5px; }
.auth-brand p { margin: 0; font-size: 14px; }
.auth-switch { margin-bottom: 20px; }
.auth-switch .tab.active { color: var(--text); }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; margin-bottom: 6px;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.field input {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field small { display: block; margin-top: 6px; font-size: 12px; }
.field-label { display: block; margin: 18px 0 8px; font-weight: 600; }

#auth-form .btn { width: 100%; margin-top: 8px; }

/* ---------- fund nudge ---------- */

.fund-nudge { text-align: center; }
.fund-nudge strong { display: block; margin-bottom: 4px; }
.fund-nudge p { margin: 0 0 14px; }
.fund-nudge .btn { width: 100%; }

/* ---------- deposit sheet ---------- */

.amount {
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 12px;
  padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg);
}
.amount .cur { font-size: 26px; font-weight: 650; color: var(--muted); }
.amount input {
  flex: 1; min-width: 0;
  padding: 4px 0;
  border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 30px; font-weight: 650;
  -moz-appearance: textfield;
}
.amount input:focus { outline: none; }
.amount input::-webkit-outer-spin-button,
.amount input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- deposit reference ---------- */

.reference-box {
  position: relative;
  padding: 18px 16px;
  margin-bottom: 12px;
  border: 1px dashed var(--accent);
  border-radius: 14px;
  background: rgba(124, 92, 255, .08);
  text-align: center;
}
.reference {
  display: block;
  margin-top: 4px;
  font-size: 30px; font-weight: 700;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}
.copy-btn {
  margin-top: 10px;
  padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.copy-btn:active { background: var(--surface-2); }

.btn.whatsapp {
  display: block;
  background: #25d366; color: #05240f;
  text-align: center; text-decoration: none;
}

.tag.pending { background: rgba(255, 176, 32, .18); color: #ffb020; }
.tag.withdrawal, .tag.paid { background: rgba(255, 92, 92, .16); color: var(--down); }
.tag.rejected { background: rgba(139, 139, 153, .18); color: var(--muted); }
.tag.cancelled { background: rgba(139, 139, 153, .18); color: var(--muted); }

/* ---------- account box ---------- */

.account-box { padding-bottom: 0; }
.account-who { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.account-who > div { display: flex; flex-direction: column; min-width: 0; }
.account-who strong { font-size: 15px; }
.avatar.small { width: 36px; height: 36px; font-size: 12px; }

.phone .section-title { text-transform: none; letter-spacing: 0; }

.section-title {
  margin: 0 4px 10px;
  font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted);
}

/* ---------- lists ---------- */

.list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 24px; }
.list:not(.plain) { background: var(--surface); border-radius: var(--radius); overflow: hidden; }

.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 0; background: transparent; color: inherit;
  font: inherit; text-align: left;
  cursor: pointer;
}
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }

.logo {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  color: #fff;
  overflow: hidden;
}
/* A light disc behind the mark: plenty of these logos are black or very
   dark and would vanish against the app's background. */
.logo.has-logo { background: #fff; }
.logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 5px;
  box-sizing: border-box;
}
.logo.small { width: 30px; height: 30px; font-size: 11px; }
.logo.small img { padding: 4px; }

.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main .nm { font-weight: 600; font-size: 15px; }
.phone .row-main .nm { text-align: right; }
.row-main .sb { color: var(--muted); font-size: 13px; }
.phone .row-main .sb { text-align: right; }
/* All-Latin sub-lines (ticker · price) read left to right; mixed Persian
   ones isolate their numbers with <bdi> instead. */
.phone .row-main .sb:not(:has(bdi)) { direction: ltr; }
.row-side { text-align: right; display: flex; flex-direction: column; }
.phone .row-side { align-items: flex-start; text-align: left; }
.row-side .px { font-weight: 600; font-size: 15px; }

.change { font-size: 13px; font-weight: 600; }
.up, .change.up { color: var(--up); }
.down, .change.down { color: var(--down); }
.flat, .change.flat { color: var(--muted); }

.tag {
  display: inline-block;
  padding: 1px 6px; margin-right: 6px;
  border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase;
}

.trade-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 11px 4px;
  font-size: 14px;
}
.trade-row + .trade-row { border-top: 1px solid var(--line); }
.trade-row .t-main { display: flex; flex-direction: column; }
.trade-row .t-when { color: var(--muted); font-size: 12px; }
.tag.deposit { background: rgba(124, 92, 255, .18); color: var(--accent); }
.tag.refund { background: rgba(139, 139, 153, .18); color: var(--muted); }
.phone .tag { margin-right: 0; margin-left: 6px; }

.empty {
  padding: 26px 16px;
  text-align: center; color: var(--muted); font-size: 14px;
}

/* ---------- stock screen ---------- */

.price-block { display: flex; align-items: baseline; gap: 10px; margin: 14px 4px 4px; }
.big-price { font-size: 34px; letter-spacing: -1px; }

.spark { width: 100%; height: 90px; margin-bottom: 18px; display: block; }

.tabs {
  display: flex; gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 14px;
}
.tab {
  flex: 1;
  padding: 10px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font: inherit; font-weight: 650; font-size: 15px;
  cursor: pointer;
}
.tab.active { background: var(--surface-2); color: var(--text); }

.instrument-note {
  display: flex; gap: 8px;
  margin: 12px 0 0; padding: 11px 13px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted); font-size: 12px; line-height: 1.5;
}
.instrument-note::before { content: "ⓘ"; flex: none; font-style: normal; }

.position-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px; font-weight: 650;
}

.kv {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 0;
  font-size: 14px;
}
.kv span { color: var(--muted); }
.kv.total { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; }

.empty-position { color: var(--muted); font-size: 14px; }
.empty-position p { margin: 0; }

.actions { display: flex; gap: 10px; }

/* ---------- buttons ---------- */

.btn {
  flex: 1;
  padding: 15px;
  border: 0; border-radius: 14px;
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 650; font-size: 16px;
  cursor: pointer;
}
.btn:active { filter: brightness(.92); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.buy { background: var(--accent); }
.btn.sell { background: var(--surface-2); color: var(--text); }
.btn.confirm { width: 100%; margin-top: 16px; }
.btn.ghost { width: 100%; margin-top: 8px; background: transparent; color: var(--muted); }
.btn.reset { margin-top: 4px; font-size: 14px; }

/* ---------- portfolio ---------- */

.overview .balance { display: block; margin: 2px 0 4px; font-size: 32px; }
.bar { height: 6px; margin: 16px 0 10px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #4a2fd6); width: 0; transition: width .4s ease; }

/* ---------- trade sheet ---------- */

.sheet-wrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }

.sheet {
  position: relative;
  width: 100%; max-width: 430px;
  padding: 10px 18px 24px;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  animation: rise .22s ease;
  max-height: 92vh; overflow-y: auto;
}
@keyframes rise { from { transform: translateY(100%); } }

.grabber { width: 38px; height: 4px; margin: 0 auto 14px; border-radius: 2px; background: var(--line); }
.sheet h3 { margin: 0 0 2px; font-size: 20px; }
.sheet > .small { margin: 0 0 16px; }

.qty { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.qty input {
  flex: 1; min-width: 0;
  padding: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 22px; font-weight: 650; text-align: center;
  -moz-appearance: textfield;
}
.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.step {
  width: 46px; height: 46px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--text);
  font-size: 22px; line-height: 1;
  cursor: pointer;
}
.step:active { background: var(--line); }

.quick-qty { display: flex; gap: 8px; margin-bottom: 18px; }
.quick-qty button {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.quick-qty button:active { background: var(--surface-2); color: var(--text); }

.breakdown { padding: 14px 16px; background: var(--bg); border-radius: 14px; }
.breakdown .kv { padding: 6px 0; }
.breakdown .kv.total b { font-size: 17px; }
.breakdown .note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.sheet-error {
  margin: 12px 0 0; padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 92, 92, .12); color: var(--down);
  font-size: 13px;
}

/* ---------- tab bar + toast ---------- */

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  max-width: 430px; margin: 0 auto;
  padding: 10px 16px 14px;
  background: rgba(11, 11, 15, .92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar-btn {
  flex: 1;
  padding: 8px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.tabbar-btn.active { color: var(--text); }

.toast {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  z-index: 50;
  max-width: 380px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
  animation: rise .2s ease;
}
.toast.good { color: var(--up); }
.toast.bad { color: var(--down); }

.disclaimer { margin: 10px 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ---------- trading halted ---------- */

.halt-banner {
  display: flex; flex-direction: column; gap: 3px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid rgba(255, 176, 32, .35);
  border-radius: 14px;
  background: rgba(255, 176, 32, .1);
  color: #ffb020;
  font-size: 13px; line-height: 1.5;
}
.halt-banner strong { font-size: 14px; }
.halt-banner span { color: var(--muted); }

/* ---------- instrument explainer ---------- */

.about {
  margin: 0 0 18px;
  padding: 13px 15px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px; line-height: 1.55;
}

/* ---------- buy by shares or by money ---------- */

.tabs.buy-mode { margin-bottom: 14px; }
.tabs.buy-mode .tab { font-size: 14px; padding: 9px 6px; }
.phone #mode-amount .amount { margin-bottom: 12px; }

/* The line that answers "what do I actually get for my money". */
.breakdown .kv.highlight b { color: var(--text); font-size: 17px; }
.breakdown .kv.highlight span { color: var(--text); }
