:root {
  --bg: #0a0a0b;
  --surface: #121214;
  --raised: #1a1a1e;
  --fg: #f4f4f5;
  --muted: #a1a1aa;
  --subtle: #71717a;
  --accent: #c8ccd4;
  --accent-fg: #0a0a0b;
  --go: #3f7a5a;
  --go-fg: #ecf8f1;
  --stop: #b4544a;
  --stop-fg: #fdeceb;
  --wait: #8a7a55;
  --border: rgba(244, 244, 245, 0.08);
  --border-strong: rgba(244, 244, 245, 0.14);
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius-xs: 0.25rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #0a0a0b 0%, #101014 100%);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}
button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; }
button, input { font-family: inherit; }
a { color: inherit; text-decoration: none; }
svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--subtle);
  margin: 0;
}
h1 {
  margin: 0.25rem 0 0;
  font-size: 1.875rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
h2 { margin: 0; font-size: 0.875rem; font-weight: 500; }
.lead { margin: 0.5rem 0 0; max-width: 36rem; font-size: 0.875rem; line-height: 1.5; color: var(--muted); }
.hint { margin: 0.25rem 0 0; font-size: 0.75rem; color: var(--subtle); line-height: 1.45; }
.subtle { color: var(--subtle); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

.login {
  max-width: 28rem;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 1rem;
}
.mark {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-sm);
  background: var(--raised);
  box-shadow: 0 0 0 1px var(--border);
  display: grid;
  place-items: center;
  font-weight: 600;
  letter-spacing: -0.04em;
  margin-bottom: 1.25rem;
}
.form { margin-top: 2rem; display: flex; flex-direction: column; gap: 1rem; padding: 1.5rem; border-radius: var(--radius-lg); }
.form label { display: flex; flex-direction: column; gap: 0.25rem; }
.form label span, .nums label {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
}
.form input, .nums input {
  height: 2.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--fg);
  padding: 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  box-shadow: 0 0 0 1px var(--border);
  outline: none;
}
.form input:focus, .nums input:focus { box-shadow: 0 0 0 1px var(--border-strong); }
.err { margin: 0; color: var(--stop-fg); font-size: 0.875rem; }
.btn-accent {
  height: 3rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.875rem;
  font-weight: 500;
  transition: transform 150ms var(--ease);
}
.btn-accent:active { transform: scale(0.98); }
.login-foot {
  margin: 1.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
}

.wrap { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
@media (min-width: 640px) { .wrap { padding: 2rem 1.5rem 4rem; } h1 { font-size: 2.25rem; } }

.top {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
  .top { flex-direction: row; align-items: flex-end; justify-content: space-between; margin-bottom: 2rem; }
}
.top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.75rem; }
.account { display: flex; align-items: center; gap: 0.75rem; }
.ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2.75rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.ghost:hover { background: var(--raised); color: var(--fg); }
.pnl-line { margin: 0; font-family: var(--mono); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.pnl-line .tag { margin-left: 0.5rem; font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); }
.go { color: var(--go-fg); }
.stop { color: var(--stop-fg); }

.arm {
  display: flex;
  height: 3.5rem;
  min-width: 13rem;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--muted);
  box-shadow: 0 0 0 1px var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 200ms var(--ease), color 200ms var(--ease);
}
@media (min-width: 640px) { .arm { width: auto; } }
.arm.on { background: var(--go); color: var(--go-fg); }
.arm.live.on { background: var(--stop); color: var(--stop-fg); }
.arm-copy { display: inline-flex; align-items: center; gap: 0.5rem; }
.knob-track {
  position: relative;
  width: 2.75rem;
  height: 1.5rem;
  border-radius: 999px;
  background: #0a0a0b;
}
.arm.on .knob-track { background: rgba(10,10,11,0.3); }
.knob {
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: var(--fg);
  transition: transform 200ms var(--ease);
}
.arm.on .knob { transform: translateX(1.25rem); }

.mode {
  display: flex;
  height: 3rem;
  min-width: 13rem;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--muted);
  box-shadow: 0 0 0 1px var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 200ms var(--ease), color 200ms var(--ease);
}
@media (min-width: 640px) { .mode { width: auto; } }
.mode.live { background: var(--stop); color: var(--stop-fg); }
.mode.live .knob-track { background: rgba(10,10,11,0.3); }
.mode.live .knob { transform: translateX(1.25rem); }
.mode-hint { margin: 0; font-size: 0.6875rem; color: var(--subtle); text-align: right; max-width: 16rem; }
body.live-mode { background: linear-gradient(180deg, #160c0c 0%, #101014 100%); }

.cred-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.85rem;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
}
.cred-label input, .cred-label textarea {
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--fg);
  padding: 0.65rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  box-shadow: 0 0 0 1px var(--border);
  outline: none;
  resize: vertical;
}
.cred-label input { height: 2.75rem; }
.cred-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.85rem; }
.btn-accent.slim { height: 2.75rem; padding: 0 1rem; width: auto; }
.cred-status { margin: 0.75rem 0 0; font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.paper-warn {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-xs);
  background: rgba(138,122,85,0.16);
  color: #f3e6c4;
  font-size: 0.75rem;
  line-height: 1.45;
}

.grid { display: grid; gap: 1rem; }
@media (min-width: 1024px) {
  .grid { grid-template-columns: 5fr 7fr; }
}
.col { display: flex; flex-direction: column; gap: 1rem; }
.col.wide {
  display: grid;
  gap: 1rem;
}
@media (min-width: 1024px) {
  .col.wide { grid-template-columns: 1fr 1fr; }
}
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 0 0 1px var(--border);
}
.amount-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.hero-num { margin: 0; font-family: var(--mono); font-size: 2.25rem; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 0.5rem; }
.chips button {
  height: 2.75rem;
  min-width: 2.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.875rem;
  box-shadow: 0 0 0 1px var(--border);
}
.chips button.on { background: var(--accent); color: var(--accent-fg); box-shadow: none; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  width: 100%;
  height: 2.75rem;
  margin-top: 1.25rem;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: rgba(244,244,245,0.18);
  border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: var(--fg);
  margin-top: -0.55rem;
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: rgba(244,244,245,0.18);
  border-radius: 999px;
}
input[type="range"]::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
}

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1rem; }
.toggle {
  height: 2.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--fg);
  text-align: left;
  padding: 0 0.75rem;
  box-shadow: 0 0 0 1px var(--border);
  font-size: 0.875rem;
}
.toggle.off { color: var(--subtle); background: transparent; }
.toggle span { font-size: 0.75rem; color: var(--subtle); margin-right: 0.5rem; }
.nums label { display: flex; flex-direction: column; gap: 0.25rem; }
.nums input { font-variant-numeric: tabular-nums; }
.feed-err {
  margin: 1rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
  background: rgba(180,84,74,0.12);
  color: var(--stop-fg);
  font-size: 0.75rem;
}
.last-at { margin: 0.75rem 0 0; font-size: 0.6875rem; font-variant-numeric: tabular-nums; }
.skeleton { color: var(--muted); }

.mkt { display: flex; flex-direction: column; }
.mkt-top { display: flex; justify-content: space-between; gap: 0.75rem; }
.mkt h3 { margin: 0.25rem 0 0; font-size: 1.125rem; font-weight: 500; }
.chip {
  align-self: flex-start;
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 0 0 1px var(--border);
  color: var(--subtle);
}
.chip.buy { background: rgba(63,122,90,0.2); color: var(--go-fg); }
.chip.wait { color: var(--wait); }
.stats {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats dt { font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); }
.stats dd { margin: 0.15rem 0 0; font-family: var(--mono); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.why { margin: 1rem 0 0; padding-top: 0.75rem; border-top: 1px solid var(--border); font-size: 0.875rem; line-height: 1.5; color: var(--muted); }

.journal { margin-top: 2rem; padding: 0; overflow: hidden; }
.journal-head {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1rem 1rem;
}
@media (min-width: 640px) {
  .journal-head { flex-direction: row; justify-content: space-between; padding: 1.5rem 1.5rem 1.25rem; }
}
.journal-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.seg, .filters {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--raised);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px var(--border);
}
.filters { margin: 0 1rem 1rem; background: transparent; box-shadow: none; padding: 0; flex-wrap: wrap; }
.seg button, .filters button {
  height: 2.25rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--subtle);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0 0.85rem;
  text-transform: capitalize;
}
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 0 0 1px var(--border); }
.filters button.on { background: var(--accent); color: var(--accent-fg); }

.log-list { max-height: 28rem; overflow-y: auto; border-top: 1px solid var(--border); margin: 0; padding: 0; list-style: none; }
.log-list li { border-bottom: 1px solid var(--border); }
.log-list button.row {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  color: inherit;
}
@media (min-width: 640px) { .log-list button.row { padding: 0.75rem 1.5rem; } }
.log-list .when { font-family: var(--mono); font-size: 0.6875rem; color: var(--subtle); font-variant-numeric: tabular-nums; }
.log-list .head { font-size: 0.875rem; font-weight: 500; }
.log-list .why { margin: 0; padding: 0; border: 0; }
.log-list pre {
  margin: 0 1rem 1rem;
  padding: 0.75rem;
  background: var(--raised);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
}
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--subtle); font-size: 0.875rem; }

.profit { border-top: 1px solid var(--border); }
.profit-hero { padding: 1.25rem 1.5rem; }
.profit-hero .big { margin: 0.25rem 0 0; font-family: var(--mono); font-size: 2.25rem; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
#eqChart { width: 100%; height: 12rem; display: block; }
.settle-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.settle-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
@media (min-width: 640px) {
  .settle-list li { flex-direction: row; justify-content: space-between; align-items: baseline; }
}

.form.tight { margin-top: 1rem; padding: 0; }
.form select {
  height: 2.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--fg);
  padding: 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  box-shadow: 0 0 0 1px var(--border);
  outline: none;
}
.user-row { align-items: flex-start; }
.user-row .user-actions { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.user-row .head { margin: 0; font-size: 0.875rem; font-weight: 500; }
body.viewer .arm,
body.viewer .mode,
body.viewer #usdRange,
body.viewer #usdChips,
body.viewer .toggle,
body.viewer .nums input,
body.viewer #liveCard label,
body.viewer #liveCard .cred-actions,
body.viewer #clearBtn {
  pointer-events: none;
  opacity: 0.45;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
