:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #141b24;
  --panel-2: #101820;
  --line: #273443;
  --text: #eef4fb;
  --muted: #92a2b5;
  --green: #1fc987;
  --red: #ff5a66;
  --blue: #26c6e6;
  --gold: #f7c85f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-screen[hidden] {
  display: none;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.auth-panel h1 {
  font-size: 28px;
}

.auth-panel p {
  margin: 0;
  color: var(--muted);
}

.auth-forms,
.paywall {
  display: grid;
  gap: 10px;
}

.auth-forms[hidden],
.paywall[hidden] {
  display: none;
}

.paywall {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e151f;
}

.paywall span,
.auth-message {
  color: var(--muted);
}

.auth-message:not(:empty) {
  color: var(--gold);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  background: #121c28;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

button:hover {
  border-color: rgba(38, 198, 230, 0.62);
  background: #172533;
}

.icon-btn,
.toolbar-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
  background: #0f1823;
}

.toolbar-btn {
  color: var(--muted);
  font-weight: 800;
}

.stats-btn {
  min-height: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 750;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

[hidden] {
  display: none !important;
}

.shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  min-height: 100vh;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow,
#status {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

#status:empty,
#marketTitle:empty {
  display: none;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

.controls,
.account,
.settings-panel {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #0e151f;
  color: var(--text);
}

.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #041617;
  font-weight: 800;
}

.account {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.logout-btn {
  justify-self: start;
  min-height: 32px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.settings-panel,
.floating-panel {
  position: fixed;
  top: 74px;
  right: 24px;
  z-index: 10;
  width: min(320px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 27, 36, 0.98);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
}

.settings-panel[hidden],
.floating-panel[hidden] {
  display: none;
}

.stats-panel h3 {
  margin: 0 0 14px;
  padding-right: 34px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 18px;
  align-items: center;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
}

.stats-grid strong {
  font-size: 14px;
  text-align: right;
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  min-height: 32px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.account div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.account span {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto minmax(160px, 230px);
  min-width: 0;
}

.market-bar,
.trade-panel,
.history {
  padding: 18px 24px;
}

.market-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.quote-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 8px;
}

#lastPrice {
  font-size: 24px;
  font-weight: 850;
}

#lastChange {
  color: var(--muted);
  font-size: 13px;
}

.chart-wrap {
  position: relative;
  min-height: 320px;
  background: #0b1016;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.trade-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
  gap: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.trade-form {
  display: grid;
  grid-template-columns: minmax(88px, 120px) repeat(5, minmax(66px, auto));
  gap: 8px;
  align-items: end;
}

.account-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(118px, auto));
  gap: 8px;
  align-items: stretch;
}

.account-metrics div {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 46px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e151f;
}

.account-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.account-metrics strong {
  font-size: 17px;
  line-height: 1.1;
}

.advance-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e151f;
  color: var(--muted);
  font-size: 12px;
}

.advance-toggle input {
  width: 15px;
  min-height: 15px;
  margin: 0;
}

.trade-form button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.trade-form input {
  min-height: 34px;
}

.long {
  background: rgba(31, 201, 135, 0.16);
  border-color: rgba(31, 201, 135, 0.5);
  color: #7df0c3;
}

.short {
  background: rgba(255, 90, 102, 0.14);
  border-color: rgba(255, 90, 102, 0.5);
  color: #ff9aa2;
}

.position {
  align-self: stretch;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #0e151f;
}

.position[hidden] {
  display: none;
}

.history {
  overflow: hidden;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.trade-log {
  display: grid;
  gap: 8px;
  max-height: 155px;
  overflow: auto;
}

.log-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e151f;
  color: var(--muted);
  font-size: 13px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .account {
    margin-top: 0;
  }

  .workspace {
    grid-template-rows: auto 55vh auto minmax(180px, 260px);
  }

  .market-bar,
  .trade-panel {
    grid-template-columns: 1fr;
  }

  .market-bar {
    align-items: start;
  }

  .quote-strip,
  .top-actions {
    justify-content: flex-end;
  }

  .trade-form {
    grid-template-columns: minmax(84px, 110px) repeat(5, minmax(62px, 1fr));
    align-items: end;
  }
}

@media (max-width: 520px) {
  .side-panel,
  .market-bar,
  .trade-panel,
  .history {
    padding: 16px;
  }

  .market-bar {
    position: relative;
    gap: 10px;
    padding-right: 58px;
  }

  .quote-strip {
    justify-content: start;
  }

  .top-actions {
    position: absolute;
    top: 14px;
    right: 16px;
  }

  .top-actions .toolbar-btn,
  .top-actions #statsBtn {
    display: none;
  }

  .trade-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .account-metrics,
  .trade-form label,
  .advance-toggle {
    grid-column: 1 / -1;
  }

  .quote-strip {
    flex-wrap: wrap;
  }

  .account-metrics {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .log-row {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    top: 82px;
    right: 16px;
    left: 16px;
    width: auto;
  }
}
