:root {
  --bg0: #0b1220;
  --bg1: #0b1b2b;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --text: #e8eefc;
  --muted: rgba(232, 238, 252, 0.65);
  --mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial;
  color: var(--text);
  background:
    radial-gradient(1000px 700px at 20% 10%, #163b61 0%, transparent 60%),
    radial-gradient(900px 700px at 80% 20%, #3b1d63 0%, transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      600px 400px at 20% 70%,
      rgba(38, 210, 255, 0.1),
      transparent 60%
    ),
    radial-gradient(
      500px 350px at 80% 60%,
      rgba(255, 77, 199, 0.1),
      transparent 60%
    );
  filter: blur(0px);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 18px 36px;
  position: relative;
}

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

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

.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(38, 210, 255, 0.3),
    rgba(255, 77, 199, 0.25)
  );
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.title {
  font-size: 18px;
  font-weight: 700;
}
.subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

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

.btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0px);
}

.meta {
  text-align: right;
}
.metaLabel {
  font-size: 11px;
  color: var(--muted);
}
.metaValue {
  font-size: 13px;
  font-family: var(--mono);
}

.metaValue {
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 16px;
}

.card--wide {
  padding: 16px 16px 10px;
}

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

.cardTitle {
  font-size: 15px;
  font-weight: 700;
}

.pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.healthRow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 2px 10px;
}

.dotWrap {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  position: relative;
}

.dot--unknown {
  background: rgba(232, 238, 252, 0.5);
}
.dot--ok {
  background: rgba(0, 255, 170, 0.85);
}
.dot--bad {
  background: rgba(255, 72, 72, 0.9);
}

.dot--ok::after,
.dot--bad::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.25;
  animation: pulse 1.3s ease-in-out infinite;
}

.dot--ok {
  color: rgba(0, 255, 170, 0.85);
}
.dot--bad {
  color: rgba(255, 72, 72, 0.9);
}

@keyframes pulse {
  0% {
    transform: scale(0.55);
    opacity: 0.18;
  }
  50% {
    transform: scale(1);
    opacity: 0.3;
  }
  100% {
    transform: scale(0.55);
    opacity: 0.18;
  }
}

.healthText .healthState {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.4px;
}
.healthText .healthHint {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.kv {
  display: grid;
  gap: 10px;
}
.kvRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.kvKey {
  font-size: 12px;
  color: var(--muted);
}
.kvVal {
  font-size: 12px;
  color: var(--text);
}
.mono {
  font-family: var(--mono);
}

.tableControls {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fieldLabel {
  font-size: 11px;
  color: var(--muted);
}

.input,
.select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  min-width: 180px;
}
.select {
  min-width: 120px;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  white-space: nowrap;
}

.badge--ib{
  background: rgba(0,255,170,0.10);
  border-color: rgba(0,255,170,0.22);
  color: rgba(0,255,170,0.92);
  font-weight: 800;
}

.badge--ledger{
  background: rgba(255,202,40,0.10);
  border-color: rgba(255,202,40,0.22);
  color: rgba(255,202,40,0.92);
  font-weight: 800;
}

.badge--hybrid{
  background: rgba(64,160,255,0.10);
  border-color: rgba(64,160,255,0.22);
  color: rgba(120,190,255,0.95);
  font-weight: 800;
}

.tableWrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.table thead th {
  position: sticky;
  top: 0;
  background: rgba(8, 15, 28, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  padding: 12px 12px;
}

.table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 11px 12px;
  font-size: 12px;
}

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

.right {
  text-align: right;
}

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

.pos {
  color: rgba(0, 255, 170, 0.9);
  font-weight: 700;
}
.neg {
  color: rgba(255, 72, 72, 0.92);
  font-weight: 700;
}

.footerNote {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.summaryGrid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:16px;
  margin-bottom:16px;
}

.summaryCard{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 16px;
}

.summaryLabel{
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.summaryValue{
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.summaryHint{
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.summaryValue.pos{
  color: rgba(0,255,170,0.92);
}

.summaryValue.neg{
  color: rgba(255,72,72,0.92);
}

.row-pos td{
  background: rgba(0,255,170,0.04);
}

.row-neg td{
  background: rgba(255,72,72,0.04);
}

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

/* ---------- MOBILE RESPONSIVE ---------- */

@media (max-width: 900px){

  .container{
    padding:16px 12px 24px;
  }

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

  .actions{
    width:100%;
    justify-content:space-between;
  }

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

  .card{
    padding:14px;
  }

  .tableControls{
    width:100%;
    justify-content:space-between;
  }

  .input,
  .select{
    min-width:120px;
  }

}

/* smaller phones */

@media (max-width:600px){

  .title{
    font-size:16px;
  }

  .subtitle{
    font-size:12px;
  }

  .logo{
    width:36px;
    height:36px;
  }

  .meta{
    font-size:11px;
  }

  .table{
    font-size:11px;
  }

}

/* ---------- MOBILE DRAWER P/L ---------- */

.drawerList {
  display: none;
}

.drawerEmpty {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
}

.tradeDrawer {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.tradeDrawer + .tradeDrawer {
  margin-top: 12px;
}

.tradeDrawerHeader {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.tradeDrawerHeader:active {
  background: rgba(255, 255, 255, 0.04);
}

.tradeDrawerLeft {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tradeDrawerSymbol {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.tradeDrawerSide {
  font-size: 12px;
  color: var(--muted);
}

.tradeDrawerRight {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tradeDrawerPnL {
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.tradeDrawerChevron {
  font-size: 14px;
  color: var(--muted);
  transition: transform 140ms ease;
}

.tradeDrawer.open .tradeDrawerChevron {
  transform: rotate(180deg);
}

.tradeDrawerBody {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tradeDrawer.open .tradeDrawerBody {
  display: block;
}

.tradeDrawerGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  padding-top: 12px;
}

.tradeField {
  min-width: 0;
}

.tradeFieldLabel {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.tradeFieldValue {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.tradeFieldValue.pos {
  color: rgba(0, 255, 170, 0.9);
  font-weight: 700;
}

.tradeFieldValue.neg {
  color: rgba(255, 72, 72, 0.92);
  font-weight: 700;
}

.tradeDrawerMeta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

@media (max-width: 768px) {
  .summaryGrid {
    display: flex;
    flex-direction: column;
  }

  .summaryCard:nth-child(3) { order: 1; } /* Connected */
  .summaryCard:nth-child(1) { order: 2; } /* Net Unrealized */
  .summaryCard:nth-child(2) { order: 3; } /* Open Symbols */

  .tableWrap {
    display: none;
  }

  .drawerList {
    display: block;
  }

  .cardHeader {
    flex-direction: column;
    align-items: stretch;
  }

  .tableControls {
    width: 100%;
    justify-content: space-between;
  }

  .field {
    flex: 1 1 0;
  }

  .input,
  .select {
    width: 100%;
    min-width: 0;
  }
}

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

  .tradeDrawerHeader {
    padding: 13px;
  }

  .tradeDrawerBody {
    padding: 0 13px 13px;
  }

  .tradeDrawerSymbol {
    font-size: 15px;
  }

  .tradeDrawerPnL {
    font-size: 12px;
    max-width: 140px;
    line-height: 1.35;
  }
}