@font-face { font-family: "Vazirmatn"; src: url("fonts/Vazirmatn-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("fonts/Vazirmatn-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --line: #2a2f3a;
  --text: #e9ecf2;
  --muted: #8b93a3;
  --accent: #d4af5a;      /* gold */
  --buy: #2fbf71;         /* 🟢 customer buys */
  --sell: #e5534b;        /* 🔴 customer sells */
  --warn: #e0a43a;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: "Vazirmatn", system-ui, sans-serif;
  font-size: 15px; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }

#app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; background: rgba(15,17,21,.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-mark { color: var(--accent); font-size: 18px; }

.view { flex: 1; padding: 16px 16px calc(84px + var(--safe-bottom)); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.hello { font-size: 20px; font-weight: 700; margin: 0 0 2px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap;
}
.chip-ok { color: var(--buy); border-color: rgba(47,191,113,.35); }
.chip-warn { color: var(--warn); border-color: rgba(224,164,58,.4); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: right; cursor: pointer;
}
.tile .ic { font-size: 22px; display: block; margin-bottom: 4px; }
.tile .t { font-weight: 700; display: block; }
.tile .s { color: var(--muted); font-size: 12px; }
.tile:active { background: var(--surface-2); }

.state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 8px; gap: 12px; }
.state .big { font-size: 40px; }
.state p { margin: 0; max-width: 320px; }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer;
}
.btn-primary { background: var(--accent); color: #1a1406; border-color: transparent; font-weight: 700; }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  background: rgba(23,26,33,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  background: none; border: 0; padding: 4px 0; font-size: 10.5px; color: var(--muted); cursor: pointer;
}
.tab .ic { font-size: 18px; line-height: 1.4; filter: grayscale(1) opacity(.7); }
.tab.is-active { color: var(--accent); }
.tab.is-active .ic { filter: none; }

/* ---------- phase 2: rates / balance / history ---------- */
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.center { text-align: center; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.page-head h1 { margin: 0; font-size: 19px; }
.page-head p { margin: 2px 0 0; }
.icon-btn {
  flex: none; width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-size: 18px; cursor: pointer;
}
.icon-btn.spin { animation: spin .8s linear infinite; }
.banner { border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.banner.warn { background: rgba(224,164,58,.1); border: 1px solid rgba(224,164,58,.35); color: var(--warn); }
.soon { font-size: 10px; font-weight: 400; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }

h2.group { font-size: 14px; color: var(--muted); margin: 18px 4px 8px; font-weight: 700; }
.card.rate { padding: 12px 14px; }
.rate-title { font-weight: 700; margin-bottom: 8px; }
.prices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.price {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 10px;
  background: var(--surface-2); border-right: 3px solid var(--line);
}
.price.buy { border-right-color: var(--buy); }
.price.sell { border-right-color: var(--sell); }
.price .plabel { font-size: 12px; color: var(--muted); }
.price .num { font-size: 16px; font-weight: 700; text-align: right; }
.price .closed { font-size: 13px; color: var(--warn); }

.kv { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); }
.card h2 { margin: 0 0 8px; }
.net { font-weight: 700; font-size: 14px; white-space: nowrap; }
.net.neg { color: var(--sell); }
.net.pos { color: var(--buy); }
.net.zero { color: var(--muted); }
.qty, .mv { padding: 8px 0; border-top: 1px solid var(--line); }
.qty:first-of-type, .mv:first-of-type { border-top: 0; }
.qlabel { font-weight: 700; }
.btn.wide { display: block; width: 100%; text-align: center; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.fchip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; cursor: pointer;
}
.fchip.is-on { background: var(--accent); color: #1a1406; border-color: transparent; font-weight: 700; }
.datebox { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.datebox input {
  flex: 1 1 200px; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; direction: rtl;
}
.datebox .err { flex-basis: 100%; margin: 0; color: var(--sell); }
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.btn.ghost { visibility: hidden; }
.card.trade { border-right: 3px solid var(--line); }
.card.trade.buy { border-right-color: var(--buy); }
.card.trade.sell { border-right-color: var(--sell); }
.tcode { color: var(--muted); font-size: 13px; }
.tline { margin: 4px 0 8px; }
.trade.buy .side { color: var(--buy); }
.trade.sell .side { color: var(--sell); }
.tgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.tgrid > div { display: flex; flex-direction: column; }
.st { font-size: 12px; white-space: nowrap; }
.st-approved { color: var(--buy); }
.st-rejected, .st-cancelled { color: var(--sell); }
.st-waiting_admin, .st-price_changed { color: var(--warn); }
.st-expired { color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }

/* ---------- phase 3: trade ---------- */
button.price.slot { font: inherit; color: inherit; border-top: 0; border-bottom: 0; border-left: 0; text-align: right; cursor: pointer; }
button.price.slot:active { background: var(--line); }
.stepper { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; }
.step { width: 52px; height: 52px; padding: 0; font-size: 24px; flex: none; }
.qty-input {
  flex: 1; min-width: 0; height: 52px; text-align: center; font-size: 22px; font-weight: 700;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-family: inherit;
}
.qty-input:focus, .datebox input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.err { color: var(--sell); margin: 6px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.actions .btn { flex: 1 1 140px; text-align: center; padding: 12px 14px; }
.btn:disabled { opacity: .6; }
.kv.total { font-weight: 700; font-size: 16px; }
.status-box { display: flex; flex-direction: column; gap: 4px; }
.status-box.waiting { flex-direction: row; align-items: center; gap: 14px; border-color: rgba(224,164,58,.4); }
.status-box.waiting .spinner { flex: none; }
.status-box p { margin: 0; }
.status-box.st-approved { border-color: rgba(47,191,113,.45); }
.status-box.st-rejected, .status-box.st-cancelled { border-color: rgba(229,83,75,.45); }
.status-box.st-price_changed { border-color: rgba(224,164,58,.45); }
@keyframes flash { 0% { background: rgba(212,175,90,.35); } 100% { background: transparent; } }
.flash { animation: flash 1.2s ease-out; }
.banner.flash { animation: none; }

/* ---------- toman ---------- */
.amt { display: inline-flex; align-items: baseline; gap: 4px; direction: rtl; }
.unit { font-size: 11px; color: var(--muted); font-weight: 400; }
.price .amt { justify-content: flex-start; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; }
.live-dot.on { background: var(--buy); box-shadow: 0 0 0 3px rgba(47,191,113,.18); }

/* ---------- 🛠 admin ---------- */
.top-right { display: flex; align-items: center; gap: 6px; }
.mode-chip { cursor: pointer; color: var(--accent); }
.tabbar.admin { grid-template-columns: repeat(3, 1fr); }
.tab { position: relative; }
.badge {
  position: absolute; top: 0; left: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--sell); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(80px + var(--safe-bottom)); z-index: 30;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); text-align: center; animation: rise .2s ease-out;
}
.toast.bad { border-color: rgba(229,83,75,.6); color: #ffb4ae; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.dash { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dtile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 2px;
}
.dtile[data-agoto] { cursor: pointer; }
.dcount { font-size: 26px; font-weight: 700; line-height: 1.2; }
.dlabel { font-size: 12px; color: var(--muted); }
.ddetail { font-size: 11px; color: var(--muted); margin-top: 4px; }
.dtile.tone-alert { border-color: rgba(229,83,75,.55); }
.dtile.tone-alert .dcount { color: var(--sell); }
.dtile.tone-warn { border-color: rgba(224,164,58,.5); }
.dtile.tone-warn .dcount { color: var(--warn); }
.dtile.tone-ok .dcount { color: var(--muted); }
.left-chip { font-size: 13px; color: var(--warn); }
.left-chip.urgent { color: var(--sell); font-weight: 700; }
.effect { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin: 6px 0; line-height: 1.9; }
.btn-ok { background: var(--buy); color: #04170c; border-color: transparent; font-weight: 700; }
.btn-reject { color: #ffb4ae; border-color: rgba(229,83,75,.5); }
.rejbox { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.rejbox .reason {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; margin-top: 4px;
}
.pre { white-space: pre-line; }
.halt-all, .halt-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.btn.halt { font-size: 12px; }
.btn.halt.is-closed { border-color: rgba(229,83,75,.6); color: #ffb4ae; background: rgba(229,83,75,.08); }
.small-btn { padding: 6px 10px; font-size: 12px; }
.card.rate.is-off { opacity: .6; }
.rateform { display: flex; flex-direction: column; gap: 10px; }
.fld { display: flex; flex-direction: column; gap: 4px; padding-right: 10px; border-right: 3px solid var(--line); }
.fld.buy { border-right-color: var(--buy); }
.fld.sell { border-right-color: var(--sell); }
.fld input {
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); font: inherit; font-size: 18px; font-weight: 700; text-align: left;
}
.fld .hint { min-height: 1.2em; }

/* ---------- 🌐 web version / wide screens ---------- */
.ghost-btn { margin-top: 14px; background: transparent; }
#logout-btn { cursor: pointer; }
a.btn { text-decoration: none; color: #1a1406; }
@media (min-width: 640px) {
  #app { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); min-height: 100vh; }
  .tabbar, .toast { max-width: 560px; margin: 0 auto; }
  .tabbar { left: 0; right: 0; }
  .toast { left: 16px; right: 16px; }
}

/* ---------- 🧾📒 requests ---------- */
.banner.info { background: rgba(212,175,90,.07); border: 1px solid rgba(212,175,90,.28); color: var(--text); }
.card.req.is-open { border-color: rgba(224,164,58,.45); }
.req-title { font-weight: 700; margin-bottom: 4px; }
.st-text { font-size: 13px; }
.tone-ok { color: var(--buy); }
.tone-bad { color: var(--sell); }
.tone-warn { color: var(--warn); }
.tone-muted { color: var(--muted); }
.details { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(229,83,75,.07); color: #ffb4ae; font-size: 13px; }
.card.req .btn.wide { margin-top: 10px; }

/* ---------- 📤 receipt upload ---------- */
.top-actions { margin: 0 0 10px; }
button.card.pick { display: block; width: 100%; text-align: right; font: inherit; color: inherit; cursor: pointer; }
.files { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.file {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.file.bad { border-color: rgba(229,83,75,.5); color: #ffb4ae; }
.fic { font-size: 20px; }
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xbtn { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 6px; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
label.picker { cursor: pointer; text-align: center; border-style: dashed; padding: 14px; }
label.picker.disabled { opacity: .5; pointer-events: none; }
