:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #edf2f7;
  --ink: #111827;
  --muted: #667085;
  --line: #d7dee8;
  --line-strong: #c0cad7;
  --nav: #171a21;
  --green: #087f5b;
  --red: #b42318;
  --amber: #b54708;
  --blue: #255f9f;
  --violet: #6941c6;
  --shadow: 0 14px 34px rgba(17, 24, 39, 0.08);
  --tight-shadow: 0 3px 10px rgba(17, 24, 39, 0.05);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 22px;
  color: #f8fafc;
  background: var(--nav);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #101828;
  background: #75d5a3;
  border-radius: 8px;
  font-weight: 950;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.1;
}

.brand p,
.side-label {
  margin-top: 3px;
  color: rgba(248, 250, 252, 0.62);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 11px;
  color: rgba(248, 250, 252, 0.74);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.nav-item span {
  color: rgba(248, 250, 252, 0.42);
  font-size: 11px;
  font-weight: 900;
}

.nav-item strong {
  font-size: 13px;
}

.nav-item:hover,
.nav-item.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.side-panel {
  margin-top: auto;
  padding: 13px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
}

.side-value {
  margin-top: 7px;
  color: rgba(248, 250, 252, 0.92);
  font-size: 13px;
  line-height: 1.35;
}

.workspace {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  padding: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(280px, 0.7fr);
  gap: 12px;
  align-items: center;
  min-height: 70px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--tight-shadow);
}

.desk-title {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.desk-title span,
.panel-head p,
.metric span,
.mini-kpi span {
  color: var(--muted);
  font-size: 12px;
}

.desk-title span {
  font-weight: 900;
  text-transform: uppercase;
}

.desk-title strong {
  max-width: 780px;
  font-size: 17px;
  line-height: 1.25;
}

.command-group,
.toolbar,
.segmented {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar {
  justify-content: flex-end;
}

.command,
.icon-button,
.link-button,
.segmented button {
  min-height: 36px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.command {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 850;
}

.command.primary {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.command.danger {
  color: #ffffff;
  background: var(--red);
  border-color: var(--red);
}

.command:disabled,
.icon-button:disabled,
.mini-action:disabled {
  cursor: wait;
  opacity: 0.55;
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  color: inherit;
  background: rgba(17, 24, 39, 0.08);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.primary .btn-icon,
.danger .btn-icon {
  background: rgba(255, 255, 255, 0.18);
}

.icon-button {
  width: 38px;
  font-weight: 950;
}

.link-button {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

.link-button.is-disabled {
  pointer-events: none;
  opacity: 0.42;
}

.search,
.live-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 850;
}

.live-toggle input {
  min-height: auto;
}

.search input {
  width: 210px;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.live-strip {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.live-strip > div:first-child {
  display: flex;
  gap: 9px;
  align-items: center;
  min-width: 240px;
}

.live-strip span,
.activity-feed span {
  color: var(--muted);
  font-size: 12px;
}

.live-strip strong {
  font-size: 13px;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(8, 127, 91, 0.12);
}

.pulse.is-running {
  background: var(--amber);
  animation: pulse 900ms ease-in-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(181, 71, 8, 0.28);
  }
  100% {
    box-shadow: 0 0 0 9px rgba(181, 71, 8, 0);
  }
}

.activity-feed {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  overflow: hidden;
  max-width: 58%;
}

.activity-feed span {
  overflow: hidden;
  max-width: 260px;
  padding: 5px 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.is-visible {
  display: grid;
  gap: 14px;
  animation: viewIn 220ms ease both;
}

@keyframes viewIn {
  from {
    transform: translateY(4px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.metrics {
  display: grid;
  grid-template-columns: repeat(8, minmax(118px, 1fr));
  gap: 8px;
}

.metric {
  min-height: 70px;
  padding: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--tight-shadow);
}

.metric.primary-metric {
  border-left: 4px solid var(--blue);
}

.metric span {
  display: block;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  font-size: 21px;
  line-height: 1.05;
  text-overflow: ellipsis;
}

.breakdown-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.breakdown-strip > div {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  padding: 9px 11px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.breakdown-strip h3 {
  flex: 0 0 auto;
  margin: 0 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.breakdown-strip span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
  min-height: 25px;
  padding: 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.breakdown-strip em {
  font-style: normal;
  font-weight: 950;
}

.pnl-chart-panel {
  display: grid;
  gap: 10px;
  margin: 0 12px 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pnl-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.pnl-chart-head h3 {
  font-size: 14px;
}

.pnl-chart-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.pnl-periods {
  background: var(--surface);
}

.pnl-chart {
  min-height: 230px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(23, 105, 170, 0.07), transparent 28%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pnl-chart svg {
  display: block;
  width: 100%;
  height: 230px;
}

.chart-grid,
.chart-zero {
  stroke: #dfe7ee;
  stroke-width: 1;
}

.chart-zero {
  stroke-dasharray: 5 5;
}

.chart-area {
  fill: url("#pnlFill");
  stroke: none;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke: var(--green);
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: drawLine 680ms ease forwards;
}

.chart-line.neg {
  stroke: var(--red);
}

.chart-points circle {
  fill: var(--green);
  stroke: #ffffff;
  stroke-width: 2;
  animation: pointPop 360ms ease both;
}

.chart-points.neg circle {
  fill: var(--red);
}

.chart-label,
.chart-delta {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.chart-value {
  fill: var(--green);
  font-size: 18px;
  font-weight: 950;
}

.chart-value.neg,
.chart-delta.neg {
  fill: var(--red);
}

.chart-value.pos,
.chart-delta.pos {
  fill: var(--green);
}

.chart-empty {
  display: grid;
  min-height: 230px;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes pointPop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.brief-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.72fr);
  gap: 14px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(300px, 0.84fr) minmax(360px, 1fr) minmax(360px, 0.95fr);
  gap: 14px;
  align-items: start;
}

.book-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.book-command {
  display: grid;
  grid-template-columns: minmax(280px, 0.76fr) minmax(0, 1.24fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
  padding: 14px;
  color: #ffffff;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  box-shadow: var(--tight-shadow);
}

.book-title {
  display: grid;
  gap: 5px;
  align-content: center;
}

.book-title span,
.book-summary-card span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.book-title strong {
  font-size: 24px;
  line-height: 1.1;
}

.book-title p,
.book-summary-card small {
  color: rgba(255, 255, 255, 0.70);
  font-size: 12px;
  line-height: 1.38;
}

.book-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(118px, 1fr));
  gap: 8px;
}

.book-summary-card {
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: 86px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.book-summary-card strong {
  color: #ffffff;
  font-size: 21px;
  line-height: 1.1;
}

.book-summary-card.pos strong {
  color: #7ee2a8;
}

.book-summary-card.neg strong {
  color: #ff9c8f;
}

.panel,
.assistant-panel,
.control-panel,
.ai-desk,
.intelligence-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head.compact {
  min-height: 56px;
}

.panel-head h2 {
  font-size: 15px;
  line-height: 1.2;
}

.segmented {
  flex: 0 0 auto;
  padding: 3px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted);
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: 12px;
  font-weight: 900;
}

.segmented button.is-active {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.assistant-brief,
.selected-controls,
.ai-advisor-deck,
.intelligence-deck,
.card-list,
.detail-body,
.detail-empty {
  padding: 14px;
}

.intelligence-panel {
  position: relative;
  overflow: hidden;
}

.intelligence-panel::before {
  position: absolute;
  inset: -1px auto auto 0;
  width: 100%;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, var(--blue), var(--green), var(--amber), var(--red));
  opacity: 0.9;
}

.intelligence-deck {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr 1fr;
  gap: 10px;
}

.brain-card {
  display: grid;
  gap: 9px;
  align-content: start;
  min-width: 0;
  min-height: 180px;
  padding: 12px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(23, 105, 170, 0.06), transparent 44%),
    var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--tight-shadow);
}

.brain-card.wide {
  grid-column: 1 / -1;
  min-height: auto;
}

.brain-card.capital.reject {
  border-top: 3px solid var(--red);
}

.brain-card.capital.watch {
  border-top: 3px solid var(--amber);
}

.brain-card.capital.buy {
  border-top: 3px solid var(--green);
}

.brain-card > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.brain-card > strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.08;
  text-overflow: ellipsis;
}

.brain-card > p,
.brain-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.brain-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.brain-kpis div,
.strategy-mini,
.rule-mini,
.missed-mini,
.learning-mini,
.tuning-mini,
.recommendation-mini {
  min-width: 0;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brain-kpis span,
.strategy-mini span,
.rule-mini span,
.missed-mini span,
.learning-mini span,
.tuning-mini span,
.recommendation-mini span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.brain-kpis strong,
.strategy-mini strong,
.rule-mini strong,
.missed-mini strong,
.learning-mini strong,
.tuning-mini strong,
.recommendation-mini strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
}

.strategy-stack,
.rule-stack,
.missed-stack,
.learning-stack,
.tuning-stack {
  display: grid;
  gap: 7px;
}

.strategy-mini.hot {
  border-left: 3px solid var(--green);
}

.strategy-mini.cold,
.strategy-mini.bleeding {
  border-left: 3px solid var(--red);
}

.strategy-mini.learning {
  border-left: 3px solid var(--amber);
}

.tuning-mini.hot {
  border-left: 3px solid var(--green);
}

.tuning-mini.cold,
.tuning-mini.bleeding {
  border-left: 3px solid var(--red);
}

.learning-mini {
  border-left: 3px solid var(--blue);
}

.recommendation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.export-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.opportunity-panel {
  overflow: hidden;
}

.opportunity-inbox {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.inbox-lane {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 220px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--tight-shadow);
}

.inbox-lane.enter-now {
  border-top: 3px solid var(--green);
}

.inbox-lane.watch-closely,
.inbox-lane.migration-soon,
.inbox-lane.manually-review {
  border-top: 3px solid var(--amber);
}

.inbox-lane.missed-runner,
.inbox-lane.dead-rug-risk {
  border-top: 3px solid var(--red);
}

.inbox-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.inbox-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.inbox-head strong {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.inbox-items {
  display: grid;
  gap: 7px;
}

.inbox-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 8px;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.inbox-item:hover {
  border-color: rgba(37, 95, 159, 0.45);
  box-shadow: 0 12px 28px rgba(16, 20, 24, 0.08);
  transform: translateY(-1px);
}

.inbox-item strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
}

.inbox-item span,
.inbox-item em,
.inbox-item p {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.3;
}

.recommendation-mini.high {
  border-left: 3px solid var(--red);
}

.recommendation-mini.medium {
  border-left: 3px solid var(--amber);
}

.recommendation-mini.low {
  border-left: 3px solid var(--blue);
}

.assistant-brief {
  display: grid;
  gap: 11px;
}

.assistant-opinion {
  padding: 11px 12px;
  color: #25364a;
  background: #eef6ff;
  border: 1px solid #cfe3fa;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 9px;
}

.brief-card,
.brief-tips,
.ai-summary-card,
.ai-card,
.trade-card,
.candidate-card,
.closed-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brief-card {
  min-height: 112px;
  padding: 10px;
  border-top: 3px solid var(--blue);
}

.brief-card.buy {
  border-top-color: var(--green);
}

.brief-card.watch {
  border-top-color: var(--amber);
}

.brief-card.risk {
  border-top-color: var(--red);
}

.brief-card h3,
.brief-tips h3,
.ai-card h3,
.list-block h4,
.intel-head h4,
.link-chip-block h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.brief-card ul,
.brief-tips ul,
.ai-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 16px;
  color: #344054;
  font-size: 12px;
  line-height: 1.35;
}

.brief-tips {
  padding: 10px;
}

.selected-controls {
  display: grid;
  gap: 10px;
}

.control-focus {
  padding: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.control-grid .command {
  justify-content: center;
  min-width: 0;
  padding: 0 9px;
}

.control-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.control-meta span,
.muted-line {
  padding: 7px 8px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}

.ai-advisor-deck {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) repeat(3, minmax(220px, 1fr));
  gap: 10px;
}

.ai-summary-card,
.ai-card {
  display: grid;
  gap: 9px;
  align-content: start;
  min-width: 0;
  padding: 11px;
}

.ai-summary-card {
  border-top: 3px solid var(--blue);
}

.ai-summary-card.risk-off,
.ai-summary-card.panic,
.ai-card.risk {
  border-top: 3px solid var(--red);
}

.ai-summary-card.opportunistic {
  border-top-color: var(--green);
}

.ai-card.wide {
  grid-column: span 2;
}

.provider-health {
  min-height: 100%;
}

.provider-health-list {
  display: grid;
  gap: 7px;
}

.provider-health-item {
  display: grid;
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
}

.provider-health-item.buy {
  border-left-color: var(--green);
}

.provider-health-item.watch {
  border-left-color: var(--amber);
}

.provider-health-item.reject {
  border-left-color: var(--red);
}

.provider-health-item div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.provider-health-item span,
.provider-health-item small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.provider-health-item strong {
  color: var(--ink);
  font-size: 11px;
  text-transform: uppercase;
}

.provider-health-item p {
  margin: 0;
  color: #344054;
  font-size: 11px;
  line-height: 1.35;
}

.ai-chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.ai-chat-panel,
.ai-chat-status-card {
  overflow: hidden;
}

.ai-chat-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.ai-chat-stream {
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 170px);
  min-height: 560px;
  padding: 18px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(37, 95, 159, 0.05), transparent 260px),
    radial-gradient(circle at 20% 0%, rgba(8, 127, 91, 0.08), transparent 280px),
    var(--surface-2);
  scroll-behavior: smooth;
}

.ai-chat-turn {
  display: grid;
  gap: 11px;
  animation: cardIn 180ms ease both;
}

.ai-chat-message {
  display: grid;
  grid-template-columns: 34px minmax(0, 0.82fr);
  gap: 10px;
  align-items: start;
}

.ai-chat-message.ai {
  grid-template-columns: minmax(0, 0.82fr) 34px;
  justify-content: end;
}

.ai-chat-message.ai .ai-chat-avatar {
  grid-column: 2;
}

.ai-chat-message.ai .ai-chat-bubble {
  grid-column: 1;
  grid-row: 1;
  border-color: rgba(8, 127, 91, 0.25);
  background:
    linear-gradient(135deg, rgba(8, 127, 91, 0.08), transparent 45%),
    var(--surface);
}

.ai-chat-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #ffffff;
  background: #111827;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 950;
  box-shadow: var(--tight-shadow);
}

.ai-chat-avatar.ai {
  background: linear-gradient(135deg, var(--green), var(--blue));
}

.ai-chat-bubble {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--tight-shadow);
}

.ai-chat-bubble header,
.ai-chat-reply-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.ai-chat-bubble header strong {
  font-size: 13px;
}

.ai-chat-bubble header span,
.ai-chat-bubble p,
.ai-chat-mini-list span {
  color: #344054;
  font-size: 12px;
  line-height: 1.45;
}

.ai-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-chat-chips span {
  padding: 4px 7px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
}

.ai-chat-bubble details {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.ai-chat-bubble summary {
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.ai-chat-bubble pre {
  max-height: 360px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  color: #172033;
  background: #ffffff;
  border-top: 1px solid var(--line);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat-parsed {
  display: grid;
  gap: 9px;
}

.ai-chat-mini-list {
  display: grid;
  gap: 5px;
  padding: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
}

.ai-chat-mini-list.risk {
  border-left-color: var(--red);
}

.ai-chat-mini-list strong {
  color: var(--muted);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.ai-chat-error {
  padding: 10px;
  color: var(--red) !important;
  background: rgba(180, 35, 24, 0.07);
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 8px;
}

.ai-chat-sidebar {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
}

.ai-chat-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 14px;
}

.ai-chat-health {
  padding: 14px;
}

.ai-summary-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.ai-summary-card strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  text-transform: capitalize;
}

.ai-summary-card p,
.ai-summary-card small,
.ai-card p,
.opinion-card p {
  color: #344054;
  font-size: 12px;
  line-height: 1.42;
}

.ai-list {
  display: grid;
  gap: 8px;
}

.ai-list-item,
.opinion-card {
  display: grid;
  gap: 5px;
  align-content: start;
  padding: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ai-list-item span {
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.ai-list-item strong {
  font-size: 13px;
}

.opinion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 8px;
}

.opinion-card {
  min-height: 118px;
  text-align: left;
}

.opinion-card:hover {
  border-color: var(--blue);
}

.opinion-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.opinion-card em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.card-list {
  display: grid;
  gap: 10px;
}

.wide-list {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.book-grid .wide-list {
  align-content: start;
  max-height: 650px;
  overflow: auto;
}

.trade-card,
.candidate-card,
.closed-card {
  display: grid;
  gap: 10px;
  padding: 11px;
  text-align: left;
}

button.trade-card,
button.candidate-card,
button.closed-card {
  width: 100%;
  color: inherit;
}

.trade-card:hover,
.candidate-card:hover,
.closed-card:hover,
.trade-card.is-selected,
.candidate-card.is-selected,
.closed-card.is-selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 95, 159, 0.10);
}

.card-top,
.card-kpis,
.card-actions,
.card-tags {
  display: flex;
  gap: 7px;
  align-items: center;
}

.card-top {
  justify-content: space-between;
  align-items: flex-start;
}

.card-kpis,
.card-tags {
  flex-wrap: wrap;
}

.card-kpis span,
.card-tags span {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  min-height: 25px;
  padding: 0 8px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.card-kpis strong,
.card-tags strong {
  color: var(--ink);
}

.card-kpis span.pos strong {
  color: var(--green);
}

.card-kpis span.neg strong {
  color: var(--red);
}

.card-note {
  color: #344054;
  font-size: 12px;
  line-height: 1.4;
}

.row-actions,
.card-actions {
  flex-wrap: wrap;
}

.mini-action {
  min-height: 28px;
  padding: 0 8px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 950;
}

.mini-action.buy {
  color: #ffffff;
  background: var(--green);
  border-color: var(--green);
}

.mini-action.danger {
  color: #ffffff;
  background: var(--red);
  border-color: var(--red);
}

.empty-card {
  display: grid;
  min-height: 118px;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  text-align: center;
}

.coin-cell {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.coin-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  color: #ffffff;
  background: var(--nav);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 950;
}

.coin-name {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.coin-name strong {
  overflow: hidden;
  max-width: 210px;
  text-overflow: ellipsis;
}

.coin-name span {
  color: var(--muted);
  font-size: 11px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.pill.buy,
.pill.open,
.value.pos,
.pos {
  color: var(--green);
}

.pill.watch,
.watch {
  color: var(--amber);
}

.pill.reject,
.pill.closed,
.value.neg,
.neg {
  color: var(--red);
}

.score {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 28px;
  color: #ffffff;
  background: var(--nav);
  border-radius: 8px;
  font-weight: 950;
}

.score.moon {
  background: var(--green);
}

.score.risk {
  background: var(--red);
}

.detail-panel {
  position: sticky;
  top: 14px;
  align-self: start;
}

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

.detail-body {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 140px);
  overflow: auto;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.detail-title h3 {
  font-size: 22px;
}

.detail-title p {
  color: var(--muted);
  font-size: 12px;
}

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mini-kpi {
  min-width: 0;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-kpi strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.list-block {
  display: grid;
  gap: 8px;
}

.list-block ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 16px;
  color: #344054;
  font-size: 13px;
  line-height: 1.4;
}

.intel-block,
.ai-opinion-block {
  display: grid;
  gap: 11px;
  padding: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ai-opinion-block {
  background: #f5f9ff;
  border-color: #cfe3fa;
}

.ai-opinion-block.avoid,
.ai-opinion-block.reduce_risk,
.ai-opinion-block.close_if_next_tick_weak {
  background: #fff6f5;
  border-color: #ffd3cf;
}

.ai-opinion-block.protect_runner,
.ai-opinion-block.consider_micro,
.ai-opinion-block.consider_reentry {
  background: #f1fbf5;
  border-color: #ccefd8;
}

.intel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.intel-head span {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  min-height: 25px;
  padding: 0 8px;
  color: #ffffff;
  background: var(--blue);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 950;
}

.intel-description {
  color: #344054;
  font-size: 13px;
  line-height: 1.45;
}

.link-chip-block {
  display: grid;
  gap: 8px;
}

.link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.link-chips a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--blue);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.check-bars {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 105px 1fr 34px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  background: #e7edf3;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
}

.table-panel.full {
  width: 100%;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
}

.split-tables {
  display: grid;
  grid-template-columns: minmax(620px, 1.05fr) minmax(560px, 0.95fr);
  gap: 12px;
  align-items: start;
  max-height: none;
  padding: 12px;
}

.ledger-panel .table-wrap {
  overflow: visible;
}

.ledger-table-block {
  align-self: start;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ledger-block-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 9px 11px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.ledger-block-head strong {
  font-size: 13px;
}

.ledger-block-head span {
  color: var(--muted);
  font-size: 12px;
}

.ledger-scroll {
  max-height: 520px;
  overflow: auto;
}

.ledger-scroll table {
  min-width: 100%;
  height: auto;
}

.ledger-scroll th,
.ledger-scroll td {
  padding: 8px 10px;
  font-size: 12px;
  vertical-align: middle;
}

.ledger-scroll .coin-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-size: 10px;
}

.ledger-scroll .coin-cell {
  gap: 8px;
}

.ledger-scroll .coin-name strong {
  max-width: 150px;
}

.ledger-table-block:last-child td:last-child {
  min-width: 260px;
  max-width: 360px;
  white-space: normal;
  line-height: 1.35;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e7edf3;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #f2f7fb;
}

.strategy-panel {
  max-width: 1460px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  padding: 14px;
}

.data-reset-card {
  border-color: rgba(210, 54, 54, 0.24);
  background:
    linear-gradient(135deg, rgba(210, 54, 54, 0.06), transparent 42%),
    var(--surface-2);
}

.data-reset-card .command {
  align-self: end;
  justify-content: center;
}

fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

label input,
label select {
  min-height: 36px;
  width: 100%;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-label {
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.check-label input {
  min-height: auto;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #ffffff;
  background: var(--nav);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.selection-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(16, 20, 24, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.selection-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.selection-drawer {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(560px, calc(100vw - 24px));
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(16, 20, 24, 0.22);
  transform: translateX(24px) scale(0.985);
  opacity: 0;
  pointer-events: none;
  transition: transform 210ms ease, opacity 180ms ease;
}

.selection-drawer.is-open {
  transform: translateX(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  color: #ffffff;
  background: #111827;
}

.drawer-head div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.drawer-head span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.drawer-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 22px;
  line-height: 1.1;
}

.drawer-head p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  line-height: 1.35;
}

.drawer-head .icon-button {
  flex: 0 0 auto;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

a.command {
  text-decoration: none;
}

.drawer-body {
  display: grid;
  gap: 12px;
  align-content: start;
  overflow: auto;
  padding: 14px;
}

.drawer-insight {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: #f5f9ff;
  border: 1px solid #cfe3fa;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
}

.drawer-insight.buy {
  background: #f1fbf5;
  border-color: #ccefd8;
  border-left-color: var(--green);
}

.drawer-insight.risk {
  background: #fff6f5;
  border-color: #ffd3cf;
  border-left-color: var(--red);
}

.drawer-insight.watch {
  background: #fff8ed;
  border-color: #f6d7aa;
  border-left-color: var(--amber);
}

.drawer-insight span,
.drawer-timeline h4 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.drawer-insight strong {
  font-size: 15px;
  line-height: 1.3;
}

.drawer-insight p,
.drawer-timeline p {
  color: #344054;
  font-size: 12px;
  line-height: 1.42;
}

.drawer-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.drawer-timeline,
.drawer-detail {
  display: grid;
  gap: 10px;
}

.drawer-timeline {
  padding: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.drawer-timeline p {
  padding-left: 10px;
  border-left: 2px solid var(--line-strong);
}

.candidate-card,
.trade-card,
.closed-card,
tr[data-kind],
.opinion-card {
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.candidate-card,
.trade-card,
.closed-card {
  animation: cardIn 220ms ease both;
}

.candidate-card:hover,
.trade-card:hover,
.closed-card:hover,
.opinion-card:hover {
  transform: translateY(-1px);
}

tr[data-kind] {
  cursor: pointer;
}

tr[data-kind]:hover .coin-mark,
.candidate-card:hover .coin-mark,
.trade-card:hover .coin-mark,
.closed-card:hover .coin-mark {
  transform: scale(1.04);
}

.coin-mark {
  transition: transform 160ms ease;
}

@keyframes cardIn {
  from {
    transform: translateY(5px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1400px) {
  .metrics {
    grid-template-columns: repeat(4, minmax(118px, 1fr));
  }

  .workbench,
  .ai-chat-layout,
  .ai-advisor-deck {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-panel,
  .ai-card.wide {
    grid-column: span 2;
  }
}

@media (max-width: 1050px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 5;
    height: auto;
    padding: 14px;
  }

  .nav {
    display: flex;
    overflow: auto;
  }

  .side-panel {
    display: none;
  }

  .topbar,
  .brief-layout,
  .workbench,
  .ai-chat-layout,
  .book-grid,
  .ai-advisor-deck,
  .split-tables {
    grid-template-columns: 1fr;
  }

  .detail-panel,
  .ai-chat-sidebar,
  .ai-card.wide {
    position: static;
    grid-column: auto;
  }

  .ai-chat-stream {
    max-height: none;
    min-height: 460px;
  }

  .ai-chat-message,
  .ai-chat-message.ai {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .ai-chat-message.ai .ai-chat-avatar,
  .ai-chat-message.ai .ai-chat-bubble {
    grid-column: auto;
    grid-row: auto;
  }

  .brief-grid,
  .metrics,
  .breakdown-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 10px;
  }

  .topbar,
  .live-strip,
  .panel-head {
    align-items: stretch;
  }

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

  .panel-head,
  .live-strip {
    flex-direction: column;
  }

  .command-group,
  .toolbar {
    width: 100%;
  }

  .command {
    flex: 1 1 128px;
    justify-content: center;
  }

  .search {
    flex: 1;
  }

  .search input {
    width: 100%;
  }

  .metrics,
  .breakdown-strip,
  .brief-grid,
  .control-grid,
  .detail-kpis,
  .opinion-grid,
  .wide-list {
    grid-template-columns: 1fr;
  }

  .activity-feed {
    max-width: none;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .table-wrap {
    max-height: none;
  }
}

/* MoonOps cockpit refresh */
:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef3f6;
  --ink: #101418;
  --muted: #64707d;
  --line: #d9e1e7;
  --line-strong: #b9c6cf;
  --nav: #101419;
  --green: #00875a;
  --red: #c0342b;
  --amber: #b86b00;
  --blue: #1769aa;
  --shadow: 0 18px 42px rgba(16, 20, 24, 0.07);
  --tight-shadow: 0 1px 2px rgba(16, 20, 24, 0.06);
}

body {
  background: var(--bg);
}

.shell {
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  padding: 18px;
  background: #101419;
}

.brand-mark {
  background: #d6f5e5;
  color: #063824;
}

.brand h1 {
  letter-spacing: 0;
}

.nav {
  gap: 6px;
}

.nav-item {
  min-height: 46px;
  border-radius: 8px;
}

.nav-item.is-active {
  background: #1c232b;
  border-color: #2d3742;
}

.workspace {
  gap: 12px;
  padding: 14px;
}

.mission-header,
.signal-bar,
.capital-panel,
.autopilot-panel,
.assistant-panel,
.ai-desk,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--tight-shadow);
}

.mission-header {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto minmax(300px, 0.58fr);
  gap: 14px;
  align-items: center;
  min-height: 78px;
  padding: 14px;
}

.desk-title span {
  color: var(--blue);
  font-size: 11px;
}

.desk-title strong {
  max-width: 820px;
  font-size: 20px;
  line-height: 1.2;
}

.command,
.icon-button,
.link-button,
.segmented button {
  border-radius: 8px;
}

.command.primary {
  background: #111827;
  border-color: #111827;
}

.signal-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 9px 12px;
}

.signal-bar > div:first-child {
  display: flex;
  gap: 9px;
  align-items: center;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.72fr);
  gap: 12px;
  align-items: start;
}

.intel-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.75fr) minmax(0, 1.25fr);
  gap: 12px;
  align-items: start;
}

.panel-head.flat {
  border-bottom: 0;
}

.capital-panel .panel-head,
.autopilot-panel .panel-head {
  padding-bottom: 6px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

.metric {
  min-height: 72px;
  box-shadow: none;
}

.metric.primary-metric {
  background: #111827;
  border-color: #111827;
}

.metric.primary-metric span,
.metric.primary-metric strong {
  color: #ffffff;
}

.metric strong {
  font-size: 22px;
  transition: color 180ms ease, transform 180ms ease, text-shadow 180ms ease;
}

.metric strong.is-updated {
  transform: translateY(-1px) scale(1.025);
  text-shadow: 0 8px 22px rgba(23, 105, 170, 0.18);
}

.breakdown-strip {
  grid-template-columns: 1fr;
  padding: 0 12px 12px;
}

.breakdown-strip > div {
  min-height: 38px;
  padding: 7px 9px;
  box-shadow: none;
}

.autopilot-actions,
.selected-controls {
  padding: 12px;
}

.autopilot-actions {
  display: grid;
  gap: 8px;
}

.autopilot-state {
  display: grid;
  gap: 3px;
  padding: 12px;
  color: #ffffff;
  background: #111827;
  border-radius: 8px;
}

.autopilot-state span,
.autopilot-state em {
  color: rgba(255, 255, 255, 0.66);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
  text-transform: uppercase;
}

.autopilot-state strong {
  font-size: 20px;
}

.autopilot-action {
  display: grid;
  gap: 3px;
  padding: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.autopilot-action span {
  color: var(--muted);
  font-size: 11px;
}

.autopilot-action strong {
  font-size: 12px;
}

.autopilot-action p {
  color: #2d3742;
  font-size: 12px;
  line-height: 1.35;
}

.assistant-brief {
  gap: 10px;
}

.brief-tape {
  display: grid;
  gap: 7px;
}

.brief-signal {
  display: grid;
  gap: 3px;
  padding: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
}

.brief-signal.risk {
  border-left-color: var(--red);
}

.brief-signal.buy {
  border-left-color: var(--green);
}

.brief-signal.watch {
  border-left-color: var(--amber);
}

.brief-signal span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.brief-signal strong {
  font-size: 12px;
  line-height: 1.35;
}

.ai-advisor-deck {
  grid-template-columns: minmax(220px, 0.8fr) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 8px;
}

.ai-card.wide {
  grid-column: auto;
}

.ai-card,
.ai-summary-card,
.trade-card,
.candidate-card,
.closed-card,
.brief-tips {
  box-shadow: none;
}

.opinion-grid {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}

.workbench {
  grid-template-columns: minmax(280px, 0.82fr) minmax(380px, 1fr) minmax(340px, 0.92fr);
  gap: 12px;
}

.card-list {
  gap: 8px;
}

.trade-card,
.candidate-card,
.closed-card {
  background: #ffffff;
}

.detail-panel {
  top: 12px;
}

@media (max-width: 1400px) {
  .mission-header,
  .ops-grid,
  .intel-grid,
  .workbench,
  .ai-advisor-deck {
    grid-template-columns: 1fr 1fr;
  }

  .book-command {
    grid-template-columns: 1fr;
  }

  .book-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .capital-panel,
  .detail-panel {
    grid-column: span 2;
  }
}

@media (max-width: 1050px) {
  .mission-header,
  .ops-grid,
  .intel-grid,
  .workbench,
  .ai-chat-layout,
  .ai-advisor-deck,
  .book-command,
  .book-grid,
  .opportunity-inbox,
  .split-tables {
    grid-template-columns: 1fr;
  }

  .book-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .capital-panel,
  .detail-panel {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .mission-header,
  .signal-bar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .book-summary {
    grid-template-columns: 1fr;
  }

  .book-command {
    padding: 12px;
  }

  .pnl-chart-head {
    align-items: stretch;
    flex-direction: column;
  }

  .pnl-periods {
    width: 100%;
  }

  .pnl-periods button {
    flex: 1 1 auto;
  }

  .selection-drawer {
    top: 8px;
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }

  .drawer-stat-grid {
    grid-template-columns: 1fr;
  }

  .drawer-actions .command {
    flex: 1 1 132px;
    justify-content: center;
  }
}

/* MoonOps premium motion system */
body {
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(16, 20, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 20, 24, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, rgba(23, 105, 170, 0.035), transparent 34%, rgba(0, 135, 90, 0.035));
  background-size: 48px 48px, 48px 48px, 100% 100%;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent 78%);
  animation: gridDrift 28s linear infinite;
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  left: 236px;
  z-index: 2;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(23, 105, 170, 0.8), rgba(0, 135, 90, 0.7), transparent);
  transform: translateX(-100%);
  opacity: 0.65;
  animation: topScan 7s cubic-bezier(0.45, 0, 0.25, 1) infinite;
}

body.is-refreshing .workspace {
  animation: refreshBreath 1100ms ease infinite;
}

.sidebar {
  overflow: hidden;
}

.sidebar::after {
  content: "";
  position: absolute;
  right: 0;
  top: 18px;
  bottom: 18px;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(117, 213, 163, 0.38), transparent);
  animation: railCharge 4.8s ease-in-out infinite;
}

.brand-mark {
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(214, 245, 229, 0.12), 0 10px 34px rgba(117, 213, 163, 0.16);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(110deg, transparent 38%, rgba(255, 255, 255, 0.54), transparent 62%);
  transform: translateX(-75%) rotate(12deg);
  animation: markSweep 6.2s ease-in-out infinite;
}

.nav-item {
  position: relative;
  overflow: hidden;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.nav-item::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 3px;
  background: #75d5a3;
  border-radius: 999px;
  transform: scaleY(0);
  transition: transform 220ms ease;
}

.nav-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(117, 213, 163, 0.10), transparent 54%);
  transform: translateX(-45%);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

.nav-item:hover {
  transform: translateX(2px);
  color: #ffffff;
}

.nav-item:hover::after,
.nav-item.is-active::after {
  transform: translateX(0);
  opacity: 1;
}

.nav-item.is-active::before {
  transform: scaleY(1);
}

.mission-header,
.signal-bar,
.capital-panel,
.autopilot-panel,
.assistant-panel,
.ai-desk,
.panel,
.metric,
.candidate-card,
.trade-card,
.closed-card,
.ai-card,
.ai-summary-card,
.brief-signal,
.book-summary-card,
.mini-kpi,
.book-command,
.autopilot-state {
  position: relative;
}

.mission-header,
.signal-bar,
.capital-panel,
.autopilot-panel,
.assistant-panel,
.ai-desk,
.panel {
  overflow: hidden;
}

.book-command,
.autopilot-state {
  overflow: hidden;
}

.mission-header::before,
.signal-bar::before,
.panel::before,
.assistant-panel::before,
.ai-desk::before,
.capital-panel::before,
.autopilot-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 0%, rgba(23, 105, 170, 0.055) 42%, rgba(0, 135, 90, 0.075) 50%, transparent 60%);
  transform: translateX(-120%);
  opacity: 0;
}

.mission-header::before {
  opacity: 1;
  animation: surfaceSweep 8s ease-in-out infinite;
}

.signal-bar::before {
  opacity: 0.8;
  animation: surfaceSweep 6s ease-in-out infinite;
}

.panel:hover::before,
.assistant-panel:hover::before,
.ai-desk:hover::before,
.capital-panel:hover::before,
.autopilot-panel:hover::before {
  opacity: 1;
  animation: surfaceSweep 1250ms ease forwards;
}

.command,
.icon-button,
.link-button,
.mini-action,
.segmented button {
  position: relative;
  overflow: hidden;
  transition: transform 150ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.command::after,
.mini-action::after,
.icon-button::after,
.link-button::after {
  content: "";
  position: absolute;
  inset: -60% -40%;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.42), transparent 58%);
  transform: translateX(-80%) rotate(4deg);
  opacity: 0;
}

.command:hover,
.mini-action:hover,
.icon-button:hover,
.link-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(16, 20, 24, 0.10);
}

.command:hover::after,
.mini-action:hover::after,
.icon-button:hover::after,
.link-button:hover::after {
  opacity: 1;
  animation: buttonSheen 680ms ease forwards;
}

.command:active,
.mini-action:active,
.icon-button:active,
.link-button:active {
  transform: translateY(0) scale(0.985);
}

.metric,
.candidate-card,
.trade-card,
.closed-card,
.ai-card,
.ai-summary-card,
.brief-signal,
.book-summary-card,
.mini-kpi,
tbody tr[data-kind] {
  animation: premiumRise 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--stagger, 0ms);
}

.metric,
.candidate-card,
.trade-card,
.closed-card,
.ai-card,
.ai-summary-card,
.brief-signal,
.book-summary-card,
.mini-kpi {
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 220ms ease, border-color 180ms ease, background 180ms ease;
}

.metric::before,
.candidate-card::before,
.trade-card::before,
.closed-card::before,
.ai-card::before,
.ai-summary-card::before,
.brief-signal::before,
.book-summary-card::before,
.mini-kpi::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 0%, rgba(255, 255, 255, 0.0) 35%, rgba(23, 105, 170, 0.08) 46%, rgba(0, 135, 90, 0.08) 54%, transparent 68%);
  opacity: 0;
  transition: opacity 180ms ease;
}

.metric:hover,
.candidate-card:hover,
.trade-card:hover,
.closed-card:hover,
.ai-card:hover,
.ai-summary-card:hover,
.brief-signal:hover,
.book-summary-card:hover,
.mini-kpi:hover {
  transform: translateY(-2px);
  border-color: rgba(23, 105, 170, 0.34);
  box-shadow: 0 18px 44px rgba(16, 20, 24, 0.10);
}

.metric:hover::before,
.candidate-card:hover::before,
.trade-card:hover::before,
.closed-card:hover::before,
.ai-card:hover::before,
.ai-summary-card:hover::before,
.brief-signal:hover::before,
.book-summary-card:hover::before,
.mini-kpi:hover::before {
  opacity: 1;
}

.metric.primary-metric {
  background:
    linear-gradient(135deg, #111827 0%, #152033 56%, #0f2d25 100%);
}

.metric.primary-metric::after,
.autopilot-state::after,
.book-command::after {
  content: "";
  position: absolute;
  inset: auto 12px 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(117, 213, 163, 0.75), transparent);
  animation: lowerPulse 2.8s ease-in-out infinite;
}

.metric strong.trend-up {
  color: var(--green);
}

.metric strong.trend-down {
  color: var(--red);
}

.metric strong.is-updated {
  animation: numberKick 620ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.activity-feed span,
.breakdown-strip span,
.card-kpis span,
.card-tags span,
.pill {
  transition: transform 160ms ease, border-color 180ms ease, background 180ms ease;
}

.activity-feed span:hover,
.breakdown-strip span:hover,
.card-kpis span:hover,
.card-tags span:hover,
.pill:hover {
  transform: translateY(-1px);
  border-color: rgba(23, 105, 170, 0.28);
}

.table-wrap tbody tr,
.ledger-scroll tbody tr {
  animation: rowSlide 320ms ease both;
  animation-delay: var(--stagger, 0ms);
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.table-wrap tbody tr[data-kind]:hover,
.ledger-scroll tbody tr[data-kind]:hover {
  transform: translateX(2px);
  box-shadow: inset 3px 0 0 var(--blue);
}

.selection-drawer.is-open {
  animation: drawerSettle 340ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.drawer-insight,
.drawer-stat-grid,
.drawer-timeline,
.drawer-detail {
  animation: premiumRise 360ms ease both;
}

.drawer-stat-grid {
  animation-delay: 50ms;
}

.drawer-timeline {
  animation-delay: 90ms;
}

.drawer-detail {
  animation-delay: 130ms;
}

.pnl-chart {
  position: relative;
}

.pnl-chart::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, rgba(23, 105, 170, 0.07) 48%, transparent 58%);
  transform: translateX(-100%);
  animation: chartScanner 5.4s ease-in-out infinite;
}

.chart-line {
  filter: drop-shadow(0 8px 14px rgba(0, 135, 90, 0.22));
}

.chart-line.neg {
  filter: drop-shadow(0 8px 14px rgba(192, 52, 43, 0.20));
}

.view.is-visible > * {
  animation: viewSectionIn 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.view.is-visible > *:nth-child(2) {
  animation-delay: 70ms;
}

.view.is-visible > *:nth-child(3) {
  animation-delay: 120ms;
}

@keyframes gridDrift {
  from {
    background-position: 0 0, 0 0, 0 0;
  }
  to {
    background-position: 48px 48px, 48px 48px, 0 0;
  }
}

@keyframes topScan {
  0%, 18% {
    transform: translateX(-100%);
    opacity: 0;
  }
  35%, 78% {
    opacity: 0.65;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes railCharge {
  0%, 100% {
    opacity: 0.24;
    transform: scaleY(0.65);
  }
  50% {
    opacity: 0.9;
    transform: scaleY(1);
  }
}

@keyframes markSweep {
  0%, 68% {
    transform: translateX(-78%) rotate(12deg);
  }
  100% {
    transform: translateX(86%) rotate(12deg);
  }
}

@keyframes surfaceSweep {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(120%);
  }
}

@keyframes buttonSheen {
  from {
    transform: translateX(-80%) rotate(4deg);
  }
  to {
    transform: translateX(80%) rotate(4deg);
  }
}

@keyframes premiumRise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes rowSlide {
  from {
    transform: translateX(-5px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes viewSectionIn {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes drawerSettle {
  0% {
    transform: translateX(32px) scale(0.98);
  }
  70% {
    transform: translateX(-2px) scale(1.002);
  }
  100% {
    transform: translateX(0) scale(1);
  }
}

@keyframes numberKick {
  0% {
    transform: translateY(0) scale(1);
  }
  42% {
    transform: translateY(-2px) scale(1.045);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes lowerPulse {
  0%, 100% {
    opacity: 0.22;
    transform: scaleX(0.45);
  }
  50% {
    opacity: 0.95;
    transform: scaleX(1);
  }
}

@keyframes refreshBreath {
  0%, 100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.05);
  }
}

@keyframes chartScanner {
  0%, 42% {
    transform: translateX(-100%);
    opacity: 0;
  }
  56% {
    opacity: 1;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

@media (max-width: 1050px) {
  body::after {
    left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Mobile command deck */
@media (max-width: 1180px) {
  body::after {
    left: 0;
  }

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 18;
    display: grid;
    height: auto;
    min-height: 0;
    gap: 10px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  }

  .sidebar::after,
  .side-panel {
    display: none;
  }

  .brand {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 12px;
  }

  .brand h1,
  .brand p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    display: flex;
    gap: 6px;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 1 0 112px;
    grid-template-columns: 24px minmax(0, 1fr);
    min-height: 38px;
    padding: 0 9px;
  }

  .workspace {
    padding: 12px;
  }

  .mission-header,
  .ops-grid,
  .intel-grid,
  .workbench,
  .ai-advisor-deck,
  .book-command,
  .book-grid,
  .split-tables {
    grid-template-columns: 1fr;
  }

  .mission-header {
    align-items: stretch;
  }

  .toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 40px;
    justify-content: stretch;
    width: 100%;
  }

  .toolbar .live-toggle,
  .toolbar .search {
    display: flex;
  }

  .toolbar .live-toggle input {
    flex: 0 0 auto;
    width: auto;
  }

  .search {
    min-width: 0;
  }

  .search input {
    width: 100%;
  }

  .capital-panel,
  .detail-panel {
    grid-column: auto;
  }

  .detail-panel {
    position: static;
  }

  .detail-body {
    max-height: none;
  }

  .book-grid .wide-list {
    max-height: none;
    overflow: visible;
  }

  .ledger-panel .table-wrap {
    overflow: auto;
  }
}

@media (max-width: 760px) {
  body {
    min-width: 320px;
  }

  .workspace {
    gap: 10px;
    padding: 10px;
  }

  .sidebar {
    padding: 9px 10px;
  }

  .brand {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand p {
    font-size: 11px;
  }

  .nav-item {
    flex: 0 0 82px;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 2px;
    min-height: 43px;
    padding: 5px 8px;
    text-align: center;
  }

  .nav-item span {
    font-size: 10px;
  }

  .nav-item strong {
    font-size: 12px;
  }

  .mission-header {
    gap: 10px;
    min-height: 0;
    padding: 11px;
  }

  .desk-title strong {
    font-size: 16px;
  }

  .desk-title span {
    font-size: 10px;
  }

  .command-group {
    display: grid;
    grid-auto-columns: minmax(90px, max-content);
    grid-auto-flow: column;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
  }

  .command-group .command {
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .command {
    min-height: 40px;
  }

  .toolbar {
    grid-template-columns: auto minmax(0, 1fr) 40px;
    gap: 6px;
  }

  .search,
  .live-toggle {
    min-height: 40px;
    padding: 0 9px;
  }

  .signal-bar {
    display: grid;
    align-items: stretch;
    padding: 10px;
  }

  .signal-bar > div:first-child {
    align-items: flex-start;
  }

  .activity-feed {
    justify-content: flex-start;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 0 10px 10px;
  }

  .metric {
    min-height: 66px;
    padding: 10px;
  }

  .metric.primary-metric {
    grid-column: span 2;
  }

  .metric strong {
    font-size: 18px;
  }

  .breakdown-strip,
  .assistant-brief,
  .selected-controls,
  .ai-advisor-deck,
  .card-list,
  .detail-body,
  .detail-empty,
  .config-grid {
    padding: 10px;
  }

  .breakdown-strip {
    overflow-x: auto;
  }

  .pnl-chart-panel {
    margin: 0 10px 10px;
    padding: 10px;
  }

  .pnl-chart-head {
    align-items: stretch;
  }

  .pnl-periods,
  .segmented {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .pnl-periods::-webkit-scrollbar,
  .segmented::-webkit-scrollbar {
    display: none;
  }

  .pnl-periods button,
  .segmented button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .pnl-chart {
    min-height: 180px;
  }

  .pnl-chart svg {
    height: 180px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
  }

  .panel-head .command,
  .panel-head .segmented,
  .panel-head .link-button {
    width: 100%;
    justify-content: center;
  }

  .brief-grid,
  .control-grid,
  .detail-kpis,
  .drawer-stat-grid,
  .config-grid,
  .book-summary,
  .wide-list,
  .opinion-grid,
  .intelligence-deck,
  .opportunity-inbox,
  .recommendation-grid {
    grid-template-columns: 1fr;
  }

  .ai-card.wide {
    grid-column: auto;
  }

  .book-command {
    gap: 10px;
    padding: 12px;
  }

  .book-title strong {
    font-size: 21px;
  }

  .card-top {
    align-items: stretch;
    flex-direction: column;
  }

  .card-actions,
  .row-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mini-action {
    min-height: 34px;
    padding: 0 6px;
  }

  .coin-name strong {
    max-width: calc(100vw - 120px);
  }

  .table-wrap {
    max-height: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 920px;
  }

  .split-tables {
    padding: 10px;
  }

  .ledger-scroll {
    max-height: none;
  }

  .ledger-scroll table {
    min-width: 760px;
  }

  fieldset {
    padding: 12px;
  }

  label input,
  label select {
    min-height: 42px;
  }

  .selection-drawer {
    inset: 0;
    width: 100vw;
    border-radius: 0;
    transform: translateY(14px) scale(0.99);
  }

  .selection-drawer.is-open {
    transform: translateY(0) scale(1);
  }

  .drawer-head {
    padding: 14px 12px;
  }

  .drawer-head strong {
    font-size: 19px;
  }

  .drawer-actions {
    padding: 10px 12px;
  }

  .drawer-actions .command {
    flex: 1 1 120px;
  }

  .drawer-body {
    padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
  }

  .toast {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    max-width: none;
  }
}

@media (max-width: 420px) {
  .workspace {
    padding: 8px;
  }

  .mission-header,
  .signal-bar,
  .capital-panel,
  .autopilot-panel,
  .assistant-panel,
  .ai-desk,
  .intelligence-panel,
  .panel,
  .book-command {
    border-radius: 8px;
  }

  .toolbar {
    grid-template-columns: 1fr 40px;
  }

  .live-toggle {
    grid-column: 1 / -1;
    justify-content: center;
    width: 100%;
  }

  .ai-chat-stream {
    min-height: 380px;
    padding: 12px;
  }

  .ai-chat-message,
  .ai-chat-message.ai {
    grid-template-columns: 1fr;
  }

  .ai-chat-avatar {
    display: none;
  }

  .command-group {
    grid-auto-flow: row;
    grid-auto-columns: initial;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .command-group .command {
    justify-content: center;
    min-width: 0;
  }

  .command-group .command:first-child {
    grid-column: span 2;
  }

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

  .metric.primary-metric {
    grid-column: auto;
  }

  .card-actions,
  .row-actions {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .score {
    width: 38px;
  }
}
