:root {
  --bg: #f6f7f4;
  --ink: #202421;
  --muted: #6a716c;
  --line: #dfe4dc;
  --panel: #fbfcf8;
  --panel-strong: #ffffff;
  --accent: #32795f;
  --accent-soft: #dcebe3;
  --danger: #a8463b;
  --warning: #aa772e;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Geist", "Aptos", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); font-family: var(--sans); }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  min-height: 100dvh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: rgba(251, 252, 248, 0.76);
  backdrop-filter: blur(18px);
}

.brand-mark, .rail-button, .icon-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.brand-mark {
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  border-radius: 8px;
  color: var(--accent);
}

.rail-button, .icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  transition: transform 180ms cubic-bezier(.16, 1, .3, 1), border-color 180ms, background 180ms;
}

.rail-button:hover, .icon-button:hover, .text-button:hover { transform: translateY(-1px); }
.rail-button:active, .icon-button:active, .text-button:active { transform: scale(.98); }
.rail-button.active { background: var(--ink); border-color: var(--ink); color: #ffffff; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 32px clamp(18px, 4vw, 56px) 56px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
  font-weight: 760;
}
h2 { margin-bottom: 0; font-size: 22px; line-height: 1.1; letter-spacing: 0; }
h3 { margin-bottom: 6px; font-size: 17px; }

.top-actions { display: flex; align-items: center; gap: 12px; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: breathe 1800ms ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(.78); opacity: .5; }
  50% { transform: scale(1); opacity: 1; }
}

.hidden { display: none !important; }
.loading-grid {
  display: grid;
  grid-template-columns: 1.6fr .8fr;
  grid-auto-rows: 210px;
  gap: 18px;
}

.skeleton {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, #ecefeb 0%, #fbfcf8 50%, #ecefeb 100%);
  background-size: 200% 100%;
  animation: shimmer 1300ms ease-in-out infinite;
}
.skeleton.wide { grid-column: span 2; height: 160px; }
.skeleton.tall { min-height: 340px; }
@keyframes shimmer { from { background-position: 0 0; } to { background-position: -200% 0; } }

.empty-state {
  max-width: 680px;
  padding: 34px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.empty-state p { color: var(--muted); line-height: 1.6; }
.section-panel { animation: reveal 360ms cubic-bezier(.16, 1, .3, 1) both; }
@keyframes reveal { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
}
.metric { min-height: 132px; padding: 20px; background: var(--panel-strong); }
.metric span, .definition-list dt, th {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
}
.metric strong {
  display: block;
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 650;
}
.metric small { display: block; margin-top: 8px; color: var(--muted); }

.overview-grid, .split-grid, .market-layout { display: grid; gap: 18px; }
.overview-grid { grid-template-columns: minmax(0, 1.55fr) minmax(280px, .72fr); margin-bottom: 18px; }
.split-grid { grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); }
.market-layout { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); align-items: start; }

.primary-panel, .secondary-panel, .list-panel, .table-panel, .detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.primary-panel, .secondary-panel, .list-panel { padding: 22px; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 20px; }
canvas { display: block; width: 100%; min-height: 260px; }

.status-mix, .ranked-list, .position-list, .recap-list { display: grid; gap: 10px; }
.mix-row, .ranked-row, .position-card, .recap-card { border-top: 1px solid var(--line); padding-top: 14px; }
.mix-row:first-child, .ranked-row:first-child { border-top: 0; padding-top: 0; }
.mix-row header, .ranked-row header, .position-card header { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.bar { height: 7px; margin-top: 10px; border-radius: 99px; background: #e7ebe5; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }

.subtle, td small { color: var(--muted); }
.money, .number, td:nth-child(n + 2) { font-family: var(--mono); }
.positive { color: var(--accent); }
.negative { color: var(--danger); }
.warning { color: var(--warning); }

.definition-list { display: grid; grid-template-columns: 1fr auto; gap: 12px 20px; }
.definition-list dd { margin: 0; text-align: right; font-family: var(--mono); }

.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 180px auto; gap: 12px; align-items: end; margin-bottom: 18px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel-strong);
  color: var(--ink);
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.text-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  background: var(--panel-strong);
  color: var(--ink);
  transition: transform 180ms cubic-bezier(.16, 1, .3, 1);
}

.table-panel { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tbody tr { cursor: pointer; transition: background 160ms; }
tbody tr:hover, tbody tr.selected { background: var(--accent-soft); }

.detail-panel { position: sticky; top: 24px; padding: 20px; }
.detail-empty { color: var(--muted); line-height: 1.6; }
.mini-chart {
  width: 100%;
  height: 170px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}
.outcome-list { display: grid; gap: 8px; max-height: 330px; overflow: auto; }
.outcome-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.position-card { padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.position-card .definition-list { margin-top: 16px; }
.recap-card p {
  max-height: 170px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 1050px) {
  .metric-strip, .overview-grid, .split-grid, .market-layout { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail {
    position: sticky;
    z-index: 2;
    top: 0;
    height: auto;
    flex-direction: row;
    justify-content: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand-mark { display: none; }
  main { padding: 24px 14px 42px; }
  .topbar, .top-actions { align-items: stretch; }
  .topbar { flex-direction: column; }
  .metric-strip, .toolbar { grid-template-columns: 1fr; }
  h1 { font-size: 38px; }
}
