:root {
  --bg: #f6f7f9; --card: #fff; --text: #1b1f24; --muted: #667085; --line: #e3e6ea;
  --accent: #1f6feb; --accent-text: #fff; --error: #b42318; --error-bg: #fef3f2; --ok-bg: #ecfdf3;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1116; --card: #171b22; --text: #e6e8eb; --muted: #98a2b3; --line: #2a303a;
          --accent: #4c8dff; --error: #ff8a80; --error-bg: #3a1a19; --ok-bg: #12301f; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.bar { position: sticky; top: 0; z-index: 50; background: var(--card); border-bottom: 1px solid var(--line);
       box-shadow: 0 1px 8px rgba(0, 0, 0, .06); }
.bar-in { display: flex; align-items: center; justify-content: center; gap: 1.5rem; max-width: 72rem; margin: 0 auto; padding: 0 1rem; min-height: 3.5rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em;
         text-decoration: none; color: var(--text); }
.logo { color: var(--accent); }
.menu { display: flex; align-items: center; justify-content: center; gap: 1.5rem; min-width: 0; }
.links { display: flex; align-items: center; gap: .15rem; }
.links a, .group-btn { padding: .4rem .75rem; border-radius: .5rem; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem; white-space: nowrap; }
.links a:hover, .group-btn:hover, .group.open .group-btn { color: var(--text); background: var(--bg); }
.links a.on, .group.on .group-btn { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }
.group { position: relative; }
.group-btn { background: none; border: 0; cursor: pointer; font: inherit; font-weight: 500; font-size: .95rem; min-height: 0; display: flex; align-items: center; gap: .35rem; }
.group-btn::after { content: ""; width: .4rem; height: .4rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.drop { display: none; position: absolute; top: 100%; left: 0; min-width: 12rem; padding: .35rem; margin-top: .25rem; background: var(--card);
        border: 1px solid var(--line); border-radius: .75rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); flex-direction: column; z-index: 60; }
.drop::before { content: ""; position: absolute; left: 0; right: 0; top: -.6rem; height: .6rem; }   /* keeps the menu open while the pointer crosses the gap */
.group.open .drop { display: flex; }
@media (hover: hover) and (min-width: 70.01rem) { .group:hover .drop { display: flex; } }
.drop a { display: block; }
.tools { display: flex; align-items: center; gap: .9rem; flex-shrink: 0; }
.narrow-form { max-width: 32rem; margin: 0 auto; }
.nav-search { margin: 0; }
.nav-search input { margin: 0; width: 11rem; padding: .4rem .75rem .4rem 2rem; font-size: .9rem; border-radius: 999px; border: 1px solid var(--line); color: var(--text);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat .65rem center; }
.lang { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-size: .8rem; white-space: nowrap; }
.lang a { padding: .2rem .6rem; text-decoration: none; color: var(--muted); }
.lang a.current { background: var(--bg); color: var(--text); font-weight: 700; }
.signout { background: none; color: var(--muted); border: 1px solid var(--line); min-height: 0; padding: .35rem .8rem; font-size: .85rem; border-radius: 999px; white-space: nowrap; }
.signout:hover { color: var(--text); background: var(--bg); }
.menu-btn { display: none; margin-left: auto; width: 2.5rem; min-height: 2.5rem; padding: 0; background: none; border: 1px solid var(--line); border-radius: .5rem; position: relative; }
.menu-btn span, .menu-btn span::before, .menu-btn span::after { position: absolute; left: .65rem; right: .65rem; height: 2px; background: var(--text); border-radius: 2px; content: ""; }
.menu-btn span { top: 50%; margin-top: -1px; } .menu-btn span::before { top: -6px; left: 0; right: 0; } .menu-btn span::after { top: 6px; left: 0; right: 0; }
@media (max-width: 70rem) {
  .bar-in { flex-wrap: wrap; gap: 0 1rem; }
  .menu-btn { display: block; }
  .menu { display: none; flex: 1 0 100%; flex-direction: column; align-items: stretch; gap: .75rem; padding: .5rem 0 1rem; }
  .bar.open .menu { display: flex; }
  .links { flex-direction: column; align-items: stretch; }
  .links a, .group-btn { padding: .6rem .75rem; font-size: 1rem; }
  .group-btn { width: 100%; justify-content: space-between; }
  .drop { position: static; box-shadow: none; border: 0; margin: 0 0 .25rem .75rem; padding: 0; min-width: 0; }
  .tools { flex-wrap: wrap; } .nav-search { flex: 1 0 100%; } .nav-search input { width: 100%; }
}
main { max-width: 56rem; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: .75rem; padding: 1rem 1.25rem;
        margin-bottom: 1rem; overflow-x: auto; }
.narrow { max-width: 26rem; margin: 2rem auto; }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; } h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
label { display: block; margin-bottom: .75rem; font-size: .9rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=date], select {
  display: block; width: 100%; margin-top: .25rem; padding: .65rem .75rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: .5rem; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; }
button { font: inherit; padding: .65rem 1.1rem; border: 0; border-radius: .5rem; cursor: pointer;
         background: var(--accent); color: var(--accent-text); min-height: 2.75rem; }
button.link { background: none; color: var(--accent); padding: 0; min-height: 0; }
form.inline { display: inline; margin: 0; }
.muted { color: var(--muted); }
.notice { padding: .65rem .9rem; border-radius: .5rem; background: var(--ok-bg); }
.notice.error { background: var(--error-bg); color: var(--error); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: .75rem 0; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
code { background: var(--bg); padding: .15rem .4rem; border-radius: .3rem; user-select: all; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.live { color: #16a34a; font-size: .65rem; vertical-align: middle; }
.pos { color: #16a34a; } .neg { color: #dc2626; }
.small { font-size: .85rem; }
.struck td { opacity: .5; text-decoration: line-through; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.head h1 { margin-bottom: .1rem; }
.rename-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: .5rem 0 .75rem; }
.rename-row h1 { margin: 0; }
.rename-row summary { cursor: pointer; }
.rename-row details[open] summary { display: inline; }
.price { margin: .25rem 0; } .price .big { font-size: 2rem; font-weight: 600; margin-right: .5rem; }
.search { display: flex; gap: .5rem; } .search input { margin: 0; flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .75rem; align-items: end; }
.grid label { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; margin-bottom: .5rem; }
.stats div { display: flex; flex-direction: column; } .stats b { font-size: 1.05rem; font-weight: 600; }
.row { display: flex; gap: .35rem; align-items: center; }
.row input[type=text] { margin: 0; padding: .35rem .5rem; width: 5.5rem; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.small { padding: .3rem .6rem; min-height: 0; font-size: .85rem; }
.controls { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: .5rem; }
.controls label.inline { margin: 0; display: flex; gap: .4rem; align-items: center; }
.controls select { width: auto; margin: 0; padding: .4rem .5rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: .5rem; overflow: hidden; }
.seg button { background: transparent; color: var(--text); border-radius: 0; min-height: 0; padding: .35rem .8rem; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.legend { min-height: 1.4rem; font-size: .85rem; font-variant-numeric: tabular-nums; }
#chart { width: 100%; height: 420px; }
@media (max-width: 40rem) { main { padding: .5rem; } .card { padding: .75rem; } #chart { height: 320px; } }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.dot.ok { background: #16a34a; } .dot.warn { background: #d97706; } .dot.bad { background: #dc2626; }
ul.plain { list-style: none; padding: 0; margin: .25rem 0; font-size: .85rem; font-variant-numeric: tabular-nums; }
a.button { display: inline-block; padding: .65rem 1.1rem; border-radius: .5rem; background: var(--accent); color: var(--accent-text); text-decoration: none; }
a.button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.cond { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.cond select { flex: 1 1 16rem; margin: 0; width: auto; }
.cond input.p1, .cond input.p2 { width: 6rem; margin: 0; }
.cond input[hidden] { display: none; }
.cond label.check { margin: 0; }
.chart { width: 100%; height: 340px; } .chart.short { height: 160px; }
details summary { cursor: pointer; margin: .5rem 0; }
[hidden] { display: none !important; }

.suggest { position: fixed; z-index: 1000; margin: 0; padding: .25rem 0; list-style: none; background: var(--card); color: var(--text);
           border: 1px solid var(--line); border-radius: .5rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); overflow-y: auto; max-height: 20rem; }
.suggest li { padding: .55rem .75rem; cursor: pointer; display: grid; grid-template-columns: minmax(6.5rem, max-content) 1fr; column-gap: .75rem; align-items: baseline; }
.suggest li[aria-selected=true], .suggest li:hover { background: var(--accent); color: var(--accent-text); }
.suggest .name { color: inherit; opacity: .75; font-size: .9rem; overflow-wrap: anywhere; }

/* stock page */
.quote-grid { display: grid; grid-template-columns: minmax(10rem, 1fr) 3fr; gap: 1rem 1.5rem; align-items: start; margin-top: .5rem; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem 1.25rem; }
.st { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .88rem; padding: .15rem 0;
      border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.st span { color: var(--muted); } .st b { font-weight: 500; text-align: right; }
.st small { color: var(--muted); font-size: .75rem; margin-left: .35rem; }
.pos-grid .st { flex-wrap: wrap; } .pos-grid .st b { font-size: 1rem; }
.book { margin-top: .75rem; } .book-head, .book-px { display: flex; justify-content: space-between; font-size: .85rem; }
.book-bar { display: flex; height: .3rem; border-radius: .2rem; overflow: hidden; margin: .25rem 0; background: var(--line); }
.book-bar i { display: block; } #bid-bar { background: #16a34a; } #ask-bar { background: #dc2626; }
.ma-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .35rem; }
.chip { background: transparent; color: var(--muted); border: 1px solid var(--line); min-height: 0; padding: .15rem .55rem; font-size: .78rem; border-radius: 1rem; }
.chip.on { color: var(--chip); border-color: var(--chip); }
@media (max-width: 40rem) { .quote-grid { grid-template-columns: 1fr; } .stats3 { grid-template-columns: repeat(2, 1fr); } }

/* order book */
.ob { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ob-side { margin: 0; font-variant-numeric: tabular-nums; }
.ob-side tbody tr { background: linear-gradient(to left, var(--bar) var(--w, 0%), transparent var(--w, 0%)); }
.ob-side.bids { --bar: rgba(22, 163, 74, .22); } .ob-side.asks { --bar: rgba(220, 38, 38, .22); }
.ob-side.asks tbody tr { background: linear-gradient(to right, var(--bar) var(--w, 0%), transparent var(--w, 0%)); }
.ob-side .px { font-weight: 600; } .bids .px { color: #16a34a; } .asks .px { color: #dc2626; }
.ob-side tr.flash td { animation: obflash .8s ease-out; }
@keyframes obflash { from { background: rgba(250, 204, 21, .45); } to { background: transparent; } }
#orderbook.no-orders .ob-orders { display: none; }
@media (max-width: 40rem) { .ob { gap: .5rem; } .ob-side th, .ob-side td { padding: .3rem .25rem; font-size: .82rem; } }
.ob-layout { display: grid; grid-template-columns: 3fr 2fr; gap: 1.25rem; align-items: start; }
.ob-ticks { margin: 0; font-variant-numeric: tabular-nums; }
.ob-ticks td { padding: .3rem .4rem; } .ob-ticks .vol { white-space: nowrap; }
.t-buy .vol { color: #16a34a; } .t-sell .vol { color: #dc2626; } .t-neutral .vol { color: var(--muted); }
.t-buy td:nth-child(2) { color: #16a34a; } .t-sell td:nth-child(2) { color: #dc2626; }
@media (max-width: 52rem) { .ob-layout { grid-template-columns: 1fr; } }

/* price header */
.sym { margin-right: .35rem; }
.price .big { font-size: 2.4rem; font-weight: 700; letter-spacing: -.01em; margin-right: .25rem; transition: background .6s; border-radius: .3rem; }
.price .big.tick { background: rgba(250, 204, 21, .35); transition: none; }
.price .arrow { font-size: 1.1rem; vertical-align: middle; }
.chg { margin: 0; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* markets */
.mk-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; } .mk-head h1 { margin: 0; font-size: 1.3rem; }
.mk-tabs a { padding: .35rem .8rem; text-decoration: none; color: var(--text); } .mk-tabs a.on { background: var(--accent); color: var(--accent-text); }
.mk-indices { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem; }
.mk-index .big { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-breadth { display: flex; height: .7rem; border-radius: .35rem; overflow: hidden; gap: 2px; margin-bottom: .5rem; }
.mk-breadth .up { background: #16a34a; } .mk-breadth .down { background: #dc2626; } .mk-breadth .flat { background: var(--line); }
a.mk-link { display: block; color: inherit; text-decoration: none; } a.mk-link:hover { outline: 2px solid var(--accent); }
.ms-title { margin: 0 auto 0 0; font-size: 1.3rem; }
.mk-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; } .mk-bar h2 { margin: 0 auto 0 0; }
.mk-map { position: relative; width: 100%; overflow: hidden; border-radius: .5rem; }
.mk-tile { position: absolute; box-sizing: border-box; border: 1px solid var(--card); padding: .3rem .4rem; overflow: hidden;
           color: var(--text); text-decoration: none; display: flex; flex-direction: column; font-size: .8rem; line-height: 1.2; }
.mk-tile b { font-weight: 600; } .mk-tile:hover { outline: 2px solid var(--accent); z-index: 1; }
.mk-movers { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; } .mk-movers .card { margin: 0; }
.mv td { padding: .3rem .4rem; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; }
th[data-sort] { cursor: pointer; }

/* retail gold */
table.gold th.grp { text-align: center; border-bottom: 0; } table.gold td.best { font-weight: 700; color: #16a34a; }
table.gold tr.stale { opacity: .65; }

/* commodities and currency */
.cm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; }
.cm-card { border: 1px solid var(--line); border-radius: .6rem; padding: .7rem .9rem; } .cm-card.stale { opacity: .6; }
.cm-card .big { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; } .small { font-size: .78rem; } .zh { margin-left: .25rem; }
.fx-list { list-style: none; margin: 0; padding: 0; }
.fx-list li { display: flex; align-items: center; gap: .6rem; padding: .55rem .2rem; border-bottom: 1px solid var(--line); background: var(--card); }
.fx-list li.drag { box-shadow: 0 4px 16px rgba(0,0,0,.3); position: relative; z-index: 1; }
.fx-list .grip { cursor: grab; touch-action: none; color: var(--muted); user-select: none; padding: .4rem .3rem; letter-spacing: -2px; }
.fx-list .flag { font-size: 1.7rem; line-height: 1; } .fx-list .cur { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.fx-list .cur b { font-size: 1.1rem; font-weight: 500; } .fx-list .cur small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-list input { width: 11rem; max-width: 45%; margin: 0; text-align: right; font-size: 1.4rem; font-variant-numeric: tabular-nums; border: 0; background: transparent; }
.fx-list input:focus { background: var(--bg); } .fx-list .rm { background: none; color: var(--muted); min-height: 0; padding: .2rem .5rem; font-size: 1.3rem; }
.fx-add { display: flex; gap: .5rem; margin-top: 1rem; } .fx-add input { margin: 0; flex: 1; }

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 1rem; }
.tabs a { padding: .5rem .9rem; border-radius: .5rem .5rem 0 0; color: var(--muted, inherit); text-decoration: none; border: 1px solid transparent; border-bottom: 0; }
.tabs a.on { color: var(--text); background: var(--card); border-color: var(--line); font-weight: 600; }
.tab-panel[hidden] { display: none; }
