:root {
  --bg: #0f1a2b;          /* deep river ink */
  --panel: #15233a;
  --panel-2: #1b2c48;
  --line: #243a5c;
  --grid: rgba(36, 58, 92, .55);
  --text: #e3e9f2;
  --muted: #8a9bb6;
  --up: #2fb596;
  --up-soft: rgba(47, 181, 150, .35);
  --down: #e5626c;
  --down-soft: rgba(229, 98, 108, .35);
  --brass: #d8a442;       /* primary actions */
  --radius-s: 6px;
  --radius-l: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-family: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif; font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; line-height: 1.15; }
h2 { font-size: 1.05rem; margin-top: 1.6em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.up { color: var(--up); }
.down { color: var(--down); }
.r { text-align: right; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .8rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 600; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.mark { width: 22px; height: 14px; border-radius: 0 0 11px 11px; background: linear-gradient(var(--up) 0 50%, var(--down) 50%); }
.top nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.top nav a { color: var(--text); }
.top nav a.quiet { color: var(--muted); }

main { max-width: 1080px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 3rem; }
main.wide { max-width: 1440px; }
.intro { margin-bottom: 1.2rem; }
.intro p { margin: 0; }

.foot { border-top: 1px solid var(--line); padding: 1.2rem clamp(1rem, 3vw, 2rem); color: var(--muted); font-size: .82rem; }
.foot p { max-width: 70ch; margin: 0; }

/* ---------- Controls ---------- */
.btn {
  display: inline-block; border: 0; cursor: pointer;
  background: var(--brass); color: #1a1405;
  font: inherit; font-weight: 600;
  padding: .7rem 1.1rem; border-radius: var(--radius-s);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.small { padding: .4rem .75rem; font-size: .88rem; }
.btn.buy { background: var(--up); color: #04231b; }
.btn.sell { background: var(--down); color: #2b0508; }
.link { background: none; border: 0; color: var(--brass); font: inherit; cursor: pointer; padding: 0; }

label { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .6rem .7rem; width: 100%;
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus, textarea:focus { border-color: var(--brass); outline: none; }
.stack { display: grid; gap: .8rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline input { width: 12rem; padding: .4rem .6rem; font-size: .9rem; }

.flash { padding: .75rem 1rem; border-radius: var(--radius-s); margin-bottom: 1rem; border-left: 3px solid var(--up); background: var(--panel); }
.flash.err { border-color: var(--down); }
.flash.warn { border-color: var(--brass); }
.empty { padding: 1.6rem; border: 1px dashed var(--line); border-radius: var(--radius-l); color: var(--muted); text-align: center; }

.tag { font-size: .78rem; padding: .15rem .5rem; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.tag.approved, .tag.paid, .tag.filled, .tag.active { color: var(--up); }
.tag.rejected, .tag.cancelled, .tag.halted { color: var(--down); }
.tag.pending, .tag.partial, .tag.open { color: var(--brass); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-l); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); font-size: .82rem; text-align: left; background: var(--panel); }
th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
.markets tbody tr { cursor: pointer; }
.markets tbody tr:hover { background: var(--panel); }
.pair { color: var(--text); font-size: 1.05rem; }
.pair span { color: var(--muted); }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 1rem; min-width: 0; }
.panel h2 { margin: 0; font-size: .95rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.two h2 { margin: 0; }
.narrow { max-width: 720px; margin-top: 1.6rem; }
.auth { max-width: 420px; margin: 2rem auto; }

/* ---------- Ticker ---------- */
.ticker {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: .6rem 2rem;
  padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line);
}
.pairname h1 { margin: 0; font-size: 1.6rem; }
.pairname h1 span { color: var(--muted); font-weight: 500; }
.pairname p { margin: 0; }
.lastbox { display: flex; flex-direction: column; }
.last { font-size: 2.1rem; font-weight: 600; line-height: 1.05; letter-spacing: -.02em; }
.stats { display: flex; flex-wrap: wrap; gap: .4rem 1.8rem; margin: 0; }
.stats dt { color: var(--muted); font-size: .78rem; }
.stats dd { margin: 0; font-weight: 500; }
.stats .band dd { color: var(--brass); }
.wide-stats { margin-bottom: 1rem; padding: 1rem; background: var(--panel); border-radius: var(--radius-l); }

/* ---------- Market grid ---------- */
.mk {
  display: grid; gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 290px 300px;
  grid-template-areas:
    "chart book trade"
    "orders book trades";
}
.chart-panel { grid-area: chart; }
.book { grid-area: book; }
.trade { grid-area: trade; }
.trades { grid-area: trades; }
.myorders { grid-area: orders; }

#chart { position: relative; height: 430px; }
.empty-chart { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); text-align: center; padding: 2rem; z-index: 2; pointer-events: none; }
.tfs { display: flex; gap: .2rem; }
.tfs button, .pcts button {
  background: none; border: 1px solid transparent; color: var(--muted);
  font: inherit; font-size: .85rem; padding: .25rem .55rem; border-radius: var(--radius-s); cursor: pointer;
}
.tfs button.on { color: var(--text); border-color: var(--line); background: var(--panel-2); }

.rowhead, .lvl, .tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem; font-size: .84rem; }
.rowhead { color: var(--muted); font-size: .76rem; padding: 0 .4rem .35rem; }
.rowhead span:not(:first-child), .lvl span:not(:first-child), .tr span:not(:first-child) { text-align: right; }
.lvl {
  width: 100%; border: 0; background: none; color: var(--text); font: inherit; font-size: .84rem;
  padding: .2rem .4rem; cursor: pointer; position: relative; text-align: left;
}
.lvl::before { content: ""; position: absolute; top: 1px; bottom: 1px; right: 0; width: var(--w); opacity: .16; border-radius: 3px; }
.lvl.ask::before { background: var(--down); }
.lvl.bid::before { background: var(--up); }
.lvl.ask .p { color: var(--down); }
.lvl.bid .p { color: var(--up); }
.lvl:hover { background: var(--panel-2); }
.lvl span { position: relative; }
.spread { text-align: center; color: var(--muted); font-size: .82rem; padding: .5rem 0; margin: .3rem 0; border-block: 1px solid var(--line); }
.tr { padding: .2rem .4rem; }
#trades { max-height: 360px; overflow-y: auto; }
.pad { padding: .5rem .4rem; margin: 0; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: var(--radius-s); padding: 3px; margin-bottom: .9rem; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: .5rem; border-radius: 4px; cursor: pointer; }
.tabs button.on.buy { background: var(--up); color: #04231b; }
.tabs button.on.sell { background: var(--down); color: #2b0508; }
.pcts { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; }
.pcts button { border-color: var(--line); }
.pcts button:hover { color: var(--text); }
.total { margin: 0; color: var(--muted); font-size: .9rem; }
.total span { color: var(--text); font-weight: 600; }
.trade .btn { width: 100%; padding: .85rem; }
.formmsg { margin: 0; font-size: .88rem; min-height: 1.3em; }
.formmsg.ok { color: var(--up); }
.formmsg.err { color: var(--down); }
.myorders td, .myorders th { padding: .5rem .7rem; font-size: .88rem; }
.myorders .table-wrap { border: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .mk { grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "chart chart" "book trade" "trades trade" "orders orders"; }
}
@media (max-width: 720px) {
  .mk { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chart" "trade" "book" "trades" "orders"; }
  .ticker { grid-template-columns: 1fr auto; }
  .stats { grid-column: 1 / -1; }
  #chart { height: 320px; }
  .hide-s { display: none; }
  th, td { padding: .6rem .6rem; }
  .last { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Order types, margin, positions ---------- */
.mode { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; margin-bottom: .7rem; }
.mode button {
  background: none; border: 1px solid var(--line); color: var(--muted); font: inherit; font-weight: 600;
  padding: .45rem; border-radius: var(--radius-s); cursor: pointer;
}
.mode button span { font-weight: 400; font-size: .78rem; }
.mode button.on { color: var(--brass); border-color: var(--brass); }
.otypes { display: flex; gap: 1rem; border-bottom: 1px solid var(--line); }
.otypes button, .subtabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  font: inherit; font-size: .9rem; font-weight: 500; padding: .35rem 0; margin-bottom: -1px; cursor: pointer;
}
.otypes button.on, .subtabs button.on { color: var(--text); border-bottom-color: var(--brass); }
.subtabs { display: flex; gap: 1.2rem; }
.count { color: var(--brass); font-variant-numeric: tabular-nums; }
.lev { display: grid; grid-template-columns: repeat(auto-fit, minmax(3rem, 1fr)); gap: .3rem; }
.lev button {
  background: var(--bg); border: 1px solid var(--line); color: var(--muted); font: inherit; font-weight: 600;
  padding: .4rem 0; border-radius: var(--radius-s); cursor: pointer;
}
.lev button.on { background: var(--brass); border-color: var(--brass); color: #1a1405; }
.mkt-note { margin: 0; }
.summary { margin: 0; display: grid; gap: .3rem; font-size: .88rem; }
.summary:empty { display: none; }
.summary div { display: flex; justify-content: space-between; gap: .5rem; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; }
.ack { display: flex; gap: .5rem; align-items: flex-start; font-size: .82rem; line-height: 1.4; }
.ack input { width: auto; margin-top: .15rem; }
.pos-actions { white-space: nowrap; }
.pos-actions details { display: inline-block; margin-left: .7rem; }
.pos-actions summary { color: var(--brass); font-size: .88rem; }
.pos-actions .inline { margin-top: .4rem; }
.pos-actions input { width: 6.5rem; padding: .35rem .5rem; font-size: .88rem; }
[hidden] { display: none !important; }
input.short { width: 5.5rem; padding: .35rem .5rem; }
td select { width: auto; padding: .35rem .5rem; }

/* ---------- Account, notifications, market maker, prose ---------- */
.mm-badge { font-style: normal; font-size: .62rem; font-weight: 600; letter-spacing: .02em; color: var(--brass); border: 1px solid var(--brass); border-radius: 3px; padding: 0 .2rem; margin-right: .3rem; vertical-align: 1px; }
.book-note { margin: .6rem .4rem 0; }
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; align-items: start; }
.acct-grid h2 { margin: 0; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.checklist li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-s); }
.checklist li strong { font-weight: 500; }
.checklist li.done { border-color: var(--up); }
.checklist li.done strong { color: var(--up); }
.codes { columns: 2; font-size: 1.05rem; margin: 0; padding-left: 1.4rem; }
.qr { width: 200px; max-width: 100%; background: #fff; border-radius: var(--radius-s); line-height: 0; }
.qr svg { width: 100%; height: auto; }
code { background: var(--bg); padding: .1rem .35rem; border-radius: 4px; font-size: .9em; word-break: break-all; }
.notes { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius-l); }
.notes li { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.notes li:last-child { border-bottom: 0; }
.notes li p { margin: .2rem 0 0; }
.notes li.unread { background: var(--panel); box-shadow: inset 3px 0 0 var(--brass); }
.notes time { white-space: nowrap; }
.bell { position: relative; }
.bell .dot { position: absolute; top: -.35rem; right: -.7rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem; border-radius: 99px; background: var(--down); color: #fff; font-size: .68rem; font-weight: 600; display: grid; place-items: center; }
.verify-bar { background: var(--panel-2); border-bottom: 1px solid var(--line); padding: .55rem clamp(1rem, 3vw, 2rem); font-size: .9rem; }
.alert-form { flex-wrap: wrap; gap: .8rem; }
.alert-form input:not(.short) { width: 12rem; }
.kyc-card { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 1.2rem; margin-bottom: 1rem; }
.kyc-docs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; }
.kyc-docs figure { margin: 0; }
.kyc-docs img { width: 100%; height: 190px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--line); }
.kyc-docs figcaption { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.prose { max-width: 68ch; }
.prose h2 { margin-top: 1.8em; }
.prose p { line-height: 1.65; }
.secret-box { padding: 1rem; border: 1px dashed var(--brass); border-radius: var(--radius-s); background: var(--bg); display: grid; gap: .4rem; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .8rem 1rem; overflow-x: auto; font-size: .85rem; line-height: 1.5; }
@media (max-width: 720px) { .kyc-card { grid-template-columns: 1fr; } }
.demo-banner { margin: -.5rem 0 1rem; padding: .7rem 1rem; border-radius: var(--radius-s); background: repeating-linear-gradient(135deg, var(--panel) 0 14px, var(--panel-2) 14px 28px); border: 1px solid var(--brass); }
.demo-banner strong { color: var(--brass); }
.demo-coins { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.demo-coins a { color: var(--muted); padding: .4rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-s); }
.demo-coins a span { font-size: .8rem; }
.demo-coins a.on { color: var(--text); border-color: var(--brass); }
.demo-coins a:hover { text-decoration: none; color: var(--text); }
.demo-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "chart trade" "chart wallet"; }
.demo-grid .chart-panel { grid-area: chart; }
.demo-grid .trade { grid-area: trade; }
.demo-wallet { grid-area: wallet; }
.demo-wallet h2 { margin: 0; }
.demo-wallet h2.sub { margin: 1rem 0 .5rem; font-size: .9rem; }
.demo-value { margin: 0 0 .7rem; }
.demo-value strong { font-size: 1.3rem; }
.demo-wallet td, .demo-wallet th { padding: .45rem .6rem; font-size: .85rem; }
#d-last { transition: color .3s; }
@media (max-width: 900px) { .demo-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chart" "trade" "wallet"; } }
@media print {
  .top, .foot, .no-print, .verify-bar { display: none !important; }
  body { background: #fff; color: #000; }
  .table-wrap, th, td, .wide-stats { border-color: #bbb !important; background: #fff !important; color: #000 !important; }
  .up, .down, .muted { color: #000 !important; }
}
.checklist li.done strong a { color: var(--up); }
input.code-in { width: 9rem; padding: .4rem .6rem; letter-spacing: .08em; }
