:root {
  color-scheme: dark;
  --bg: #070b10;
  --panel: #0e151d;
  --panel2: #111b25;
  --panel3: #091018;
  --ink: #e7edf2;
  --muted: #8b98a7;
  --dim: #5f6d7a;
  --line: rgba(144, 163, 180, 0.18);
  --line2: rgba(144, 163, 180, 0.32);
  --green: #48d597;
  --green-soft: rgba(72, 213, 151, 0.12);
  --amber: #e4b45f;
  --amber-soft: rgba(228, 180, 95, 0.14);
  --blue: #6db6e8;
  --blue-soft: rgba(109, 182, 232, 0.13);
  --red: #eb6b78;
  --red-soft: rgba(235, 107, 120, 0.12);
  --shadow: 0 26px 72px rgba(0, 0, 0, 0.34);
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Geist, Satoshi, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
}

.terminal-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 12% -12%, rgba(72, 213, 151, 0.12), transparent 62%),
    radial-gradient(760px 500px at 98% 0%, rgba(109, 182, 232, 0.08), transparent 58%),
    linear-gradient(rgba(144, 163, 180, 0.044) 1px, transparent 1px),
    linear-gradient(90deg, rgba(144, 163, 180, 0.034) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 28px 28px, 28px 28px, auto;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.10;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.36'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  width: min(1640px, calc(100% - 20px));
  margin: 0 auto;
  padding: 10px 0 44px;
}

.topbar,
.hero,
.scoreboard,
.panel {
  border: 1px solid var(--line);
  background: rgba(14, 21, 29, 0.94);
  box-shadow: var(--shadow);
}

.topbar {
  position: sticky;
  top: 8px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 8px 10px;
  backdrop-filter: blur(18px);
}

.brand,
.nav a,
.order-table a { color: inherit; text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(72, 213, 151, 0.42);
  color: var(--green);
  background: #08130f;
  font-family: var(--mono);
  font-weight: 950;
  letter-spacing: -0.08em;
}
.brand strong,
.brand em { display: block; }
.brand strong { font-family: var(--mono); font-size: 0.92rem; letter-spacing: 0.02em; }
.brand em { color: var(--muted); font-family: var(--mono); font-size: 0.67rem; font-style: normal; letter-spacing: 0.08em; }

.nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.nav a {
  border: 1px solid var(--line);
  padding: 7px 9px;
  color: var(--muted);
  background: rgba(255,255,255,0.025);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.03em;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.nav a:hover { color: var(--ink); border-color: var(--line2); background: rgba(255,255,255,0.045); }
.nav a:active { transform: translateY(1px); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 10px;
  margin-top: 8px;
  padding: 16px;
}

.eyebrow,
.panel-heading span,
.scoreboard span,
.status-panel span,
.command-strip span,
.rule-list strong,
.next-build span,
.note-rank,
.action-line span,
.memo-grid span,
.setup-row span,
.equity-head span {
  display: block;
  margin: 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 6px 0 0;
  font-size: clamp(1.9rem, 4vw, 4.55rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
}

.mandate {
  max-width: 1080px;
  margin: 12px 0 0;
  color: #b9c4ce;
  font-size: 0.98rem;
  line-height: 1.46;
}

.command-strip {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  border: 1px solid rgba(72, 213, 151, 0.28);
  background: var(--green-soft);
  padding: 12px;
}
.command-strip strong { color: var(--green); font-family: var(--mono); font-size: 0.9rem; line-height: 1.4; }

.status-panel { border: 1px solid var(--line); background: var(--panel3); }
.status-panel div { display: grid; grid-template-columns: 94px minmax(0, 1fr); gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.status-panel div:last-child { border-bottom: 0; }
.status-panel strong { color: var(--green); font-family: var(--mono); font-size: 0.76rem; text-align: right; line-height: 1.36; }

.scoreboard {
  display: grid;
  grid-template-columns: 1.35fr 0.52fr 0.75fr 1.25fr;
  gap: 1px;
  margin-top: 8px;
  padding: 1px;
  background: var(--line);
}
.scoreboard article { min-height: 82px; padding: 12px; background: var(--panel); }
.scoreboard strong {
  display: block;
  margin-top: 9px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(0.88rem, 1.25vw, 1.28rem);
  line-height: 1.16;
  letter-spacing: -0.035em;
}

.panel { margin-top: 8px; padding: 12px; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.panel-heading.compact { align-items: start; }
.panel-heading h2 { margin: 3px 0 0; font-size: clamp(1.05rem, 1.6vw, 1.55rem); letter-spacing: -0.045em; }
.panel-heading p { max-width: 560px; margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.36; text-align: right; }

.table-wrap { overflow-x: auto; }
.order-table { width: 100%; min-width: 1180px; border-collapse: collapse; font-family: var(--mono); font-size: 0.76rem; }
.order-table th,
.order-table td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: top; }
.order-table th { color: var(--dim); font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; }
.order-table tr { cursor: pointer; transition: background 140ms ease; }
.order-table tbody tr:hover { background: rgba(255,255,255,0.035); }
.order-table td strong,
.order-table td span { display: block; }
.order-table td span { margin-top: 3px; color: var(--muted); font-size: 0.68rem; line-height: 1.32; }
.upside { color: var(--green); font-weight: 900; }

.call,
.risk {
  display: inline-flex;
  align-items: center;
  width: max-content;
  border: 1px solid var(--line2);
  padding: 4px 7px;
  color: var(--ink);
  background: rgba(255,255,255,0.035);
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 950;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.call-buy { border-color: rgba(72, 213, 151, 0.5); color: var(--green); background: var(--green-soft); }
.call-tactical { border-color: rgba(109, 182, 232, 0.48); color: var(--blue); background: var(--blue-soft); }
.call-wait { border-color: rgba(228, 180, 95, 0.48); color: var(--amber); background: var(--amber-soft); }
.call-watch { color: #b7c2cd; }
.risk-high { border-color: rgba(235, 107, 120, 0.45); color: var(--red); background: var(--red-soft); }
.risk-mid { border-color: rgba(228, 180, 95, 0.45); color: var(--amber); background: var(--amber-soft); }

.book-grid { display: grid; grid-template-columns: minmax(340px, 0.8fr) minmax(0, 1.2fr); gap: 8px; }
.rule-list { display: grid; gap: 1px; margin-top: 12px; background: var(--line); }
.rule-list article { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 8px; padding: 10px; background: var(--panel3); }
.rule-list span { color: #b8c2cc; font-size: 0.86rem; line-height: 1.38; }

.arena-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr); gap: 12px; margin-top: 12px; }
.equity-card { border: 1px solid var(--line); background: var(--panel3); padding: 12px; }
.equity-head { display: flex; justify-content: space-between; gap: 12px; }
.equity-head strong { color: var(--green); font-family: var(--mono); font-size: 0.72rem; }
.equity-card svg { width: 100%; height: auto; margin-top: 10px; overflow: visible; }
.equity-card path { fill: none; stroke: var(--green); stroke-width: 5; stroke-linecap: round; filter: drop-shadow(0 8px 18px rgba(72, 213, 151, 0.12)); }
.equity-card path.bench { stroke: var(--blue); stroke-width: 3; opacity: 0.72; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-family: var(--mono); font-size: 0.68rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; background: var(--green); display: inline-block; }
.legend span:nth-child(2) i { background: var(--blue); }
.next-build { display: grid; gap: 8px; }
.next-build article { border: 1px solid var(--line); background: rgba(255,255,255,0.025); padding: 10px; }
.next-build strong { display: block; margin-top: 5px; color: #c4ced8; font-size: 0.86rem; line-height: 1.34; }

.notes-stack { display: grid; gap: 8px; margin-top: 12px; }
.note { border: 1px solid var(--line); background: var(--panel2); padding: 12px; scroll-margin-top: 76px; }
.note.flash { animation: flash 900ms ease; }
@keyframes flash { 0% { border-color: rgba(72,213,151,.72); background: rgba(72,213,151,.08); } 100% { border-color: var(--line); background: var(--panel2); } }
.note-header { display: flex; align-items: start; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.note-header h3 { margin: 4px 0 0; font-size: clamp(1.05rem, 1.8vw, 1.7rem); letter-spacing: -0.055em; }
.note-header h3 em { color: var(--muted); font-style: normal; font-weight: 600; }
.note-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.action-line { margin-top: 12px; border: 1px solid rgba(72, 213, 151, 0.28); background: var(--green-soft); padding: 12px; }
.action-line strong { display: block; margin-top: 5px; color: #d7efe5; font-size: 0.96rem; line-height: 1.44; }
.memo-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; margin-top: 12px; background: var(--line); }
.memo-grid article { min-height: 78px; padding: 10px; background: var(--panel3); }
.memo-grid article.wide { grid-column: span 3; }
.memo-grid strong { display: block; margin-top: 7px; color: var(--ink); font-family: var(--mono); font-size: 0.78rem; line-height: 1.34; }
.narrative { margin: 12px 0 0; color: #c5ced6; font-size: 0.92rem; line-height: 1.5; }
.note-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.note-columns section { border-top: 1px solid var(--line); padding-top: 10px; }
.note-columns h4 { margin: 0 0 8px; color: var(--muted); font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
ul { margin: 0; padding-left: 18px; color: #c0cad2; font-size: 0.84rem; line-height: 1.45; }
li + li { margin-top: 5px; }
.setup-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.setup-row strong { color: var(--green); font-family: var(--mono); font-size: 0.78rem; line-height: 1.4; }

.skeleton-line,
.skeleton-block { background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.08), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-line { height: 18px; width: 42%; }
.skeleton-block { height: 160px; margin-top: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 980px) {
  .shell { width: min(100% - 12px, 1640px); }
  .topbar,
  .hero,
  .panel-heading,
  .note-header { align-items: stretch; flex-direction: column; }
  .hero,
  .book-grid,
  .arena-body { grid-template-columns: 1fr; }
  .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .memo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .memo-grid article.wide { grid-column: span 2; }
  .note-columns { grid-template-columns: 1fr; }
  .panel-heading p { text-align: left; }
}

@media (max-width: 620px) {
  .topbar { position: relative; top: 0; }
  .nav { justify-content: flex-start; }
  .hero { padding: 12px; }
  .hero h1 { font-size: 2.15rem; }
  .command-strip,
  .status-panel div,
  .setup-row { grid-template-columns: 1fr; }
  .scoreboard { grid-template-columns: 1fr; }
  .memo-grid { grid-template-columns: 1fr; }
  .memo-grid article.wide { grid-column: auto; }
}
