/* ============================================================
   quant ops — dark, terminal-inspired, mobile-first
   ============================================================ */

:root {
  --bg: #0a0c10;
  --bg-2: #0e1116;
  --card: #131720;
  --card-hi: #1a1f2b;
  --line: #1f2533;
  --line-hi: #2a3142;
  --fg: #e6e8ee;
  --fg-2: #b9bdc7;
  --muted: #6f7686;
  --muted-2: #4d5462;
  --accent: #5cd6ff;
  --pos: #4ad991;
  --pos-bg: rgba(74, 217, 145, 0.10);
  --neg: #ff6464;
  --neg-bg: rgba(255, 100, 100, 0.10);
  --warn: #f5b342;

  --radius: 10px;
  --pad: 16px;
  --gap: 12px;
  --tap: 44px;

  --safe-top: env(safe-area-inset-top, 0);
  --safe-bot: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(var(--safe-bot) + 24px);
}

a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.6; }

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

/* ───────── topbar (sticky) ───────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10, 12, 16, 0.92);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px var(--pad);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}
.brand-name {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--card);
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--line);
}

.topbar-stats {
  display: flex;
  gap: 14px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 60px;
}
.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 1px;
}
.stat-val {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}
.stat-lg .stat-val {
  font-size: 18px;
  font-weight: 600;
}

/* ───────── main ───────── */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px var(--pad) 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0;
}
.card-head h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 500;
}
.card-head .muted { font-size: 11px; }

/* ───────── grid (state) ───────── */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.kv {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.kv span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.kv b {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ───────── chart container ───────── */

.chart {
  width: 100%;
  height: 240px;
  border-radius: 6px;
  overflow: hidden;
}
.chart-sm { height: 80px; margin-top: 6px; }
@media (min-width: 600px) {
  .chart { height: 300px; }
  .chart-sm { height: 90px; }
}

/* ───────── rows (positions/trades/runs) ───────── */

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.rows li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  min-height: var(--tap);
}
.rows li:first-child { border-top: 0; }

.rows.compact li { padding: 8px 0; min-height: 36px; }

.row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.row-title {
  font-size: 14px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
}
.row-title .ticker {
  color: var(--accent);
  font-weight: 500;
}
.row-title .name {
  color: var(--fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.row-sub {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
.row-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.row-meta .primary {
  font-size: 14px;
  font-weight: 500;
}
.row-meta .secondary {
  font-size: 11px;
  color: var(--muted);
}

/* weight bar (positions) */
.weight-bar {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.weight-bar > div {
  height: 100%;
  background: var(--accent);
  opacity: 0.7;
  transition: width 0.3s ease;
}

/* side pills */
.pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.pill-buy { background: var(--pos-bg); color: var(--pos); }
.pill-sell { background: var(--neg-bg); color: var(--neg); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.kill-armed { color: var(--pos); }
.kill-disarmed { color: var(--neg); }

/* ───────── decisions ───────── */

.decisions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  counter-reset: dec;
}
.decisions li {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  counter-increment: dec;
}
.decisions h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.decisions h3::before {
  content: counter(dec, decimal-leading-zero);
  color: var(--muted-2);
  font-weight: 400;
}
.decisions .gate {
  display: inline-block;
  background: var(--card-hi);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}
.decisions .meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.decisions .body {
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--fg-2);
  line-height: 1.55;
}

/* ───────── footer ───────── */

footer {
  max-width: 1100px;
  margin: 24px auto 0;
  padding: 0 var(--pad);
  font-size: 11px;
}

/* ───────── tablet+ refinements ───────── */

@media (min-width: 720px) {
  body { font-size: 13px; }
  .topbar-inner { padding: 12px 20px; }
  main { padding: 16px 20px 0; gap: 16px; }
  .card { padding: 16px 18px; }
  .card-head h2 { font-size: 11px; }
  .stat-lg .stat-val { font-size: 20px; }
}

/* ───────── reduce motion ───────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
