/* ==========================================================================
   GoldB2B — "Bullion desk" design system
   Paper & ink, brass hairlines, monospaced figures. No shadows, no gradients.
   RTL/LTR via logical properties. Simple mode = larger type & targets.
   ========================================================================== */
@font-face { font-family: Vazirmatn; src: url(../fonts/Vazirmatn-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(../fonts/Vazirmatn-Medium.woff2) format("woff2"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(../fonts/Vazirmatn-Bold.woff2) format("woff2"); font-weight: 700 800; font-display: swap; }
@font-face { font-family: Plex; src: url(../fonts/IBMPlexMono-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0020-007F, U+00A0-00FF, U+2212, U+25B2, U+25BC, U+2013, U+2014; }
@font-face { font-family: Plex; src: url(../fonts/IBMPlexMono-Medium.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0020-007F, U+00A0-00FF, U+2212, U+25B2, U+25BC, U+2013, U+2014; }
@font-face { font-family: Plex; src: url(../fonts/IBMPlexMono-SemiBold.woff2) format("woff2"); font-weight: 600 700; font-display: swap; unicode-range: U+0020-007F, U+00A0-00FF, U+2212, U+25B2, U+25BC, U+2013, U+2014; }

:root {
  --paper: #f3efe6;
  --surface: #fbf9f4;
  --sunk: #ebe6da;
  --ink: #15130e;
  --ink-2: #4f4a40;
  --ink-3: #8a8373;
  --line: #d9d2c2;
  --line-soft: #e6e0d3;
  --brass: #9c7a32;
  --brass-2: #c9a55a;
  --brass-soft: #efe3c6;
  --buy: #1d6a4d;
  --buy-soft: #dcebe2;
  --sell: #9a2e21;
  --sell-soft: #f3dfda;
  --warn: #8a5a00;
  --warn-soft: #f6e8c7;
  --info-soft: #e4e7ea;
  --band: #15130e;       /* header band */
  --band-ink: #efe9dc;
  --radius: 6px;
  --radius-sm: 4px;
  --fs: 15px;
  --tap: 44px;
  --num: Plex, Vazirmatn, ui-monospace, Menlo, monospace;
  --text: Vazirmatn, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #100f0b; --surface: #17150f; --sunk: #1e1b14; --ink: #efe9dc; --ink-2: #bdb5a4; --ink-3: #857e6e;
    --line: #2e2a21; --line-soft: #26231b; --brass: #d0ad62; --brass-2: #e2c27b; --brass-soft: #2f2616;
    --buy: #4fbf8b; --buy-soft: #16271f; --sell: #ee7c6c; --sell-soft: #2c1915; --warn: #e8b64e; --warn-soft: #2d2412;
    --info-soft: #1c1f23; --band: #0a0907; --band-ink: #efe9dc; color-scheme: dark;
  }
}
body.simple { --fs: 18px; --tap: 54px; }
body.pro { --fs: 14px; --tap: 38px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 var(--fs)/1.7 var(--text); text-rendering: optimizeLegibility; }
a { color: inherit; text-decoration-color: var(--brass-2); text-underline-offset: 3px; }
a:hover { color: var(--brass); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.55em; } h2 { font-size: 1.12em; } h3 { font-size: 1em; }
p { margin: 0 0 1em; }
small, .muted { color: var(--ink-3); }
.num, .mono, .lock-timer { font-family: var(--num); font-variant-numeric: tabular-nums; }
.mono { direction: ltr; unicode-bidi: embed; font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
::selection { background: var(--brass-soft); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---------- Header band + ticker ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--band); color: var(--band-ink); }
.topbar .in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; color: inherit; text-decoration: none; }
.brand:hover { color: inherit; }
.brand .mark { width: 26px; height: 26px; }
.brand .dot { display: none; }
.nav { display: flex; gap: 2px; margin-inline-start: 18px; height: 100%; }
.nav a { display: flex; align-items: center; padding: 0 12px; color: color-mix(in srgb, var(--band-ink) 70%, transparent); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--band-ink); }
.nav a.on { color: var(--band-ink); border-bottom-color: var(--brass-2); }
.topbar .btn.ghost { color: var(--band-ink); }
.topbar .btn.ghost:hover { background: color-mix(in srgb, var(--band-ink) 10%, transparent); }
.spacer { flex: 1; }

.ticker { background: var(--surface); border-bottom: 1px solid var(--line); overflow: hidden; white-space: nowrap; font-size: .86em; }
.ticker .track { display: inline-flex; gap: 34px; padding: 7px 16px; animation: tick 60s linear infinite; }
.ticker:hover .track { animation-play-state: paused; }
.ticker .it { display: inline-flex; gap: 8px; align-items: baseline; }
.ticker .it b { font-family: var(--num); font-weight: 600; }
.ticker .lbl { color: var(--ink-2); }
[dir="rtl"] .ticker .track { animation-name: tick-rtl; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes tick-rtl { from { transform: translateX(0); } to { transform: translateX(50%); } }
@media (prefers-reduced-motion: reduce) { .ticker .track { animation: none; } }

/* ---------- Layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 16px 48px; }
.narrow { max-width: 580px; margin-inline: auto; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin: 0; }
.eyebrow { display: block; font-size: .72em; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); margin-bottom: 4px; }
@media (max-width: 900px) {
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .nav { display: none; }
  .g4.keep { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wrap { padding-bottom: 110px; }
}

/* ---------- Bottom tab bar (phones) ---------- */
.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: none; background: var(--band); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: color-mix(in srgb, var(--band-ink) 62%, transparent); font-size: .74em; padding: 6px 0; text-decoration: none; border-top: 2px solid transparent; }
.tabbar a.on { color: var(--band-ink); border-top-color: var(--brass-2); }
.tabbar svg { width: 22px; height: 22px; }
@media (max-width: 900px) { .tabbar { display: flex; } }

/* ---------- Panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.flat { background: transparent; }
.card.accent { border-top: 2px solid var(--brass); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: -2px 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1em; }
.card-head a { font-size: .88em; color: var(--brass); text-decoration: none; }
.section-title { font-size: .76em; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, color .12s; }
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); color: var(--paper); }
.btn.buy { background: var(--buy); border-color: var(--buy); color: #fff; }
.btn.sell { background: var(--sell); border-color: var(--sell); color: #fff; }
.btn.buy:hover, .btn.sell:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--sell); border-color: color-mix(in srgb, var(--sell) 35%, var(--line)); background: transparent; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: .88em; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Primary actions as ledger tiles */
.big-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.big-actions .btn { min-height: 92px; border: 0; border-radius: 0; background: transparent; color: var(--ink); flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 14px 20px; font-size: 1.08em; border-inline-end: 1px solid var(--line); position: relative; }
.big-actions .btn:last-child { border-inline-end: 0; }
.big-actions .btn::before { content: ""; position: absolute; inset-block: 14px; inset-inline-start: 0; width: 3px; background: var(--line); }
.big-actions .btn.buy::before { background: var(--buy); }
.big-actions .btn.sell::before { background: var(--sell); }
.big-actions .btn:hover { background: var(--sunk); filter: none; color: var(--ink); }
.big-actions .btn small { font-weight: 400; font-size: .76em; }
.big-actions svg { width: 22px; height: 22px; color: var(--ink-3); }
.big-actions .btn.buy svg { color: var(--buy); } .big-actions .btn.sell svg { color: var(--sell); }
@media (max-width: 560px) { .big-actions { grid-template-columns: 1fr 1fr; } .big-actions .btn:last-child { grid-column: span 2; border-top: 1px solid var(--line); } .big-actions .btn:nth-child(2) { border-inline-end: 0; } }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .86em; color: var(--ink-2); margin-bottom: 6px; font-weight: 600; }
.input, select.input, textarea.input { width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--brass-soft); }
.input.num, input[inputmode="decimal"], input[inputmode="numeric"], input[data-money] { direction: ltr; text-align: end; font-family: var(--num); }
.hint { font-size: .84em; color: var(--ink-3); margin-top: 4px; }
.err { font-size: .84em; color: var(--sell); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg label { cursor: pointer; }
.seg label + label { border-inline-start: 1px solid var(--line); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 16px; font-weight: 600; color: var(--ink-2); }
.seg input:checked + span { background: var(--ink); color: var(--paper); }
.seg .buy input:checked + span { background: var(--buy); color: #fff; }
.seg .sell input:checked + span { background: var(--sell); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: -2px; }

/* ---------- Tables & lists ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: .74em; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--ink); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--sunk) 55%, transparent); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: end; }
.table-wrap { overflow-x: auto; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.list li:last-child { border-bottom: 0; }

/* Rate board (dashboard / prices) */
.board { width: 100%; border-collapse: collapse; }
.board td { padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
.board tr:last-child td { border-bottom: 0; }
.board .name { font-weight: 600; }
.board .px { font-family: var(--num); font-weight: 600; font-size: 1.18em; text-align: end; white-space: nowrap; }
.board .chg { font-family: var(--num); text-align: end; width: 1%; white-space: nowrap; padding-inline-start: 16px; font-size: .9em; }
.board .age { color: var(--ink-3); font-size: .8em; text-align: end; width: 1%; white-space: nowrap; padding-inline-start: 16px; }
body.simple .board .px { font-size: 1.35em; }

/* ---------- Labels ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 3px; font-size: .76em; font-weight: 600; border: 1px solid var(--line); color: var(--ink-2); background: transparent; white-space: nowrap; line-height: 1.8; }
.tag.buy { color: var(--buy); border-color: color-mix(in srgb, var(--buy) 40%, transparent); background: var(--buy-soft); }
.tag.sell { color: var(--sell); border-color: color-mix(in srgb, var(--sell) 40%, transparent); background: var(--sell-soft); }
.tag.gold { color: var(--brass); border-color: color-mix(in srgb, var(--brass) 45%, transparent); background: var(--brass-soft); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.topbar .tag.gold { background: var(--brass-2); color: var(--band); border: 0; }
.tick { display: inline-block; width: 15px; height: 15px; vertical-align: -2px; color: #2f7fd1; }
.tier-bronze { color: #8f6238; } .tier-silver { color: #6f7880; } .tier-gold { color: var(--brass); } .tier-diamond { color: #2f7fd1; }
.up { color: var(--buy); } .down { color: var(--sell); }

/* ---------- Figures ---------- */
.price-tile { display: flex; flex-direction: column; gap: 2px; }
.price-tile .label { color: var(--ink-2); font-size: .88em; }
.price-tile .value { font-family: var(--num); font-size: 1.5em; font-weight: 600; }
.stat .value { font-family: var(--num); font-size: 1.7em; font-weight: 600; }
.stat .label { color: var(--ink-3); font-size: .78em; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }

/* ---------- Notices ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--info-soft); border-inline-start: 3px solid var(--ink-3); }
.alert.success { background: var(--buy-soft); color: var(--buy); border-color: var(--buy); }
.alert.error { background: var(--sell-soft); color: var(--sell); border-color: var(--sell); }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }

/* ---------- Progress / chat ---------- */
.steps { display: flex; gap: 4px; margin: 6px 0 18px; }
.steps div { flex: 1; height: 3px; background: var(--line); }
.steps div.on { background: var(--ink); }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: var(--radius); background: var(--sunk); }
.bubble.me { align-self: flex-end; background: var(--brass-soft); }
.bubble small { display: block; font-size: .74em; }

/* Order book */
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.book .lvl { display: flex; justify-content: space-between; padding: 4px 8px; font-family: var(--num); font-size: .92em; }
.book .bid .lvl { background: linear-gradient(to left, var(--buy-soft) var(--w, 0%), transparent 0); }
.book .ask .lvl { background: linear-gradient(to right, var(--sell-soft) var(--w, 0%), transparent 0); }

.sparkline { width: 100%; height: 36px; }
.sparkline path { fill: none; stroke: var(--brass); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.empty { text-align: center; color: var(--ink-3); padding: 34px 12px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.otp-input { letter-spacing: .5em; text-align: center !important; font-size: 1.5em; font-family: var(--num); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; }
dl.kv dt { color: var(--ink-3); } dl.kv dd { margin: 0; font-weight: 600; }

/* ---------- Auth (split screen) ---------- */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-side { background: var(--band); color: var(--band-ink); padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-side .brand { font-size: 1.15em; }
.auth-side h2 { font-size: 1.9em; line-height: 1.35; font-weight: 800; margin: 0 0 10px; max-width: 16em; }
.auth-side p { color: color-mix(in srgb, var(--band-ink) 65%, transparent); max-width: 30em; }
.auth-side .board td { border-color: color-mix(in srgb, var(--band-ink) 12%, transparent); }
.auth-side .board .age { color: color-mix(in srgb, var(--band-ink) 45%, transparent); }
.auth-side .rule { height: 1px; background: linear-gradient(to left, var(--brass-2), transparent); }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.7em; }
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-side { padding: 22px 20px; }
  .auth-side .hide-m { display: none; }
  .auth-side h2 { font-size: 1.25em; }
}

/* ---------- Admin ---------- */
.admin-side { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 26px; }
.admin-side nav { border-inline-end: 1px solid var(--line); padding-inline-end: 12px; align-self: start; position: sticky; top: 76px; }
.admin-side nav a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; color: var(--ink-2); text-decoration: none; border-inline-start: 2px solid transparent; }
.admin-side nav a.on, .admin-side nav a:hover { color: var(--ink); border-inline-start-color: var(--brass); background: var(--sunk); }
.admin-side nav .sep { border-top: 1px solid var(--line); margin: 8px 0; }
@media (max-width: 900px) { .admin-side { grid-template-columns: 1fr; } .admin-side nav { position: static; display: flex; overflow-x: auto; gap: 4px; border: 0; padding: 0; } .admin-side nav a { white-space: nowrap; } .admin-side nav .sep { display: none; } }

.hide-sm { }
@media (max-width: 560px) { .hide-sm { display: none; } }

/* ---------- Phones: tables become cards ---------- */
@media (max-width: 700px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px; margin-bottom: 10px; background: var(--surface); }
  .table.stack tbody tr:hover td { background: transparent; }
  .table.stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line-soft); text-align: end; }
  .table.stack td:last-child { border-bottom: 0; }
  .table.stack td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: .84em; text-align: start; font-family: var(--text); }
  .table.stack td.empty { display: block; text-align: center; }
  .card:has(> .table-wrap > .table.stack), .card:has(> .table.stack) { background: transparent; border: 0; padding: 0; }
  h1 { font-size: 1.3em; }
  .seg span { padding: 7px 11px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .board .age { display: none; }
  .board .px { font-size: 1.05em; }
  body.simple .board .px { font-size: 1.15em; }
  .board .chg { padding-inline-start: 8px; }
}
@media (pointer: coarse) { .btn.sm { min-height: 40px; } .check input { width: 22px; height: 22px; } }
@media print { .topbar, .ticker, .tabbar, .no-print { display: none !important; } body { background: #fff; } }
