/* memeperp MVP trading screen — tokens from design/DESIGN_SPEC.md (Figma "Warm palette") */
:root {
  --bg-page: #07080D;
  --bg-panel: #12141C;
  --border-panel: #1F2230;
  --bg-input: #0B0C12;
  --bg-control: #1B1E29;
  --border-control: #2A2F3B;
  --bg-row-selected: #30204E;
  --accent: #8E47EB;
  --accent-text: #BA88FC;
  --text-primary: #EEF1F6;
  --text-secondary: #A3A9B7;
  --text-muted: #697083;
  --long-fill: #228747;
  --long-text: #29A356;
  --short: #DF3428;
  --warning: #FFB547;
  --ui: 'Manrope', system-ui, sans-serif;
  --num: 'Funnel Sans', 'Manrope', system-ui, sans-serif;
  --gap: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-page); color: var(--text-primary);
  font: 600 13px/20px var(--ui); -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.num { font-family: var(--num); font-weight: 500; font-variant-numeric: tabular-nums; }
.lbl { color: var(--text-muted); font-weight: 600; }
.dim { color: var(--text-muted); }
.long, .pos { color: var(--long-text); }
.short, .neg { color: var(--short); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

.app { display: flex; flex-direction: column; height: 100vh; min-height: 760px; min-width: 1180px; padding: 0 var(--gap) var(--gap); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 24px; height: 56px; flex: none; padding: 0 8px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand-name { font: 800 16px/24px var(--ui); }
.nav { display: flex; gap: 4px; }
.nav-item { height: 32px; padding: 0 12px; border-radius: 8px; display: flex; align-items: center; color: var(--text-secondary); }
.nav-item.active { background: var(--bg-control); color: var(--text-primary); }
.nav-item[aria-disabled] { cursor: default; }
.search {
  margin-left: auto; width: 280px; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border-radius: 8px; background: var(--bg-panel); box-shadow: inset 0 0 0 1px var(--border-panel); color: var(--text-muted);
}
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text-primary); }
.search input::placeholder { color: var(--text-muted); }
.search kbd { font: 600 11px/16px var(--ui); padding: 0 6px; border-radius: 4px; background: var(--bg-control); color: var(--text-muted); }
.wallet-wrap { position: relative; }
.btn-accent {
  height: 36px; padding: 0 16px 0 6px; border-radius: 8px; background: var(--accent); color: #fff;
  font: 700 13px/20px var(--ui); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn-accent:hover { filter: brightness(1.08); }
.btn-accent:disabled { opacity: .5; cursor: default; }
.wallet-ico { width: 24px; height: 24px; border-radius: 6px; background: rgba(255,255,255,.16); display: grid; place-items: center; }
.menu {
  position: absolute; right: 0; top: 44px; z-index: 20; width: 280px; padding: 12px; border-radius: 12px;
  background: var(--bg-panel); box-shadow: inset 0 0 0 1px var(--border-panel), 0 12px 32px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 8px;
}
.menu-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; line-height: 16px; }
.menu-link { color: var(--accent-text); font-size: 12px; }
.btn-ghost {
  height: 32px; padding: 0 12px; border-radius: 8px; background: var(--bg-control); box-shadow: inset 0 0 0 1px var(--border-control);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-primary);
}
.btn-ghost:hover { background: #222634; }

/* ---------- layout ---------- */
.grid {
  flex: 1; min-height: 0; display: grid; gap: var(--gap);
  grid-template-columns: 288px minmax(0, 1fr) 344px;
  grid-template-rows: minmax(0, 1fr) 260px;
  grid-template-areas:
    "markets chart right"
    "markets tables right";
}
.right-col { grid-area: right; display: flex; flex-direction: column; gap: var(--gap); min-height: 0; overflow: auto; }
.right-col > .panel { flex: none; }
.panel { background: var(--bg-panel); border-radius: 12px; box-shadow: inset 0 0 0 1px var(--border-panel); min-height: 0; }
.markets { grid-area: markets; display: flex; flex-direction: column; overflow: hidden; }
.chart-panel { grid-area: chart; display: flex; flex-direction: column; overflow: hidden; }
.tables { grid-area: tables; display: flex; flex-direction: column; overflow: hidden; }
.order { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.account { padding: 12px; }
.risk { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- markets ---------- */
.markets-head { display: flex; align-items: center; justify-content: space-between; padding: 12px; }
.seg { display: flex; gap: 2px; }
.seg-item { height: 20px; padding: 0 8px; border-radius: 4px; font: 600 12px/16px var(--ui); color: var(--text-secondary); }
.seg-item.active { background: var(--bg-control); color: var(--text-primary); }
.icon-btn { width: 32px; height: 28px; border-radius: 8px; background: var(--bg-control); color: var(--text-secondary); cursor: default; }
.cols, .market-row { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; }
.cols { font: 700 11px/16px var(--ui); letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); height: 28px; }
.market-list { overflow: auto; flex: 1; }
.market-row { height: 48px; gap: 12px; cursor: pointer; }
.market-row:hover { background: var(--bg-control); }
.market-row.selected { background: var(--bg-row-selected); }
.market-row .left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.coin {
  position: relative; isolation: isolate; width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font: 800 12px/1 var(--ui); overflow: hidden;
}
.coin i { position: absolute; inset: 0; z-index: -1; }   /* per-ticker gradient */
.market-row .name { font: 700 13px/20px var(--ui); display: flex; align-items: center; gap: 6px; }
.market-row .vol { font: 600 12px/16px var(--ui); color: var(--text-muted); }
.market-row .right { text-align: right; }
.market-row .price { font: 500 13px/20px var(--num); }
.market-row .chg { font: 500 12px/16px var(--num); }
.badge-lev { height: 16px; padding: 0 4px; border-radius: 4px; background: var(--bg-row-selected); color: var(--accent-text); font: 700 11px/16px var(--ui); display: inline-flex; align-items: center; }
.badge-muted { height: 20px; padding: 0 6px; border-radius: 4px; background: var(--bg-control); color: var(--text-secondary); font: 600 11px/20px var(--ui); }
.badge-warn { height: 16px; padding: 0 4px; border-radius: 4px; background: rgba(255,181,71,.12); color: var(--warning); font: 700 11px/16px var(--ui); }
.empty { padding: 24px 12px; color: var(--text-muted); text-align: center; font-size: 12px; }

/* ---------- chart panel ---------- */
.chart-bar { display: flex; align-items: center; gap: 16px; height: 44px; padding: 0 12px; border-bottom: 1px solid var(--border-panel); flex: none; }
.ticker { display: flex; align-items: center; gap: 8px; }
.ticker .coin { width: 24px; height: 24px; font-size: 11px; }
.ticker-name { font: 700 13px/20px var(--ui); }
.tfs { display: flex; gap: 2px; }
.tfs button { height: 24px; padding: 0 8px; border-radius: 4px; font: 600 12px/16px var(--ui); color: var(--text-secondary); }
.tfs button.active { background: var(--bg-control); color: var(--text-primary); }
.sep { width: 1px; height: 16px; background: var(--border-control); }
.tool { display: flex; align-items: center; gap: 6px; font: 600 12px/16px var(--ui); color: var(--text-secondary); }
.tool.active { color: var(--text-primary); }
.stats { display: flex; align-items: center; gap: 24px; padding: 8px 12px; flex: none; }
.big { font: 500 20px/28px var(--num); min-width: 72px; }
.stat { display: flex; flex-direction: column; }
.stat .lbl { font: 600 11px/16px var(--ui); }
.stat .num { font: 500 13px/20px var(--num); white-space: nowrap; }
.ls { margin-left: auto; width: 140px; }
.ls-labels { display: flex; justify-content: space-between; font: 600 11px/16px var(--ui); }
.ls-bar { height: 4px; border-radius: 2px; background: var(--short); overflow: hidden; margin-top: 4px; }
.ls-bar i { display: block; height: 100%; width: 50%; background: var(--long-fill); }
.chart { flex: 1; min-height: 0; position: relative; }

/* ---------- tables ---------- */
.tabs { display: flex; gap: 20px; padding: 0 12px; height: 40px; flex: none; border-bottom: 1px solid var(--border-panel); }
.tab { height: 40px; color: var(--text-secondary); font: 600 13px/20px var(--ui); }
.tab.active { color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--accent); }
.tab .count { margin-left: 4px; color: var(--text-muted); }
.table-wrap { flex: 1; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  position: sticky; top: 0; background: var(--bg-panel); z-index: 1;
  font: 700 11px/16px var(--ui); letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted);
  text-align: left; padding: 8px 12px; white-space: nowrap;
}
td { padding: 4px 12px; font: 400 13px/20px var(--ui); white-space: nowrap; }
td.n { font: 500 13px/20px var(--num); }
td.t { font: 500 13px/20px var(--num); color: var(--text-muted); }
th.r, td.r { text-align: right; }
.pill { display: inline-block; min-width: 42px; height: 20px; padding: 0 8px; border-radius: 999px; text-align: center; font: 700 11px/20px var(--ui); background: var(--bg-row-selected); color: var(--accent-text); }
.pill.you { background: rgba(41,163,86,.14); color: var(--long-text); }
.tbl-empty { padding: 28px 12px; color: var(--text-muted); text-align: center; font-size: 12px; }
.link-btn { color: var(--accent-text); font: 700 12px/16px var(--ui); }

/* ---------- order form ---------- */
.order-head { display: flex; align-items: center; justify-content: space-between; }
.tabs-sm { display: flex; gap: 16px; }
.tab-sm { color: var(--text-secondary); font: 600 13px/20px var(--ui); }
.tab-sm.active { color: var(--text-primary); }
.dropdown { height: 24px; padding: 0 8px; border-radius: 4px; background: var(--bg-control); color: var(--text-secondary); font: 600 12px/16px var(--ui); display: inline-flex; align-items: center; gap: 4px; }
.row-kv, .kv { display: flex; align-items: center; justify-content: space-between; font: 600 12px/16px var(--ui); }
.row-kv .num, .kv .num { font: 500 12px/16px var(--num); color: var(--text-secondary); }
.stepper { display: flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px; border-radius: 6px; background: var(--bg-input); box-shadow: inset 0 0 0 1px var(--border-panel); }
.stepper button { width: 20px; color: var(--text-secondary); font: 600 14px/20px var(--ui); }
.stepper .num { font: 500 14px/20px var(--num); color: var(--text-primary); min-width: 34px; text-align: center; }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; background: transparent; margin: 0; --fill: 0%; }
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(var(--accent), var(--accent)) 0 / var(--fill) 100% no-repeat, var(--border-control); }
.slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border-control); }
.slider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: var(--text-primary); border: 3px solid var(--accent); }
.slider::-moz-range-thumb { width: 8px; height: 8px; border-radius: 50%; background: var(--text-primary); border: 3px solid var(--accent); }
.ticks { display: flex; justify-content: space-between; margin-top: -6px; font: 600 11px/16px var(--ui); color: var(--text-muted); }
.field { height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 8px; background: var(--bg-input); box-shadow: inset 0 0 0 1px var(--border-panel); }
.field:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }
.field input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font: 500 16px/24px var(--num); color: var(--text-primary); }
.field input::placeholder { color: var(--text-muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 700 13px/20px var(--ui); color: var(--text-primary); }
.usdt { width: 20px; height: 20px; border-radius: 50%; background: #26A17B; color: #fff; font: 700 12px/20px var(--ui); text-align: center; font-style: normal; }
.checks { display: flex; gap: 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font: 600 12px/16px var(--ui); color: var(--text-secondary); cursor: pointer; }
.check input { display: none; }
.check i { width: 14px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--border-control); background: var(--bg-input); }
.check input:checked + i { background: var(--accent); box-shadow: none; }
.check input:disabled + i { opacity: .5; }
.check:has(input:disabled) { cursor: default; opacity: .6; }
.buysell { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-buy, .btn-sell { height: 44px; border-radius: 8px; color: #fff; font: 700 14px/20px var(--ui); }
.btn-buy { background: var(--long-fill); }
.btn-sell { background: var(--short); }
.btn-buy:hover, .btn-sell:hover { filter: brightness(1.1); }
.btn-buy:disabled, .btn-sell:disabled { opacity: .45; cursor: default; filter: none; }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary .col { display: flex; flex-direction: column; gap: 4px; }
.summary .head { font: 700 12px/16px var(--ui); }
.preview { height: 36px; border-radius: 8px; background: var(--bg-input); display: flex; align-items: center; justify-content: center; font: 600 12px/16px var(--ui); color: var(--text-muted); padding: 0 12px; text-align: center; }

/* ---------- account / risk ---------- */
.two-btn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.btn-ctl { height: 36px; border-radius: 8px; background: var(--bg-control); box-shadow: inset 0 0 0 1px var(--border-control); font: 600 13px/20px var(--ui); }
.btn-ctl:hover { background: #222634; }
.acct { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acct .col { display: flex; flex-direction: column; gap: 4px; }
.sec { font: 700 11px/16px var(--ui); letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; }
.risk-title { font: 700 13px/20px var(--ui); display: flex; align-items: center; gap: 6px; }
.info { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--text-muted); color: var(--text-muted); font: 700 9px/14px var(--ui); text-align: center; cursor: help; }
.risk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bar { height: 4px; border-radius: 2px; background: var(--border-control); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; }
.bar .bl { background: var(--long-fill); }
.bar .bs { background: var(--short); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4,5,8,.72); display: grid; place-items: center; z-index: 50; }
.overlay[hidden] { display: none; }
.dlg { width: 420px; padding: 20px; border-radius: 12px; background: var(--bg-panel); box-shadow: inset 0 0 0 1px var(--border-panel); display: flex; flex-direction: column; gap: 12px; }
.dlg h2 { margin: 0; font: 700 16px/24px var(--ui); }
.dlg p { margin: 0; font: 600 12px/18px var(--ui); color: var(--text-secondary); }
.dlg pre { margin: 0; max-height: 220px; overflow: auto; padding: 8px; border-radius: 8px; background: var(--bg-input); font: 12px/16px ui-monospace, Menlo, monospace; color: var(--text-secondary); white-space: pre-wrap; }
.dlg-btns { display: flex; gap: 8px; }
.dlg-btns .btn-accent { padding: 0 16px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: 560px;
  padding: 10px 16px; border-radius: 8px; background: var(--bg-control); box-shadow: inset 0 0 0 1px var(--border-control), 0 8px 24px rgba(0,0,0,.5);
  font: 600 13px/20px var(--ui);
}
.toast.err { box-shadow: inset 0 0 0 1px var(--short), 0 8px 24px rgba(0,0,0,.5); }
.toast.ok { box-shadow: inset 0 0 0 1px var(--long-fill), 0 8px 24px rgba(0,0,0,.5); }

/* ---------- stand additions ---------- */
.spacer { margin-left: auto; }
.warn { color: var(--warning); }
.link-btn { cursor: pointer; }
.badge-new { height: 16px; padding: 0 4px; border-radius: 4px; background: rgba(41,163,86,.14); color: var(--long-text); font: 700 11px/16px var(--ui); }
.market-row .name { flex-wrap: nowrap; white-space: nowrap; }
.net-banner {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 70; padding: 6px 16px; border-radius: 0 0 8px 8px;
  background: rgba(223,52,40,.16); color: #ffb3ad; box-shadow: inset 0 0 0 1px rgba(223,52,40,.5); font: 600 12px/16px var(--ui);
}
.wallets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wallet-opt {
  height: 40px; border-radius: 8px; background: var(--bg-control); box-shadow: inset 0 0 0 1px var(--border-control);
  display: flex; align-items: center; gap: 10px; padding: 0 12px; font: 700 13px/20px var(--ui);
}
.wallet-opt i { width: 20px; height: 20px; border-radius: 6px; }
.wallet-opt.active { box-shadow: inset 0 0 0 1px var(--accent); background: var(--bg-row-selected); }
.menu a.btn-ghost { text-decoration: none; }
.chart-wrap { flex: 1; min-height: 0; position: relative; display: flex; }
.chart-state {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(18,20,28,.86); text-align: center; padding: 24px;
}
.state-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-control); display: grid; place-items: center; color: var(--text-secondary); font: 700 15px/1 var(--ui); }
.state-title { font: 700 15px/22px var(--ui); }
.state-text { max-width: 420px; color: var(--text-secondary); font: 600 12px/18px var(--ui); }
.market-table { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; overflow: hidden; }
.grid.expanded .chart-panel, .grid.expanded .tables { display: none; }
.mt-head { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--border-panel); }
.mt-name { display: flex; align-items: center; gap: 8px; }
.mt-name .coin { width: 24px; height: 24px; font-size: 11px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg-control); }
.spark { display: block; }

/* ---------- portfolio / create pages ---------- */
.page { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: var(--gap); }
.page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--gap); align-items: start; }
.card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { margin: 0; font: 700 15px/22px var(--ui); }
.card h3 { margin: 0; font: 700 13px/20px var(--ui); color: var(--text-secondary); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
.kpi { padding: 14px 16px; }
.kpi .lbl { display: block; font: 600 11px/16px var(--ui); }
.kpi .val { font: 500 22px/30px var(--num); }
.kpi .sub { font: 500 12px/16px var(--num); }
.empty-card { padding: 32px 16px; text-align: center; color: var(--text-muted); font: 600 13px/20px var(--ui); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label.fl { display: flex; flex-direction: column; gap: 6px; font: 600 12px/16px var(--ui); color: var(--text-secondary); }
.form .hint { font: 600 11px/16px var(--ui); color: var(--text-muted); }
.form .field input.txt { font: 600 15px/24px var(--ui); }
.scen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.scen button { height: 32px; border-radius: 8px; background: var(--bg-control); box-shadow: inset 0 0 0 1px var(--border-control); font: 600 12px/16px var(--ui); color: var(--text-secondary); }
.scen button.active { box-shadow: inset 0 0 0 1px var(--accent); color: var(--text-primary); background: var(--bg-row-selected); }
.steps { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.steps li { display: flex; gap: 10px; font: 600 12px/18px var(--ui); color: var(--text-secondary); }
.steps li b { width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--bg-control); display: grid; place-items: center; font: 700 11px/1 var(--ui); color: var(--accent-text); }
.launch-log { margin: 0; max-height: 220px; overflow: auto; padding: 8px; border-radius: 8px; background: var(--bg-input); font: 12px/16px ui-monospace, Menlo, monospace; color: var(--text-secondary); white-space: pre-wrap; }
