/* trading api — paper terminal theme.
   One stylesheet for the landing page, the dashboard, and the OAuth
   consent screen. No preprocessor, no build step. */

:root {
  color-scheme: light;
  --bg: #F5F4F0;
  --fg: #262622;
  --muted: #83827B;
  --border: #E4E2DB;
  --accent: #176B4A;          /* green — chart line, active states */
  --up: #3D8B5F;
  --down: #A23232;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  /* syntax highlighting for code blocks */
  --tk-str: #3D8B5F;
  --tk-key: #2F6F9F;
  --tk-num: #B0692B;
  --tk-flag: #176B4A;
  --tk-env: #8B5CF6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.6 "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
code, .mono { font-family: var(--mono); }
::selection { background: rgba(23,107,74,.20); }

h1, h2, p { margin-top: 0; }
h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; letter-spacing: -.01em; }

/* ---------- buttons ---------- */
button {
  border: 0; border-radius: 8px; padding: .65rem .9rem;
  font: 600 14px "Inter", system-ui, sans-serif;
  color: #fff; background: var(--fg); cursor: pointer;
}
button:hover { background: var(--accent); }
button:disabled { cursor: wait; opacity: .65; }
button.secondary {
  color: var(--fg); background: #fff; border: 1px solid var(--border);
}
button.secondary:hover { border-color: var(--muted); background: #fff; }
button.danger { background: var(--down); padding: .4rem .7rem; }
.button-link {
  display: inline-block; padding: .65rem .9rem; border-radius: 8px;
  background: var(--fg); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
}
.button-link:hover { background: var(--accent); }

/* ---------- forms ---------- */
label { display: block; margin-bottom: .35rem; font-weight: 600; font-size: 13.5px; }
input {
  width: 100%;
  border: 1px solid var(--border); border-radius: 8px;
  padding: .65rem .75rem; background: #fff; color: var(--fg);
  font: 500 14px var(--mono);
}
/* checkboxes/radios keep their natural size: at width:100% a nowrap label's
   content (box + text) overflows its card and widens the whole page, which
   makes mobile browsers zoom the page out to fit */
input[type="checkbox"], input[type="radio"] { width: auto; }
input:focus { outline: none; border-color: var(--accent); }
input:disabled { opacity: .4; }
form > button { margin-top: .8rem; }

.fieldrow { display: flex; gap: 10px; }
.fieldrow input { flex: 1; }
.fieldrow button { margin: 0; white-space: nowrap; }

/* ---------- shared bits ---------- */
.muted { color: var(--muted); }
.status, .error, .success { margin: .8rem 0 0; }
.status { color: var(--muted); }
.error { color: var(--down); }
.success { color: var(--up); }
.eyebrow {
  color: var(--accent); font: 600 11.5px var(--mono);
  letter-spacing: .1em; text-transform: uppercase; margin-bottom: .5rem;
}
.logo { font: 600 15px var(--mono); letter-spacing: -.01em; }
.logo b { color: var(--accent); font-weight: 600; }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 22px;
  box-shadow: 0 1px 2px rgba(38,38,34,.04), 0 12px 40px rgba(38,38,34,.06);
}

.address, .secret-once code {
  display: block; overflow-wrap: anywhere;
  padding: .75rem; border-radius: 8px; border: 1px solid var(--border);
  background: #F5F4F0; font-family: var(--mono); font-size: 12.5px;
}
.secret-once { margin: 1rem 0; padding: 1rem; border: 1px solid #E0B746; border-radius: 10px; background: #FFF9E9; }
.secret-once code { margin-top: .6rem; background: #fff; }
.confirm-box { margin: 1rem 0; padding: 1rem; border: 1px solid #E0B746; border-radius: 10px; background: #FFF9E9; }
.confirm-box code { margin: .6rem 0; background: #fff; }
.confirm-box button { margin-right: .6rem; }

.inline { display: grid; grid-template-columns: minmax(180px, 1fr) auto; align-items: end; gap: .6rem; max-width: 520px; }
.inline label { grid-column: 1 / -1; margin-bottom: -.3rem; }
.inline button { margin: 0; }

/* ---------- tables ---------- */
.table-wrap {
  margin-top: 1.1rem; overflow-x: auto;
  border: 1px solid var(--border); border-radius: 10px;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: .6rem .85rem; text-align: left; }
th {
  color: var(--muted); font: 500 11px var(--mono);
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
  background: #FBFAF7; border-bottom: 1px solid var(--border);
}
td { border-bottom: 1px solid #EFEDE7; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAF8F3; }
th.num, td.num {
  text-align: right; font-family: var(--mono); font-size: 12.5px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.nowrap { white-space: nowrap; }
code.trunc {
  display: inline-block; max-width: 170px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
td code { font-size: 12px; }

/* status + direction pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font: 600 11px var(--mono); letter-spacing: .01em; white-space: nowrap;
}
.p-ok, .p-long, .p-filled { color: #2E6B4F; background: #E7F0EA; }
.p-bad, .p-short, .p-rejected { color: #A04437; background: #F6E9E7; }
.p-warn, .p-pending { color: #8A6D1F; background: #FAF3DC; }
.p-neutral { color: var(--muted); background: #F0EFEA; }

/* secondary line under a cell's main value (e.g. rejection reason) */
.cell-sub { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }

/* market cell: icon + symbol */
.mkt { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.mkt img { width: 16px; height: 16px; display: block; object-fit: contain; }

/* compact row action button */
.rowbtn-cell { text-align: right; }
button.rowbtn {
  padding: .32rem .7rem; border-radius: 7px;
  border: 1px solid var(--border); background: #fff; color: var(--fg);
  font: 600 12px "Inter", system-ui, sans-serif;
}
button.rowbtn:hover { border-color: var(--muted); background: #fff; }
button.rowbtn-danger { color: var(--down); border-color: #E5C7C2; }
button.rowbtn-danger:hover { background: var(--down); border-color: var(--down); color: #fff; }

/* ---------- top bar (dashboard + OAuth) ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem max(1rem, calc((100% - 1150px) / 2));
  border-bottom: 1px solid var(--border);
}

/* ---------- dashboard grid + metrics ---------- */
.grid { width: min(1150px, calc(100% - 2rem)); margin: 2rem auto; display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1rem; align-items: start; }
.full { grid-column: 1 / -1; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin: 1rem 0 0; }
.metrics div { padding: .9rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: #F5F4F0; }
.metrics dt { color: var(--muted); font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.metrics dd { margin: .25rem 0 0; font: 600 1.35rem var(--mono); letter-spacing: -.02em; }

@media (max-width: 768px) {
  .grid { grid-template-columns: 1fr; margin-top: 1rem; }
  .full { grid-column: auto; }
  .metrics { grid-template-columns: 1fr; }

  /* 16px text controls stop iOS Safari zooming the page when a field is
     focused. Checkboxes and radios intentionally retain their native size. */
  body input:not([type="checkbox"]):not([type="radio"]),
  body select,
  body textarea { font-size: 16px; }
  .dash-page #terminal .trm-field input,
  .dash-page #terminal .trm-field select { font-size: 16px; }
  .dash-page .hs-px { font-size: 27px; }

  /* Reusable wide-data pattern: opted-in tables collapse into labelled cards;
     each cell's data-label becomes the caption shown beside its value. */
  .responsive-table { border: 0; }
  .responsive-table table, .responsive-table tbody { display: block; }
  .responsive-table thead { display: none; }
  .responsive-table tr {
    display: block; padding: .55rem .85rem;
    border: 1px solid var(--border); border-radius: 10px; background: #fff;
  }
  .responsive-table tr + tr { margin-top: 8px; }
  .responsive-table td {
    display: flex; flex-wrap: wrap; align-items: baseline;
    justify-content: space-between; gap: 4px 14px;
    padding: .22rem 0; border: 0;
  }
  .responsive-table td[data-label]::before {
    content: attr(data-label); flex: none;
    color: var(--muted); font: 500 11px var(--mono);
    text-transform: uppercase; letter-spacing: .05em;
  }
  /* unlabelled cells (empty states, row actions, the edit-limits row)
     take a full line of their own */
  .responsive-table td:not([data-label]) { display: block; }
  .responsive-table .cell-sub { flex-basis: 100%; text-align: right; }
  .dash-page button.rowbtn { padding: .5rem .9rem; }

  /* Compact demos can keep their visual density while exposing comfortable
     phone-sized hit areas. The ticker remains deliberately thinner. */
  body.landing button:not(.tkr-item):not(.fbo-revoke) { min-height: 40px; }
  body.landing .tkr-item { min-height: 36px; }
  body.landing .fbo-revoke { min-height: 32px; }
  body.landing nav a.cta {
    display: inline-flex; align-items: center; min-height: 40px;
  }
}

@media (max-width: 560px) {
  .inline { grid-template-columns: 1fr; }
}

/* ---------- dedicated cash deposit page ---------- */
.fund-page { min-height: 100vh; }
.fund-back {
  display: inline-flex; align-items: center; gap: 7px;
  padding: .42rem .8rem; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--fg); font-weight: 600; font-size: 13.5px; text-decoration: none;
}
.fund-back span { color: var(--accent); transition: transform .15s ease; }
.fund-back:hover { border-color: var(--muted); color: var(--fg); background: #fff; }
.fund-back:hover span { transform: translateX(-2px); }
.fund-shell { width: min(960px, calc(100% - 2rem)); margin: clamp(2rem, 7vh, 5.5rem) auto 3rem; }
.fund-card {
  display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(330px, .96fr);
  padding: 0; overflow: hidden; box-shadow: 0 1px 2px rgba(38,38,34,.04), 0 24px 70px rgba(38,38,34,.09);
}
.fund-copy { padding: clamp(2rem, 5vw, 3rem); }
.fund-copy .eyebrow { margin-bottom: .8rem; }
.fund-copy h1 { font-size: clamp(2rem, 4vw, 2.6rem); max-width: 12ch; }
.fund-lede { margin-top: 1rem; color: var(--muted); font-size: 16px; line-height: 1.7; max-width: 44ch; }

/* numbered steps joined by a hairline; the React checkout publishes
   data-fund-step on .fund-card to mark the active and completed steps */
.fund-steps { list-style: none; display: grid; gap: 1.1rem; margin-top: 2.2rem; }
.fund-steps li { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.fund-steps li:not(:last-child)::before {
  content: ""; position: absolute; left: 13.5px; top: 32px; bottom: -14px;
  width: 1px; background: var(--border);
}
.fund-steps li > span {
  position: relative; display: grid; place-items: center; width: 28px; height: 28px;
  border: 1px solid var(--border); border-radius: 50%; background: #fff;
  color: var(--muted); font: 600 11px var(--mono);
}
.fund-steps div { display: grid; gap: 1px; }
.fund-steps strong { font-size: 13.5px; }
.fund-steps small { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.fund-card[data-fund-step="1"] .fund-steps li[data-step="1"] > span,
.fund-card[data-fund-step="2"] .fund-steps li[data-step="2"] > span,
.fund-card[data-fund-step="3"] .fund-steps li[data-step="3"] > span {
  border-color: rgba(23,107,74,.45); color: var(--accent); background: rgba(23,107,74,.08);
  box-shadow: 0 0 0 3px rgba(23,107,74,.10);
}
.fund-card[data-fund-step="2"] .fund-steps li[data-step="1"] > span,
.fund-card[data-fund-step="3"] .fund-steps li[data-step="1"] > span,
.fund-card[data-fund-step="3"] .fund-steps li[data-step="2"] > span {
  border-color: var(--accent); background: var(--accent); color: #fff; font-size: 0;
}
.fund-card[data-fund-step="2"] .fund-steps li[data-step="1"] > span::after,
.fund-card[data-fund-step="3"] .fund-steps li[data-step="1"] > span::after,
.fund-card[data-fund-step="3"] .fund-steps li[data-step="2"] > span::after {
  content: "✓"; font-size: 12px;
}
.fund-card[data-fund-step="3"] .fund-steps li[data-step="1"]::before {
  background: rgba(23,107,74,.4);
}

/* checkout column: tinted panel holding the white checkout card (React) */
.fund-checkout {
  min-width: 0; min-height: 400px; padding: clamp(1.25rem, 3.5vw, 2rem);
  border-left: 1px solid var(--border); background: #F5F4F0;
  display: flex; align-items: center;
}
.fund-widget {
  width: 100%; padding: 20px;
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
  box-shadow: 0 1px 2px rgba(38,38,34,.04), 0 10px 30px rgba(38,38,34,.06);
}
.fund-label { color: var(--muted); font: 600 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.fund-amount-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.fund-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
button.fund-chip {
  padding: .5rem 0; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--fg); font: 600 13px var(--mono);
}
button.fund-chip:hover { border-color: var(--muted); background: #fff; }
button.fund-chip[aria-pressed="true"] { border-color: rgba(23,107,74,.45); background: rgba(23,107,74,.08); color: var(--accent); }
.fund-custom { position: relative; display: block; margin-top: 8px; }
.fund-custom span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font: 500 15px var(--mono); }
.fund-custom input { padding-left: 26px; font: 600 16px var(--mono); }
.fund-custom input[aria-invalid="true"] { border-color: #E5C7C2; }
.fund-hint { margin-top: 6px; color: var(--down); font-size: 12px; }
button.fund-buy { width: 100%; margin-top: 14px; padding: .85rem 1rem; background: var(--accent); font-size: 14.5px; }
button.fund-buy:hover { background: var(--accent); filter: brightness(1.06); }
button.fund-buy:disabled { filter: none; opacity: .55; }
.fund-provider-note { margin-top: .75rem; color: var(--muted); text-align: center; font-size: 11.5px; line-height: 1.5; }
.fund-alert { margin-top: 1rem; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; background: #fff; font-size: 12.5px; line-height: 1.55; }
.fund-alert-error { color: var(--down); border-color: #E5C7C2; background: #F9EFED; }
.fund-done { text-align: center; }
.fund-done-badge {
  display: grid; place-items: center; width: 44px; height: 44px; margin: 4px auto 12px;
  border: 1px solid rgba(23,107,74,.30); border-radius: 50%;
  background: rgba(23,107,74,.09); color: var(--accent); font-size: 19px;
}
.fund-done-title { display: block; font-size: 16.5px; letter-spacing: -.01em; }
.fund-done-message { margin: 8px auto 0; color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 32ch; }
a.fund-return {
  display: block; margin-top: 16px; padding: .78rem 1rem; border-radius: 8px;
  background: var(--fg); color: #fff; text-align: center; text-decoration: none; font-weight: 600; font-size: 14px;
}
a.fund-return:hover { background: var(--accent); }
button.fund-again {
  width: 100%; margin-top: 6px; padding: .45rem; border: 0; background: none;
  color: var(--muted); font: 600 13px "Inter", system-ui, sans-serif;
}
button.fund-again:hover { background: none; color: var(--accent); }
.fund-loading { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; color: var(--muted); font-size: 13px; }
.fund-loading i { width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: fund-spin .8s linear infinite; }
@keyframes fund-spin { to { transform: rotate(360deg); } }
.fund-footnote { max-width: 640px; margin: 1rem auto 0; color: var(--muted); text-align: center; font-size: 11.5px; line-height: 1.6; }

@media (max-width: 720px) {
  .fund-shell { margin-top: 1rem; }
  .fund-card { grid-template-columns: 1fr; }
  .fund-copy { padding-bottom: 1.6rem; }
  .fund-copy h1 { max-width: none; }
  .fund-checkout { min-height: 0; border-left: 0; border-top: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  .fund-loading i { animation: none; }
  .fund-back span { transition: none; }
}

/* ---------- OAuth consent screen ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 420px); }
.login-card form + form { margin-top: 1rem; }
.oauth-card { max-width: 42rem; }
.oauth-details { display: grid; gap: .75rem; margin: 1.25rem 0; }
.oauth-details div { display: grid; gap: .25rem; }
.oauth-details dd { margin: 0; overflow-wrap: anywhere; }
.oauth-actions { display: flex; gap: .75rem; margin-top: 1rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; }
.checkbox input { width: auto; }

/* ============================================================
   Landing page
   ============================================================ */

body.landing { padding-bottom: 64px; }

/* nav */
.landing nav {
  display: flex; align-items: center;
  padding: 26px 0 22px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.landing nav .logo {
  font: 600 15.5px var(--mono); letter-spacing: -.02em;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.landing nav .logo b {
  color: var(--accent); font-weight: 700;
  font-size: 17px; line-height: 1;
}
.landing nav .spacer { flex: 1; }
.landing nav a { color: var(--muted); text-decoration: none; font-size: 14px; margin-left: 26px; }
.landing nav a:hover { color: var(--fg); }
.landing nav a.cta {
  color: #fff; background: var(--fg); border-radius: 8px;
  padding: 8px 16px; font-weight: 500;
}
.landing nav a.cta:hover { background: var(--accent); }
@media (max-width: 640px) {
  .landing nav a { margin-left: 16px; }
  .landing nav a:not(.cta) { display: none; }
}

.kicker { font: 500 12.5px var(--mono); color: var(--accent); letter-spacing: .02em; }
.landing h1 {
  font-size: clamp(36px, 5.6vw, 54px); font-weight: 700;
  letter-spacing: -.035em; line-height: 1.08; margin: 14px 0 16px;
}
/* live values flash when the sim updates them */
.up   { color: var(--up); }
.down { color: var(--down); }
@keyframes ta-flash { 0% { background: rgba(23,107,74,.20); } 100% { background: transparent; } }
.flash { animation: ta-flash .7s ease-out; border-radius: 4px; }

/* sections */
.landing section { margin-top: 96px; scroll-margin-top: 24px; }
.landing h2 { font-size: 28px; font-weight: 700; letter-spacing: -.025em; margin-bottom: 8px; }
.sec-sub { color: var(--muted); margin-bottom: 30px; max-width: 56ch; }

/* sign-in */
.signin-card { max-width: 560px; }
.signin-card form + form { margin-top: 1rem; }

/* agent tabs */
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 12px 0; margin-bottom: 16px; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  border-radius: 8px; font: 500 13px var(--mono); padding: 6px 14px; color: var(--muted);
}
.tab:hover { color: var(--fg); background: rgba(38,38,34,.05); }
.tab.tab-active { background: rgba(23,107,74,.12); color: var(--accent); }

.code {
  display: block; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; font: 400 12px/1.75 var(--mono);
  white-space: pre; overflow-x: auto;
}

/* syntax tokens (hand-highlighted in the templates) */
.tk-cmd  { color: var(--fg); font-weight: 500; }
.tk-flag { color: var(--tk-flag); }
.tk-url  { color: var(--tk-key); }
.tk-str  { color: var(--tk-str); }
.tk-key  { color: var(--tk-key); }
.tk-num  { color: var(--tk-num); }
.tk-env  { color: var(--tk-env); }
.tk-kw   { color: var(--tk-env); }
.tk-punc { color: var(--fg); }
.tk-com  { color: var(--muted); font-style: italic; }

/* ---------- dashboard API terminal ---------- */
.api-error {
  margin: 0; padding: .7rem 1rem; border-radius: 10px;
  border: 1px solid #E5C7C2; background: #FDF6F5;
}
.endpoint {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 400;
  color: var(--muted); margin-left: 0.5rem;
}
/* The trade card reuses the landing page's hero (hs-*) and terminal (#terminal
   .trm-*) styles so the dashboard mirrors the marketing components exactly;
   only dashboard-specific glue lives here. */
#terminal .hs-ws { margin: 12px -22px 0; } /* bleed to the .card's 22px padding */
#terminal form { display: block; }
#terminal .trm-row { margin-top: 12px; }
#terminal .trm-sum { margin-top: 12px; }
#terminal .trm-place { margin-top: 12px; width: 100%; }
.trm-result { margin-top: 12px; }
.trm-result .trm-call {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: #FCFBF8;
}
.trm-result .trm-call .trace-head { border-bottom: 1px solid var(--border); background: #FBFAF7; }
.trm-result .trm-call .trace-detail { padding: 8px 12px 11px; }
.trm-result > .error { margin-top: 0; }
.pnl-up { color: var(--up); }
.pnl-down { color: var(--down); }
#terminal h2 .hs-ws-live { display: inline-flex; margin-left: 6px; font: 500 11px var(--mono); vertical-align: 2px; }
#terminal .hs-pricerow { align-items: center; flex-wrap: wrap; }
#terminal .hs-pricerow .hs-symicon { width: 20px; height: 20px; }
#terminal .hs-pricerow .hs-symicon[hidden] { display: none; }

/* ---------- trade chart panel ---------- */
#terminal .hs-spark {
  height: 172px; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 10px; background: #FCFBF8;
  overflow: hidden;
}
#terminal .hs-spark canvas { width: 100%; height: 100%; display: block; color: var(--accent); cursor: crosshair; }
@keyframes px-tick-up { 0% { color: var(--up); } 100% { color: inherit; } }
@keyframes px-tick-down { 0% { color: var(--down); } 100% { color: inherit; } }
.hs-px.tick-up { animation: px-tick-up .6s ease-out; }
.hs-px.tick-down { animation: px-tick-down .6s ease-out; }

/* ---------- account: tabbed deposit + withdraw ---------- */
.funds {
  display: grid; grid-template-columns: 1fr; gap: 14px;
  margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--border);
}
/* deposit/withdraw switch reads as the section heading */
.fund-tabs { display: flex; gap: 20px; padding: 0; margin: 0; border-bottom: 1px solid var(--border); }
.fund-tabs .tab {
  font: 600 15px "Inter", system-ui, sans-serif; letter-spacing: -.01em;
  color: var(--muted); padding: 2px 1px 9px; margin-bottom: -1px; border-radius: 0;
  box-shadow: inset 0 -2px 0 transparent;
}
.fund-tabs .tab:hover { color: var(--fg); background: none; }
.fund-tabs .tab.tab-active { color: var(--fg); background: none; box-shadow: inset 0 -2px 0 var(--accent); }
.fund-panel { min-width: 0; }
/* #withdrawals is display:contents: its two children (form, history) join the
   funds grid directly, so the history table spans the full card width while
   htmx keeps swapping #withdrawals as one unit */
#withdrawals { display: contents; }
.wd-form { min-width: 0; }
.wd-history { grid-column: 1 / -1; min-width: 0; margin-top: 2px; }
.wd-history-label {
  font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: 6px;
}
.wd-history .table-wrap { margin-top: 0; }
/* tab toggling */
.funds[data-tab="withdraw"] [data-fund-panel="deposit"] { display: none; }
.funds[data-tab="deposit"] .wd-form,
.funds[data-tab="deposit"] .wd-history { display: none; }
.fund-panel h3 { font-size: .95rem; margin-bottom: .45rem; }
.fund-note { font-size: 13px; margin-bottom: .7rem; }
.fund-actions { margin-top: .8rem; }
.fund-actions .fund-note { margin: .6rem 0 0; }
/* deposit method choice: cash (dedicated page) vs crypto (inline reveal) */
.deposit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.deposit-option {
  position: relative; display: grid; gap: 3px; padding: 12px 34px 12px 13px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  color: var(--fg); text-align: left; text-decoration: none; cursor: pointer;
}
button.deposit-option { font: 400 14px "Inter", system-ui, sans-serif; }
.deposit-option:hover { background: #fff; border-color: rgba(23,107,74,.45); }
.deposit-option-top { display: flex; align-items: center; gap: 8px; }
.deposit-option-top svg { width: 16px; height: 16px; flex: none; color: var(--accent); }
.deposit-option strong { font-size: 13.5px; font-weight: 600; }
.deposit-option small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.deposit-option-go { position: absolute; top: 13px; right: 13px; color: var(--muted); transition: transform .15s ease, color .15s ease; }
.deposit-option:hover .deposit-option-go { color: var(--accent); transform: translateX(2px); }
button.deposit-option[aria-expanded="true"] { border-color: rgba(23,107,74,.45); background: rgba(23,107,74,.05); }
button.deposit-option[aria-expanded="true"] .deposit-option-go { transform: rotate(90deg); color: var(--accent); }
.deposit-crypto { margin-top: 10px; }
.deposit-crypto .fund-note { margin-bottom: .5rem; }
@media (max-width: 520px) { .deposit-grid { grid-template-columns: 1fr; } }
.funds-foot { margin: 1.1rem 0 0; font-size: 12px; }
.addr-row { display: flex; gap: 8px; align-items: stretch; }
.addr-row .address {
  flex: 1; min-width: 0; display: flex; align-items: center;
  padding: .45rem .7rem; font-size: 12px;
}
.addr-row .rowbtn { flex: none; }
.fund-form > label { margin-top: .6rem; }
.fund-form > label:first-child { margin-top: 0; }
.fund-form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.fund-form-row label { margin-top: 0; }
.fund-form-row button { margin: 0; white-space: nowrap; }

/* ---------- request log ---------- */
.trace-shell { width: min(1150px, calc(100% - 2rem)); margin: 0 auto 2rem; }
.trace-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.trace-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border); background: #FBFAF7;
}
.trace-title { display: flex; align-items: baseline; gap: 10px; }
.trace-title h2 { font-size: 1rem; margin: 0; }
.trace-count {
  font: 600 11px var(--mono); color: var(--muted);
  background: #F0EFEA; border-radius: 999px; padding: 1px 9px;
}
.trace-actions { display: flex; gap: 6px; }
button.trace-btn {
  padding: .3rem .65rem; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; color: var(--muted); font: 600 11.5px "Inter", system-ui, sans-serif;
}
button.trace-btn:hover { color: var(--fg); border-color: var(--muted); background: #fff; }
button.trace-btn[aria-pressed="true"] { color: var(--accent); border-color: rgba(23,107,74,.4); background: rgba(23,107,74,.08); }
.trace { font-family: var(--mono); font-size: 12px; max-height: 26rem; overflow-y: auto; background: #fff; }
.trace-entry { border-bottom: 1px solid #EFEDE7; }
.trace-entry:last-child { border-bottom: none; }
.trace-entry.trace-open { background: #FCFBF8; }
.trace-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 12px; font: 400 12px var(--mono); color: var(--fg); text-align: left;
}
button.trace-head { border: 0; border-radius: 0; background: transparent; cursor: pointer; }
button.trace-head:hover { background: #FAF8F3; }
.trace-caret { flex: none; color: var(--muted); font-size: 8px; transition: transform .15s; }
.trace-entry.trace-open .trace-caret { transform: rotate(90deg); }
.trace-method { flex: none; font-weight: 700; font-size: 10px; padding: 1px 6px; border-radius: 5px; letter-spacing: .02em; }
.m-get { color: #2F6F9F; background: #E8F0F6; }
.m-post { color: #2E6B4F; background: #E7F0EA; }
.m-delete { color: #A04437; background: #F6E9E7; }
.m-other { color: var(--muted); background: #F0EFEA; }
.trace-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace-entry.trace-fail .trace-path { color: var(--down); }
.trace-status { flex: none; font-weight: 600; font-size: 10.5px; padding: 1px 8px; border-radius: 999px; }
.s-2 { color: #2E6B4F; background: #E7F0EA; }
.s-3 { color: var(--muted); background: #F0EFEA; }
.s-4 { color: #8A6D1F; background: #FAF3DC; }
.s-5, .s-err { color: #A04437; background: #F6E9E7; }
.trace-ms, .trace-time { flex: none; color: var(--muted); font-size: 11px; }
.trace-ms { margin-left: auto; }
.trace-detail { padding: 3px 12px 11px 34px; display: grid; gap: 3px; }
.trace-detail[hidden] { display: none; }
.trace-line { word-break: break-all; white-space: pre-wrap; line-height: 1.55; }
.trace-dim { color: var(--muted); }
.trace-err { color: var(--down); }
.trace-json {
  margin: 2px 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; max-height: 15rem; overflow: auto;
  font: 400 11.5px/1.6 var(--mono); white-space: pre;
}
.trace-empty { padding: 18px; color: var(--muted); text-align: center; }

/* re-open affordance, shown only when the log is hidden */
.trace-pill {
  display: none; position: fixed; right: 18px; bottom: 18px; z-index: 40;
  padding: .55rem .95rem; border-radius: 999px;
  background: var(--fg); color: #fff; font: 600 12.5px "Inter", system-ui, sans-serif;
  box-shadow: 0 8px 28px rgba(38,38,34,.28); align-items: baseline; gap: 6px;
}
.trace-pill b { color: #9FD6B8; font-family: var(--mono); }
.trace-pill:hover { background: var(--accent); }
body.trace-hidden .trace-shell { display: none; }
body.trace-hidden .trace-pill { display: inline-flex; }

/* wide screens: dock the log as an always-visible rail on the right */
@media (min-width: 1600px) {
  body:not(.trace-hidden) { padding-right: 400px; }
  body:not(.trace-hidden) .trace-shell { position: fixed; top: 57px; right: 0; bottom: 0; z-index: 30; width: 400px; margin: 0; }
  body:not(.trace-hidden) .trace-card { height: 100%; border-radius: 0; border: none; border-left: 1px solid var(--border); box-shadow: none; }
  body:not(.trace-hidden) .trace { max-height: none; flex: 1; }
}

@media (max-width: 760px) {
  .trace-detail { padding-left: 12px; }
  .trace-time { display: none; }
}
