:root {
  color-scheme: dark;
  --bg: #0e141b;
  --bg-raise: #141c26;
  --card: #17202b;
  --line: #2c3b4c;
  --text: #e8eef5;
  --muted: #93a3b5;
  --gold: #e4c98a;
  --gold-ink: #1c1508;
  --gain: #3dbe8b;
  --loss: #e36b6b;
  --equity: #e4c98a;
  --crypto: #7eb6ff;
  --bank: #7dcea0;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 480px at 10% -10%, rgba(228, 201, 138, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
}

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

button { cursor: pointer; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.boot { color: var(--muted); }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 24px;
  margin-bottom: 22px;
}

.brand { min-width: 220px; }

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  vertical-align: middle;
  margin-right: 10px;
}

.brand h1 {
  display: inline;
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  white-space: nowrap;
}

.tabs, .session {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.session { margin-left: auto; }

.ccy-switch {
  display: inline-flex;
  align-items: stretch;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: transparent;
}

.ccy-switch button {
  height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 0 14px;
  background: transparent;
}

.ccy-switch button[aria-pressed="true"] {
  background: var(--gold);
  color: var(--gold-ink);
}

.ccy-switch label {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  margin: 0;
  padding: 0 8px 0 12px;
}

.ccy-switch label span {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ccy-switch select {
  height: 32px;
  min-width: 168px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0 8px;
}

.ccy-switch[data-mode="secondary"] {
  border-color: var(--gold);
}

.ccy-switch[data-mode="secondary"] select {
  background: var(--gold);
  color: var(--gold-ink);
}

.tabs button,
.ghost,
.primary,
.danger {
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  white-space: nowrap;
}

.tabs button[aria-pressed="true"] {
  background: var(--gold);
  color: var(--gold-ink);
  border-color: var(--gold);
}

.primary {
  background: var(--gold);
  color: var(--gold-ink);
  border-color: var(--gold);
  font-weight: 600;
}

.danger { color: var(--loss); }

.device {
  height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

#market-stats {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.metric span,
.metric strong,
.metric em {
  display: block;
  white-space: nowrap;
}

.metric span { color: var(--muted); font-size: 0.86rem; }

.metric strong {
  margin: 8px 0 4px;
  font-size: 1.35rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.metric em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong.gain { color: var(--gain); }
.metric strong.loss { color: var(--loss); }

.alloc {
  margin: 16px 0 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
}

.alloc-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #243140;
}

.alloc-bar i { display: block; height: 100%; }
.alloc-bar .equity { background: var(--equity); }
.alloc-bar .crypto { background: var(--crypto); }
.alloc-bar .bank { background: var(--bank); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
}

.legend span {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.legend b { color: var(--text); font-weight: 600; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.panel, .gate, .ledger, .bank-note {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.panel-head, .ledger h2, .gate h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
}

.panel-head h2, .ledger h2, .gate h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
}

.panel-head p, .warn, .empty, .bank-note p {
  margin: 0;
  color: var(--muted);
}

.panel-head { justify-content: space-between; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }

td.num, th.num { text-align: right; }

.kind {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
}

.gain { color: var(--gain); }
.loss { color: var(--loss); }

.entry {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field span { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }

.field input, .field select {
  height: 44px;
  width: 100%;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e141b;
}

.field input:focus, .field select:focus, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.entry .primary { align-self: end; }

.ledger { margin-top: 16px; }

.ledger li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.ledger li span:first-child { min-width: 0; overflow-wrap: anywhere; }

.ledger li span:last-child { flex: none; white-space: nowrap; color: var(--muted); }

.ledger ul { list-style: none; margin: 0; padding: 0; }

.bank-note { margin-bottom: 16px; }

.bank-note strong { display: block; margin-bottom: 6px; white-space: nowrap; }

.gate {
  max-width: 720px;
  margin: 48px auto;
}

.gate .entry { grid-template-columns: repeat(3, minmax(140px, 1fr)) auto; }

.alert {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(227, 107, 107, 0.12);
  color: #ffc9c9;
}

.warn { margin-top: 10px; }

.alloc-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.alloc-layout canvas {
  width: 220px;
  height: 220px;
}

.market-controls {
  grid-template-columns: minmax(180px, 1.6fr) minmax(140px, 1fr) minmax(140px, 1fr);
  margin-top: 0;
}

.market-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin: 16px 0 8px;
}

.market-head h2,
.market-head strong,
.market-head em {
  margin: 0;
  white-space: nowrap;
}

.market-head strong {
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
}

.market-head em { font-style: normal; }

.chart-wrap {
  width: 100%;
  height: 380px;
  margin-top: 8px;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.readout {
  min-height: 1.4em;
  margin: 8px 0 0;
  color: var(--muted);
  white-space: nowrap;
}

#market-board tr { cursor: pointer; }

.equation {
  margin: 14px 0 16px;
  color: var(--muted);
}

.equation-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -6px 0 16px; }

.report-range { margin-top: 0; }

.equation-actions .ghost { height: 44px; }

.equation b {
  color: var(--text);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.foot {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.86rem;
}

@media (max-width: 1100px) {
  .entry, .gate .entry { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .entry .primary, .gate .entry .primary { grid-column: 1 / -1; justify-self: start; min-width: 180px; }
}

@media (max-width: 720px) {
  .shell { width: min(100% - 20px, 1180px); }
  .session { margin-left: 0; }
  .entry, .gate .entry { grid-template-columns: 1fr 1fr; }
  .market-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .brand p { white-space: normal; }
  .alloc-layout { grid-template-columns: 1fr; }
  .alloc-layout canvas { justify-self: center; }
}
