/* ژر صرافی تحت وب — mobile first, right to left. Patch 74. */
@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 {
  --red: #D32F2F; --red-dark: #B71C1C; --blue: #1E40AF; --blue-soft: #EEF3FF;
  --ink: #15191E; --muted: #5B6470; --line: #E3E6EA; --bg: #F5F6F8; --card: #FFFFFF;
  --green: #15803D; --green-soft: #E8F6EE; --amber: #B45309; --amber-soft: #FFF5E6;
  --radius: 14px; --tap: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E8EAED; --muted: #A3ABB5; --line: #2B3038; --bg: #0F1215; --card: #181C21;
    --blue-soft: #1A2440; --green-soft: #12301F; --amber-soft: #33240F;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Vazirmatn", Tahoma, sans-serif; font-size: 15px; line-height: 1.6;
  color: var(--ink); background: var(--bg); -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--red); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px 20px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.mark { width: 46px; height: 46px; border-radius: 13px; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 700; flex: none; }
.brand h1 { font-size: 19px; margin: 0; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

/* form */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); outline: none; font-size: 16px; /* 16px: no zoom on iPhone */
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.input.ltr { direction: ltr; text-align: left; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.on.buy { background: var(--green); color: #fff; }
.seg button.on.sell { background: var(--red); color: #fff; }
.error { background: #FDECEC; color: var(--red-dark); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.ok { background: var(--green-soft); color: var(--green); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.notice { background: var(--amber-soft); color: var(--amber); padding: 10px 16px; font-size: 14px; }

/* shell */
.shell { min-height: 100vh; padding-bottom: calc(68px + var(--safe-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar .mark { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: 12px; color: var(--muted); }
.offline { background: var(--amber); color: #fff; text-align: center; font-size: 13px; padding: 4px; }
main { padding: 16px; max-width: 980px; margin: 0 auto; }
main > * + * { margin-top: 12px; }
a { color: var(--blue); text-decoration: none; }
.btn svg { width: 22px; height: 22px; flex: none; }
.topbar .btn.ghost { border: 0; min-width: var(--tap); padding: 0; color: var(--muted); }
h2.page { font-size: 18px; margin: 4px 0 14px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(var(--tab-count, 5), 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom);
}
.tabs a { min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 12px; }
.tabs a svg { width: 22px; height: 22px; }
.tabs a.on { color: var(--red); font-weight: 700; }
.tabs a.wide-only { display: none; }

/* cards */
.grid { display: grid; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h3 { font-size: 15px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat > span { font-size: 12px; color: var(--muted); display: block; }
.stat b { font-size: 20px; display: block; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .main { min-width: 0; }
.list .main b, .list .main span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .main span { font-size: 12px; color: var(--muted); }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.pill.buy { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill.sell { background: #FDECEC; color: var(--red-dark); border-color: transparent; }
.pill.lock { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.rates { width: 100%; border-collapse: collapse; }
.rates th, .rates td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.rates th { font-size: 12px; color: var(--muted); font-weight: 400; }
.rates th + th { text-align: left; }
.rates td.num { text-align: left; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }
.total { display: flex; justify-content: space-between; align-items: baseline; background: var(--blue-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.total b { font-size: 20px; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.filters .input { min-height: 44px; }

/* patch 75 */
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 13px; }
.seg button.on.blue { background: var(--blue); color: #fff; }
.seg.one { grid-template-columns: 1fr; }
.actions.wrap { flex-wrap: wrap; }
.actions.wrap .btn { flex: 1 1 calc(50% - 10px); }
.list.links a { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; color: var(--ink); }
.list.links svg { width: 22px; height: 22px; color: var(--muted); }
.bal { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; margin: 6px 0 10px; }
b.good { color: var(--green); } b.bad { color: var(--red); }
details { margin-top: 8px; } summary { cursor: pointer; padding: 6px 0; }
.sigpad { display: block; width: 100%; height: 170px; border: 1px dashed var(--muted); border-radius: 12px; background: #fff; touch-action: none; }
.sig-label { display: flex !important; justify-content: space-between; align-items: center; }
.filters > .input { flex: 1; }

/* bottom sheet (phone) / dialog (wide) */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--card); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + var(--safe-bottom)); }
.sheet h3 { margin: 0 0 6px; font-size: 17px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet .actions .btn { flex: 1; }

/* wider screens: side navigation instead of bottom tabs */
@media (min-width: 900px) {
  .shell { padding-bottom: 0; padding-right: 220px; }
  .tabs { top: 61px; bottom: 0; left: auto; right: 0; width: 220px; grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; gap: 4px; padding: 12px; border-top: 0; border-left: 1px solid var(--line); }
  .tabs a { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 46px; padding: 0 14px; border-radius: 11px; font-size: 14px; }
  .tabs a.on { background: var(--red); color: #fff; }
  .tabs a.wide-only { display: flex; }
  .tabs a.more-tab { display: none; }
  .grid.two { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .sheet-back { align-items: center; }
  .sheet { border-radius: 20px; }
}

/* patch 83 */
.toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 50; }
.version { text-align: center; margin-top: 18px; }

/* patch 84 */
.btn.help { background: #FFF8E1; color: #7A5300; border: 1px solid #F2C94C; }
.btn.warn { color: #B45309; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.help-sheet ol { padding-inline-start: 22px; line-height: 1.9; }
.help-sheet details { margin: 6px 0; }
.help-sheet summary { font-weight: 700; cursor: pointer; }
@media print { .tabs, .topbar, .actions, .seg, .filters, .btn { display: none !important; } main { padding: 0 !important; } }

/* patch 87: document preview */
.doc-row { cursor: pointer; }
.doc-row:hover { background: #F3F6FB; }
.sig-view { margin: 8px 0; padding: 8px; border: 1px solid var(--line, #D6DAE0); border-radius: 10px; text-align: center; background: #fff; }
.sig-view img { max-width: 100%; max-height: 140px; }

/* patch 88: the offline queue */
.btn.queue { background: #FFF7E6; border-color: #F0C36D; color: #7A5300; }
.btn.queue.bad { background: #FDECEC; border-color: #E8A0A0; color: #9B1C1C; }
.error.small { font-size: 12px; padding: 0; background: none; border: none; }
div.notice { margin: 8px 0; }

/* patch 90 */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow: auto; }
.bubble { padding: 10px 12px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; line-height: 1.7; }
.bubble.user { align-self: flex-start; background: #EAF0FF; }
.bubble.assistant { align-self: flex-end; background: #F3F5F8; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.bigcode { font-size: 34px; font-weight: 800; letter-spacing: 6px; text-align: center; padding: 14px; border: 2px dashed #1F6BFF; border-radius: 14px; margin: 10px 0; }
.field.check { display: flex; gap: 8px; align-items: center; }
b.neg { color: #B91C1C; }
.board { background: #0B1324; color: #fff; border-radius: 18px; padding: 20px; }
.board-head { display: flex; justify-content: space-between; font-size: 22px; margin-bottom: 12px; }
.board table { width: 100%; border-collapse: collapse; font-size: clamp(22px, 5vw, 56px); }
.board th { color: #9FB3D9; font-weight: 600; text-align: right; padding: 6px 10px; }
.board td { padding: 10px; border-top: 1px solid #22304D; font-weight: 800; }
.board td:first-child { color: #FCD34D; }

/* patch 91: English reads left to right */
.lang-row { margin-top: 14px; }
.lang-row select { width: auto; min-width: 140px; }
[dir="ltr"] body { text-align: left; }
[dir="ltr"] .rates th, [dir="ltr"] .rates td, [dir="ltr"] .board th { text-align: left; }
[dir="ltr"] .rates th + th, [dir="ltr"] .rates td.num { text-align: right; }
@media (min-width: 900px) {
  [dir="ltr"] .shell { padding-right: 0; padding-left: 220px; }
  [dir="ltr"] .tabs { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--line); }
}

/* patch 92: the ژر همیار popup on every page -- big buttons for everyone */
.hamyar-fab { position: fixed; z-index: 15; left: 16px; bottom: calc(72px + var(--safe-bottom)); width: 64px; height: 64px;
  border-radius: 50%; border: 0; background: var(--blue); color: #fff; box-shadow: 0 6px 18px rgba(30,64,175,0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; gap: 0; }
.hamyar-fab .face { font-size: 26px; line-height: 1; }
.hamyar-fab .label { font-size: 11px; font-weight: 700; }
.hamyar-panel { position: fixed; z-index: 18; left: 0; right: 0; bottom: 0; top: 8vh; background: var(--card);
  border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,0.25); display: flex; flex-direction: column;
  padding: 10px 12px calc(10px + var(--safe-bottom)); }
.hy-head { display: flex; align-items: center; gap: 4px; font-size: 17px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.hy-head .grow { flex: 1; }
.hy-head .btn.ghost { min-width: 44px; font-size: 18px; border: 0; }
.hy-log { flex: 1 1 auto; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; font-size: 16px; min-height: 80px; }
.hy-ask { flex: none; max-height: 52vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.hy-input { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.hy-input .input { flex: 1; min-width: 0; }
.hy-mic.on { background: var(--red); color: #fff; }
.hy-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hy-tiles .tile { min-height: 84px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--blue-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 14px; font-weight: 700; cursor: pointer; }
.hy-tiles .tile .ic { font-size: 30px; line-height: 1; }
.hy-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.btn.big { min-height: 56px; font-size: 17px; font-weight: 700; }
.hy-lines { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 17px; }
.hy-lines th { text-align: start; font-weight: 400; color: var(--muted); padding: 4px 6px; }
.hy-lines td { text-align: end; font-weight: 700; padding: 4px 6px; }
.hy-lines tr + tr { border-top: 1px solid var(--line); }
.hamyar-card.big .ok.big { font-size: 17px; }
.numpad { display: flex; flex-direction: column; gap: 8px; }
.numpad-show { min-height: 52px; border: 2px solid var(--blue); border-radius: var(--radius); font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }
.numpad .keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; direction: ltr; }
.numpad .key { min-height: 54px; font-size: 24px; font-weight: 700; }
@media (min-width: 900px) {
  .hamyar-fab { bottom: 24px; left: 24px; }
  .hamyar-panel { left: 24px; right: auto; bottom: 24px; top: auto; width: 420px; height: min(720px, 88vh); border-radius: 20px; }
}
@media print { .hamyar-fab, .hamyar-panel { display: none !important; } }

/* patch 93: «قالب‌های چاپ» */
.tpl-preview { width: 100%; min-height: 560px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.tpl-blocks { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.tpl-block { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.tpl-block.off { opacity: 0.55; }
.tpl-block .row { display: flex; align-items: center; gap: 4px; }
.tpl-block .grow { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 13px; }

