/* ============ Let-Glow theme ============ */
:root {
    --primary: #d0621f;
    --primary-light: #ec8a45;
    --primary-dark: #a8420f;
    --brown: #7a2b0c;
    --brown-dark: #5a1d05;
    --text: #4a1606;
    --muted: #8b5a43;
    --cream: #fdf2e7;
    --peach: #fbe1cb;
    --card: #fff8f1;
    --border: #eaa678;
    --up: #1c9a52;
    --down: #d9381a;
    --radius: 14px;
    --bottom-h: 150px;
    --shadow: 0 3px 10px rgba(122, 43, 12, .12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { overscroll-behavior: none; overflow-x: hidden; }
.rate-row > *, .rate-head > * { min-width: 0; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text);
    background:
        radial-gradient(120% 60% at 0% 0%, #f9d9bd 0%, transparent 45%),
        radial-gradient(120% 60% at 100% 10%, #fbe3cf 0%, transparent 50%),
        var(--cream);
    background-attachment: fixed;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) calc(var(--bottom-h) + env(safe-area-inset-bottom, 0)) env(safe-area-inset-left, 0);
    -webkit-text-size-adjust: none;
    -webkit-user-select: none;
    user-select: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; }
a { color: var(--primary-dark); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid #f0a060; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.lg-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px 4px;
}
.lg-logo img { height: 92px; display: block; }
.icon-btn {
    width: 44px; height: 44px; border: 0; background: transparent; color: var(--brown);
    display: inline-flex; align-items: center; justify-content: center; border-radius: 12px;
    position: relative; cursor: pointer; padding: 0;
}
.icon-btn svg { width: 30px; height: 30px; stroke-width: 2.2; }
.lg-bell .dot { position: absolute; top: 7px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #e2412a; }

/* ---------- strips ---------- */
.lg-strip, .lg-ticker {
    display: flex; align-items: center; color: #fff; font-size: 14px; font-weight: 600;
    min-height: 34px;
}
.lg-strip { background: linear-gradient(90deg, #8a300c, #b3490f 50%, #8a300c); }
.lg-strip-left, .lg-ticker-left { flex: 0 0 auto; max-width: 46%; padding: 0 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-strip-sep { width: 1px; align-self: stretch; margin: 7px 0; background: rgba(255, 255, 255, .55); }
.marquee { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; padding: 0 12px; text-align: center; }
.marquee > span { display: inline-block; }
/* Ticker HTML from the API: keep everything on one line */
.marquee > span * {
    display: inline; margin: 0; padding: 0; white-space: nowrap; background: none;
    /* API HTML carries inline colours / sizes (e.g. dark blue 10px) that are unreadable on the strip */
    color: inherit !important; font-size: inherit !important; font-family: inherit !important;
}
.marquee > span br { display: none; }

/* Metal icons (gold / silver) */
.metal-icon { width: 20px; height: 20px; vertical-align: -4px; margin-right: 6px; flex: 0 0 auto; }
.fix-message { text-align: center; font-size: 15px; }
.marquee.scrolling { text-align: left; }
/* Text enters from the right edge and scrolls fully off the left, then repeats */
.marquee.scrolling > span { padding-left: 100%; animation: marquee 12s linear infinite; will-change: transform; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
/* Reduced-motion users: keep the marquee but slow it down */
@media (prefers-reduced-motion: reduce) { .marquee.scrolling > span { animation-duration: 30s !important; } }

/* ---------- page title bar ---------- */
.lg-titlebar {
    display: flex; align-items: center; gap: 6px; margin: 10px 12px 0;
    background: var(--peach); border-radius: 12px; padding: 2px 4px;
}
.lg-titlebar h1 { flex: 1; text-align: center; font-size: 17px; margin: 0; color: var(--brown); }
.lg-titlebar .spacer { width: 44px; }
.lg-titlebar .icon-btn svg { width: 24px; height: 24px; }

.page { padding: 4px 0 20px; }

/* ---------- spot card ---------- */
.spot-card {
    margin: 12px 12px 6px; border-radius: var(--radius); display: flex; color: #fff; overflow: hidden;
    background:
        radial-gradient(90% 120% at 20% 120%, rgba(255, 180, 120, .35), transparent 60%),
        linear-gradient(135deg, #a93e0e 0%, #db7331 50%, #9e360b 100%);
    box-shadow: 0 5px 14px rgba(150, 55, 12, .35);
    border: 1px solid rgba(255, 255, 255, .25);
}
.spot-card:empty { display: none; }
.spot { flex: 1 1 0; min-width: 0; text-align: center; padding: 10px 4px 12px; }
.spot + .spot { border-left: 1px solid rgba(255, 255, 255, .4); }
.spot-title { font-size: 13px; font-weight: 700; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-title .metal-icon { width: 16px; height: 16px; }
.spot-value { font-size: 22px; font-weight: 800; line-height: 1.3; margin: 2px 0; }
.spot-value b { display: inline-block; padding: 0 5px; border-radius: 6px; transition: background .2s; }
.spot-value.up b { background: var(--up); }
.spot-value.down b { background: var(--down); }
.spot-sub { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-sub .bid { color: #ffe3c8; }
.spot-sub .sep { margin: 0 6px; opacity: .7; }

/* ---------- category tabs ---------- */
.cat-tabs { display: flex; gap: 8px; margin: 10px 12px 0; justify-content: center; }
.cat-tabs button {
    flex: 1; border: 1.5px solid var(--border); background: var(--card); color: var(--brown);
    border-radius: 20px; padding: 6px 0; font-weight: 700; font-size: 13px; cursor: pointer;
}
.cat-tabs button[aria-selected="true"] { background: var(--brown); color: #fff; border-color: var(--brown); }

/* ---------- rate table ---------- */
.rate-head, .rate-row { display: grid; grid-template-columns: 1.45fr 1fr 1fr; align-items: center; }
.rate-head {
    margin: 12px 12px 6px; background: var(--peach); border-radius: 12px; padding: 4px;
    font-size: 16px; font-weight: 700; color: var(--brown);
}
.rate-head span { text-align: center; padding: 10px 4px; }
.rate-head .active {
    color: #fff; border-radius: 10px;
    background: linear-gradient(180deg, #ef8c48, #c9561a);
    box-shadow: 0 2px 6px rgba(160, 60, 15, .35);
}
.rate-row {
    margin: 10px 12px; padding: 16px 12px; border-radius: 12px; cursor: pointer; width: calc(100% - 24px);
    background: linear-gradient(180deg, #fffaf5, #fdeee1); border: 1.5px solid var(--border);
    box-shadow: var(--shadow); text-align: left; color: inherit; font: inherit;
}
.rate-row:active { transform: scale(.99); }
.rate-name { font-weight: 800; font-size: 14px; text-transform: uppercase; line-height: 1.3; overflow-wrap: anywhere; }
.rate-pos { display: block; font-size: 11px; font-weight: 700; color: var(--primary-dark); margin-top: 3px; text-transform: none; }
.rate-val { text-align: center; }
.rate-val b { display: inline-block; font-size: 24px; font-weight: 800; padding: 0 4px; border-radius: 6px; transition: background .2s, color .2s; }
.rate-val small { display: block; font-size: 11px; font-weight: 700; margin-top: 2px; }
.rate-val.up b { background: var(--up); color: #fff; }
.rate-val.down b { background: var(--down); color: #fff; }
/* Rate Alert: live bid / ask of the selected product (tappable) */
.alert-live { margin: 0 0 12px; padding: 8px; border-radius: 12px; border: 1.5px solid var(--border); background: linear-gradient(180deg, #fffaf5, #fdeee1); }
.alert-live-head, .alert-live-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: center; }
.alert-live-head { font-weight: 700; color: var(--brown); font-size: 14px; padding-bottom: 4px; }
.alert-live .state { padding: 14px; }
.rate-pick {
    border: 1px dashed transparent; background: none; font: inherit; color: inherit;
    padding: 6px 2px; border-radius: 10px; cursor: pointer; min-height: 44px;
}
.rate-pick:hover, .rate-pick:focus-visible { border-color: var(--border); background: rgba(236, 138, 69, .08); }
.rate-pick:active { transform: scale(.97); }
.alert-rates-hint { margin: 4px 0 0; text-align: center; }
.low { color: var(--down); }
.high { color: var(--up); }

/* ---------- floating contact ---------- */
.fab {
    position: fixed; bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom, 0)); z-index: 30;
    width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; background: linear-gradient(180deg, #e27a36, #a9400f);
    border: 4px solid #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}
.fab svg { width: 26px; height: 26px; }
.fab-left { left: 14px; }
.fab-right { right: 14px; }

/* ---------- bottom ---------- */
.lg-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding-bottom: env(safe-area-inset-bottom, 0); background: #5a1d05; }
.lg-wave {
    position: absolute; left: 0; right: 0; top: -22px; height: 30px; pointer-events: none;
    background: linear-gradient(90deg, #f4a468, #d86a26, #f4a468);
    border-radius: 60% 40% 0 0 / 100% 100% 0 0; opacity: .9;
}
.lg-ticker { position: relative; background: linear-gradient(90deg, #cf6425, #b24c14 50%, #cf6425); }
.lg-nav { display: grid; grid-template-columns: repeat(4, 1fr); background: linear-gradient(180deg, #a2410f, #7f2e09); }
.lg-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 8px;
    color: #fde6d4; text-decoration: none; font-size: 12px; font-weight: 600;
}
.lg-nav a.active { color: #fff; background: rgba(255, 255, 255, .1); }
.lg-nav svg { width: 24px; height: 24px; }
.lg-copy { text-align: center; color: #f3cfb4; font-size: 12px; padding: 5px 0; background: #5a1d05; }

/* ---------- drawer ---------- */
.lg-drawer-backdrop { position: fixed; inset: 0; background: rgba(40, 10, 0, .45); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.lg-drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.lg-drawer {
    position: fixed; top: 0; bottom: 0; left: 0; width: 82%; max-width: 320px; z-index: 61; overflow-y: auto;
    background: var(--cream); transform: translateX(-102%); transition: transform .25s; visibility: hidden;
    padding-top: env(safe-area-inset-top, 0);
}
.lg-drawer.open { transform: translateX(0); visibility: visible; }
.lg-drawer-head { position: relative; text-align: center; padding: 14px 10px 10px; background: var(--peach); }
.lg-drawer-head img { height: 80px; }
.lg-drawer-head p { margin: 4px 0 0; font-weight: 600; color: var(--brown); }
.lg-drawer-head .icon-btn { position: absolute; right: 6px; top: 6px; }
.lg-drawer ul { list-style: none; margin: 0; padding: 6px 0 0; }
.lg-drawer a {
    display: flex; align-items: center; justify-content: space-between; padding: 13px 18px;
    color: var(--text); text-decoration: none; font-weight: 600; border-bottom: 1px solid #f3d5bd;
}
.lg-drawer a svg { width: 18px; height: 18px; color: var(--primary); }
.lg-drawer a.active { background: linear-gradient(90deg, #f6c39d, transparent); color: var(--brown-dark); }
.lg-drawer a.danger { color: var(--down); }
.lg-version {
    margin: 0; padding: 14px 18px calc(18px + env(safe-area-inset-bottom, 0));
    text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--muted);
}

/* ---------- generic ---------- */
.card {
    margin: 10px 12px; padding: 14px; border-radius: 12px; background: var(--card);
    border: 1.5px solid var(--border); box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 8px; color: var(--brown); font-size: 16px; }
.card .meta { color: var(--muted); font-size: 12px; }
.card-link { display: block; text-decoration: none; color: inherit; }
.content-html { line-height: 1.55; overflow-wrap: anywhere; }
.content-html img { max-width: 100%; height: auto; }
.content-html table { width: 100%; border-collapse: collapse; }
.content-html td, .content-html th { border: 1px solid #efc7a8; padding: 6px; }

.state { text-align: center; padding: 40px 16px; color: var(--muted); font-weight: 600; }
.spinner {
    display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -4px;
    border: 3px solid #f2c9a8; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.list-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.list-item .title { font-weight: 800; text-transform: uppercase; }
.list-item .right { text-align: right; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin-top: 6px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; text-align: right; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 800; color: #fff; }
.badge.buy { background: var(--up); }
.badge.sell { background: var(--down); }
.badge.neutral { background: var(--muted); }
.row-actions { display: flex; gap: 8px; margin-top: 10px; }
.row-actions .btn { flex: 1; }

/* ---------- forms ---------- */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 5px; color: var(--brown); }
.form-control {
    width: 100%; padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--border);
    background: #fff; color: var(--text); font-size: 15px; min-height: 44px;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(208, 98, 31, .2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 0; cursor: pointer;
    font-weight: 800; font-size: 15px; text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-block { width: 100%; }
.btn-primary { color: #fff; background: linear-gradient(180deg, #ec8a45, #c3521a); box-shadow: 0 3px 8px rgba(160, 60, 15, .3); }
.btn-light { color: var(--brown); background: var(--peach); }
.btn-buy { color: #fff; background: linear-gradient(180deg, #2bb466, #168244); }
.btn-sell { color: #fff; background: linear-gradient(180deg, #ea5434, #bb2c10); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }

.segmented { display: flex; background: var(--peach); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.segmented button {
    flex: 1; border: 0; background: transparent; padding: 10px 4px; border-radius: 10px;
    font-weight: 700; color: var(--brown); cursor: pointer; font-size: 14px;
}
.segmented button[aria-selected="true"] { color: #fff; background: linear-gradient(180deg, #ef8c48, #c9561a); }

/* ---------- buy / sell ---------- */
.bidask { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bidask div { text-align: center; padding: 12px; border-radius: 12px; color: #fff; }
.bidask .b { background: linear-gradient(180deg, #2bb466, #168244); }
.bidask .a { background: linear-gradient(180deg, #ea5434, #bb2c10); }
.bidask span { display: block; font-size: 13px; font-weight: 600; opacity: .9; }
.bidask strong { font-size: 26px; }

/* ---------- gauge ---------- */
.gauge { display: block; margin: 0 auto; width: 220px; height: 130px; }
.gauge svg { width: 220px; height: 130px; }
.gauge .track { stroke: #f3d2b8; stroke-width: 18; }
.gauge .bar { stroke-width: 18; transition: stroke-dashoffset 1.2s ease-out; }
.gauge text { fill: var(--brown); stroke: none; font-weight: 800; }
.trend-result { text-align: center; font-size: 26px; font-weight: 900; margin: 4px 0 8px; }
.trend-result.buy { color: var(--up); }
.trend-result.sell { color: var(--down); }

/* ---------- chart ---------- */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-price { text-align: center; font-size: 30px; font-weight: 900; }
.chart-price.up { color: var(--up); }
.chart-price.down { color: var(--down); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid #f0cfb5; text-align: right; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { color: var(--brown); background: var(--peach); }
.table-scroll { overflow-x: auto; }

/* ---------- KYC docs ---------- */
.doc-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; }
.card h2 + .form-group, form.card h2:not(:first-child) { margin-top: 16px; }
.doc-item { border: 1px dashed var(--border); border-radius: 10px; padding: 10px; background: #fff; }
.doc-item .doc-title { font-weight: 700; margin-bottom: 6px; }
.doc-item img { max-width: 100%; max-height: 160px; display: block; margin: 6px 0; border-radius: 6px; }
.doc-item .doc-actions { display: flex; gap: 8px; align-items: center; }
.doc-item input[type=file] { flex: 1; min-width: 0; font-size: 12px; }

/* ---------- modal ---------- */
.lg-modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(40, 10, 0, .5); display: flex; align-items: center; justify-content: center; padding: 20px; }
.lg-modal { width: 100%; max-width: 380px; background: var(--cream); border-radius: 16px; padding: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); max-height: 85vh; overflow-y: auto; }
.lg-modal-title { margin: 0 0 10px; font-size: 18px; color: var(--brown); }
.lg-modal-body p { margin: 0 0 10px; line-height: 1.5; }
.lg-modal-actions { display: flex; gap: 10px; margin-top: 12px; }
.lg-modal-actions .btn { flex: 1; }

/* ---------- toast ---------- */
.lg-toast {
    position: fixed; left: 50%; bottom: calc(var(--bottom-h) + 24px); transform: translateX(-50%) translateY(20px);
    z-index: 100; max-width: 90%; padding: 12px 18px; border-radius: 12px; color: #fff; background: #3a1405;
    font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center;
}
.lg-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.lg-toast.success { background: #167a41; }
.lg-toast.error { background: #b52a10; }

iframe.embed { width: 100%; height: 70vh; border: 0; border-radius: 10px; background: #fff; }
