/* Customer app. Dark by default (traders read rates on black), light on request. Accent comes from the dealer. */
:root {
  --accent: #E2B13C;
  --bg: #0b0b0d;
  --surface: #141418;
  --surface2: #1c1c22;
  --line: #2a2a33;
  --text: #f5f3ee;
  --muted: #a7a39a;
  --accent-text: var(--accent);
  --up: #3fd47a;
  --dn: #ff6b6b;
  --up-bg: rgba(63, 212, 122, 0.2);
  --dn-bg: rgba(255, 107, 107, 0.2);
  --warn-bg: #3a2b05;
  --warn-text: #ffd36b;
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface2: #f0ede6;
  --line: #e2ddd2;
  --text: #17150f;
  --muted: #5d584d;
  --accent-text: color-mix(in srgb, var(--accent) 55%, #000);
  --up: #0f8a3c;
  --dn: #c62828;
  --up-bg: rgba(15, 138, 60, 0.14);
  --dn-bg: rgba(198, 40, 40, 0.14);
  --warn-bg: #fff3d1;
  --warn-text: #6b4a00;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); }
.boot { display: grid; place-items: center; min-height: 70vh; color: var(--muted); text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot-fail { padding: 48px 20px; text-align: center; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.logo { border-radius: 10px; flex: none; }
.brand { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.brand b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.2px; }
.brand small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.live i { background: var(--up); box-shadow: 0 0 0 0 var(--up); animation: pulse 2s infinite; }
.live.closed i { background: var(--muted); }
.live.delayed i, .live.reconnecting i, .live.connecting i { background: #f0b429; }
.live.offline i { background: var(--dn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(63, 212, 122, 0.6); } 70% { box-shadow: 0 0 0 7px rgba(63, 212, 122, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 212, 122, 0); } }

/* world prices */
.intl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 14px 4px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 7px 10px; text-align: center; transition: background-color 0.6s; }
.tile small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.4px; }
.tile b { font-size: 18px; font-variant-numeric: tabular-nums; }
.tile.up { animation: flashUp 1s; }
.tile.dn { animation: flashDn 1s; }

.ticker { overflow: hidden; white-space: nowrap; margin: 6px 14px 0; border-radius: 10px; background: var(--surface2); color: var(--accent-text); font-size: 14px; font-weight: 600; padding: 6px 0; }
.ticker span { display: inline-block; padding-left: 100%; animation: marquee 20s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .ticker span { animation: none; padding-left: 12px; white-space: normal; } }

.banner { margin: 10px 14px 0; padding: 9px 12px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }

/* tabs */
.tabs { display: flex; gap: 8px; padding: 12px 14px 4px; overflow-x: auto; scrollbar-width: none; }
.tab { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 16px; font-weight: 600; cursor: pointer; }
.tab.on { background: var(--accent); border-color: var(--accent); color: #111; }

/* rates */
.rates { margin: 8px 14px 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.rhead, .row { display: grid; grid-template-columns: 1.25fr 1fr 1fr; align-items: center; gap: 6px; padding: 0 12px; }
.rhead { padding-top: 8px; padding-bottom: 8px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.6px; background: var(--surface2); }
.rhead span:not(:first-child) { text-align: right; }
.row { width: 100%; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; min-height: 72px; padding-top: 10px; padding-bottom: 10px; cursor: pointer; }
.row:hover { background: var(--surface2); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nm { min-width: 0; }
.nm b { display: block; font-size: 15px; line-height: 1.25; }
.nm small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.px { display: flex; flex-direction: column; align-items: flex-end; }
.px.off .v { color: var(--muted); }
.v { font-size: clamp(20px, 6vw, 26px); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: 0.2px; border-radius: 6px; padding: 0 4px; margin-right: -4px; }
.px:last-child .v { color: var(--accent-text); }
.v.up { animation: flashUp 0.9s; }
.v.dn { animation: flashDn 0.9s; }
.v.up::after { content: " ▲"; font-size: 0.5em; color: var(--up); vertical-align: middle; }
.v.dn::after { content: " ▼"; font-size: 0.5em; color: var(--dn); vertical-align: middle; }
@keyframes flashUp { 0% { background: var(--up-bg); } 100% { background: transparent; } }
@keyframes flashDn { 0% { background: var(--dn-bg); } 100% { background: transparent; } }
.hl { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.fine { color: var(--muted); font-size: 12px; margin: 10px 14px; }
.fine.center { text-align: center; }

/* bottom nav */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr); max-width: 560px; margin: 0 auto; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav { border: 0; background: transparent; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.nav .ni { font-size: 19px; line-height: 1; }
.nav.on { color: var(--accent-text); }

/* sheets */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity 0.18s; }
.backdrop.in { opacity: 1; }
.backdrop.out { opacity: 0; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; border: 1px solid var(--line); border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); transform: translateY(24px); transition: transform 0.2s; }
.backdrop.in .sheet { transform: none; }
@media (min-width: 700px) { .backdrop { align-items: center; } .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); } }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; background: var(--surface); z-index: 1; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 18px; }
.sheet-body { padding: 0 16px 18px; }
.icon-btn { border: 0; background: var(--surface2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; }
.sub { color: var(--muted); margin: 0 0 10px; font-size: 13px; }
.pop-body { white-space: pre-wrap; font-size: 16px; }

/* booking */
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side { border: 2px solid var(--line); background: var(--surface2); border-radius: 14px; padding: 10px; text-align: left; cursor: pointer; }
.side small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.3px; }
.side b { font-size: 26px; font-variant-numeric: tabular-nums; }
.side.buy.on { border-color: var(--up); background: var(--up-bg); }
.side.sell.on { border-color: var(--dn); background: var(--dn-bg); }
.chart { width: 100%; height: 120px; display: block; margin-top: 12px; }
.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; }
.sbtn { border: 1px solid var(--line); background: var(--surface2); border-radius: 12px; font-size: 24px; cursor: pointer; }
input[type="text"], input[type="tel"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px; font-size: 17px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.qty { text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.limit { margin-top: 10px; font-size: 20px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface2); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.segs { display: flex; gap: 6px; margin-top: 12px; background: var(--surface2); border-radius: 12px; padding: 4px; }
.seg { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 10px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.top-segs { margin: 12px 14px 0; }
.amount { margin-top: 12px; font-size: 16px; font-weight: 700; }
.note { background: var(--surface2); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.err { color: var(--dn); font-weight: 600; margin: 10px 0 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface2); border-radius: 12px; padding: 11px 16px; font-weight: 700; cursor: pointer; text-decoration: none; color: var(--text); min-height: 46px; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; }
.btn.danger { color: var(--dn); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.buyc { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn.sellc { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.armed { box-shadow: 0 0 0 4px var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row-btns > * { flex: 1 1 auto; }
.link-btn { display: block; border: 0; background: none; color: var(--accent-text); padding: 10px 0 0; cursor: pointer; text-decoration: underline; font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.form { display: block; }

/* lists and cards */
.list { margin: 4px 0 0; }
.sec { margin: 18px 14px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.card { display: block; width: calc(100% - 28px); margin: 10px 14px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-align: left; }
.card p { margin: 6px 0 0; }
.card.click { cursor: pointer; }
.card.cancelled { opacity: 0.6; }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-top b { flex: 1; min-width: 0; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; letter-spacing: 0.4px; }
.badge.b { background: var(--up-bg); color: var(--up); }
.badge.s { background: var(--dn-bg); color: var(--dn); }
.empty { text-align: center; color: var(--muted); padding: 28px 14px; }
.dealer { display: flex; gap: 12px; align-items: flex-start; }
.dealer img { border-radius: 12px; }
.line-link { display: block; padding: 8px 0; font-weight: 600; text-decoration: none; font-size: 16px; }
.copyrow { display: grid; grid-template-columns: 80px 1fr auto; align-items: center; gap: 8px; margin-top: 8px; }
.copyrow b { font-variant-numeric: tabular-nums; word-break: break-all; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 14px 0; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); font-size: 14px; text-align: center; }
.tool span { font-size: 24px; }
.setrow { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.setrow > span { flex: 1; }
.setrow .segs { margin: 0; flex: 1.4; }
.credit { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 14px 0; }
.slip { text-align: center; }
.slip .tick { width: 56px; height: 56px; border-radius: 50%; margin: 4px auto 10px; background: var(--up-bg); color: var(--up); display: grid; place-items: center; font-size: 30px; font-weight: 800; }
.slip dl, .calc-out { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; text-align: left; margin: 0; }
.slip dt, .calc-out dt { color: var(--muted); }
.slip dd, .calc-out dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.calc-out { margin-top: 14px; background: var(--surface2); border-radius: 12px; padding: 12px; }
.calc-out .total { font-size: 18px; color: var(--accent-text); }
.share-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.reg-done { font-size: 16px; }

/* toasts */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 14px; }
.toast { max-width: 520px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); transition: opacity 0.35s, transform 0.35s; }
.toast.ok { background: #16a34a; color: #fff; }
.toast.error { background: #dc2626; color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

@media (prefers-reduced-motion: reduce) {
  .v.up, .v.dn, .tile.up, .tile.dn { animation-duration: 0.01s; }
  .live.live i { animation: none; }
}
