:root {
  --bg: #090b12;
  --surface: #111522;
  --surface-2: #171c2d;
  --line: #272d40;
  --muted: #858eaa;
  --text: #f3f5fb;
  --violet: #7775ff;
  --cyan: #23c6d9;
  --amber: #ffc933;
  --green: #39d29b;
  --red: #ff6f78;
  --shadow: 0 18px 48px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(119, 117, 255, .08), transparent 220px),
    var(--bg);
  letter-spacing: 0;
}

button { font: inherit; }

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--violet);
  font-size: 11px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.15;
  font-weight: 760;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.live-pill {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid rgba(57, 210, 155, .28);
  border-radius: 5px;
  color: var(--green);
  background: rgba(57, 210, 155, .08);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.live-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(57, 210, 155, .1);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.icon-button:active { transform: translateY(1px); }
.icon-button.is-loading { animation: spin .8s linear infinite; }

.spread-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 0 12px;
}

.spread-tabs::-webkit-scrollbar { display: none; }

.spread-tab {
  flex: 0 0 auto;
  min-width: 116px;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.spread-tab b { display: block; color: var(--text); font-size: 13px; }
.spread-tab span { font: 600 10px/1.3 ui-monospace, monospace; }
.spread-tab.active { border-color: rgba(119, 117, 255, .72); background: rgba(119, 117, 255, .12); }

.spread-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary {
  padding: 22px 24px 20px;
  border-bottom: 1px solid var(--line);
}

.spread-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.spread-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.spread-title h2 { margin: 0; font-size: 20px; }
.spread-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.symbol-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  color: #090b12;
  background: var(--violet);
  font-weight: 900;
  font-size: 15px;
}

.status-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 4px;
  color: var(--amber);
  background: rgba(255, 201, 51, .1);
  font-size: 11px;
  font-weight: 750;
}

.status-badge.open { color: var(--green); background: rgba(57, 210, 155, .1); }
.status-badge.opening { color: var(--cyan); background: rgba(35, 198, 217, .1); }

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress-head strong {
  color: var(--text);
  font: 750 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 4px;
  background: #252b3c;
}

.progress-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, #5966ff, #8b78ff);
  box-shadow: 0 0 18px rgba(119, 117, 255, .36);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 20px;
  border-top: 1px solid var(--line);
}

.metric { padding: 16px 14px 0 0; min-width: 0; }
.metric span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 7px; }
.metric strong { font: 750 17px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.metric strong.positive { color: var(--green); }
.metric strong.negative { color: var(--red); }

.legs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.leg { min-width: 0; padding: 20px 24px 22px; }
.leg + .leg { border-left: 1px solid var(--line); }

.leg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 20px; }
.exchange { display: flex; align-items: center; gap: 10px; min-width: 0; }
.exchange-badge {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  color: #071014;
  font-weight: 900;
  background: var(--cyan);
}
.exchange-badge.amber { background: var(--amber); }
.exchange-badge.violet { color: white; background: var(--violet); }
.exchange-name { min-width: 0; }
.exchange-name strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 16px; text-transform: uppercase; }
.funding { margin-top: 3px; color: var(--muted); font: 650 11px/1.2 ui-monospace, monospace; }

.side-badge { padding: 7px 9px; border-radius: 4px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.side-badge.long { color: var(--green); background: rgba(57, 210, 155, .1); }
.side-badge.short { color: var(--red); background: rgba(255, 111, 120, .1); }

.leg-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.stat { min-width: 0; }
.stat span { display: block; color: var(--muted); font-size: 10px; font-weight: 760; margin-bottom: 6px; }
.stat strong { display: block; overflow: hidden; text-overflow: ellipsis; font: 700 15px/1.25 ui-monospace, SFMono-Regular, Menlo, monospace; }
.stat .positive { color: var(--green); }
.stat .negative { color: var(--red); }

.pnl-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 82px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.pnl-total span { color: var(--muted); font-size: 12px; font-weight: 750; }
.pnl-total strong { font: 800 25px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.pnl-total strong.positive { color: var(--green); }
.pnl-total strong.negative { color: var(--red); }

.state-panel {
  min-height: 330px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.state-panel strong { color: var(--text); }
.state-panel p { max-width: 320px; margin: 0; font-size: 13px; line-height: 1.5; }
.state-icon { font-size: 30px; color: var(--violet); }
.loader { width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--violet); border-radius: 50%; animation: spin .8s linear infinite; }

footer { display: flex; justify-content: space-between; gap: 14px; padding: 14px 2px 0; color: #687087; font-size: 10px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  h1 { font-size: 21px; }
  .summary { padding: 18px 16px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 4px; }
  .metric { padding-top: 14px; }
  .metric strong { font-size: 15px; }
  .legs-grid { grid-template-columns: 1fr; }
  .leg { padding: 18px 16px 20px; }
  .leg + .leg { border-left: 0; border-top: 1px solid var(--line); }
  .pnl-total { padding: 16px; }
  .pnl-total strong { font-size: 22px; }
}

@media (max-width: 390px) {
  .live-pill { display: none; }
  .spread-heading { align-items: center; }
  .progress-head { align-items: flex-end; }
  .progress-head strong { font-size: 12px; }
  .leg-stats { gap: 16px 12px; }
  .stat strong { font-size: 14px; }
}
