:root {
  --bg: #f4ecd8;
  --bg-2: #efe6d0;
  --panel: #faf6ed;
  --line: #d4cbba;
  --line-soft: #2a252014;
  --ink: #2a2520;
  --ink-2: #5f564b;
  --muted: #7a7060;
  --muted-2: #998c76;
  --accent: #8b2020;
  --ok: #1f6b3a;
  --ok-soft: #1f6b3a14;
  --down: #8b2020;
  --down-soft: #8b202012;
  --btn: #163226;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.4 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; overflow: hidden; }

button, input, select { font: inherit; color: inherit; }

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 46px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #f3ead6;
}

.brand svg { height: 26px; width: auto; display: block; }
.brand { text-decoration: none; flex: none; }

.nav { display: flex; align-items: stretch; gap: 2px; flex: 1; min-width: 0; }
.nav a, .more-btn {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 12px 10px 10px;
  font: 600 12.5px Inter, system-ui, sans-serif;
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover, .more-btn:hover, .nav a.on, .more-btn.on {
  color: var(--ink);
}
.nav a.on { border-bottom-color: var(--ink); }

.more-wrap { position: relative; }
.more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  z-index: 40;
  box-shadow: 0 12px 28px #2a25201a;
}
.more-menu a, .more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
  font: 500 12.5px Inter, system-ui, sans-serif;
}
.more-menu a:hover, .more-menu button:hover { background: #2a252008; color: var(--ink); }

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.ghost, .primary {
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
.ghost {
  background: transparent;
  border: 1px solid #2a25201f;
  color: var(--ink-2);
}
.ghost:hover { border-color: #2a252040; color: var(--ink); background: #fffaf01a; }
.primary {
  background: var(--btn);
  border: 1px solid var(--btn);
  color: #f4ecd8;
  font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .45; cursor: not-allowed; }

.wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #2a25201f;
  border-radius: 999px;
  padding: 5px 10px 5px 8px;
  color: var(--ink);
  font: 500 12px IBM Plex Mono, ui-monospace, monospace;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #2f9d55;
  box-shadow: 0 0 0 3px #2f9d5526;
}

#app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.trade-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: minmax(0, 1fr) 214px;
}

.chart-wrap {
  grid-column: 1;
  grid-row: 1;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.pair {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}
.pair .px { font-variant-numeric: tabular-nums; font-size: 15px; }
.pair .chg { font-size: 12px; font-weight: 600; }
.chg.up { color: var(--ok); }
.chg.dn { color: var(--down); }
.stat { color: var(--muted); font-size: 11.5px; letter-spacing: .02em; }
.stat b { color: var(--ink); font-weight: 600; margin-left: 4px; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }
.sel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 8px;
  cursor: pointer;
}

.chart-stage { position: relative; flex: 1; min-height: 0; }
#ohlc {
  width: 100%;
  height: 100%;
  display: block;
}
.chart-watermark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #2a252014;
  font: 600 72px/1 Inter, system-ui, sans-serif;
  letter-spacing: -.04em;
}

.ticket {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f7f1e2;
  overflow: auto;
}
.acct {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.acct .k { color: var(--muted); font-size: 11.5px; }
.acct .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.acct .v.up { color: var(--ok); }
.acct .v.dn { color: var(--down); }

.sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 12px 16px 0;
  gap: 0;
}
.sides button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 0 10px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.sides button.on.long { color: var(--ok); border-bottom-color: var(--ok); }
.sides button.on.short { color: var(--down); border-bottom-color: var(--down); }

.ticket-body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lbl { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.avail { font-variant-numeric: tabular-nums; font-weight: 600; }
.chip-row { display: flex; gap: 6px; }
.chip {
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.chip.on { border-color: var(--ink); color: var(--ink); background: #fff; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > span, .field-label { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.inputish {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.inputish input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.inputish .suffix { color: var(--muted); font-size: 12px; }

input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
  cursor: pointer;
}
.lev-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted-2);
  font-size: 11px;
}
.lev-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.mode-row { display: flex; gap: 6px; }
.mode-row .chip { flex: 1; text-align: center; }
.place { width: 100%; padding: 12px; border-radius: 8px; font-size: 14px; margin-top: 4px; }

.book {
  grid-column: 1;
  grid-row: 2;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f6efe0;
}
.book-head {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 36px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
}
.tabs { display: flex; gap: 12px; }
.tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 0;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.book-head .right { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }

.table-wrap { overflow: auto; flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 10px; text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
th {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 600;
  position: sticky;
  top: 0;
  background: #f6efe0;
}
td { border-top: 1px solid var(--line-soft); }
.long-tag { color: var(--ok); font-weight: 600; }
.short-tag { color: var(--down); font-weight: 600; }
.linkish {
  background: none;
  border: 0;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.empty { color: var(--muted); padding: 28px 14px; }

.page {
  flex: 1;
  overflow: auto;
  padding: 28px 32px 60px;
  max-width: 1180px;
}
.page h1 { font: 700 28px/1.2 Inter, system-ui, sans-serif; letter-spacing: -.02em; margin-bottom: 8px; }
.page .lead { color: var(--ink-2); max-width: 62ch; margin-bottom: 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}
.card .k { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; margin-bottom: 6px; }
.card .v { font: 600 22px/1.2 Inter, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.panel-table { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.panel-table th { background: #2a252006; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #2a25204d;
  display: grid;
  place-items: center;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 24px 50px #2a25202e;
}
.modal h2 { font-size: 20px; margin-bottom: 6px; }
.modal-lead { color: var(--ink-2); margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@media (max-width: 980px) {
  body { overflow: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .trade-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 420px auto auto;
  }
  .chart-wrap { grid-column: 1; grid-row: 1; border-right: 0; }
  .ticket { grid-column: 1; grid-row: 2; }
  .book { grid-column: 1; grid-row: 3; min-height: 220px; }
  .chart-watermark { font-size: 40px; }
}
