:root {
  --bg0: #0b1220;
  --bg1: #0d1a2a;
  --bg2: #121d30;

  --card: rgba(255, 255, 255, 0.05);
  --card-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);

  --text: #e8eefc;
  --muted: rgba(232, 238, 252, 0.65);
  --muted-soft: rgba(232, 238, 252, 0.5);

  --gold: rgba(234, 199, 101, 0.98);
  --gold-bg: rgba(212, 175, 55, 0.08);
  --gold-border: rgba(212, 175, 55, 0.2);

  --ok: rgba(0, 255, 170, 0.9);
  --ok-bg: rgba(0, 255, 170, 0.08);
  --ok-border: rgba(0, 255, 170, 0.2);

  --warn: rgba(255, 213, 79, 0.98);
  --warn-bg: rgba(212, 175, 55, 0.08);
  --warn-border: rgba(212, 175, 55, 0.22);

  --bad: rgba(255, 106, 106, 0.95);
  --bad-bg: rgba(255, 72, 72, 0.08);
  --bad-border: rgba(255, 72, 72, 0.2);

  --info: rgba(120, 190, 255, 0.95);
  --info-bg: rgba(120, 190, 255, 0.08);
  --info-border: rgba(120, 190, 255, 0.22);

  --shadow:
    0 10px 30px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.02);

  --radius-card: 20px;
  --radius-inner: 16px;

  --mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

* {
  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 18% 10%, #163453 0%, transparent 58%),
    radial-gradient(900px 700px at 85% 15%, #342055 0%, transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      600px 420px at 20% 70%,
      rgba(38, 210, 255, 0.07),
      transparent 60%
    ),
    radial-gradient(
      520px 360px at 82% 58%,
      rgba(255, 77, 199, 0.07),
      transparent 60%
    );
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 16px 30px;
  position: relative;
}

.mono {
  font-family: var(--mono);
}

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

.right {
  text-align: right;
}

.pos {
  color: var(--ok);
  font-weight: 700;
}

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

/* ---------- HEADER ---------- */

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

.topbar--brand {
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand--hero {
  gap: 14px;
  align-items: center;
}

.brandLogo {
  width: 180px;
  max-width: 40vw;
  height: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.35));
  flex-shrink: 0;
}

.title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.1;
}

.subtitle {
  margin-top: 4px;
  font-size: 13px;
  opacity: 0.7;
  color: rgba(232, 238, 252, 0.74);
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.meta {
  text-align: right;
}

.metaLabel {
  font-size: 11px;
  color: var(--muted);
}

.metaValue {
  font-size: 13px;
  font-family: var(--mono);
  white-space: nowrap;
}

/* ---------- ALERTS ---------- */

.alertStrip {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

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

.alertItem {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.alertItem--bad {
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.alertItem--warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.alertItem--info {
  border-color: var(--info-border);
  background: var(--info-bg);
}

.alertText {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.alertChip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  border: 1px solid var(--border);
}

.alertChip--bad {
  color: var(--bad);
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.alertChip--warn {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.alertChip--info {
  color: var(--info);
  border-color: var(--info-border);
  background: var(--info-bg);
}

/* ---------- SUMMARY ---------- */

.summaryGrid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.summaryGrid--four {
  grid-template-columns: repeat(4, 1fr);
}

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

.summaryCard::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(212, 175, 55, 0.85),
    rgba(255, 255, 255, 0)
  );
  opacity: 0.6;
}

.summaryCard:last-child {
  background: linear-gradient(
    145deg,
    rgba(52, 32, 85, 0.55),
    rgba(255, 255, 255, 0.03)
  );
}

.summaryLabel {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 0.2px;
  opacity: 0.7;
}

.summaryValue {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.4px;
}

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

/* ---------- PANELS ---------- */

.grid {
  display: grid;
  gap: 14px;
}

.grid--split {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

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

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

.card--wide {
  min-height: 100%;
}

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

.cardTitle {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--gold-border);
  background: var(--gold-bg);
  color: var(--gold);
  white-space: nowrap;
}

.grid--health .card {
  max-width: 420px;
}

/* ---------- FORM CONTROLS ---------- */

.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: 14px;
  padding: 10px 12px;
  outline: none;
  min-width: 180px;
}

.select {
  min-width: 120px;
}

/* ---------- BADGES ---------- */

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

.badge--ib {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}

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

.badge--hybrid {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}

.badge--strategy {
  background: rgba(212, 175, 55, 0.06);
  border-color: var(--gold-border);
  color: var(--gold);
}

.badge--broker {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}

.badge--mismatch {
  background: rgba(255, 202, 40, 0.12);
  border-color: rgba(255, 202, 40, 0.26);
  color: var(--warn);
}

/* ---------- DRAWERS ---------- */

.drawerList {
  display: block;
}

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

.strategyDrawer,
.tradeDrawer {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-inner);
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

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

.strategyDrawerHeader,
.tradeDrawerHeader {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
}

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

.strategyDrawerMain,
.tradeDrawerMain {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.strategyDrawerTop,
.tradeDrawerTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.strategyDrawerTopRight,
.tradeDrawerTopRight {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.strategyDrawerSymbol,
.tradeDrawerSymbol {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.strategyDrawerPosition,
.tradeDrawerSide {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  opacity: 0.6;
}

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

.tradeMiniStat {
  font-size: 12px;
  font-weight: 600;
  color: rgba(232, 238, 252, 0.85);
  line-height: 1.35;
}

.tradeDrawerTimeCompact {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted-soft);
  font-family: var(--mono);
}

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

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

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

.strategyDrawer.open .strategyDrawerBody,
.tradeDrawer.open .tradeDrawerBody {
  display: block;
}

.strategyDrawerGrid,
.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;
}

.mismatchText {
  margin-top: 2px;
  font-size: 11px;
  color: var(--warn);
}

.lastActionText {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

.lastActionText strong {
  display: block;
  font-weight: 700;
  color: rgba(232, 238, 252, 0.9);
  margin-bottom: 2px;
}

/* ---------- EVENTS ---------- */

.eventFeed {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.eventItem {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
}

.eventItem--ok {
  border-color: var(--ok-border);
  background: rgba(0, 255, 170, 0.045);
}

.eventItem--warn {
  border-color: var(--warn-border);
  background: rgba(212, 175, 55, 0.05);
}

.eventItem--bad {
  border-color: var(--bad-border);
  background: rgba(255, 72, 72, 0.045);
}

.eventItem--info {
  border-color: var(--info-border);
  background: rgba(120, 190, 255, 0.045);
}

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

.eventTime {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
  opacity: 0.6;
}

.eventBadge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  border: 1px solid var(--border);
}

.eventBadge--ok {
  color: var(--ok);
  border-color: var(--ok-border);
  background: var(--ok-bg);
}

.eventBadge--warn {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.eventBadge--bad {
  color: var(--bad);
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.eventBadge--info {
  color: var(--info);
  border-color: var(--info-border);
  background: var(--info-bg);
}

.eventMessage {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.85;
}

/* ---------- HEALTH ---------- */

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

.dotWrap {
  width: 40px;
  height: 40px;
  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);
  color: rgba(0, 255, 170, 0.85);
}

.dot--bad {
  background: rgba(255, 72, 72, 0.9);
  color: 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;
}

@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: 18px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.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);
}

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

@media (max-width: 1100px) {
  .summaryGrid--four {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 900px) {
  .container {
    padding: 18px 12px 28px;
  }

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

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

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

  .eventFeed {
    max-height: none;
  }

  .grid--health .card {
    max-width: none;
  }

  .brandLogo {
    width: 180px;
    max-width: 60vw;
  }

  .title {
    font-size: 18px;
  }

  .subtitle {
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .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;
  }

  .strategyDrawerGrid,
  .tradeDrawerGrid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .brandLogo {
    width: 150px;
    max-width: 66vw;
  }

  .title {
    font-size: 17px;
  }

  .subtitle {
    font-size: 12px;
  }

  .strategyDrawerHeader,
  .tradeDrawerHeader {
    padding: 14px;
  }

  .strategyDrawerBody,
  .tradeDrawerBody {
    padding: 0 14px 14px;
  }

  .strategyDrawerSymbol,
  .tradeDrawerSymbol {
    font-size: 14px;
  }

  .tradeDrawerBottom {
    gap: 10px;
  }

  .tradeDrawerTimeCompact {
    margin-left: 0;
    width: 100%;
  }

  .eventMessage {
    font-size: 12px;
  }
}