:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #171c24;
  --panel-2: #1e2530;
  --line: #2b3340;
  --text: #ecf1f8;
  --muted: #93a0b2;
  --green: #26d07c;
  --red: #ff5c73;
  --amber: #f4b740;
  --cyan: #45c7f4;
}

* {
  box-sizing: border-box;
}

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

.app {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.topnav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.topnav a.active {
  background: var(--cyan);
  color: #061016;
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

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

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 148px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 18px rgba(255, 92, 115, 0.7);
}

.status.ok .dot {
  background: var(--green);
  box-shadow: 0 0 18px rgba(38, 208, 124, 0.7);
}

.settings {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
}

.settingsHead,
.settingGroup {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 14px;
  align-items: start;
}

.settingsHead {
  align-items: center;
}

.saveBox {
  display: flex;
  align-items: center;
  gap: 12px;
}

#saveStatus,
#saveStatusLive {
  color: var(--muted);
  font-size: 12px;
}

.successTextInline {
  color: var(--green) !important;
}

.warningTextInline {
  color: var(--amber) !important;
}

.dangerTextInline {
  color: var(--red) !important;
}

.settingsHead h2,
.groupCopy h3 {
  margin: 0;
}

.groupCopy h3 {
  font-size: 15px;
}

.groupCopy p,
.dangerText,
.warningText {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.apiDanger {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.monitorPage .liveGate {
  display: none;
}

.livePage .monitorOnly {
  display: none;
}

.dangerText {
  grid-column: 2;
  color: var(--red);
}

.warningText {
  grid-column: 2;
  color: var(--amber);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.apiControls {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.wideField {
  grid-column: span 2;
}

.toggle {
  align-content: end;
}

.toggle input {
  width: 38px;
  accent-color: var(--cyan);
}

input:disabled {
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #10151d;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

button {
  cursor: pointer;
  background: var(--cyan);
  color: #061016;
  font-weight: 700;
  border-color: transparent;
}

.smallBtn {
  width: auto;
  min-width: 92px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.summary div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.summary strong {
  font-size: 18px;
}

.tableWrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 44px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

th:first-child,
td:first-child {
  text-align: left;
}

tr.highlight {
  background: rgba(69, 199, 244, 0.08);
}

tr.strongRow {
  background: rgba(38, 208, 124, 0.1);
}

tr.staleRow {
  opacity: 0.62;
}

tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.symbol {
  font-weight: 800;
  color: #ffffff;
}

.up,
.hot {
  color: var(--green);
  font-weight: 700;
}

.down {
  color: var(--red);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  justify-content: center;
  min-width: 78px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #071018;
  font-weight: 800;
}

.long,
.squeezeUp {
  background: var(--green);
}

.short,
.squeezeDown {
  background: var(--red);
}

.oiOnly {
  background: var(--amber);
}

.watch {
  background: #657185;
  color: #f6f8fb;
}

.strength {
  display: inline-flex;
  width: 72px;
  height: 8px;
  border-radius: 99px;
  background: #2c3440;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 8px;
}

.strength span {
  display: block;
  height: 100%;
  background: var(--cyan);
}

td b {
  display: inline-block;
  width: 24px;
}

.history {
  margin: 0 0 18px;
}

.paper {
  margin: 0 0 18px;
}

.liveGate {
  margin: 0 0 18px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.unlockPanel {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px) 120px auto;
  gap: 12px;
  align-items: end;
  padding: 12px;
  background: #10151d;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.unlockPanel h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.liveSettings {
  margin-bottom: 12px;
}

.liveHead {
  margin-top: 8px;
}

.paperStats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.paperStats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.paperStats strong {
  font-size: 17px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: right;
  line-height: 1.25;
}

.apiErrorDetail {
  margin: -2px 0 10px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 92, 115, 0.35);
  border-radius: 8px;
  background: rgba(255, 92, 115, 0.08);
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.paperTables {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.paperStrategy {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.paperPanel {
  min-width: 0;
}

.positionsPanel {
  max-height: 240px;
  overflow: auto;
}

.tradesPanel {
  max-height: 520px;
  overflow: auto;
}

.miniHead {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sectionHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 10px;
}

.mainListHead {
  margin-top: 18px;
}

.sectionHead h2 {
  margin: 0;
  font-size: 18px;
}

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

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app {
    width: calc(100vw - 20px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .controls,
  .apiControls,
  .settingsHead,
  .settingGroup,
  .summary,
  .unlockPanel,
  .paperStats,
  .paperStrategy,
  .paperTables {
    grid-template-columns: 1fr;
  }

  .wideField {
    grid-column: span 1;
  }

  .dangerText,
  .warningText {
    grid-column: 1;
  }

  .tableWrap {
    max-width: calc(100vw - 20px);
  }

  table {
    min-width: 1180px;
  }
}
