:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page: #0b1017;
  --surface: #111821;
  --surface-raised: #151f2a;
  --stroke: #283542;
  --text: #f2f6fb;
  --muted: #aab8c8;
  --soft: #8b9db0;
  --mint: #5de0b4;
  --mint-soft: #153229;
  --chart-up: #3fdfaa;
  --chart-down: #fb7383;
  --chart-ema: #c5a5fa;
  --chart-vwap: #80c7ff;
  background: var(--page);
  color: var(--text);
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, select, input { font: inherit; }
a { color: inherit; }
button, select, input[type="file"], input[type="checkbox"], input[type="range"], summary { cursor: pointer; }
button:disabled, input:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 4px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.topbar {
  background: #0e141d;
  border-bottom: 1px solid var(--stroke);
}

.topbar-inner, .workspace {
  width: min(100% - 3rem, 1440px);
  margin-inline: auto;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 66px;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  text-decoration: none;
  align-items: center;
  gap: .67rem;
  font-size: 1.11rem;
  font-weight: 750;
  letter-spacing: -.025em;
  white-space: nowrap;
}

.instrument-icon, .side-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.brand-mark {
  display: block;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 9px;
}

.topbar nav { display: flex; gap: .45rem; align-items: center; }
.topbar nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding-inline: .85rem;
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 8px;
  text-decoration: none;
}

.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--text); background: var(--surface-raised); }

.workspace {
  padding-block: clamp(1.35rem, 3vw, 2.55rem) 2.4rem;
}

.workspace-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.3rem;
}

.workspace-heading h1 {
  margin: 0;
  font-size: clamp(1.65rem, 2.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -.044em;
  line-height: 1.12;
}
.workspace-heading p {
  margin: .4rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.timezone {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .875rem;
  line-height: 1.45;
  color: var(--muted);
}
.timezone svg { width: 18px; height: 18px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 285px);
  gap: clamp(.9rem, 1.5vw, 1.25rem);
  align-items: start;
}

.chart-card, .side-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 14px;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  padding: 1.05rem 1.15rem .95rem;
}

.instrument, .chart-options, .overlays, .overlay {
  display: flex;
  align-items: center;
}
.instrument { gap: .66rem; min-width: 0; }
.instrument-icon {
  width: 41px;
  height: 41px;
  border-radius: 10px;
  background: #142c2b;
  color: var(--mint);
}
.instrument-icon svg { width: 22px; height: 22px; }
.instrument h2 { margin: 0; font-size: 1.22rem; line-height: 1.18; font-weight: 750; }
.chart-badge { display: block; margin-top: .18rem; color: var(--muted); font-size: .875rem; line-height: 1.3; }
.chart-options { flex-wrap: wrap; justify-content: end; gap: .62rem; }
.overlays { flex-wrap: wrap; gap: .38rem .63rem; }
.overlay {
  gap: .36rem;
  min-height: 32px;
  font-size: .875rem;
  white-space: nowrap;
  color: var(--muted);
  cursor: pointer;
}
.overlay input { margin: 0; width: 15px; height: 15px; accent-color: var(--mint); }
.overlay > span { width: 6px; height: 6px; border-radius: 50%; }
.ema-dot { background: var(--chart-ema); }
.vwap-dot { background: var(--chart-vwap); }

.select-wrap {
  position: relative;
  display: inline-block;
}
.select-wrap::after {
  position: absolute;
  right: .68rem;
  top: calc(50% - 4px);
  width: 7px;
  height: 7px;
  content: "";
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  pointer-events: none;
}
.select-wrap select {
  width: 100%;
  min-height: 38px;
  appearance: none;
  padding: .42rem 1.7rem .42rem .65rem;
  background: var(--surface-raised);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: var(--text);
  font-size: .875rem;
  font-weight: 560;
  line-height: 1.25;
}
.select-wrap select:hover { border-color: #51667a; }

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .75rem;
  margin: 0;
  padding: .85rem 1.15rem;
  border-block: 1px solid var(--stroke);
  background: #121c27;
}
.metrics dt {
  color: var(--soft);
  font-size: .875rem;
  line-height: 1.35;
}
.metrics dd {
  margin: .27rem 0 0;
  color: var(--text);
  font-size: clamp(.875rem, 1.4vw, 1.095rem);
  font-weight: 690;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: nowrap;
}

.positive, .is-up, [data-direction="up"] { color: var(--chart-up) !important; }
.negative, .is-down, [data-direction="down"] { color: var(--chart-down) !important; }

.chart-body {
  position: relative;
  height: clamp(360px, 49vh, 465px);
  margin-inline: .45rem;
}

#chart {
  display: block;
  width: 100%;
  height: 100%;
}

#chart:focus-visible { outline-offset: -3px; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .35rem;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}
.chart-empty strong { color: var(--text); }

.playback {
  padding: .84rem 1.15rem 1rem;
  border-top: 1px solid var(--stroke);
  border-radius: 0 0 14px 14px;
}
.playback-top, .playback-controls, .speed-label {
  display: flex;
  align-items: center;
  gap: .45rem;
}
.playback-top { justify-content: space-between; gap: .6rem 1rem; flex-wrap: wrap; }
.playback-controls { flex-wrap: wrap; }
.speed-label { gap: .55rem; font-size: .875rem; color: var(--muted); }
.button {
  min-height: 38px;
  padding: .45rem .72rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: var(--text);
  font-size: .875rem;
  font-weight: 620;
  line-height: 1.26;
  background: var(--surface-raised);
}
.button:not(:disabled):hover { border-color: #5d7185; background: #1d2b39; }
.button-main {
  min-width: 78px;
  background: var(--mint);
  border-color: var(--mint);
  color: #092018;
  font-weight: 730;
}
.button-main:not(:disabled):hover { background: #84f0cb; border-color: #84f0cb; }
.button:disabled { opacity: .56; }
.scrubber { display: block; margin-top: .83rem; }
.scrubber input {
  display: block;
  width: 100%;
  margin: 0;
  min-height: 20px;
  accent-color: var(--mint);
}
.playback-times {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .3rem;
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
#replay-clock { color: var(--text); }

.replay-ticket { padding: .9rem 1.15rem 1rem; border-top: 1px solid var(--stroke); }
.sim-header { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .65rem; }
.sim-header h2 { margin: 0; font-size: 1rem; }
.sim-quantity { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .875rem; }
.replay-ticket input {
  min-width: 0;
  min-height: 38px;
  padding: .35rem .5rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
}
.sim-quantity input { width: 4rem; }
.sim-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.sim-actions button { min-height: 44px; }
.sim-buy { background: #14382d; color: #a5ebcf; border-color: #376d5d; }
.sim-sell { background: #3d232d; color: #ffd0d6; border-color: #844854; }
.sim-buy:not(:disabled):hover { background: #1b483a; border-color: #62ab97; }
.sim-sell:not(:disabled):hover { background: #56303c; border-color: #ba7480; }
.sim-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .65rem;
  margin: .85rem 0 0;
  line-height: 1.35;
}
.sim-stats dt { color: var(--muted); font-size: .875rem; }
.sim-stats dd { margin: .2rem 0 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.sim-details { display: grid; gap: .55rem; margin-top: .8rem; color: var(--muted); font-size: .875rem; }
.sim-details summary { padding-block: .2rem; }
.sim-details p { margin: .55rem 0 0; line-height: 1.45; }
.sim-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin: .5rem 0; }
.sim-settings label { display: flex; min-width: 0; flex-direction: column; gap: .3rem; }
.sim-settings input { width: 100%; }
.sim-table-wrap { max-height: 200px; overflow: auto; margin-top: .3rem; }
.sim-table { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
.sim-table :is(th, td) { padding: .34rem .5rem; border-bottom: 1px solid var(--stroke); }
.sim-table th { color: var(--text); }

.sidebar { display: grid; gap: clamp(.75rem, 1.25vw, 1.08rem); }
.side-card { padding: 1rem; }
.side-title { display: flex; align-items: center; gap: .62rem; margin-bottom: .9rem; }
.side-icon {
  width: 29px;
  height: 29px;
  background: #1d2a36;
  color: #b2c5d8;
  border-radius: 8px;
}
.side-icon svg { width: 17px; height: 17px; }
.side-card h2 { margin: 0; font-size: 1rem; font-weight: 690; line-height: 1.3; }

.import-label {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .37rem;
  padding: 1.1rem .55rem;
  background: #10241f;
  border: 1px dashed #3a655a;
  border-radius: 9px;
  color: var(--mint);
  text-align: center;
  cursor: pointer;
}
.import-label:hover, .import-label:focus-within, .import-label.dragging, .import-label[data-drag="true"] {
  background: #17382d;
  border-color: var(--mint);
}
.import-label svg { width: 24px; height: 24px; }
.import-label strong { font-size: .94rem; line-height: 1.23; }
.import-label > span { color: #b9c8c5; font-size: .875rem; }
.import-label input {
  opacity: 0;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.zone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  margin: .8rem 0;
  color: var(--muted);
  font-size: .875rem;
}
.zone-row select { min-height: 36px; }
.button-secondary { width: 100%; }
.import-status { margin: .63rem 0 0; color: var(--muted); font-size: .875rem; line-height: 1.4; overflow-wrap: anywhere; }
.import-status:empty { display: none; }
.import-status[data-state="error"] { color: var(--chart-down); }
.import-help { margin-top: .75rem; color: var(--muted); font-size: .875rem; }
.import-help summary { line-height: 1.4; }
.import-help p { margin: .5rem 0 0; line-height: 1.55; }
.import-help code { overflow-wrap: anywhere; }

.dataset { margin: 0; display: grid; gap: .67rem; }
.dataset > div {
  display: grid;
  grid-template-columns: minmax(6.1rem, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: .45rem;
  font-size: .875rem;
  line-height: 1.38;
}
.dataset dt { color: var(--soft); }
.dataset dd {
  margin: 0;
  text-align: right;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

@media (max-width: 975px) {
  .topbar-inner, .workspace { width: min(100% - 1.8rem, 1440px); }
  .dashboard { grid-template-columns: minmax(0, 1fr) minmax(224px, 245px); }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overlays { gap: .1rem .55rem; }
}

@media (max-width: 735px) {
  .dashboard { grid-template-columns: minmax(0, 1fr); }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-body { height: clamp(320px, 56vh, 435px); }
}

@media (max-width: 480px) {
  .topbar-inner, .workspace { width: calc(100% - 1.2rem); }
  .topbar-inner { min-height: 60px; gap: .4rem; }
  .brand { gap: .4rem; font-size: .96rem; }
  .brand-mark { width: 33px; height: 33px; }
  .topbar nav a { padding-inline: .42rem; }
  .workspace-heading { align-items: start; gap: .45rem; margin-bottom: .88rem; }
  .workspace-heading p { line-height: 1.35; }
  .chart-toolbar { flex-wrap: wrap; padding: .85rem .75rem; }
  .chart-options { justify-content: start; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: .75rem; gap: .62rem .45rem; }
  .playback { padding: .72rem .75rem .84rem; }
  .replay-ticket { padding-inline: .75rem; }
  .sim-stats, .sim-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { grid-template-columns: minmax(0, 1fr); }
}
