
:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090b0e;
  color: #d9dde1;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #090b0e; }
.terminal { width: min(1480px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 32px; }
.terminal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid #262b31;
  padding-bottom: 12px;
}
.desk-label { color: #f0f3f6; font-size: 20px; font-weight: 720; letter-spacing: 0; }
.account-line { margin-top: 4px; color: #7f8790; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.account-line a { color: #aeb5bd; text-decoration: none; border-bottom: 1px solid #3b444e; margin-left: 10px; }
.account-line a:first-child { margin-left: 0; }
.account-line a:hover { color: #f0f3f6; border-color: #78818b; }
.status-grid {
  display: grid;
  grid-template-columns: repeat(5, auto);
  gap: 8px 16px;
  align-items: center;
  color: #7f8790;
  font-size: 11px;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.status-grid b { color: #d9dde1; font-weight: 680; }
.dot-value::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 6px 1px 0;
  border-radius: 50%;
  background: #69717a;
}
.dot-value.ok::before { background: #4ea66a; }
.dot-value.warn::before { background: #d0a44e; }
.dot-value.bad::before { background: #c85b5b; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid #242a30;
  border-left: 0;
  margin: 14px 0;
  background: #101317;
}
.kpi {
  min-width: 0;
  padding: 10px 12px;
  border-left: 1px solid #242a30;
}
.kpi span, .panel-title span {
  display: block;
  color: #78818b;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.kpi strong {
  display: block;
  margin-top: 6px;
  color: #f0f3f6;
  font-size: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, .65fr);
  gap: 12px;
}
.memo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .55fr);
  gap: 12px;
  margin-top: 14px;
}
.memo-main { grid-column: 1 / -1; }
.memo-body { padding: 12px; color: #aeb5bd; font-size: 13px; line-height: 1.55; }
.memo-body p { margin: 0 0 12px; max-width: 980px; }
.formula {
  margin: 8px 0;
  padding: 8px 10px;
  border-left: 2px solid #58616c;
  background: #0b0e12;
  color: #eef1f4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.memo-table th, .memo-table td { text-align: left; }
.panel {
  min-width: 0;
  background: #101317;
  border: 1px solid #242a30;
}
.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 9px 11px;
  border-bottom: 1px solid #242a30;
}
h2 {
  margin: 0;
  color: #eef1f4;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.positions-panel, .performance-panel, .orders-panel, .fills-panel, .activity-panel { grid-column: 1 / -1; }
.portfolio-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  padding: 12px;
}
.gross-bar {
  display: flex;
  height: 20px;
  border: 1px solid #2a3037;
  background: #0b0e12;
}
.gross-segment { min-width: 2px; }
.gross-segment.long { background: #4d8f64; }
.gross-segment.short { background: #a55353; }
.gross-segment.cash { background: #68727d; }
.exposure-ledger { display: grid; gap: 8px; margin-top: 12px; }
.ledger-group { border-top: 1px solid #242a30; padding-top: 8px; }
.ledger-group:first-child { border-top: 0; padding-top: 0; }
.ledger-title {
  color: #78818b;
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.ledger-row {
  display: grid;
  grid-template-columns: 72px 1fr auto auto;
  gap: 10px;
  align-items: center;
  min-height: 24px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.ledger-line { height: 4px; background: #242a30; }
.ledger-line span { display: block; height: 100%; }
.ledger-line .long { background: #4d8f64; }
.ledger-line .short { background: #a55353; }
.ledger-line .cash { background: #68727d; }
.portfolio-metrics { border-left: 1px solid #242a30; padding-left: 12px; }
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #20262c;
  font-size: 12px;
}
.kv-table td:first-child { color: #78818b; text-transform: uppercase; font-size: 10px; font-weight: 760; }
.kv-table td:last-child { text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.table-wrap { overflow-x: auto; }
.table-wrap.compact { max-height: 260px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.data-table th, .data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #20262c;
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
}
.data-table th {
  color: #78818b;
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
}
.data-table th:first-child, .data-table td:first-child,
.data-table th:nth-child(2), .data-table td:nth-child(2) { text-align: left; }
.data-table td { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.data-table .company { max-width: 260px; overflow: hidden; text-overflow: ellipsis; font-family: inherit; color: #aeb5bd; }
.badge {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid #333b44;
  color: #b8c0c8;
  font-size: 10px;
  font-weight: 780;
}
.badge.long { border-color: #305940; color: #73c38a; }
.badge.short { border-color: #653a3a; color: #df7b7b; }
.positive { color: #77c98e !important; }
.negative { color: #df7b7b !important; }
.muted { color: #78818b !important; }
.chart, .mini-chart { padding: 10px 12px; }
.chart svg, .mini-chart svg { width: 100%; height: 230px; display: block; }
.mini-chart svg { height: 76px; }
.range-tabs { display: flex; gap: 4px; }
.range-tabs button {
  border: 1px solid #2a3037;
  background: #0b0e12;
  color: #7f8790;
  padding: 3px 7px;
  font: inherit;
  font-size: 11px;
}
.range-tabs button.active { color: #f0f3f6; border-color: #58616c; }
.activity-list { list-style: none; margin: 0; padding: 8px 11px; }
.activity-list li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid #20262c;
  font-size: 12px;
}
.activity-list time { color: #78818b; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.log-drawer { border-top: 1px solid #242a30; padding: 9px 11px; }
.log-drawer summary { cursor: pointer; color: #aeb5bd; font-size: 12px; }
pre {
  max-height: 360px;
  overflow: auto;
  color: #949ca5;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .status-grid { grid-template-columns: repeat(3, auto); }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .memo-grid { grid-template-columns: 1fr; }
  .portfolio-body { grid-template-columns: 1fr; }
  .portfolio-metrics { border-left: 0; border-top: 1px solid #242a30; padding-left: 0; padding-top: 10px; }
}

@media (max-width: 680px) {
  .terminal { width: min(100% - 16px, 1480px); padding-top: 12px; }
  .terminal-header { flex-direction: column; }
  .status-grid { grid-template-columns: repeat(2, auto); }
  .kpi-strip { grid-template-columns: 1fr; }
  .ledger-row { grid-template-columns: 60px 1fr auto; }
  .ledger-row .weight { display: none; }
}
